Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(791)

Unified Diff: frog/minfrog

Issue 8799018: Fixed lambdas that have the same name as one of their parameters/locals (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: frog/minfrog
diff --git a/frog/minfrog b/frog/minfrog
index a3004adc6eb64eb0602b61818d33b2c7ef60287a..6d74e72488acf047daf0f46dbc8f74d5a1d3035e 100755
--- a/frog/minfrog
+++ b/frog/minfrog
@@ -2520,10 +2520,6 @@ function MethodGenerator(method, enclosingMethod) {
else {
this._scope = new BlockScope(this, null, false);
}
- if (this.enclosingMethod != null && this.method.name != '') {
- var m = this.method;
- this._scope.create(m.name, m.get$functionType(), m.definition.span, true, false);
- }
this._usedTemps = new HashSetImplementation();
this._freeTemps = [];
}
@@ -2920,7 +2916,6 @@ MethodGenerator.prototype._makeLambdaMethod = function(name, func) {
meth.set$isLambda(true);
meth.set$enclosingElement(this.method);
meth.resolve$0();
- $globals.world.gen.genMethod(meth, this);
return meth;
}
MethodGenerator.prototype.visitBool = function(node) {
@@ -2989,9 +2984,9 @@ MethodGenerator.prototype.visitVariableDefinition = function(node) {
return false;
}
MethodGenerator.prototype.visitFunctionDefinition = function(node) {
- var name = $globals.world.toJsIdentifier(node.name.name);
- var meth = this._makeLambdaMethod(name, node);
- var funcValue = this._scope.create(name, meth.get$functionType(), this.method.get$definition().get$span(), true, false);
+ var meth = this._makeLambdaMethod(node.name.name, node);
+ var funcValue = this._scope.create(meth.get$name(), meth.get$functionType(), this.method.get$definition().get$span(), true, false);
+ $globals.world.gen.genMethod(meth, this);
meth.get$generator().writeDefinition$2(this.writer);
return false;
}
@@ -3365,13 +3360,16 @@ MethodGenerator.prototype._makeThisValue = function(node) {
}
}
MethodGenerator.prototype.visitLambdaExpression = function(node) {
- var name = '';
- if (node.func.name != null) {
- name = $globals.world.toJsIdentifier(node.func.name.name);
- }
+ var name = (node.func.name != null) ? node.func.name.name : '';
var meth = this._makeLambdaMethod(name, node.func);
+ var lambdaGen = new MethodGenerator(meth, this);
+ if ($ne(name, '')) {
+ lambdaGen._scope.create(name, meth.get$functionType(), meth.definition.span, true, false);
+ lambdaGen._pushBlock(false);
+ }
+ lambdaGen.run();
var w = new CodeWriter();
- meth.get$generator().writeDefinition$2(w, node);
+ meth.generator.writeDefinition(w, node);
return new Value(meth.get$functionType(), w.get$text(), node.span, true);
}
MethodGenerator.prototype.visitCallExpression = function(node) {
« frog/gen.dart ('K') | « frog/gen.dart ('k') | tests/corelib/corelib.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698