| 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 class DartBackend extends Backend { | 5 class DartBackend extends Backend { |
| 6 final List<CompilerTask> tasks; | 6 final List<CompilerTask> tasks; |
| 7 final UnparseValidator unparseValidator; | 7 final UnparseValidator unparseValidator; |
| 8 | 8 |
| 9 Map<Element, TreeElements> get resolvedElements() => | 9 Map<Element, TreeElements> get resolvedElements() => |
| 10 compiler.enqueuer.resolution.resolvedElements; | 10 compiler.enqueuer.resolution.resolvedElements; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 Set<ClassElement> classes = new Set<ClassElement>(); | 62 Set<ClassElement> classes = new Set<ClassElement>(); |
| 63 PlaceholderCollector collector = new PlaceholderCollector(compiler); | 63 PlaceholderCollector collector = new PlaceholderCollector(compiler); |
| 64 resolvedElements.forEach((element, treeElements) { | 64 resolvedElements.forEach((element, treeElements) { |
| 65 if (!shouldOutput(element)) return; | 65 if (!shouldOutput(element)) return; |
| 66 if (element is AbstractFieldElement) return; | 66 if (element is AbstractFieldElement) return; |
| 67 collector.collect(element, treeElements); | 67 collector.collect(element, treeElements); |
| 68 new ReferencedElementCollector( | 68 new ReferencedElementCollector( |
| 69 compiler, element, treeElements, typedefs, classes) | 69 compiler, element, treeElements, typedefs, classes) |
| 70 .collect(); | 70 .collect(); |
| 71 }); | 71 }); |
| 72 final emptyTreeElements = new TreeElementMapping(); |
| 73 collectElement(element) { collector.collect(element, emptyTreeElements); } |
| 74 typedefs.forEach(collectElement); |
| 75 classes.forEach(collectElement); |
| 72 | 76 |
| 73 ConflictingRenamer renamer = | 77 ConflictingRenamer renamer = |
| 74 new ConflictingRenamer(compiler, collector.placeholders); | 78 new ConflictingRenamer(compiler, collector.placeholders); |
| 75 Emitter emitter = new Emitter(compiler, renamer); | 79 Emitter emitter = new Emitter(compiler, renamer); |
| 76 resolvedElements.forEach((element, treeElements) { | 80 resolvedElements.forEach((element, treeElements) { |
| 77 if (!shouldOutput(element)) return; | 81 if (!shouldOutput(element)) return; |
| 78 if (element.isMember()) { | 82 if (element.isMember()) { |
| 79 ClassElement enclosingClass = element.getEnclosingClass(); | 83 ClassElement enclosingClass = element.getEnclosingClass(); |
| 80 assert(enclosingClass.isClass()); | 84 assert(enclosingClass.isClass()); |
| 81 assert(enclosingClass.isTopLevel()); | 85 assert(enclosingClass.isTopLevel()); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 ReferencedElementCollector( | 139 ReferencedElementCollector( |
| 136 this.compiler, | 140 this.compiler, |
| 137 this.element, this.treeElements, | 141 this.element, this.treeElements, |
| 138 this.typedefs, this.classes); | 142 this.typedefs, this.classes); |
| 139 | 143 |
| 140 visitNode(Node node) { node.visitChildren(this); } | 144 visitNode(Node node) { node.visitChildren(this); } |
| 141 | 145 |
| 142 visitTypeAnnotation(TypeAnnotation typeAnnotation) { | 146 visitTypeAnnotation(TypeAnnotation typeAnnotation) { |
| 143 final type = compiler.resolveTypeAnnotation(element, typeAnnotation); | 147 final type = compiler.resolveTypeAnnotation(element, typeAnnotation); |
| 144 Element typeElement = type.element; | 148 Element typeElement = type.element; |
| 145 if (typeElement.isTypedef()) typedefs.add(typeElement); | 149 if (typeElement.isTypedef() && !typedefs.contains(typeElement)) { |
| 150 typedefs.add(typeElement); |
| 151 new ReferencedElementCollector( |
| 152 compiler, typeElement, new TreeElementMapping(), typedefs, classes) |
| 153 .collect(); |
| 154 } |
| 146 if (typeElement.isClass()) classes.add(typeElement); | 155 if (typeElement.isClass()) classes.add(typeElement); |
| 147 typeAnnotation.visitChildren(this); | 156 typeAnnotation.visitChildren(this); |
| 148 } | 157 } |
| 149 | 158 |
| 150 void collect() { | 159 void collect() { |
| 151 element.parseNode(compiler).accept(this); | 160 element.parseNode(compiler).accept(this); |
| 152 } | 161 } |
| 153 } | 162 } |
| OLD | NEW |