| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 // simple and they have 1-character names in the minified mode. | 73 // simple and they have 1-character names in the minified mode. |
| 74 bool hasFixedBackendName() => true; | 74 bool hasFixedBackendName() => true; |
| 75 String fixedBackendName() => name.slowToString(); | 75 String fixedBackendName() => name.slowToString(); |
| 76 | 76 |
| 77 DartType computeType(Compiler compiler) => compiler.types.dynamicType; | 77 DartType computeType(Compiler compiler) => compiler.types.dynamicType; |
| 78 | 78 |
| 79 String toString() => "ClosureFieldElement($name)"; | 79 String toString() => "ClosureFieldElement($name)"; |
| 80 } | 80 } |
| 81 | 81 |
| 82 class ClosureClassElement extends ClassElementX { | 82 class ClosureClassElement extends ClassElementX { |
| 83 DartType rawType; |
| 84 DartType thisType; |
| 85 |
| 83 ClosureClassElement(SourceString name, | 86 ClosureClassElement(SourceString name, |
| 84 Compiler compiler, | 87 Compiler compiler, |
| 85 this.methodElement, | 88 this.methodElement, |
| 86 Element enclosingElement) | 89 Element enclosingElement) |
| 87 : super(name, | 90 : super(name, |
| 88 enclosingElement, | 91 enclosingElement, |
| 89 // By assigning a fresh class-id we make sure that the hashcode | 92 // By assigning a fresh class-id we make sure that the hashcode |
| 90 // is unique, but also emit closure classes after all other | 93 // is unique, but also emit closure classes after all other |
| 91 // classes (since the emitter sorts classes by their id). | 94 // classes (since the emitter sorts classes by their id). |
| 92 compiler.getNextFreeClassId(), | 95 compiler.getNextFreeClassId(), |
| 93 STATE_DONE) { | 96 STATE_DONE) { |
| 94 compiler.closureClass.ensureResolved(compiler); | 97 compiler.closureClass.ensureResolved(compiler); |
| 95 supertype = compiler.closureClass.computeType(compiler); | 98 supertype = compiler.closureClass.computeType(compiler); |
| 96 interfaces = const Link<DartType>(); | 99 interfaces = const Link<DartType>(); |
| 97 allSupertypes = const Link<DartType>().prepend(supertype); | 100 allSupertypes = const Link<DartType>().prepend(supertype); |
| 101 thisType = rawType = new InterfaceType(this); |
| 98 } | 102 } |
| 99 | 103 |
| 100 bool isClosure() => true; | 104 bool isClosure() => true; |
| 101 | 105 |
| 102 /** | 106 /** |
| 103 * The most outer method this closure is declared into. | 107 * The most outer method this closure is declared into. |
| 104 */ | 108 */ |
| 105 Element methodElement; | 109 Element methodElement; |
| 106 } | 110 } |
| 107 | 111 |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 } | 690 } |
| 687 | 691 |
| 688 visitTryStatement(TryStatement node) { | 692 visitTryStatement(TryStatement node) { |
| 689 // TODO(ngeoffray): implement finer grain state. | 693 // TODO(ngeoffray): implement finer grain state. |
| 690 bool oldInTryStatement = inTryStatement; | 694 bool oldInTryStatement = inTryStatement; |
| 691 inTryStatement = true; | 695 inTryStatement = true; |
| 692 node.visitChildren(this); | 696 node.visitChildren(this); |
| 693 inTryStatement = oldInTryStatement; | 697 inTryStatement = oldInTryStatement; |
| 694 } | 698 } |
| 695 } | 699 } |
| OLD | NEW |