merging in satyr/for-of-diet

This commit is contained in:
Jeremy Ashkenas
2010-09-22 23:26:11 -04:00
2 changed files with 8 additions and 4 deletions

View File

@@ -1644,7 +1644,7 @@
return n instanceof CodeNode;
});
scope = o.scope;
name = (this.name && this.name.compile(o)) || scope.freeVariable('i');
name = this.name && this.name.compile(o);
index = this.index && this.index.compile(o);
if (name && !this.pattern && (range || !codeInBody)) {
scope.find(name, {
@@ -1659,7 +1659,10 @@
if (!(topLevel)) {
rvar = scope.freeVariable('result');
}
ivar = codeInBody ? scope.freeVariable('i') : (range ? name : index || scope.freeVariable('i'));
ivar = range ? name : index;
if (!ivar || codeInBody) {
ivar = scope.freeVariable('i');
}
varPart = '';
guardPart = '';
body = Expressions.wrap([this.body]);

View File

@@ -1380,12 +1380,13 @@ exports.ForNode = class ForNode extends BaseNode
source = if range then @source.base else @source
codeInBody = @body.contains (n) -> n instanceof CodeNode
scope = o.scope
name = (@name and @name.compile(o)) or scope.freeVariable 'i'
name = @name and @name.compile o
index = @index and @index.compile o
scope.find(name, immediate: yes) if name and not @pattern and (range or not codeInBody)
scope.find(index, immediate: yes) if index
rvar = scope.freeVariable 'result' unless topLevel
ivar = if codeInBody then scope.freeVariable 'i' else if range then name else index or scope.freeVariable 'i'
ivar = if range then name else index
ivar = scope.freeVariable 'i' if not ivar or codeInBody
varPart = ''
guardPart = ''
body = Expressions.wrap([@body])