mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
optimizing comprehensions source references
This commit is contained in:
parent
5605ba32e3
commit
d4dac214ab
11 changed files with 70 additions and 86 deletions
|
@ -2,6 +2,6 @@
|
||||||
lunch = eat food for food in ['toast', 'cheese', 'wine']
|
lunch = eat food for food in ['toast', 'cheese', 'wine']
|
||||||
|
|
||||||
# Naive collision detection.
|
# Naive collision detection.
|
||||||
for roid in asteroids
|
for roid, index in asteroids
|
||||||
for roid2 in asteroids when roid isnt roid2
|
for roid2 in asteroids when roid isnt roid2
|
||||||
roid.explode() if roid.overlaps roid2
|
roid.explode() if roid.overlaps roid2
|
|
@ -1,4 +1,4 @@
|
||||||
var _i, _j, _len, _len2, _ref, _ref2, _result, food, lunch, roid, roid2;
|
var _i, _j, _len, _len2, _len3, _ref, _result, food, index, lunch, roid, roid2;
|
||||||
lunch = (function() {
|
lunch = (function() {
|
||||||
_result = []; _ref = ['toast', 'cheese', 'wine'];
|
_result = []; _ref = ['toast', 'cheese', 'wine'];
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
|
@ -7,12 +7,10 @@ lunch = (function() {
|
||||||
}
|
}
|
||||||
return _result;
|
return _result;
|
||||||
})();
|
})();
|
||||||
_ref = asteroids;
|
for (index = 0, _len2 = asteroids.length; index < _len2; index++) {
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
roid = asteroids[index];
|
||||||
roid = _ref[_i];
|
for (_j = 0, _len3 = asteroids.length; _j < _len3; _j++) {
|
||||||
_ref2 = asteroids;
|
roid2 = asteroids[_j];
|
||||||
for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
|
|
||||||
roid2 = _ref2[_j];
|
|
||||||
if (roid !== roid2) {
|
if (roid !== roid2) {
|
||||||
if (roid.overlaps(roid2)) {
|
if (roid.overlaps(roid2)) {
|
||||||
roid.explode();
|
roid.explode();
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
var Animal, Horse, Snake, sam, tom;
|
var Animal, Horse, Snake, sam, tom;
|
||||||
var __extends = function(child, parent) {
|
var __extends = function(child, parent) {
|
||||||
var ctor = function(){};
|
var ctor = function() {};
|
||||||
ctor.prototype = parent.prototype;
|
ctor.prototype = parent.prototype;
|
||||||
child.prototype = new ctor();
|
child.prototype = new ctor();
|
||||||
child.prototype.constructor = child;
|
child.prototype.constructor = child;
|
||||||
if (typeof parent.extended === "function") parent.extended(child);
|
if (typeof parent.extended === "function") parent.extended(child);
|
||||||
child.__super__ = parent.prototype;
|
child.__super__ = parent.prototype;
|
||||||
};
|
};
|
||||||
Animal = (function() {
|
Animal = (function() {
|
||||||
return function Animal(_arg) {
|
return function Animal(_arg) {
|
||||||
this.name = _arg;
|
this.name = _arg;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
var _ref, _result, globals, name;
|
var _result, globals, name;
|
||||||
var __hasProp = Object.prototype.hasOwnProperty;
|
var __hasProp = Object.prototype.hasOwnProperty;
|
||||||
globals = (function() {
|
globals = (function() {
|
||||||
_result = []; _ref = window;
|
_result = [];
|
||||||
for (name in _ref) {
|
for (name in window) {
|
||||||
if (!__hasProp.call(_ref, name)) continue;
|
if (!__hasProp.call(window, name)) continue;
|
||||||
_result.push(name);
|
_result.push(name);
|
||||||
}
|
}
|
||||||
return _result;
|
return _result;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
var Account;
|
var Account;
|
||||||
var __bind = function(func, context) {
|
var __bind = function(func, context) {
|
||||||
return function(){ return func.apply(context, arguments); };
|
return function() { return func.apply(context, arguments); };
|
||||||
};
|
};
|
||||||
Account = function(customer, cart) {
|
Account = function(customer, cart) {
|
||||||
this.customer = customer;
|
this.customer = customer;
|
||||||
this.cart = cart;
|
this.cart = cart;
|
||||||
|
|
62
index.html
62
index.html
|
@ -829,10 +829,10 @@ lyrics = (function() {
|
||||||
lunch <span class="Keyword">=</span> eat food <span class="Keyword">for</span> food <span class="Keyword">in</span> [<span class="String"><span class="String">'</span>toast<span class="String">'</span></span>, <span class="String"><span class="String">'</span>cheese<span class="String">'</span></span>, <span class="String"><span class="String">'</span>wine<span class="String">'</span></span>]
|
lunch <span class="Keyword">=</span> eat food <span class="Keyword">for</span> food <span class="Keyword">in</span> [<span class="String"><span class="String">'</span>toast<span class="String">'</span></span>, <span class="String"><span class="String">'</span>cheese<span class="String">'</span></span>, <span class="String"><span class="String">'</span>wine<span class="String">'</span></span>]
|
||||||
|
|
||||||
<span class="Comment"><span class="Comment">#</span> Naive collision detection.</span>
|
<span class="Comment"><span class="Comment">#</span> Naive collision detection.</span>
|
||||||
<span class="Keyword">for</span> roid <span class="Keyword">in</span> asteroids
|
<span class="Keyword">for</span> roid, index <span class="Keyword">in</span> asteroids
|
||||||
<span class="Keyword">for</span> roid2 <span class="Keyword">in</span> asteroids <span class="Keyword">when</span> roid <span class="Keyword">isnt</span> roid2
|
<span class="Keyword">for</span> roid2 <span class="Keyword">in</span> asteroids <span class="Keyword">when</span> roid <span class="Keyword">isnt</span> roid2
|
||||||
roid.explode() <span class="Keyword">if</span> roid.overlaps roid2
|
roid.explode() <span class="Keyword">if</span> roid.overlaps roid2
|
||||||
</pre><pre class="idle"><span class="Storage">var</span> _i, _j, _len, _len2, _ref, _ref2, _result, food, lunch, roid, roid2;
|
</pre><pre class="idle"><span class="Storage">var</span> _i, _j, _len, _len2, _len3, _ref, _result, food, index, lunch, roid, roid2;
|
||||||
lunch <span class="Keyword">=</span> (<span class="Storage">function</span>() {
|
lunch <span class="Keyword">=</span> (<span class="Storage">function</span>() {
|
||||||
_result <span class="Keyword">=</span> []; _ref <span class="Keyword">=</span> [<span class="String"><span class="String">'</span>toast<span class="String">'</span></span>, <span class="String"><span class="String">'</span>cheese<span class="String">'</span></span>, <span class="String"><span class="String">'</span>wine<span class="String">'</span></span>];
|
_result <span class="Keyword">=</span> []; _ref <span class="Keyword">=</span> [<span class="String"><span class="String">'</span>toast<span class="String">'</span></span>, <span class="String"><span class="String">'</span>cheese<span class="String">'</span></span>, <span class="String"><span class="String">'</span>wine<span class="String">'</span></span>];
|
||||||
<span class="Keyword">for</span> (_i <span class="Keyword">=</span> <span class="Number">0</span>, _len <span class="Keyword">=</span> _ref.<span class="LibraryConstant">length</span>; _i <span class="Keyword"><</span> _len; _i<span class="Keyword">++</span>) {
|
<span class="Keyword">for</span> (_i <span class="Keyword">=</span> <span class="Number">0</span>, _len <span class="Keyword">=</span> _ref.<span class="LibraryConstant">length</span>; _i <span class="Keyword"><</span> _len; _i<span class="Keyword">++</span>) {
|
||||||
|
@ -841,12 +841,10 @@ lunch <span class="Keyword">=</span> (<span class="Storage">function</span>() {
|
||||||
}
|
}
|
||||||
<span class="Keyword">return</span> _result;
|
<span class="Keyword">return</span> _result;
|
||||||
})();
|
})();
|
||||||
_ref <span class="Keyword">=</span> asteroids;
|
<span class="Keyword">for</span> (index <span class="Keyword">=</span> <span class="Number">0</span>, _len2 <span class="Keyword">=</span> asteroids.<span class="LibraryConstant">length</span>; index <span class="Keyword"><</span> _len2; index<span class="Keyword">++</span>) {
|
||||||
<span class="Keyword">for</span> (_i <span class="Keyword">=</span> <span class="Number">0</span>, _len <span class="Keyword">=</span> _ref.<span class="LibraryConstant">length</span>; _i <span class="Keyword"><</span> _len; _i<span class="Keyword">++</span>) {
|
roid <span class="Keyword">=</span> asteroids[index];
|
||||||
roid <span class="Keyword">=</span> _ref[_i];
|
<span class="Keyword">for</span> (_j <span class="Keyword">=</span> <span class="Number">0</span>, _len3 <span class="Keyword">=</span> asteroids.<span class="LibraryConstant">length</span>; _j <span class="Keyword"><</span> _len3; _j<span class="Keyword">++</span>) {
|
||||||
_ref2 <span class="Keyword">=</span> asteroids;
|
roid2 <span class="Keyword">=</span> asteroids[_j];
|
||||||
<span class="Keyword">for</span> (_j <span class="Keyword">=</span> <span class="Number">0</span>, _len2 <span class="Keyword">=</span> _ref2.<span class="LibraryConstant">length</span>; _j <span class="Keyword"><</span> _len2; _j<span class="Keyword">++</span>) {
|
|
||||||
roid2 <span class="Keyword">=</span> _ref2[_j];
|
|
||||||
<span class="Keyword">if</span> (roid <span class="Keyword">!</span><span class="Keyword">==</span> roid2) {
|
<span class="Keyword">if</span> (roid <span class="Keyword">!</span><span class="Keyword">==</span> roid2) {
|
||||||
<span class="Keyword">if</span> (roid.overlaps(roid2)) {
|
<span class="Keyword">if</span> (roid.overlaps(roid2)) {
|
||||||
roid.explode();
|
roid.explode();
|
||||||
|
@ -1045,22 +1043,22 @@ six = (one = 1) + (two = 2) + (three = 3);;alert(six);'>run: six</button><br cla
|
||||||
<div class='code'><pre class="idle"><span class="Comment"><span class="Comment">#</span> The first ten global properties.</span>
|
<div class='code'><pre class="idle"><span class="Comment"><span class="Comment">#</span> The first ten global properties.</span>
|
||||||
|
|
||||||
globals <span class="Keyword">=</span> (name <span class="Keyword">for</span> name <span class="Keyword">of</span> window)[<span class="Number">0</span>...<span class="Number">10</span>]
|
globals <span class="Keyword">=</span> (name <span class="Keyword">for</span> name <span class="Keyword">of</span> window)[<span class="Number">0</span>...<span class="Number">10</span>]
|
||||||
</pre><pre class="idle"><span class="Storage">var</span> _ref, _result, globals, name;
|
</pre><pre class="idle"><span class="Storage">var</span> _result, globals, name;
|
||||||
<span class="Storage">var</span> __hasProp <span class="Keyword">=</span> <span class="LibraryClassType">Object</span>.<span class="LibraryConstant">prototype</span>.hasOwnProperty;
|
<span class="Storage">var</span> __hasProp <span class="Keyword">=</span> <span class="LibraryClassType">Object</span>.<span class="LibraryConstant">prototype</span>.hasOwnProperty;
|
||||||
globals <span class="Keyword">=</span> (<span class="Storage">function</span>() {
|
globals <span class="Keyword">=</span> (<span class="Storage">function</span>() {
|
||||||
_result <span class="Keyword">=</span> []; _ref <span class="Keyword">=</span> <span class="LibraryClassType">window</span>;
|
_result <span class="Keyword">=</span> [];
|
||||||
<span class="Keyword">for</span> (name <span class="Keyword">in</span> _ref) {
|
<span class="Keyword">for</span> (name <span class="Keyword">in</span> <span class="LibraryClassType">window</span>) {
|
||||||
<span class="Keyword">if</span> (<span class="Keyword">!</span>__hasProp.<span class="LibraryFunction">call</span>(_ref, name)) <span class="Keyword">continue</span>;
|
<span class="Keyword">if</span> (<span class="Keyword">!</span>__hasProp.<span class="LibraryFunction">call</span>(<span class="LibraryClassType">window</span>, name)) <span class="Keyword">continue</span>;
|
||||||
_result.<span class="LibraryFunction">push</span>(name);
|
_result.<span class="LibraryFunction">push</span>(name);
|
||||||
}
|
}
|
||||||
<span class="Keyword">return</span> _result;
|
<span class="Keyword">return</span> _result;
|
||||||
})().<span class="LibraryFunction">slice</span>(<span class="Number">0</span>, <span class="Number">10</span>);
|
})().<span class="LibraryFunction">slice</span>(<span class="Number">0</span>, <span class="Number">10</span>);
|
||||||
</pre><button onclick='javascript: var _ref, _result, globals, name;
|
</pre><button onclick='javascript: var _result, globals, name;
|
||||||
var __hasProp = Object.prototype.hasOwnProperty;
|
var __hasProp = Object.prototype.hasOwnProperty;
|
||||||
globals = (function() {
|
globals = (function() {
|
||||||
_result = []; _ref = window;
|
_result = [];
|
||||||
for (name in _ref) {
|
for (name in window) {
|
||||||
if (!__hasProp.call(_ref, name)) continue;
|
if (!__hasProp.call(window, name)) continue;
|
||||||
_result.push(name);
|
_result.push(name);
|
||||||
}
|
}
|
||||||
return _result;
|
return _result;
|
||||||
|
@ -1194,13 +1192,13 @@ tom.move()
|
||||||
|
|
||||||
</pre><pre class="idle"><span class="Storage">var</span> Animal, Horse, Snake, sam, tom;
|
</pre><pre class="idle"><span class="Storage">var</span> Animal, Horse, Snake, sam, tom;
|
||||||
<span class="Storage">var</span> <span class="FunctionName">__extends</span> = <span class="Storage">function</span>(<span class="FunctionArgument">child, parent</span>) {
|
<span class="Storage">var</span> <span class="FunctionName">__extends</span> = <span class="Storage">function</span>(<span class="FunctionArgument">child, parent</span>) {
|
||||||
<span class="Storage">var</span> <span class="FunctionName">ctor</span> = <span class="Storage">function</span>(){};
|
<span class="Storage">var</span> <span class="FunctionName">ctor</span> = <span class="Storage">function</span>() {};
|
||||||
<span class="LibraryClassType">ctor</span>.<span class="LibraryConstant">prototype</span> = parent.<span class="LibraryConstant">prototype</span>;
|
<span class="LibraryClassType">ctor</span>.<span class="LibraryConstant">prototype</span> = parent.<span class="LibraryConstant">prototype</span>;
|
||||||
<span class="LibraryClassType">child</span>.<span class="LibraryConstant">prototype</span> = <span class="Keyword">new</span> <span class="TypeName">ctor</span>();
|
<span class="LibraryClassType">child</span>.<span class="LibraryConstant">prototype</span> = <span class="Keyword">new</span> <span class="TypeName">ctor</span>();
|
||||||
<span class="LibraryClassType">child</span>.<span class="LibraryConstant">prototype</span>.<span class="FunctionName">constructor</span> = child;
|
<span class="LibraryClassType">child</span>.<span class="LibraryConstant">prototype</span>.<span class="FunctionName">constructor</span> = child;
|
||||||
<span class="Keyword">if</span> (<span class="Keyword">typeof</span> parent.extended <span class="Keyword">===</span> <span class="String"><span class="String">"</span>function<span class="String">"</span></span>) parent.extended(child);
|
<span class="Keyword">if</span> (<span class="Keyword">typeof</span> parent.extended <span class="Keyword">===</span> <span class="String"><span class="String">"</span>function<span class="String">"</span></span>) parent.extended(child);
|
||||||
child.__super__ <span class="Keyword">=</span> parent.<span class="LibraryConstant">prototype</span>;
|
child.__super__ <span class="Keyword">=</span> parent.<span class="LibraryConstant">prototype</span>;
|
||||||
};
|
};
|
||||||
Animal <span class="Keyword">=</span> (<span class="Storage">function</span>() {
|
Animal <span class="Keyword">=</span> (<span class="Storage">function</span>() {
|
||||||
<span class="Keyword">return</span> <span class="Storage">function</span> <span class="FunctionName">Animal</span>(<span class="FunctionArgument">_arg</span>) {
|
<span class="Keyword">return</span> <span class="Storage">function</span> <span class="FunctionName">Animal</span>(<span class="FunctionArgument">_arg</span>) {
|
||||||
<span class="Variable">this</span>.<span class="LibraryConstant">name</span> <span class="Keyword">=</span> _arg;
|
<span class="Variable">this</span>.<span class="LibraryConstant">name</span> <span class="Keyword">=</span> _arg;
|
||||||
|
@ -1236,13 +1234,13 @@ sam.move();
|
||||||
tom.move();
|
tom.move();
|
||||||
</pre><button onclick='javascript: var Animal, Horse, Snake, sam, tom;
|
</pre><button onclick='javascript: var Animal, Horse, Snake, sam, tom;
|
||||||
var __extends = function(child, parent) {
|
var __extends = function(child, parent) {
|
||||||
var ctor = function(){};
|
var ctor = function() {};
|
||||||
ctor.prototype = parent.prototype;
|
ctor.prototype = parent.prototype;
|
||||||
child.prototype = new ctor();
|
child.prototype = new ctor();
|
||||||
child.prototype.constructor = child;
|
child.prototype.constructor = child;
|
||||||
if (typeof parent.extended === "function") parent.extended(child);
|
if (typeof parent.extended === "function") parent.extended(child);
|
||||||
child.__super__ = parent.prototype;
|
child.__super__ = parent.prototype;
|
||||||
};
|
};
|
||||||
Animal = (function() {
|
Animal = (function() {
|
||||||
return function Animal(_arg) {
|
return function Animal(_arg) {
|
||||||
this.name = _arg;
|
this.name = _arg;
|
||||||
|
@ -1418,8 +1416,8 @@ _ref = tag.split(""), open = _ref[0], contents = __slice.call(_ref, 1, _ref.leng
|
||||||
<span class="Variable">@customer</span>.purchase <span class="Variable">@cart</span>
|
<span class="Variable">@customer</span>.purchase <span class="Variable">@cart</span>
|
||||||
</pre><pre class="idle"><span class="Storage">var</span> Account;
|
</pre><pre class="idle"><span class="Storage">var</span> Account;
|
||||||
<span class="Storage">var</span> <span class="FunctionName">__bind</span> = <span class="Storage">function</span>(<span class="FunctionArgument">func, context</span>) {
|
<span class="Storage">var</span> <span class="FunctionName">__bind</span> = <span class="Storage">function</span>(<span class="FunctionArgument">func, context</span>) {
|
||||||
<span class="Keyword">return</span> <span class="Storage">function</span>(){ <span class="Keyword">return</span> func.<span class="LibraryFunction">apply</span>(context, arguments); };
|
<span class="Keyword">return</span> <span class="Storage">function</span>() { <span class="Keyword">return</span> func.<span class="LibraryFunction">apply</span>(context, arguments); };
|
||||||
};
|
};
|
||||||
<span class="FunctionName">Account</span> = <span class="Storage">function</span>(<span class="FunctionArgument">customer, cart</span>) {
|
<span class="FunctionName">Account</span> = <span class="Storage">function</span>(<span class="FunctionArgument">customer, cart</span>) {
|
||||||
<span class="Variable">this</span>.customer <span class="Keyword">=</span> customer;
|
<span class="Variable">this</span>.customer <span class="Keyword">=</span> customer;
|
||||||
<span class="Variable">this</span>.cart <span class="Keyword">=</span> cart;
|
<span class="Variable">this</span>.cart <span class="Keyword">=</span> cart;
|
||||||
|
|
|
@ -55,11 +55,10 @@
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
printTasks = function() {
|
printTasks = function() {
|
||||||
var _ref, desc, name, spaces, task;
|
var desc, name, spaces, task;
|
||||||
puts('');
|
puts('');
|
||||||
_ref = tasks;
|
for (name in tasks) {
|
||||||
for (name in _ref) {
|
task = tasks[name];
|
||||||
task = _ref[name];
|
|
||||||
spaces = 20 - name.length;
|
spaces = 20 - name.length;
|
||||||
spaces = spaces > 0 ? Array(spaces + 1).join(' ') : '';
|
spaces = spaces > 0 ? Array(spaces + 1).join(' ') : '';
|
||||||
desc = task.description ? ("# " + (task.description)) : '';
|
desc = task.description ? ("# " + (task.description)) : '';
|
||||||
|
|
|
@ -49,12 +49,12 @@
|
||||||
return compileScripts();
|
return compileScripts();
|
||||||
};
|
};
|
||||||
compileScripts = function() {
|
compileScripts = function() {
|
||||||
var _i, _len, _ref2, _result;
|
var _i, _len, _result;
|
||||||
_result = []; _ref2 = sources;
|
_result = [];
|
||||||
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
for (_i = 0, _len = sources.length; _i < _len; _i++) {
|
||||||
(function() {
|
(function() {
|
||||||
var base, compile;
|
var base, compile;
|
||||||
var source = _ref2[_i];
|
var source = sources[_i];
|
||||||
return _result.push((function() {
|
return _result.push((function() {
|
||||||
base = source;
|
base = source;
|
||||||
compile = function(source, topLevel) {
|
compile = function(source, topLevel) {
|
||||||
|
|
18
lib/nodes.js
18
lib/nodes.js
|
@ -1639,7 +1639,7 @@
|
||||||
return '';
|
return '';
|
||||||
};
|
};
|
||||||
ForNode.prototype.compileNode = function(o) {
|
ForNode.prototype.compileNode = function(o) {
|
||||||
var body, codeInBody, forPart, guardPart, idt1, index, ivar, lvar, name, namePart, range, ref, returnResult, rvar, scope, source, sourcePart, stepPart, svar, topLevel, varPart, vars;
|
var _ref2, body, codeInBody, forPart, guardPart, idt1, index, ivar, lvar, name, namePart, range, returnResult, rvar, scope, source, sourcePart, stepPart, svar, topLevel, varPart, vars;
|
||||||
topLevel = del(o, 'top') && !this.returns;
|
topLevel = del(o, 'top') && !this.returns;
|
||||||
range = this.source instanceof ValueNode && this.source.base instanceof RangeNode && !this.source.properties.length;
|
range = this.source instanceof ValueNode && this.source.base instanceof RangeNode && !this.source.properties.length;
|
||||||
source = range ? this.source.base : this.source;
|
source = range ? this.source.base : this.source;
|
||||||
|
@ -1677,16 +1677,12 @@
|
||||||
step: this.step
|
step: this.step
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
svar = this.source.compile(o);
|
_ref2 = this.source.compileReference(merge(o, {
|
||||||
if (IDENTIFIER.test(svar) && scope.check(svar, {
|
top: true
|
||||||
immediate: true
|
}), {
|
||||||
})) {
|
precompile: true
|
||||||
sourcePart = '';
|
}), sourcePart = _ref2[0], svar = _ref2[1];
|
||||||
} else {
|
sourcePart = sourcePart === svar ? '' : ("" + sourcePart + ";");
|
||||||
ref = scope.freeVariable('ref');
|
|
||||||
sourcePart = ("" + ref + " = " + svar + ";");
|
|
||||||
svar = ref;
|
|
||||||
}
|
|
||||||
namePart = this.pattern ? new AssignNode(this.name, literal("" + svar + "[" + ivar + "]")).compile(merge(o, {
|
namePart = this.pattern ? new AssignNode(this.name, literal("" + svar + "[" + ivar + "]")).compile(merge(o, {
|
||||||
top: true
|
top: true
|
||||||
})) : (name ? ("" + name + " = " + svar + "[" + ivar + "]") : undefined);
|
})) : (name ? ("" + name + " = " + svar + "[" + ivar + "]") : undefined);
|
||||||
|
|
|
@ -281,11 +281,10 @@
|
||||||
levels = {};
|
levels = {};
|
||||||
openLine = {};
|
openLine = {};
|
||||||
this.scanTokens(function(token, i) {
|
this.scanTokens(function(token, i) {
|
||||||
var _i, _len, _ref, _ref2, close, open, tag;
|
var _i, _len, _ref, close, open, tag;
|
||||||
tag = token[0];
|
tag = token[0];
|
||||||
_ref = pairs;
|
for (_i = 0, _len = pairs.length; _i < _len; _i++) {
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
_ref = pairs[_i], open = _ref[0], close = _ref[1];
|
||||||
_ref2 = _ref[_i], open = _ref2[0], close = _ref2[1];
|
|
||||||
levels[open] |= 0;
|
levels[open] |= 0;
|
||||||
if (tag === open) {
|
if (tag === open) {
|
||||||
if (levels[open] === 0) {
|
if (levels[open] === 0) {
|
||||||
|
@ -316,11 +315,10 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
exports.Rewriter.prototype.rewriteClosingParens = function() {
|
exports.Rewriter.prototype.rewriteClosingParens = function() {
|
||||||
var _ref, debt, key, stack;
|
var debt, key, stack;
|
||||||
stack = [];
|
stack = [];
|
||||||
debt = {};
|
debt = {};
|
||||||
_ref = INVERSES;
|
for (key in INVERSES) {
|
||||||
for (key in _ref) {
|
|
||||||
(debt[key] = 0);
|
(debt[key] = 0);
|
||||||
}
|
}
|
||||||
return this.scanTokens(function(token, i, tokens) {
|
return this.scanTokens(function(token, i, tokens) {
|
||||||
|
|
|
@ -1429,13 +1429,8 @@ exports.ForNode = class ForNode extends BaseNode
|
||||||
sourcePart = source.compileVariables(o)
|
sourcePart = source.compileVariables(o)
|
||||||
forPart = source.compile merge o, index: ivar, step: @step
|
forPart = source.compile merge o, index: ivar, step: @step
|
||||||
else
|
else
|
||||||
svar = @source.compile o
|
[sourcePart, svar] = @source.compileReference merge(o, top: yes), precompile: yes
|
||||||
if IDENTIFIER.test(svar) and scope.check(svar, immediate: on)
|
sourcePart = if sourcePart is svar then '' else "#{sourcePart};"
|
||||||
sourcePart = ''
|
|
||||||
else
|
|
||||||
ref = scope.freeVariable 'ref'
|
|
||||||
sourcePart = "#{ref} = #{svar};"
|
|
||||||
svar = ref
|
|
||||||
namePart = if @pattern
|
namePart = if @pattern
|
||||||
new AssignNode(@name, literal "#{svar}[#{ivar}]").compile merge o, top: on
|
new AssignNode(@name, literal "#{svar}[#{ivar}]").compile merge o, top: on
|
||||||
else if name
|
else if name
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue