fixing trailing herecomments with 'break'

This commit is contained in:
Jeremy Ashkenas
2010-12-16 08:23:34 -05:00
parent 346621ed21
commit a7158ec69c
2 changed files with 5 additions and 5 deletions

View File

@@ -1915,7 +1915,7 @@
return this;
};
Switch.prototype.compileNode = function(o) {
var block, body, code, cond, conditions, exprs, i, idt1, idt2, _i, _len, _len2, _ref, _ref2, _ref3, _ref4;
var block, body, code, cond, conditions, expr, i, idt1, idt2, _i, _len, _len2, _ref, _ref2, _ref3, _ref4;
idt1 = o.indent + TAB;
idt2 = o.indent = idt1 + TAB;
code = this.tab + ("switch (" + (((_ref = this.subject) != null ? _ref.compile(o, LEVEL_PAREN) : void 0) || false) + ") {\n");
@@ -1936,8 +1936,8 @@
if (i === this.cases.length - 1 && !this.otherwise) {
break;
}
exprs = block.expressions;
if (!exprs.length || !last(exprs).isPureStatement()) {
expr = last(block.expressions);
if (!expr || !expr.isPureStatement() || expr instanceof Comment) {
code += idt2 + 'break;\n';
}
}

View File

@@ -1524,8 +1524,8 @@ exports.Switch = class Switch extends Base
code += idt1 + "case #{ cond.compile o, LEVEL_PAREN }:\n"
code += body + '\n' if body = block.compile o, LEVEL_TOP
break if i is @cases.length - 1 and not @otherwise
exprs = block.expressions
if not exprs.length or not last(exprs).isPureStatement()
expr = last block.expressions
if not expr or not expr.isPureStatement() or expr instanceof Comment
code += idt2 + 'break;\n'
code += idt1 + "default:\n#{ @otherwise.compile o, LEVEL_TOP }\n" if @otherwise
code + @tab + '}'