OLD | NEW |
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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 * The most outer method this closure is declared into. | 142 * The most outer method this closure is declared into. |
143 */ | 143 */ |
144 final Element methodElement; | 144 final Element methodElement; |
145 } | 145 } |
146 | 146 |
147 // TODO(ahe): These classes continuously cause problems. We need to | 147 // TODO(ahe): These classes continuously cause problems. We need to |
148 // move these classes to elements/modelx.dart or see if we can find a | 148 // move these classes to elements/modelx.dart or see if we can find a |
149 // more general solution. | 149 // more general solution. |
150 class BoxElement extends ElementX { | 150 class BoxElement extends ElementX { |
151 BoxElement(String name, Element enclosingElement) | 151 BoxElement(String name, Element enclosingElement) |
152 : super(name, ElementKind.VARIABLE, enclosingElement); | 152 : super(name, ElementKind.VARIABLE_LIST, enclosingElement); |
153 | 153 |
154 DartType computeType(Compiler compiler) => compiler.types.dynamicType; | 154 DartType computeType(Compiler compiler) => compiler.types.dynamicType; |
155 } | 155 } |
156 | 156 |
157 // TODO(ngeoffray, ahe): These classes continuously cause problems. We need to | 157 // TODO(ngeoffray, ahe): These classes continuously cause problems. We need to |
158 // move these classes to elements/modelx.dart or see if we can find a | 158 // move these classes to elements/modelx.dart or see if we can find a |
159 // more general solution. | 159 // more general solution. |
160 class BoxFieldElement extends ElementX { | 160 class BoxFieldElement extends ElementX { |
161 BoxFieldElement(String name, | 161 BoxFieldElement(String name, |
162 this.variableElement, | 162 this.variableElement, |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 if (fromElement == updatedElement) { | 382 if (fromElement == updatedElement) { |
383 assert(freeVariableMapping[fromElement] == updatedElement); | 383 assert(freeVariableMapping[fromElement] == updatedElement); |
384 assert(Elements.isLocal(updatedElement) | 384 assert(Elements.isLocal(updatedElement) |
385 || updatedElement.isTypeVariable()); | 385 || updatedElement.isTypeVariable()); |
386 // The variable has not been boxed. | 386 // The variable has not been boxed. |
387 fieldCaptures.add(updatedElement); | 387 fieldCaptures.add(updatedElement); |
388 } else { | 388 } else { |
389 // A boxed element. | 389 // A boxed element. |
390 freeVariableMapping[fromElement] = updatedElement; | 390 freeVariableMapping[fromElement] = updatedElement; |
391 Element boxElement = updatedElement.enclosingElement; | 391 Element boxElement = updatedElement.enclosingElement; |
392 assert(boxElement.kind == ElementKind.VARIABLE); | 392 assert(boxElement is BoxElement); |
393 boxes.add(boxElement); | 393 boxes.add(boxElement); |
394 } | 394 } |
395 }); | 395 }); |
396 ClassElement closureElement = data.closureClassElement; | 396 ClassElement closureElement = data.closureClassElement; |
397 assert(closureElement != null || | 397 assert(closureElement != null || |
398 (fieldCaptures.isEmpty && boxes.isEmpty)); | 398 (fieldCaptures.isEmpty && boxes.isEmpty)); |
399 void addElement(Element element, String name) { | 399 void addElement(Element element, String name) { |
400 Element fieldElement = new ClosureFieldElement( | 400 Element fieldElement = new ClosureFieldElement( |
401 name, element, closureElement); | 401 name, element, closureElement); |
402 closureElement.addMember(fieldElement, compiler); | 402 closureElement.addMember(fieldElement, compiler); |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 } | 827 } |
828 | 828 |
829 visitTryStatement(TryStatement node) { | 829 visitTryStatement(TryStatement node) { |
830 // TODO(ngeoffray): implement finer grain state. | 830 // TODO(ngeoffray): implement finer grain state. |
831 bool oldInTryStatement = inTryStatement; | 831 bool oldInTryStatement = inTryStatement; |
832 inTryStatement = true; | 832 inTryStatement = true; |
833 node.visitChildren(this); | 833 node.visitChildren(this); |
834 inTryStatement = oldInTryStatement; | 834 inTryStatement = oldInTryStatement; |
835 } | 835 } |
836 } | 836 } |
OLD | NEW |