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

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

Issue 11273121: Support closures inside initializers. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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 library closureToClassMapper; 5 library closureToClassMapper;
6 6
7 import "elements/elements.dart"; 7 import "elements/elements.dart";
8 import "dart2jslib.dart"; 8 import "dart2jslib.dart";
9 import "tree/tree.dart"; 9 import "tree/tree.dart";
10 import "util/util.dart"; 10 import "util/util.dart";
(...skipping 27 matching lines...) Expand all
38 } 38 }
39 assert(closureMappingCache[node] != null); 39 assert(closureMappingCache[node] != null);
40 return closureMappingCache[node]; 40 return closureMappingCache[node];
41 }); 41 });
42 } 42 }
43 43
44 ClosureClassMap getMappingForNestedFunction(FunctionExpression node) { 44 ClosureClassMap getMappingForNestedFunction(FunctionExpression node) {
45 return measure(() { 45 return measure(() {
46 ClosureClassMap nestedClosureData = closureMappingCache[node]; 46 ClosureClassMap nestedClosureData = closureMappingCache[node];
47 if (nestedClosureData == null) { 47 if (nestedClosureData == null) {
48 // TODO(floitsch): we can only assume that the reason for not having a 48 compiler.internalError("No closure cache", node: node);
49 // closure data here is, because the function is inside an initializer.
50 compiler.unimplemented("Closures inside initializers", node: node);
51 } 49 }
52 return nestedClosureData; 50 return nestedClosureData;
53 }); 51 });
54 } 52 }
55 } 53 }
56 54
57 class ClosureFieldElement extends Element { 55 class ClosureFieldElement extends Element {
58 ClosureFieldElement(SourceString name, ClassElement enclosing) 56 ClosureFieldElement(SourceString name, ClassElement enclosing)
59 : super(name, ElementKind.FIELD, enclosing); 57 : super(name, ElementKind.FIELD, enclosing);
60 58
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 if (element.isParameter()) { 601 if (element.isParameter()) {
604 // TODO(ahe): This is a hack. This method should *not* call 602 // TODO(ahe): This is a hack. This method should *not* call
605 // visitChildren. 603 // visitChildren.
606 return node.name.accept(this); 604 return node.name.accept(this);
607 } 605 }
608 606
609 visitInvokable(element, node, () { 607 visitInvokable(element, node, () {
610 // TODO(ahe): This is problematic. The backend should not repeat 608 // TODO(ahe): This is problematic. The backend should not repeat
611 // the work of the resolver. It is the resolver's job to create 609 // the work of the resolver. It is the resolver's job to create
612 // parameters, etc. Other phases should only visit statements. 610 // parameters, etc. Other phases should only visit statements.
613 // TODO(floitsch): we avoid visiting the initializers on purpose so that
614 // we get an error-message later in the builder.
615 if (node.parameters != null) node.parameters.accept(this); 611 if (node.parameters != null) node.parameters.accept(this);
612 if (node.initializers != null) node.initializers.accept(this);
616 if (node.body != null) node.body.accept(this); 613 if (node.body != null) node.body.accept(this);
617 }); 614 });
618 } 615 }
619 616
620 visitFunctionDeclaration(FunctionDeclaration node) { 617 visitFunctionDeclaration(FunctionDeclaration node) {
621 node.visitChildren(this); 618 node.visitChildren(this);
622 declareLocal(elements[node]); 619 declareLocal(elements[node]);
623 } 620 }
624 621
625 visitTryStatement(TryStatement node) { 622 visitTryStatement(TryStatement node) {
626 // TODO(ngeoffray): implement finer grain state. 623 // TODO(ngeoffray): implement finer grain state.
627 bool oldInTryStatement = inTryStatement; 624 bool oldInTryStatement = inTryStatement;
628 inTryStatement = true; 625 inTryStatement = true;
629 node.visitChildren(this); 626 node.visitChildren(this);
630 inTryStatement = oldInTryStatement; 627 inTryStatement = oldInTryStatement;
631 } 628 }
632 } 629 }
OLDNEW
« no previous file with comments | « no previous file | lib/compiler/implementation/ssa/builder.dart » ('j') | lib/compiler/implementation/ssa/codegen.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698