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

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

Issue 13866010: Correctly compile unresolved for-in loops. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Additional problems found during testing. Created 7 years, 8 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 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 "dart_types.dart"; 9 import "dart_types.dart";
10 import "scanner/scannerlib.dart" show Token; 10 import "scanner/scannerlib.dart" show Token;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 return measure(() { 56 return measure(() {
57 ClosureClassMap nestedClosureData = closureMappingCache[node]; 57 ClosureClassMap nestedClosureData = closureMappingCache[node];
58 if (nestedClosureData == null) { 58 if (nestedClosureData == null) {
59 compiler.internalError("No closure cache", node: node); 59 compiler.internalError("No closure cache", node: node);
60 } 60 }
61 return nestedClosureData; 61 return nestedClosureData;
62 }); 62 });
63 } 63 }
64 } 64 }
65 65
66 // TODO(ahe): These classes continuously cause problems. We need to
67 // move these classes to elements/modelx.dart or see if we can find a
68 // more general solution.
66 class ClosureFieldElement extends ElementX { 69 class ClosureFieldElement extends ElementX {
67 ClosureFieldElement(SourceString name, ClassElement enclosing) 70 ClosureFieldElement(SourceString name, ClassElement enclosing)
68 : super(name, ElementKind.FIELD, enclosing); 71 : super(name, ElementKind.FIELD, enclosing);
69 72
70 bool isInstanceMember() => true; 73 bool isInstanceMember() => true;
71 bool isAssignable() => false; 74 bool isAssignable() => false;
72 // The names of closure variables don't need renaming, since their use is very 75 // The names of closure variables don't need renaming, since their use is very
73 // simple and they have 1-character names in the minified mode. 76 // simple and they have 1-character names in the minified mode.
74 bool hasFixedBackendName() => true; 77 bool hasFixedBackendName() => true;
75 String fixedBackendName() => name.slowToString(); 78 String fixedBackendName() => name.slowToString();
76 79
77 DartType computeType(Compiler compiler) => compiler.types.dynamicType; 80 DartType computeType(Compiler compiler) => compiler.types.dynamicType;
78 81
79 String toString() => "ClosureFieldElement($name)"; 82 String toString() => "ClosureFieldElement($name)";
80 } 83 }
81 84
85 // TODO(ahe): These classes continuously cause problems. We need to
86 // move these classes to elements/modelx.dart or see if we can find a
87 // more general solution.
82 class ClosureClassElement extends ClassElementX { 88 class ClosureClassElement extends ClassElementX {
83 DartType rawType; 89 DartType rawType;
84 DartType thisType; 90 DartType thisType;
85 /// Node that corresponds to this closure, used for source position. 91 /// Node that corresponds to this closure, used for source position.
86 final FunctionExpression node; 92 final FunctionExpression node;
87 93
88 ClosureClassElement(this.node, 94 ClosureClassElement(this.node,
89 SourceString name, 95 SourceString name,
90 Compiler compiler, 96 Compiler compiler,
91 this.methodElement, 97 this.methodElement,
(...skipping 15 matching lines...) Expand all
107 bool isClosure() => true; 113 bool isClosure() => true;
108 114
109 Token position() => node.getBeginToken(); 115 Token position() => node.getBeginToken();
110 116
111 /** 117 /**
112 * The most outer method this closure is declared into. 118 * The most outer method this closure is declared into.
113 */ 119 */
114 Element methodElement; 120 Element methodElement;
115 } 121 }
116 122
123 // TODO(ahe): These classes continuously cause problems. We need to
124 // move these classes to elements/modelx.dart or see if we can find a
125 // more general solution.
117 class BoxElement extends ElementX { 126 class BoxElement extends ElementX {
118 BoxElement(SourceString name, Element enclosingElement) 127 BoxElement(SourceString name, Element enclosingElement)
119 : super(name, ElementKind.VARIABLE, enclosingElement); 128 : super(name, ElementKind.VARIABLE, enclosingElement);
120 } 129 }
121 130
131 // TODO(ahe): These classes continuously cause problems. We need to
132 // move these classes to elements/modelx.dart or see if we can find a
133 // more general solution.
122 class ThisElement extends ElementX { 134 class ThisElement extends ElementX {
123 ThisElement(Element enclosing) 135 ThisElement(Element enclosing)
124 : super(const SourceString('this'), ElementKind.PARAMETER, enclosing); 136 : super(const SourceString('this'), ElementKind.PARAMETER, enclosing);
125 137
126 bool isAssignable() => false; 138 bool isAssignable() => false;
127 139
128 // Since there is no declaration corresponding to 'this', use the position of 140 // Since there is no declaration corresponding to 'this', use the position of
129 // the enclosing method. 141 // the enclosing method.
130 Token position() => enclosingElement.position(); 142 Token position() => enclosingElement.position();
131 } 143 }
132 144
145 // TODO(ahe): These classes continuously cause problems. We need to
146 // move these classes to elements/modelx.dart or see if we can find a
147 // more general solution.
133 class CheckVariableElement extends ElementX { 148 class CheckVariableElement extends ElementX {
134 Element parameter; 149 Element parameter;
135 CheckVariableElement(SourceString name, this.parameter, Element enclosing) 150 CheckVariableElement(SourceString name, this.parameter, Element enclosing)
136 : super(name, ElementKind.VARIABLE, enclosing); 151 : super(name, ElementKind.VARIABLE, enclosing);
137 152
138 // Since there is no declaration for the synthetic 'check' variable, use 153 // Since there is no declaration for the synthetic 'check' variable, use
139 // parameter. 154 // parameter.
140 Token position() => parameter.position(); 155 Token position() => parameter.position();
141 } 156 }
142 157
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 } 716 }
702 717
703 visitTryStatement(TryStatement node) { 718 visitTryStatement(TryStatement node) {
704 // TODO(ngeoffray): implement finer grain state. 719 // TODO(ngeoffray): implement finer grain state.
705 bool oldInTryStatement = inTryStatement; 720 bool oldInTryStatement = inTryStatement;
706 inTryStatement = true; 721 inTryStatement = true;
707 node.visitChildren(this); 722 node.visitChildren(this);
708 inTryStatement = oldInTryStatement; 723 inTryStatement = oldInTryStatement;
709 } 724 }
710 } 725 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698