| 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 "scanner/scannerlib.dart" show Token; | 9 import "scanner/scannerlib.dart" show Token; |
| 10 import "tree/tree.dart"; | 10 import "tree/tree.dart"; |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 | 607 |
| 608 ClosureClassMap savedClosureData = closureData; | 608 ClosureClassMap savedClosureData = closureData; |
| 609 bool savedInsideClosure = insideClosure; | 609 bool savedInsideClosure = insideClosure; |
| 610 | 610 |
| 611 // Restore old values. | 611 // Restore old values. |
| 612 insideClosure = oldInsideClosure; | 612 insideClosure = oldInsideClosure; |
| 613 closureData = oldClosureData; | 613 closureData = oldClosureData; |
| 614 currentElement = oldFunctionElement; | 614 currentElement = oldFunctionElement; |
| 615 | 615 |
| 616 // Mark all free variables as captured and use them in the outer function. | 616 // Mark all free variables as captured and use them in the outer function. |
| 617 List<Element> freeVariables = savedClosureData.freeVariableMapping.keys; | 617 Iterable<Element> freeVariables = savedClosureData.freeVariableMapping.keys; |
| 618 assert(freeVariables.isEmpty || savedInsideClosure); | 618 assert(freeVariables.isEmpty || savedInsideClosure); |
| 619 for (Element freeElement in freeVariables) { | 619 for (Element freeElement in freeVariables) { |
| 620 if (capturedVariableMapping[freeElement] != null && | 620 if (capturedVariableMapping[freeElement] != null && |
| 621 capturedVariableMapping[freeElement] != freeElement) { | 621 capturedVariableMapping[freeElement] != freeElement) { |
| 622 compiler.internalError('In closure analyzer', node: node); | 622 compiler.internalError('In closure analyzer', node: node); |
| 623 } | 623 } |
| 624 capturedVariableMapping[freeElement] = freeElement; | 624 capturedVariableMapping[freeElement] = freeElement; |
| 625 useLocal(freeElement); | 625 useLocal(freeElement); |
| 626 } | 626 } |
| 627 } | 627 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 651 } | 651 } |
| 652 | 652 |
| 653 visitTryStatement(TryStatement node) { | 653 visitTryStatement(TryStatement node) { |
| 654 // TODO(ngeoffray): implement finer grain state. | 654 // TODO(ngeoffray): implement finer grain state. |
| 655 bool oldInTryStatement = inTryStatement; | 655 bool oldInTryStatement = inTryStatement; |
| 656 inTryStatement = true; | 656 inTryStatement = true; |
| 657 node.visitChildren(this); | 657 node.visitChildren(this); |
| 658 inTryStatement = oldInTryStatement; | 658 inTryStatement = oldInTryStatement; |
| 659 } | 659 } |
| 660 } | 660 } |
| OLD | NEW |