| 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 class ClosureFieldElement extends Element { | 5 class ClosureFieldElement extends Element { |
| 6 ClosureFieldElement(SourceString name, ClassElement enclosing) | 6 ClosureFieldElement(SourceString name, ClassElement enclosing) |
| 7 : super(name, ElementKind.FIELD, enclosing); | 7 : super(name, ElementKind.FIELD, enclosing); |
| 8 | 8 |
| 9 bool isInstanceMember() => true; | 9 bool isInstanceMember() => true; |
| 10 bool isAssignable() => false; | 10 bool isAssignable() => false; |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 functionElement = body.constructor; | 171 functionElement = body.constructor; |
| 172 } | 172 } |
| 173 // If the element is not declared in the current function and the element | 173 // If the element is not declared in the current function and the element |
| 174 // is not the closure itself we need to mark the element as free variable. | 174 // is not the closure itself we need to mark the element as free variable. |
| 175 if (element.enclosingElement != functionElement && | 175 if (element.enclosingElement != functionElement && |
| 176 element != functionElement) { | 176 element != functionElement) { |
| 177 assert(closureData.freeVariableMapping[element] == null || | 177 assert(closureData.freeVariableMapping[element] == null || |
| 178 closureData.freeVariableMapping[element] == element); | 178 closureData.freeVariableMapping[element] == element); |
| 179 closureData.freeVariableMapping[element] = element; | 179 closureData.freeVariableMapping[element] = element; |
| 180 } else if (inTryCatchOrFinally) { | 180 } else if (inTryCatchOrFinally) { |
| 181 // TODO(ngeoffray): only do this if the variable is mutated. | 181 // Don't mark the this-element. This would complicate things in the |
| 182 closureData.usedVariablesInTry.add(element); | 182 // builder. |
| 183 if (element != closureData.thisElement) { |
| 184 // TODO(ngeoffray): only do this if the variable is mutated. |
| 185 closureData.usedVariablesInTry.add(element); |
| 186 } |
| 183 } | 187 } |
| 184 } | 188 } |
| 185 | 189 |
| 186 void declareLocal(Element element) { | 190 void declareLocal(Element element) { |
| 187 scopeVariables.add(element); | 191 scopeVariables.add(element); |
| 188 } | 192 } |
| 189 | 193 |
| 190 visit(Node node) => node.accept(this); | 194 visit(Node node) => node.accept(this); |
| 191 | 195 |
| 192 visitNode(Node node) => node.visitChildren(this); | 196 visitNode(Node node) => node.visitChildren(this); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 declareLocal(elements[node]); | 405 declareLocal(elements[node]); |
| 402 } | 406 } |
| 403 | 407 |
| 404 visitTryStatement(TryStatement node) { | 408 visitTryStatement(TryStatement node) { |
| 405 // TODO(ngeoffray): implement finer grain state. | 409 // TODO(ngeoffray): implement finer grain state. |
| 406 inTryCatchOrFinally = true; | 410 inTryCatchOrFinally = true; |
| 407 node.visitChildren(this); | 411 node.visitChildren(this); |
| 408 inTryCatchOrFinally = false; | 412 inTryCatchOrFinally = false; |
| 409 } | 413 } |
| 410 } | 414 } |
| OLD | NEW |