|
2566 | 2566 | For.prototype.children = ['body', 'source', 'guard', 'step'];
|
2567 | 2567 |
|
2568 | 2568 | For.prototype.compileNode = function(o) {
|
2569 |
| - var body, defPart, forPart, forVarPart, guardPart, idt1, index, ivar, kvar, kvarAssign, lastJumps, lvar, name, namePart, ref, resultPart, returnResult, rvar, scope, source, stepPart, stepvar, svar, varPart, _base, _ref2; |
| 2569 | + var body, defPart, forPart, forVarPart, guardPart, idt1, index, ivar, kvar, kvarAssign, lastJumps, lvar, name, namePart, ref, resultPart, returnResult, rvar, scope, source, step, stepPart, stepVar, svar, varPart, _ref2, _ref3; |
2570 | 2570 | body = Block.wrap([this.body]);
|
2571 | 2571 | lastJumps = (_ref2 = last(body.expressions)) != null ? _ref2.jumps() : void 0;
|
2572 | 2572 | if (lastJumps && lastJumps instanceof Return) {
|
|
2589 | 2589 | kvar = (this.range && name) || index || ivar;
|
2590 | 2590 | kvarAssign = kvar !== ivar ? "" + kvar + " = " : "";
|
2591 | 2591 | if (this.step && !this.range) {
|
2592 |
| - this.complexStep = !(typeof (_base = this.step).isSimpleNumber === "function" ? _base.isSimpleNumber() : void 0); |
2593 |
| - stepvar = this.complexStep ? scope.freeVariable("step") : this.step.compile(o, LEVEL_OP); |
| 2592 | + _ref3 = this.step.cache(o, LEVEL_LIST), step = _ref3[0], stepVar = _ref3[1]; |
2594 | 2593 | }
|
2595 | 2594 | if (this.pattern) {
|
2596 | 2595 | name = ivar;
|
|
2617 | 2616 | if (!this.object) {
|
2618 | 2617 | lvar = scope.freeVariable('len');
|
2619 | 2618 | forVarPart = "" + kvarAssign + ivar + " = 0, " + lvar + " = " + svar + ".length";
|
2620 |
| - if (this.complexStep) { |
2621 |
| - forVarPart += ", " + stepvar + " = " + (this.step.compile(o, LEVEL_OP)); |
| 2619 | + if (step !== stepVar) { |
| 2620 | + forVarPart += ", " + step; |
2622 | 2621 | }
|
2623 |
| - stepPart = "" + kvarAssign + (this.step ? "" + ivar + " += " + stepvar : (kvar !== ivar ? "++" + ivar : "" + ivar + "++")); |
| 2622 | + stepPart = "" + kvarAssign + (this.step ? "" + ivar + " += " + stepVar : (kvar !== ivar ? "++" + ivar : "" + ivar + "++")); |
2624 | 2623 | forPart = "" + forVarPart + "; " + ivar + " < " + lvar + "; " + stepPart;
|
2625 | 2624 | }
|
2626 | 2625 | }
|
|
0 commit comments