| 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 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 } | 664 } |
| 665 for (Element enclosingElement = element.enclosingElement; | 665 for (Element enclosingElement = element.enclosingElement; |
| 666 enclosingElement != null && | 666 enclosingElement != null && |
| 667 (enclosingElement.kind == ElementKind.GENERATIVE_CONSTRUCTOR_BODY | 667 (enclosingElement.kind == ElementKind.GENERATIVE_CONSTRUCTOR_BODY |
| 668 || enclosingElement.kind == ElementKind.GENERATIVE_CONSTRUCTOR | 668 || enclosingElement.kind == ElementKind.GENERATIVE_CONSTRUCTOR |
| 669 || enclosingElement.kind == ElementKind.CLASS | 669 || enclosingElement.kind == ElementKind.CLASS |
| 670 || enclosingElement.kind == ElementKind.FUNCTION | 670 || enclosingElement.kind == ElementKind.FUNCTION |
| 671 || enclosingElement.kind == ElementKind.GETTER | 671 || enclosingElement.kind == ElementKind.GETTER |
| 672 || enclosingElement.kind == ElementKind.SETTER); | 672 || enclosingElement.kind == ElementKind.SETTER); |
| 673 enclosingElement = enclosingElement.enclosingElement) { | 673 enclosingElement = enclosingElement.enclosingElement) { |
| 674 SourceString surroundingName = | 674 // TODO(johnniwinther): Simplify computed names. |
| 675 Elements.operatorNameToIdentifier(enclosingElement.name); | 675 if (enclosingElement.isGenerativeConstructor() || |
| 676 parts = parts.prepend(surroundingName.slowToString()); | 676 enclosingElement.isGenerativeConstructorBody() || |
| 677 enclosingElement.isFactoryConstructor()) { |
| 678 parts = parts.prepend( |
| 679 Elements.reconstructConstructorName(enclosingElement)); |
| 680 } else { |
| 681 SourceString surroundingName = |
| 682 Elements.operatorNameToIdentifier(enclosingElement.name); |
| 683 parts = parts.prepend(surroundingName.slowToString()); |
| 684 } |
| 677 // A generative constructors's parent is the class; the class name is | 685 // A generative constructors's parent is the class; the class name is |
| 678 // already part of the generative constructor's name. | 686 // already part of the generative constructor's name. |
| 679 if (enclosingElement.kind == ElementKind.GENERATIVE_CONSTRUCTOR) break; | 687 if (enclosingElement.kind == ElementKind.GENERATIVE_CONSTRUCTOR) break; |
| 680 } | 688 } |
| 681 StringBuffer sb = new StringBuffer(); | 689 StringBuffer sb = new StringBuffer(); |
| 682 parts.printOn(sb, '_'); | 690 parts.printOn(sb, '_'); |
| 683 return sb.toString(); | 691 return sb.toString(); |
| 684 } | 692 } |
| 685 | 693 |
| 686 ClosureClassMap globalizeClosure(FunctionExpression node, Element element) { | 694 ClosureClassMap globalizeClosure(FunctionExpression node, Element element) { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 } | 815 } |
| 808 | 816 |
| 809 visitTryStatement(TryStatement node) { | 817 visitTryStatement(TryStatement node) { |
| 810 // TODO(ngeoffray): implement finer grain state. | 818 // TODO(ngeoffray): implement finer grain state. |
| 811 bool oldInTryStatement = inTryStatement; | 819 bool oldInTryStatement = inTryStatement; |
| 812 inTryStatement = true; | 820 inTryStatement = true; |
| 813 node.visitChildren(this); | 821 node.visitChildren(this); |
| 814 inTryStatement = oldInTryStatement; | 822 inTryStatement = oldInTryStatement; |
| 815 } | 823 } |
| 816 } | 824 } |
| OLD | NEW |