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

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: Address comments. 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 // TODO(ahe): we shouldn't use the scope to get the enclosing element. This
1376 // is currently needed so that nested functions get their correct enclosing
1377 // element.
1378 Element functionEnclosing = scope.element;
1379 if (functionEnclosing.kind == ElementKind.VARIABLE_LIST) {
1380 compiler.internalError("Bad enclosing element", node: node);
1381 }
1382 if (functionEnclosing.isLibrary()) {
1383 // We are in a static initializers.
1384 functionEnclosing = enclosingElement;
1385 }
1375 FunctionElement enclosing = new FunctionElement.node( 1386 FunctionElement enclosing = new FunctionElement.node(
1376 name, node, ElementKind.FUNCTION, Modifiers.EMPTY, 1387 name, node, ElementKind.FUNCTION, Modifiers.EMPTY,
1377 scope.element); 1388 functionEnclosing);
1378 setupFunction(node, enclosing); 1389 setupFunction(node, enclosing);
1379 defineElement(node, enclosing, doAddToScope: node.name !== null); 1390 defineElement(node, enclosing, doAddToScope: node.name !== null);
1380 1391
1381 // Run the body in a fresh statement scope. 1392 // Run the body in a fresh statement scope.
1382 StatementScope oldScope = statementScope; 1393 StatementScope oldScope = statementScope;
1383 statementScope = new StatementScope(); 1394 statementScope = new StatementScope();
1384 visit(node.body); 1395 visit(node.body);
1385 statementScope = oldScope; 1396 statementScope = oldScope;
1386 1397
1387 scope = scope.parent; 1398 scope = scope.parent;
(...skipping 1751 matching lines...) Expand 10 before | Expand all | Expand 10 after
3139 return result; 3150 return result;
3140 } 3151 }
3141 Element lookup(SourceString name) => localLookup(name); 3152 Element lookup(SourceString name) => localLookup(name);
3142 Element lexicalLookup(SourceString name) => localLookup(name); 3153 Element lexicalLookup(SourceString name) => localLookup(name);
3143 3154
3144 Element add(Element newElement) { 3155 Element add(Element newElement) {
3145 throw "Cannot add an element in a patch library scope"; 3156 throw "Cannot add an element in a patch library scope";
3146 } 3157 }
3147 String toString() => 'PatchLibraryScope($origin,$patch)'; 3158 String toString() => 'PatchLibraryScope($origin,$patch)';
3148 } 3159 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/elements/elements.dart ('k') | lib/compiler/implementation/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698