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

Side by Side Diff: lib/compiler/implementation/resolver.dart

Issue 10913133: Allow closures inside lazy initializers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add test. Created 8 years, 2 months 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 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 abstract class TreeElements { 5 abstract class TreeElements {
6 Element operator[](Node node); 6 Element operator[](Node node);
7 Selector getSelector(Send send); 7 Selector getSelector(Send send);
8 DartType getType(TypeAnnotation annotation); 8 DartType getType(TypeAnnotation annotation);
9 bool isParameterChecked(Element element); 9 bool isParameterChecked(Element element);
10 } 10 }
(...skipping 1354 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 } 1365 }
1366 1366
1367 visitFunctionExpression(FunctionExpression node) { 1367 visitFunctionExpression(FunctionExpression node) {
1368 visit(node.returnType); 1368 visit(node.returnType);
1369 SourceString name; 1369 SourceString name;
1370 if (node.name === null) { 1370 if (node.name === null) {
1371 name = const SourceString(""); 1371 name = const SourceString("");
1372 } else { 1372 } else {
1373 name = node.name.asIdentifier().source; 1373 name = node.name.asIdentifier().source;
1374 } 1374 }
1375 if (scope.element.kind == ElementKind.VARIABLE_LIST) {
1376 compiler.internalError("Bad enclosing element", node: node);
1377 }
1378 Element functionEnclosing = scope.element;
ahe 2012/10/11 07:36:05 How about moving this assignment above the if stat
floitsch 2012/10/11 13:58:12 Done.
1379 if (functionEnclosing.isLibrary()) {
1380 // We are in a static initializers.
1381 functionEnclosing = enclosingElement;
ahe 2012/10/11 07:36:05 This is not making any sense to me.
floitsch 2012/10/11 13:58:12 Added comments and a TODO(ahe).
1382 }
1375 FunctionElement enclosing = new FunctionElement.node( 1383 FunctionElement enclosing = new FunctionElement.node(
1376 name, node, ElementKind.FUNCTION, Modifiers.EMPTY, 1384 name, node, ElementKind.FUNCTION, Modifiers.EMPTY,
1377 scope.element); 1385 functionEnclosing);
1378 setupFunction(node, enclosing); 1386 setupFunction(node, enclosing);
1379 defineElement(node, enclosing, doAddToScope: node.name !== null); 1387 defineElement(node, enclosing, doAddToScope: node.name !== null);
1380 1388
1381 // Run the body in a fresh statement scope. 1389 // Run the body in a fresh statement scope.
1382 StatementScope oldScope = statementScope; 1390 StatementScope oldScope = statementScope;
1383 statementScope = new StatementScope(); 1391 statementScope = new StatementScope();
1384 visit(node.body); 1392 visit(node.body);
1385 statementScope = oldScope; 1393 statementScope = oldScope;
1386 1394
1387 scope = scope.parent; 1395 scope = scope.parent;
(...skipping 1751 matching lines...) Expand 10 before | Expand all | Expand 10 after
3139 return result; 3147 return result;
3140 } 3148 }
3141 Element lookup(SourceString name) => localLookup(name); 3149 Element lookup(SourceString name) => localLookup(name);
3142 Element lexicalLookup(SourceString name) => localLookup(name); 3150 Element lexicalLookup(SourceString name) => localLookup(name);
3143 3151
3144 Element add(Element newElement) { 3152 Element add(Element newElement) {
3145 throw "Cannot add an element in a patch library scope"; 3153 throw "Cannot add an element in a patch library scope";
3146 } 3154 }
3147 String toString() => 'PatchLibraryScope($origin,$patch)'; 3155 String toString() => 'PatchLibraryScope($origin,$patch)';
3148 } 3156 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698