diff --git a/lib/lexer.js b/lib/lexer.js index cd0eec6b..91f53276 100644 --- a/lib/lexer.js +++ b/lib/lexer.js @@ -578,14 +578,13 @@ })(); JS_KEYWORDS = ['if', 'else', 'true', 'false', 'new', 'return', 'try', 'catch', 'finally', 'throw', 'break', 'continue', 'for', 'in', 'while', 'delete', 'instanceof', 'typeof', 'switch', 'super', 'extends', 'class', 'this', 'null', 'debugger']; COFFEE_KEYWORDS = ['then', 'unless', 'until', 'loop', 'yes', 'no', 'on', 'off', 'of', 'by', 'when']; - COFFEE_ALIASES = { + for (op in (COFFEE_ALIASES = { and: '&&', or: '||', is: '==', isnt: '!=', not: '!' - }; - for (op in COFFEE_ALIASES) { + })) { COFFEE_KEYWORDS.push(op); } COFFEE_ALIASES['==='] = '=='; diff --git a/lib/nodes.js b/lib/nodes.js index 0bb87f40..1bf7e9c2 100644 --- a/lib/nodes.js +++ b/lib/nodes.js @@ -1593,19 +1593,16 @@ exports.For = (function() { For = (function() { return function For(_arg, source, _arg2, _arg3) { - var _ref2; + var _ref2, _ref3; this.index = _arg3; this.name = _arg2; this.body = _arg; For.__super__.constructor.call(this); - this.index || (this.index = null); - this.source = source.source; - this.guard = source.guard; - this.step = source.step; + _ref2 = source, this.source = _ref2.source, this.guard = _ref2.guard, this.step = _ref2.step; this.raw = !!source.raw; this.object = !!source.object; if (this.object) { - _ref2 = [this.index, this.name], this.name = _ref2[0], this.index = _ref2[1]; + _ref3 = [this.index, this.name], this.name = _ref3[0], this.index = _ref3[1]; } this.pattern = this.name instanceof Value; if (this.index instanceof Value) { @@ -1670,12 +1667,10 @@ step: this.step })); } else { - svar = this.source.compile(o); - if (IDENTIFIER.test(svar) && scope.check(svar, { + svar = (sourcePart = this.source.compile(o)); + if ((name || !this.raw) && !(IDENTIFIER.test(svar) && scope.check(svar, { immediate: true - })) { - sourcePart = svar; - } else { + }))) { sourcePart = ("" + (ref = scope.freeVariable('ref')) + " = " + svar); if (!(this.object)) { sourcePart = ("(" + sourcePart + ")"); diff --git a/lib/rewriter.js b/lib/rewriter.js index db77bb82..9a9152da 100644 --- a/lib/rewriter.js +++ b/lib/rewriter.js @@ -314,10 +314,10 @@ } }; exports.Rewriter.prototype.rewriteClosingParens = function() { - var _ref, debt, key, stack; + var debt, key, stack; stack = []; debt = {}; - for (key in _ref = INVERSES) { + for (key in INVERSES) { (debt[key] = 0); } return this.scanTokens(function(token, i, tokens) { diff --git a/src/lexer.coffee b/src/lexer.coffee index cfccad80..32293791 100644 --- a/src/lexer.coffee +++ b/src/lexer.coffee @@ -523,13 +523,12 @@ COFFEE_KEYWORDS = [ 'yes', 'no', 'on', 'off' 'of', 'by', 'when' ] -COFFEE_ALIASES = +COFFEE_KEYWORDS.push op for all op of COFFEE_ALIASES = and : '&&' or : '||' is : '==' isnt : '!=' not : '!' -COFFEE_KEYWORDS.push op for all op of COFFEE_ALIASES COFFEE_ALIASES['==='] = '==' # The list of keywords that are reserved by JavaScript, but not used, or are diff --git a/src/nodes.coffee b/src/nodes.coffee index 4aa5dd93..b42a608d 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -1387,10 +1387,7 @@ exports.For = class For extends Base constructor: (@body, source, @name, @index) -> super() - @index or= null - @source = source.source - @guard = source.guard - @step = source.step + {@source, @guard, @step} = source @raw = !!source.raw @object = !!source.object [@name, @index] = [@index, @name] if @object @@ -1431,12 +1428,11 @@ exports.For = class For extends Base body = Expressions.wrap([@body]) idt1 = @idt 1 if range - forPart = source.compile merge o, index: ivar, step: @step + forPart = source.compile merge o, {index: ivar, @step} else - svar = @source.compile o - if IDENTIFIER.test(svar) and scope.check(svar, immediate: on) - sourcePart = svar - else + svar = sourcePart = @source.compile o + if (name or not @raw) and + not (IDENTIFIER.test(svar) and scope.check svar, immediate: on) sourcePart = "#{ref = scope.freeVariable 'ref'} = #{svar}" sourcePart = "(#{sourcePart})" unless @object svar = ref