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 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 this.compiler, | 140 this.compiler, |
| 141 this.rootElement, this.treeElements, | 141 this.rootElement, this.treeElements, |
| 142 this.typedefs, this.classes); | 142 this.typedefs, this.classes); |
| 143 | 143 |
| 144 void collectElement(Element element) { | 144 void collectElement(Element element) { |
| 145 new ReferencedElementCollector( | 145 new ReferencedElementCollector( |
| 146 compiler, element, new TreeElementMapping(), typedefs, classes) | 146 compiler, element, new TreeElementMapping(), typedefs, classes) |
| 147 .collect(); | 147 .collect(); |
| 148 } | 148 } |
| 149 | 149 |
| 150 visitClassNode(ClassNode node) { | |
| 151 super.visitClassNode(node); | |
| 152 // Temporary hack which should go away once interfaces | |
| 153 // and default clauses are out. | |
| 154 if (node.defaultClause !== null) { | |
| 155 // Resolver cannot resolve parameterized default clauses. | |
| 156 TypeAnnotation evilCousine = new TypeAnnotation( | |
|
Roman
2012/08/15 14:52:22
What a hack!
Anton Muhin
2012/08/15 15:11:35
Yes, we can!
On 2012/08/15 14:52:22, Roman wrote:
| |
| 157 node.defaultClause.typeName, null); | |
| 158 evilCousine.accept(this); | |
| 159 } | |
| 160 } | |
| 161 | |
| 150 visitNode(Node node) { node.visitChildren(this); } | 162 visitNode(Node node) { node.visitChildren(this); } |
| 151 | 163 |
| 152 visitTypeAnnotation(TypeAnnotation typeAnnotation) { | 164 visitTypeAnnotation(TypeAnnotation typeAnnotation) { |
| 153 final type = compiler.resolveTypeAnnotation(rootElement, typeAnnotation); | 165 final type = compiler.resolveTypeAnnotation(rootElement, typeAnnotation); |
| 154 Element typeElement = type.element; | 166 Element typeElement = type.element; |
| 155 if (typeElement.isTypedef() && !typedefs.contains(typeElement)) { | 167 if (typeElement.isTypedef() && !typedefs.contains(typeElement)) { |
| 156 typedefs.add(typeElement); | 168 typedefs.add(typeElement); |
| 157 collectElement(typeElement); | 169 collectElement(typeElement); |
| 158 } | 170 } |
| 159 if (typeElement.isClass() && !classes.contains(typeElement)) { | 171 if (typeElement.isClass() && !classes.contains(typeElement)) { |
| 160 classes.add(typeElement); | 172 classes.add(typeElement); |
| 161 collectElement(typeElement); | 173 collectElement(typeElement); |
| 162 } | 174 } |
| 163 typeAnnotation.visitChildren(this); | 175 typeAnnotation.visitChildren(this); |
| 164 } | 176 } |
| 165 | 177 |
| 166 void collect() { | 178 void collect() { |
| 167 compiler.withCurrentElement(rootElement, () { | 179 compiler.withCurrentElement(rootElement, () { |
| 168 rootElement.parseNode(compiler).accept(this); | 180 rootElement.parseNode(compiler).accept(this); |
| 169 }); | 181 }); |
| 170 } | 182 } |
| 171 } | 183 } |
| OLD | NEW |