| 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 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 } | 693 } |
| 694 | 694 |
| 695 ClosureClassMap globalizeClosure(FunctionExpression node, Element element) { | 695 ClosureClassMap globalizeClosure(FunctionExpression node, Element element) { |
| 696 String closureName = computeClosureName(element); | 696 String closureName = computeClosureName(element); |
| 697 ClassElement globalizedElement = new ClosureClassElement( | 697 ClassElement globalizedElement = new ClosureClassElement( |
| 698 node, closureName, compiler, element, element.getCompilationUnit()); | 698 node, closureName, compiler, element, element.getCompilationUnit()); |
| 699 FunctionElement callElement = | 699 FunctionElement callElement = |
| 700 new FunctionElementX.from(Compiler.CALL_OPERATOR_NAME, | 700 new FunctionElementX.from(Compiler.CALL_OPERATOR_NAME, |
| 701 element, | 701 element, |
| 702 globalizedElement); | 702 globalizedElement); |
| 703 ClosureContainer enclosing = element.enclosingElement; |
| 704 enclosing.nestedClosures.add(callElement); |
| 703 globalizedElement.addMember(callElement, compiler); | 705 globalizedElement.addMember(callElement, compiler); |
| 704 // The nested function's 'this' is the same as the one for the outer | 706 // The nested function's 'this' is the same as the one for the outer |
| 705 // function. It could be [null] if we are inside a static method. | 707 // function. It could be [null] if we are inside a static method. |
| 706 Element thisElement = closureData.thisElement; | 708 Element thisElement = closureData.thisElement; |
| 707 return new ClosureClassMap(element, globalizedElement, | 709 return new ClosureClassMap(element, globalizedElement, |
| 708 callElement, thisElement); | 710 callElement, thisElement); |
| 709 } | 711 } |
| 710 | 712 |
| 711 void visitInvokable(Element element, Expression node, void visitChildren()) { | 713 void visitInvokable(Element element, Expression node, void visitChildren()) { |
| 712 bool oldInsideClosure = insideClosure; | 714 bool oldInsideClosure = insideClosure; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 } | 812 } |
| 811 | 813 |
| 812 visitTryStatement(TryStatement node) { | 814 visitTryStatement(TryStatement node) { |
| 813 // TODO(ngeoffray): implement finer grain state. | 815 // TODO(ngeoffray): implement finer grain state. |
| 814 bool oldInTryStatement = inTryStatement; | 816 bool oldInTryStatement = inTryStatement; |
| 815 inTryStatement = true; | 817 inTryStatement = true; |
| 816 node.visitChildren(this); | 818 node.visitChildren(this); |
| 817 inTryStatement = oldInTryStatement; | 819 inTryStatement = oldInTryStatement; |
| 818 } | 820 } |
| 819 } | 821 } |
| OLD | NEW |