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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env node 1 #!/usr/bin/env node
2 // ********** Library dart:core ************** 2 // ********** Library dart:core **************
3 // ********** Natives dart:core ************** 3 // ********** Natives dart:core **************
4 /** 4 /**
5 * Generates a dynamic call stub for a function. 5 * Generates a dynamic call stub for a function.
6 * Our goal is to create a stub method like this on-the-fly: 6 * Our goal is to create a stub method like this on-the-fly:
7 * function($0, $1, capture) { return this($0, $1, true, capture); } 7 * function($0, $1, capture) { return this($0, $1, true, capture); }
8 * 8 *
9 * This stub then replaces the dynamic one on Function, with one that is 9 * This stub then replaces the dynamic one on Function, with one that is
10 * specialized for that particular function, taking into account its default 10 * specialized for that particular function, taking into account its default
(...skipping 2502 matching lines...) Expand 10 before | Expand all | Expand 10 after
2513 this.writer = new CodeWriter(); 2513 this.writer = new CodeWriter();
2514 this.needsThis = false; 2514 this.needsThis = false;
2515 // Initializers done 2515 // Initializers done
2516 if (this.enclosingMethod != null) { 2516 if (this.enclosingMethod != null) {
2517 this._scope = new BlockScope(this, this.enclosingMethod._scope, false); 2517 this._scope = new BlockScope(this, this.enclosingMethod._scope, false);
2518 this.captures = new HashSetImplementation(); 2518 this.captures = new HashSetImplementation();
2519 } 2519 }
2520 else { 2520 else {
2521 this._scope = new BlockScope(this, null, false); 2521 this._scope = new BlockScope(this, null, false);
2522 } 2522 }
2523 if (this.enclosingMethod != null && this.method.name != '') {
2524 var m = this.method;
2525 this._scope.create(m.name, m.get$functionType(), m.definition.span, true, fa lse);
2526 }
2527 this._usedTemps = new HashSetImplementation(); 2523 this._usedTemps = new HashSetImplementation();
2528 this._freeTemps = []; 2524 this._freeTemps = [];
2529 } 2525 }
2530 MethodGenerator.prototype.get$enclosingMethod = function() { return this.enclosi ngMethod; }; 2526 MethodGenerator.prototype.get$enclosingMethod = function() { return this.enclosi ngMethod; };
2531 MethodGenerator.prototype.set$enclosingMethod = function(value) { return this.en closingMethod = value; }; 2527 MethodGenerator.prototype.set$enclosingMethod = function(value) { return this.en closingMethod = value; };
2532 MethodGenerator.prototype.get$needsThis = function() { return this.needsThis; }; 2528 MethodGenerator.prototype.get$needsThis = function() { return this.needsThis; };
2533 MethodGenerator.prototype.set$needsThis = function(value) { return this.needsThi s = value; }; 2529 MethodGenerator.prototype.set$needsThis = function(value) { return this.needsThi s = value; };
2534 MethodGenerator.prototype.get$library = function() { 2530 MethodGenerator.prototype.get$library = function() {
2535 return this.method.get$library(); 2531 return this.method.get$library();
2536 } 2532 }
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
2913 this._scope = new BlockScope(this, this._scope, reentrant); 2909 this._scope = new BlockScope(this, this._scope, reentrant);
2914 } 2910 }
2915 MethodGenerator.prototype._popBlock = function() { 2911 MethodGenerator.prototype._popBlock = function() {
2916 this._scope = this._scope.parent; 2912 this._scope = this._scope.parent;
2917 } 2913 }
2918 MethodGenerator.prototype._makeLambdaMethod = function(name, func) { 2914 MethodGenerator.prototype._makeLambdaMethod = function(name, func) {
2919 var meth = new MethodMember(name, this.method.declaringType, func); 2915 var meth = new MethodMember(name, this.method.declaringType, func);
2920 meth.set$isLambda(true); 2916 meth.set$isLambda(true);
2921 meth.set$enclosingElement(this.method); 2917 meth.set$enclosingElement(this.method);
2922 meth.resolve$0(); 2918 meth.resolve$0();
2923 $globals.world.gen.genMethod(meth, this);
2924 return meth; 2919 return meth;
2925 } 2920 }
2926 MethodGenerator.prototype.visitBool = function(node) { 2921 MethodGenerator.prototype.visitBool = function(node) {
2927 return this.visitValue(node).convertTo$3(this, $globals.world.nonNullBool, nod e); 2922 return this.visitValue(node).convertTo$3(this, $globals.world.nonNullBool, nod e);
2928 } 2923 }
2929 MethodGenerator.prototype.visitValue = function(node) { 2924 MethodGenerator.prototype.visitValue = function(node) {
2930 if (node == null) return null; 2925 if (node == null) return null;
2931 var value = node.visit(this); 2926 var value = node.visit(this);
2932 value.checkFirstClass$1(node.span); 2927 value.checkFirstClass$1(node.span);
2933 return value; 2928 return value;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2982 } 2977 }
2983 else { 2978 else {
2984 value = value.convertTo$3(this, type, node.values.$index(i)); 2979 value = value.convertTo$3(this, type, node.values.$index(i));
2985 this.writer.write(('' + val.get$code() + ' = ' + value.get$code())); 2980 this.writer.write(('' + val.get$code() + ' = ' + value.get$code()));
2986 } 2981 }
2987 } 2982 }
2988 this.writer.writeln(';'); 2983 this.writer.writeln(';');
2989 return false; 2984 return false;
2990 } 2985 }
2991 MethodGenerator.prototype.visitFunctionDefinition = function(node) { 2986 MethodGenerator.prototype.visitFunctionDefinition = function(node) {
2992 var name = $globals.world.toJsIdentifier(node.name.name); 2987 var meth = this._makeLambdaMethod(node.name.name, node);
2993 var meth = this._makeLambdaMethod(name, node); 2988 var funcValue = this._scope.create(meth.get$name(), meth.get$functionType(), t his.method.get$definition().get$span(), true, false);
2994 var funcValue = this._scope.create(name, meth.get$functionType(), this.method. get$definition().get$span(), true, false); 2989 $globals.world.gen.genMethod(meth, this);
2995 meth.get$generator().writeDefinition$2(this.writer); 2990 meth.get$generator().writeDefinition$2(this.writer);
2996 return false; 2991 return false;
2997 } 2992 }
2998 MethodGenerator.prototype.visitReturnStatement = function(node) { 2993 MethodGenerator.prototype.visitReturnStatement = function(node) {
2999 if (node.value == null) { 2994 if (node.value == null) {
3000 this.writer.writeln('return;'); 2995 this.writer.writeln('return;');
3001 } 2996 }
3002 else { 2997 else {
3003 if (this.method.get$isConstructor()) { 2998 if (this.method.get$isConstructor()) {
3004 $globals.world.error('return of value not allowed from constructor', node. span); 2999 $globals.world.error('return of value not allowed from constructor', node. span);
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
3358 outermostMethod._checkNonStatic(node); 3353 outermostMethod._checkNonStatic(node);
3359 outermostMethod.set$needsThis(true); 3354 outermostMethod.set$needsThis(true);
3360 return new Value(outermostMethod.method.get$declaringType(), '\$this', node != null ? node.span : null, false); 3355 return new Value(outermostMethod.method.get$declaringType(), '\$this', node != null ? node.span : null, false);
3361 } 3356 }
3362 else { 3357 else {
3363 this._checkNonStatic(node); 3358 this._checkNonStatic(node);
3364 return new Value(this.method.declaringType, 'this', node != null ? node.span : null, false); 3359 return new Value(this.method.declaringType, 'this', node != null ? node.span : null, false);
3365 } 3360 }
3366 } 3361 }
3367 MethodGenerator.prototype.visitLambdaExpression = function(node) { 3362 MethodGenerator.prototype.visitLambdaExpression = function(node) {
3368 var name = ''; 3363 var name = (node.func.name != null) ? node.func.name.name : '';
3369 if (node.func.name != null) { 3364 var meth = this._makeLambdaMethod(name, node.func);
3370 name = $globals.world.toJsIdentifier(node.func.name.name); 3365 var lambdaGen = new MethodGenerator(meth, this);
3366 if ($ne(name, '')) {
3367 lambdaGen._scope.create(name, meth.get$functionType(), meth.definition.span, true, false);
3368 lambdaGen._pushBlock(false);
3371 } 3369 }
3372 var meth = this._makeLambdaMethod(name, node.func); 3370 lambdaGen.run();
3373 var w = new CodeWriter(); 3371 var w = new CodeWriter();
3374 meth.get$generator().writeDefinition$2(w, node); 3372 meth.generator.writeDefinition(w, node);
3375 return new Value(meth.get$functionType(), w.get$text(), node.span, true); 3373 return new Value(meth.get$functionType(), w.get$text(), node.span, true);
3376 } 3374 }
3377 MethodGenerator.prototype.visitCallExpression = function(node) { 3375 MethodGenerator.prototype.visitCallExpression = function(node) {
3378 var target; 3376 var target;
3379 var position = node.target; 3377 var position = node.target;
3380 var name = ':call'; 3378 var name = ':call';
3381 if ((node.target instanceof DotExpression)) { 3379 if ((node.target instanceof DotExpression)) {
3382 var dot = node.target; 3380 var dot = node.target;
3383 target = dot.self.visit(this); 3381 target = dot.self.visit(this);
3384 name = dot.name.name; 3382 name = dot.name.name;
(...skipping 9590 matching lines...) Expand 10 before | Expand all | Expand 10 after
12975 $inheritsMembers(_DoubleLinkedQueueEntrySentinel_KeyValuePair_K$V, DoubleLinkedQ ueueEntry_KeyValuePair_K$V); 12973 $inheritsMembers(_DoubleLinkedQueueEntrySentinel_KeyValuePair_K$V, DoubleLinkedQ ueueEntry_KeyValuePair_K$V);
12976 // ********** Globals ************** 12974 // ********** Globals **************
12977 function $static_init(){ 12975 function $static_init(){
12978 } 12976 }
12979 var const$0 = new NoMoreElementsException()/*const NoMoreElementsException()*/; 12977 var const$0 = new NoMoreElementsException()/*const NoMoreElementsException()*/;
12980 var const$2 = new EmptyQueueException()/*const EmptyQueueException()*/; 12978 var const$2 = new EmptyQueueException()/*const EmptyQueueException()*/;
12981 var const$3 = new _DeletedKeySentinel()/*const _DeletedKeySentinel()*/; 12979 var const$3 = new _DeletedKeySentinel()/*const _DeletedKeySentinel()*/;
12982 var $globals = {}; 12980 var $globals = {};
12983 $static_init(); 12981 $static_init();
12984 main(); 12982 main();
OLDNEW
« 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