Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

appeasing Jeremy: switching prefix increments out for postfix equivalent

  • Loading branch information...
commit c6c527e83008188b6579ed1bd108994b58733789 1 parent fc0a169
@michaelficarra michaelficarra authored
View
2  lib/coffee-script/browser.js
@@ -42,7 +42,7 @@
coffees = (function() {
var _i, _len, _results;
_results = [];
- for (_i = 0, _len = scripts.length; _i < _len; ++_i) {
+ for (_i = 0, _len = scripts.length; _i < _len; _i++) {
s = scripts[_i];
if (s.type === 'text/coffeescript') _results.push(s);
}
View
2  lib/coffee-script/cake.js
@@ -57,7 +57,7 @@
}
_ref = options.arguments;
_results = [];
- for (_i = 0, _len = _ref.length; _i < _len; ++_i) {
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
arg = _ref[_i];
_results.push(invoke(arg));
}
View
2  lib/coffee-script/coffee-script.js
@@ -103,7 +103,7 @@
};
_module.filename = sandbox.__filename;
_ref3 = Object.getOwnPropertyNames(require);
- for (_i = 0, _len = _ref3.length; _i < _len; ++_i) {
+ for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
r = _ref3[_i];
if (r !== 'paths') _require[r] = require[r];
}
View
14 lib/coffee-script/command.js
@@ -60,7 +60,7 @@
process.argv[0] = 'coffee';
process.execPath = require.main.filename;
_results = [];
- for (_i = 0, _len = sources.length; _i < _len; ++_i) {
+ for (_i = 0, _len = sources.length; _i < _len; _i++) {
source = sources[_i];
_results.push(compilePath(source, true, path.normalize(source)));
}
@@ -96,7 +96,7 @@
return null;
}))), _ref2;
_results = [];
- for (_i = 0, _len = files.length; _i < _len; ++_i) {
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
file = files[_i];
_results.push(compilePath(file, false, base));
}
@@ -187,7 +187,7 @@
realFilename = module.filename;
module.filename = '.';
_ref2 = opts.require;
- for (_i = 0, _len = _ref2.length; _i < _len; ++_i) {
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
req = _ref2[_i];
require(req);
}
@@ -267,7 +267,7 @@
return path.join(source, file);
});
_results = [];
- for (_i = 0, _len = files.length; _i < _len; ++_i) {
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
file = files[_i];
if (!(!notSources[file])) continue;
if (sources.some(function(s) {
@@ -294,13 +294,13 @@
toRemove = (function() {
var _i, _len, _results;
_results = [];
- for (_i = 0, _len = sources.length; _i < _len; ++_i) {
+ for (_i = 0, _len = sources.length; _i < _len; _i++) {
file = sources[_i];
if (file.indexOf(source) >= 0) _results.push(file);
}
return _results;
})();
- for (_i = 0, _len = toRemove.length; _i < _len; ++_i) {
+ for (_i = 0, _len = toRemove.length; _i < _len; _i++) {
file = toRemove[_i];
removeSource(file, base, true);
}
@@ -388,7 +388,7 @@
strings = (function() {
var _i, _len, _ref2, _results;
_results = [];
- for (_i = 0, _len = tokens.length; _i < _len; ++_i) {
+ for (_i = 0, _len = tokens.length; _i < _len; _i++) {
token = tokens[_i];
_ref2 = [token[0], token[1].toString().replace(/\n/, '\\n')], tag = _ref2[0], value = _ref2[1];
_results.push("[" + tag + " " + value + "]");
View
4 lib/coffee-script/grammar.js
@@ -568,10 +568,10 @@
grammar[name] = (function() {
var _i, _j, _len, _len2, _ref, _results;
_results = [];
- for (_i = 0, _len = alternatives.length; _i < _len; ++_i) {
+ for (_i = 0, _len = alternatives.length; _i < _len; _i++) {
alt = alternatives[_i];
_ref = alt[0].split(' ');
- for (_j = 0, _len2 = _ref.length; _j < _len2; ++_j) {
+ for (_j = 0, _len2 = _ref.length; _j < _len2; _j++) {
token = _ref[_j];
if (!grammar[token]) tokens.push(token);
}
View
4 lib/coffee-script/helpers.js
@@ -14,7 +14,7 @@
exports.compact = function(array) {
var item, _i, _len, _results;
_results = [];
- for (_i = 0, _len = array.length; _i < _len; ++_i) {
+ for (_i = 0, _len = array.length; _i < _len; _i++) {
item = array[_i];
if (item) _results.push(item);
}
@@ -47,7 +47,7 @@
exports.flatten = flatten = function(array) {
var element, flattened, _i, _len;
flattened = [];
- for (_i = 0, _len = array.length; _i < _len; ++_i) {
+ for (_i = 0, _len = array.length; _i < _len; _i++) {
element = array[_i];
if (element instanceof Array) {
flattened = flattened.concat(flatten(element));
View
2  lib/coffee-script/lexer.js
@@ -222,7 +222,7 @@
_ref3 = this.interpolateString(body, {
regex: true
});
- for (_i = 0, _len = _ref3.length; _i < _len; ++_i) {
+ for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
_ref4 = _ref3[_i], tag = _ref4[0], value = _ref4[1];
if (tag === 'TOKENS') {
tokens.push.apply(tokens, value);
View
65 lib/coffee-script/nodes.js
@@ -132,11 +132,11 @@
var attr, child, _i, _j, _len, _len2, _ref2, _ref3;
if (!this.children) return this;
_ref2 = this.children;
- for (_i = 0, _len = _ref2.length; _i < _len; ++_i) {
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
attr = _ref2[_i];
if (this[attr]) {
_ref3 = flatten([this[attr]]);
- for (_j = 0, _len2 = _ref3.length; _j < _len2; ++_j) {
+ for (_j = 0, _len2 = _ref3.length; _j < _len2; _j++) {
child = _ref3[_j];
if (func(child) === false) return this;
}
@@ -228,7 +228,7 @@
Block.prototype.isStatement = function(o) {
var exp, _i, _len, _ref2;
_ref2 = this.expressions;
- for (_i = 0, _len = _ref2.length; _i < _len; ++_i) {
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
exp = _ref2[_i];
if (exp.isStatement(o)) return true;
}
@@ -238,7 +238,7 @@
Block.prototype.jumps = function(o) {
var exp, _i, _len, _ref2;
_ref2 = this.expressions;
- for (_i = 0, _len = _ref2.length; _i < _len; ++_i) {
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
exp = _ref2[_i];
if (exp.jumps(o)) return exp;
}
@@ -275,7 +275,7 @@
top = o.level === LEVEL_TOP;
codes = [];
_ref2 = this.expressions;
- for (_i = 0, _len = _ref2.length; _i < _len; ++_i) {
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
node = _ref2[_i];
node = node.unwrapAll();
node = node.unfoldSoak(o) || node;
@@ -521,7 +521,7 @@
Value.prototype.isAtomic = function() {
var node, _i, _len, _ref2;
_ref2 = this.properties.concat(this.base);
- for (_i = 0, _len = _ref2.length; _i < _len; ++_i) {
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
node = _ref2[_i];
if (node.soak || node instanceof Call) return false;
}
@@ -585,7 +585,7 @@
if ((this.base instanceof Parens || props.length) && SIMPLENUM.test(code)) {
code = "" + code + ".";
}
- for (_i = 0, _len = props.length; _i < _len; ++_i) {
+ for (_i = 0, _len = props.length; _i < _len; _i++) {
prop = props[_i];
code += prop.compile(o);
}
@@ -727,7 +727,7 @@
if (!((call = call.variable.base) instanceof Call)) break;
}
_ref3 = list.reverse();
- for (_i = 0, _len = _ref3.length; _i < _len; ++_i) {
+ for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
call = _ref3[_i];
if (ifn) {
if (call.variable instanceof Call) {
@@ -744,7 +744,7 @@
Call.prototype.filterImplicitObjects = function(list) {
var node, nodes, obj, prop, properties, _i, _j, _len, _len2, _ref2;
nodes = [];
- for (_i = 0, _len = list.length; _i < _len; ++_i) {
+ for (_i = 0, _len = list.length; _i < _len; _i++) {
node = list[_i];
if (!((typeof node.isObject === "function" ? node.isObject() : void 0) && node.base.generated)) {
nodes.push(node);
@@ -752,7 +752,7 @@
}
obj = null;
_ref2 = node.base.properties;
- for (_j = 0, _len2 = _ref2.length; _j < _len2; ++_j) {
+ for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
prop = _ref2[_j];
if (prop instanceof Assign || prop instanceof Comment) {
if (!obj) nodes.push(obj = new Obj(properties = [], true));
@@ -776,7 +776,7 @@
args = ((function() {
var _i, _len, _results;
_results = [];
- for (_i = 0, _len = args.length; _i < _len; ++_i) {
+ for (_i = 0, _len = args.length; _i < _len; _i++) {
arg = args[_i];
_results.push(arg.compile(o, LEVEL_LIST));
}
@@ -928,20 +928,21 @@
};
Range.prototype.compileNode = function(o) {
- var cond, condPart, from, gt, idx, idxName, known, lt, stepPart, to, varPart, _ref2, _ref3;
+ var cond, condPart, from, gt, idx, idxName, known, lt, namedIndex, stepPart, to, varPart, _ref2, _ref3;
if (!this.fromVar) this.compileVariables(o);
if (!o.index) return this.compileArray(o);
known = this.fromNum && this.toNum;
idx = del(o, 'index');
idxName = del(o, 'name');
+ namedIndex = idxName && idxName !== idx;
varPart = "" + idx + " = " + this.fromC;
if (this.toC !== this.toVar) varPart += ", " + this.toC;
if (this.step !== this.stepVar) varPart += ", " + this.step;
- if (idxName && idxName !== idx) varPart = "" + idxName + " = " + varPart;
_ref2 = ["" + idx + " <" + this.equals, "" + idx + " >" + this.equals], lt = _ref2[0], gt = _ref2[1];
condPart = this.stepNum ? +this.stepNum > 0 ? "" + lt + " " + this.toVar : "" + gt + " " + this.toVar : known ? ((_ref3 = [+this.fromNum, +this.toNum], from = _ref3[0], to = _ref3[1], _ref3), from <= to ? "" + lt + " " + to : "" + gt + " " + to) : (cond = "" + this.fromVar + " <= " + this.toVar, "" + cond + " ? " + lt + " " + this.toVar + " : " + gt + " " + this.toVar);
- stepPart = this.stepVar ? "" + idx + " += " + this.stepVar : known ? from <= to ? "++" + idx : "--" + idx : "" + cond + " ? ++" + idx + " : --" + idx;
- if (idxName && idxName !== idx) stepPart = "" + idxName + " = " + stepPart;
+ stepPart = this.stepVar ? "" + idx + " += " + this.stepVar : known ? namedIndex ? from <= to ? "++" + idx : "--" + idx : from <= to ? "" + idx + "++" : "" + idx + "--" : namedIndex ? "" + cond + " ? ++" + idx + " : --" + idx : "" + cond + " ? " + idx + "++ : " + idx + "--";
+ if (namedIndex) varPart = "" + idxName + " = " + varPart;
+ if (namedIndex) stepPart = "" + idxName + " = " + stepPart;
return "" + varPart + "; " + condPart + "; " + stepPart;
};
@@ -1028,7 +1029,7 @@
props = this.properties;
if (!props.length) return (this.front ? '({})' : '{}');
if (this.generated) {
- for (_i = 0, _len = props.length; _i < _len; ++_i) {
+ for (_i = 0, _len = props.length; _i < _len; _i++) {
node = props[_i];
if (node instanceof Value) {
throw new Error('cannot have an implicit value in an implicit object');
@@ -1067,7 +1068,7 @@
Obj.prototype.assigns = function(name) {
var prop, _i, _len, _ref2;
_ref2 = this.properties;
- for (_i = 0, _len = _ref2.length; _i < _len; ++_i) {
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
prop = _ref2[_i];
if (prop.assigns(name)) return true;
}
@@ -1101,7 +1102,7 @@
code = ((function() {
var _i, _len, _results;
_results = [];
- for (_i = 0, _len = objs.length; _i < _len; ++_i) {
+ for (_i = 0, _len = objs.length; _i < _len; _i++) {
obj = objs[_i];
_results.push(obj.compile(o, LEVEL_LIST));
}
@@ -1117,7 +1118,7 @@
Arr.prototype.assigns = function(name) {
var obj, _i, _len, _ref2;
_ref2 = this.objects;
- for (_i = 0, _len = _ref2.length; _i < _len; ++_i) {
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
obj = _ref2[_i];
if (obj.assigns(name)) return true;
}
@@ -1168,7 +1169,7 @@
if (this.boundFuncs.length) {
_ref2 = this.boundFuncs;
_results = [];
- for (_i = 0, _len = _ref2.length; _i < _len; ++_i) {
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
bvar = _ref2[_i];
lhs = (new Value(new Literal("this"), [new Access(bvar)])).compile(o);
_results.push(this.ctor.body.unshift(new Literal("" + lhs + " = " + (utility('bind')) + "(" + lhs + ", this)")));
@@ -1517,11 +1518,11 @@
vars = [];
exprs = [];
_ref2 = this.params;
- for (_i = 0, _len = _ref2.length; _i < _len; ++_i) {
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
param = _ref2[_i];
if (!param.splat) continue;
_ref3 = this.params;
- for (_j = 0, _len2 = _ref3.length; _j < _len2; ++_j) {
+ for (_j = 0, _len2 = _ref3.length; _j < _len2; _j++) {
p = _ref3[_j];
if (p.name.value) o.scope.add(p.name.value, 'var', true);
}
@@ -1529,7 +1530,7 @@
var _k, _len3, _ref4, _results;
_ref4 = this.params;
_results = [];
- for (_k = 0, _len3 = _ref4.length; _k < _len3; ++_k) {
+ for (_k = 0, _len3 = _ref4.length; _k < _len3; _k++) {
p = _ref4[_k];
_results.push(p.asReference(o));
}
@@ -1538,7 +1539,7 @@
break;
}
_ref4 = this.params;
- for (_k = 0, _len3 = _ref4.length; _k < _len3; ++_k) {
+ for (_k = 0, _len3 = _ref4.length; _k < _len3; _k++) {
param = _ref4[_k];
if (param.isComplex()) {
val = ref = param.asReference(o);
@@ -1697,7 +1698,7 @@
var _j, _len2, _ref2, _results;
_ref2 = list.slice(0, index);
_results = [];
- for (_j = 0, _len2 = _ref2.length; _j < _len2; ++_j) {
+ for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
node = _ref2[_j];
_results.push(node.compile(o, LEVEL_LIST));
}
@@ -1745,7 +1746,7 @@
var expressions, node, _i, _len;
expressions = this.body.expressions;
if (!expressions.length) return false;
- for (_i = 0, _len = expressions.length; _i < _len; ++_i) {
+ for (_i = 0, _len = expressions.length; _i < _len; _i++) {
node = expressions[_i];
if (node.jumps({
loop: true
@@ -1878,7 +1879,7 @@
passedParams = [];
func = exp instanceof Assign && (ref = exp.value.unwrap()) instanceof Code ? ref : exp;
_ref2 = func.params || [];
- for (_i = 0, _len = _ref2.length; _i < _len; ++_i) {
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
param = _ref2[_i];
if (param.value) {
passedParams.push(param.value);
@@ -1971,7 +1972,7 @@
var hasSplat, obj, _i, _len, _ref2;
if (this.array instanceof Value && this.array.isArray()) {
_ref2 = this.array.base.objects;
- for (_i = 0, _len = _ref2.length; _i < _len; ++_i) {
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
obj = _ref2[_i];
if (!(obj instanceof Splat)) continue;
hasSplat = true;
@@ -2250,7 +2251,7 @@
if (this.step) {
forVarPart += ", " + stepvar + " = " + (this.step.compile(o, LEVEL_OP));
}
- stepPart = "" + kvarAssign + (this.step ? "" + ivar + " += " + stepvar : "++" + ivar);
+ stepPart = "" + kvarAssign + (this.step ? "" + ivar + " += " + stepvar : (kvar !== ivar ? "++" + ivar : "" + ivar + "++"));
forPart = "" + forVarPart + "; " + ivar + " < " + lvar + "; " + stepPart;
}
}
@@ -2334,7 +2335,7 @@
};
}
_ref2 = this.cases;
- for (_i = 0, _len = _ref2.length; _i < _len; ++_i) {
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
_ref3 = _ref2[_i], conds = _ref3[0], block = _ref3[1];
if (block.jumps(o)) return block;
}
@@ -2344,7 +2345,7 @@
Switch.prototype.makeReturn = function(res) {
var pair, _i, _len, _ref2, _ref3;
_ref2 = this.cases;
- for (_i = 0, _len = _ref2.length; _i < _len; ++_i) {
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
pair = _ref2[_i];
pair[1].makeReturn(res);
}
@@ -2364,7 +2365,7 @@
for (i = _i = 0, _len = _ref3.length; _i < _len; i = ++_i) {
_ref4 = _ref3[i], conditions = _ref4[0], block = _ref4[1];
_ref5 = flatten([conditions]);
- for (_j = 0, _len2 = _ref5.length; _j < _len2; ++_j) {
+ for (_j = 0, _len2 = _ref5.length; _j < _len2; _j++) {
cond = _ref5[_j];
if (!this.subject) cond = cond.invert();
code += idt1 + ("case " + (cond.compile(o, LEVEL_PAREN)) + ":\n");
View
10 lib/coffee-script/optparse.js
@@ -32,7 +32,7 @@
isOption = !!(arg.match(LONG_FLAG) || arg.match(SHORT_FLAG));
matchedRule = false;
_ref = this.rules;
- for (_j = 0, _len2 = _ref.length; _j < _len2; ++_j) {
+ for (_j = 0, _len2 = _ref.length; _j < _len2; _j++) {
rule = _ref[_j];
if (rule.shortFlag === arg || rule.longFlag === arg) {
value = rule.hasArgument ? (skippingArgument = true, args[i + 1]) : true;
@@ -57,7 +57,7 @@
lines = [];
if (this.banner) lines.unshift("" + this.banner + "\n");
_ref = this.rules;
- for (_i = 0, _len = _ref.length; _i < _len; ++_i) {
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
rule = _ref[_i];
spaces = 15 - rule.longFlag.length;
spaces = spaces > 0 ? Array(spaces + 1).join(' ') : '';
@@ -82,7 +82,7 @@
buildRules = function(rules) {
var tuple, _i, _len, _results;
_results = [];
- for (_i = 0, _len = rules.length; _i < _len; ++_i) {
+ for (_i = 0, _len = rules.length; _i < _len; _i++) {
tuple = rules[_i];
if (tuple.length < 3) tuple.unshift(null);
_results.push(buildRule.apply(null, tuple));
@@ -109,11 +109,11 @@
var arg, l, match, result, _i, _j, _len, _len2, _ref;
args = args.slice(0);
result = [];
- for (_i = 0, _len = args.length; _i < _len; ++_i) {
+ for (_i = 0, _len = args.length; _i < _len; _i++) {
arg = args[_i];
if (match = arg.match(MULTI_FLAG)) {
_ref = match[1].split('');
- for (_j = 0, _len2 = _ref.length; _j < _len2; ++_j) {
+ for (_j = 0, _len2 = _ref.length; _j < _len2; _j++) {
l = _ref[_j];
result.push('-' + l);
}
View
4 lib/coffee-script/repl.js
@@ -91,7 +91,7 @@
var _i, _len, _ref2, _results;
_ref2 = CoffeeScript.RESERVED;
_results = [];
- for (_i = 0, _len = _ref2.length; _i < _len; ++_i) {
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
r = _ref2[_i];
if (r.slice(0, 2) !== '__') _results.push(r);
}
@@ -106,7 +106,7 @@
getCompletions = function(prefix, candidates) {
var el, _i, _len, _results;
_results = [];
- for (_i = 0, _len = candidates.length; _i < _len; ++_i) {
+ for (_i = 0, _len = candidates.length; _i < _len; _i++) {
el = candidates[_i];
if (el.indexOf(prefix) === 0) _results.push(el);
}
View
2  lib/coffee-script/rewriter.js
@@ -283,7 +283,7 @@
EXPRESSION_END = [];
- for (_i = 0, _len = BALANCED_PAIRS.length; _i < _len; ++_i) {
+ for (_i = 0, _len = BALANCED_PAIRS.length; _i < _len; _i++) {
_ref = BALANCED_PAIRS[_i], left = _ref[0], rite = _ref[1];
EXPRESSION_START.push(INVERSES[rite] = left);
EXPRESSION_END.push(INVERSES[left] = rite);
View
6 lib/coffee-script/scope.js
@@ -62,7 +62,7 @@
Scope.prototype.type = function(name) {
var v, _i, _len, _ref2;
_ref2 = this.variables;
- for (_i = 0, _len = _ref2.length; _i < _len; ++_i) {
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
v = _ref2[_i];
if (v.name === name) return v.type;
}
@@ -97,7 +97,7 @@
realVars = [];
tempVars = [];
_ref2 = this.variables;
- for (_i = 0, _len = _ref2.length; _i < _len; ++_i) {
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
v = _ref2[_i];
if (v.type === 'var') {
(v.name.charAt(0) === '_' ? tempVars : realVars).push(v.name);
@@ -110,7 +110,7 @@
var v, _i, _len, _ref2, _results;
_ref2 = this.variables;
_results = [];
- for (_i = 0, _len = _ref2.length; _i < _len; ++_i) {
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
v = _ref2[_i];
if (v.type.assigned) _results.push("" + v.name + " = " + v.type.value);
}
View
18 src/nodes.coffee
@@ -678,10 +678,10 @@ exports.Range = class Range extends Base
known = @fromNum and @toNum
idx = del o, 'index'
idxName = del o, 'name'
+ namedIndex = idxName and idxName isnt idx
varPart = "#{idx} = #{@fromC}"
varPart += ", #{@toC}" if @toC isnt @toVar
varPart += ", #{@step}" if @step isnt @stepVar
- varPart = "#{idxName} = #{varPart}" if idxName and idxName isnt idx
[lt, gt] = ["#{idx} <#{@equals}", "#{idx} >#{@equals}"]
# Generate the condition.
@@ -698,10 +698,18 @@ exports.Range = class Range extends Base
stepPart = if @stepVar
"#{idx} += #{@stepVar}"
else if known
- if from <= to then "++#{idx}" else "--#{idx}"
+ if namedIndex
+ if from <= to then "++#{idx}" else "--#{idx}"
+ else
+ if from <= to then "#{idx}++" else "#{idx}--"
else
- "#{cond} ? ++#{idx} : --#{idx}"
- stepPart = "#{idxName} = #{stepPart}" if idxName and idxName isnt idx
+ if namedIndex
+ "#{cond} ? ++#{idx} : --#{idx}"
+ else
+ "#{cond} ? #{idx}++ : #{idx}--"
+
+ varPart = "#{idxName} = #{varPart}" if namedIndex
+ stepPart = "#{idxName} = #{stepPart}" if namedIndex
# The final loop body.
"#{varPart}; #{condPart}; #{stepPart}"
@@ -1632,7 +1640,7 @@ exports.For = class For extends While
lvar = scope.freeVariable 'len'
forVarPart = "#{kvarAssign}#{ivar} = 0, #{lvar} = #{svar}.length"
forVarPart += ", #{stepvar} = #{@step.compile o, LEVEL_OP}" if @step
- stepPart = "#{kvarAssign}#{if @step then "#{ivar} += #{stepvar}" else "++#{ivar}"}"
+ stepPart = "#{kvarAssign}#{if @step then "#{ivar} += #{stepvar}" else (if kvar isnt ivar then "++#{ivar}" else "#{ivar}++")}"
forPart = "#{forVarPart}; #{ivar} < #{lvar}; #{stepPart}"
if @returns
resultPart = "#{@tab}#{rvar} = [];\n"
Please sign in to comment.
Something went wrong with that request. Please try again.