| 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("leg.dart"); | 8 #import("leg.dart"); |
| 9 #import("scanner/scannerlib.dart"); | 9 #import("scanner/scannerlib.dart"); |
| 10 #import("tree/tree.dart"); | 10 #import("tree/tree.dart"); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 this.thisElement) | 151 this.thisElement) |
| 152 : this.freeVariableMapping = new Map<Element, Element>(), | 152 : this.freeVariableMapping = new Map<Element, Element>(), |
| 153 this.capturedFieldMapping = new Map<Element, Element>(), | 153 this.capturedFieldMapping = new Map<Element, Element>(), |
| 154 this.capturingScopes = new Map<Node, ClosureScope>(), | 154 this.capturingScopes = new Map<Node, ClosureScope>(), |
| 155 this.usedVariablesInTry = new Set<Element>(), | 155 this.usedVariablesInTry = new Set<Element>(), |
| 156 this.parametersWithSentinel = new Map<Element, Element>(); | 156 this.parametersWithSentinel = new Map<Element, Element>(); |
| 157 | 157 |
| 158 bool isClosure() => closureElement !== null; | 158 bool isClosure() => closureElement !== null; |
| 159 } | 159 } |
| 160 | 160 |
| 161 class ClosureTranslator extends AbstractVisitor { | 161 class ClosureTranslator extends Visitor { |
| 162 final Compiler compiler; | 162 final Compiler compiler; |
| 163 final TreeElements elements; | 163 final TreeElements elements; |
| 164 int closureFieldCounter = 0; | 164 int closureFieldCounter = 0; |
| 165 bool inTryStatement = false; | 165 bool inTryStatement = false; |
| 166 final Map<Node, ClosureClassMap> closureMappingCache; | 166 final Map<Node, ClosureClassMap> closureMappingCache; |
| 167 | 167 |
| 168 // Map of captured variables. Initially they will map to themselves. If | 168 // Map of captured variables. Initially they will map to themselves. If |
| 169 // a variable needs to be boxed then the scope declaring the variable | 169 // a variable needs to be boxed then the scope declaring the variable |
| 170 // will update this mapping. | 170 // will update this mapping. |
| 171 Map<Element, Element> capturedVariableMapping; | 171 Map<Element, Element> capturedVariableMapping; |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 } | 597 } |
| 598 | 598 |
| 599 visitTryStatement(TryStatement node) { | 599 visitTryStatement(TryStatement node) { |
| 600 // TODO(ngeoffray): implement finer grain state. | 600 // TODO(ngeoffray): implement finer grain state. |
| 601 bool oldInTryStatement = inTryStatement; | 601 bool oldInTryStatement = inTryStatement; |
| 602 inTryStatement = true; | 602 inTryStatement = true; |
| 603 node.visitChildren(this); | 603 node.visitChildren(this); |
| 604 inTryStatement = oldInTryStatement; | 604 inTryStatement = oldInTryStatement; |
| 605 } | 605 } |
| 606 } | 606 } |
| OLD | NEW |