Chromium Code Reviews| 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 if (enclosingElement.isGenerativeConstructor() || |
| 675 Elements.operatorNameToIdentifier(enclosingElement.name); | 675 enclosingElement.isGenerativeConstructorBody() || |
| 676 parts = parts.prepend(surroundingName.slowToString()); | 676 enclosingElement.isFactoryConstructor()) { |
| 677 parts = parts.prepend( | |
| 678 Elements.reconstructConstructorName(enclosingElement)); | |
|
ahe
2013/07/11 10:09:42
I suspect we could simplify this. The name return
Johnni Winther
2013/07/11 13:09:19
The complexity does not come from trying to comput
| |
| 679 } else { | |
| 680 SourceString surroundingName = | |
| 681 Elements.operatorNameToIdentifier(enclosingElement.name); | |
| 682 parts = parts.prepend(surroundingName.slowToString()); | |
| 683 } | |
| 677 // A generative constructors's parent is the class; the class name is | 684 // A generative constructors's parent is the class; the class name is |
| 678 // already part of the generative constructor's name. | 685 // already part of the generative constructor's name. |
| 679 if (enclosingElement.kind == ElementKind.GENERATIVE_CONSTRUCTOR) break; | 686 if (enclosingElement.kind == ElementKind.GENERATIVE_CONSTRUCTOR) break; |
| 680 } | 687 } |
| 681 StringBuffer sb = new StringBuffer(); | 688 StringBuffer sb = new StringBuffer(); |
| 682 parts.printOn(sb, '_'); | 689 parts.printOn(sb, '_'); |
| 683 return sb.toString(); | 690 return sb.toString(); |
| 684 } | 691 } |
| 685 | 692 |
| 686 ClosureClassMap globalizeClosure(FunctionExpression node, Element element) { | 693 ClosureClassMap globalizeClosure(FunctionExpression node, Element element) { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 807 } | 814 } |
| 808 | 815 |
| 809 visitTryStatement(TryStatement node) { | 816 visitTryStatement(TryStatement node) { |
| 810 // TODO(ngeoffray): implement finer grain state. | 817 // TODO(ngeoffray): implement finer grain state. |
| 811 bool oldInTryStatement = inTryStatement; | 818 bool oldInTryStatement = inTryStatement; |
| 812 inTryStatement = true; | 819 inTryStatement = true; |
| 813 node.visitChildren(this); | 820 node.visitChildren(this); |
| 814 inTryStatement = oldInTryStatement; | 821 inTryStatement = oldInTryStatement; |
| 815 } | 822 } |
| 816 } | 823 } |
| OLD | NEW |