| 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 "tree/tree.dart"; | 9 import "tree/tree.dart"; |
| 10 import "util/util.dart"; | 10 import "util/util.dart"; |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 SourceString surroundingName = | 498 SourceString surroundingName = |
| 499 Elements.operatorNameToIdentifier(enclosingElement.name); | 499 Elements.operatorNameToIdentifier(enclosingElement.name); |
| 500 parts = parts.prepend(surroundingName.slowToString()); | 500 parts = parts.prepend(surroundingName.slowToString()); |
| 501 } | 501 } |
| 502 StringBuffer sb = new StringBuffer(); | 502 StringBuffer sb = new StringBuffer(); |
| 503 parts.printOn(sb, '_'); | 503 parts.printOn(sb, '_'); |
| 504 return sb.toString(); | 504 return sb.toString(); |
| 505 } | 505 } |
| 506 | 506 |
| 507 ClosureClassMap globalizeClosure(FunctionExpression node, Element element) { | 507 ClosureClassMap globalizeClosure(FunctionExpression node, Element element) { |
| 508 SourceString closureName = new SourceString(closureName(element)); | 508 SourceString name = new SourceString(closureName(element)); |
| 509 ClassElement globalizedElement = new ClosureClassElement( | 509 ClassElement globalizedElement = new ClosureClassElement( |
| 510 closureName, compiler, element, element.getCompilationUnit()); | 510 name, compiler, element, element.getCompilationUnit()); |
| 511 FunctionElement callElement = | 511 FunctionElement callElement = |
| 512 new FunctionElement.from(Compiler.CALL_OPERATOR_NAME, | 512 new FunctionElement.from(Compiler.CALL_OPERATOR_NAME, |
| 513 element, | 513 element, |
| 514 globalizedElement); | 514 globalizedElement); |
| 515 globalizedElement.backendMembers = | 515 globalizedElement.backendMembers = |
| 516 const Link<Element>().prepend(callElement); | 516 const Link<Element>().prepend(callElement); |
| 517 // The nested function's 'this' is the same as the one for the outer | 517 // The nested function's 'this' is the same as the one for the outer |
| 518 // function. It could be [null] if we are inside a static method. | 518 // function. It could be [null] if we are inside a static method. |
| 519 Element thisElement = closureData.thisElement; | 519 Element thisElement = closureData.thisElement; |
| 520 return new ClosureClassMap(element, globalizedElement, | 520 return new ClosureClassMap(element, globalizedElement, |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 } | 615 } |
| 616 | 616 |
| 617 visitTryStatement(TryStatement node) { | 617 visitTryStatement(TryStatement node) { |
| 618 // TODO(ngeoffray): implement finer grain state. | 618 // TODO(ngeoffray): implement finer grain state. |
| 619 bool oldInTryStatement = inTryStatement; | 619 bool oldInTryStatement = inTryStatement; |
| 620 inTryStatement = true; | 620 inTryStatement = true; |
| 621 node.visitChildren(this); | 621 node.visitChildren(this); |
| 622 inTryStatement = oldInTryStatement; | 622 inTryStatement = oldInTryStatement; |
| 623 } | 623 } |
| 624 } | 624 } |
| OLD | NEW |