Chromium Code Reviews| Index: lib/compiler/implementation/dart_backend/backend.dart |
| diff --git a/lib/compiler/implementation/dart_backend/backend.dart b/lib/compiler/implementation/dart_backend/backend.dart |
| index f64cc13d349566cde41f450b1fd8458559d471ba..1755a85dc7ddbd9317f79194d5923ee7cd555139 100644 |
| --- a/lib/compiler/implementation/dart_backend/backend.dart |
| +++ b/lib/compiler/implementation/dart_backend/backend.dart |
| @@ -70,10 +70,17 @@ class DartBackend extends Backend { |
| !isDartCoreLib(compiler, element.getLibrary()); |
| try { |
| + Set<TypedefElement> typedefs = new Set<TypedefElement>(); |
| PlaceholderCollector collector = new PlaceholderCollector(compiler); |
| resolvedElements.forEach((element, treeElements) { |
| if (!shouldOutput(element)) return; |
| + if (element is AbstractFieldElement) return; |
| collector.collect(element, treeElements); |
| + new AdditionalElementCollector( |
| + compiler, |
|
Roman
2012/08/09 16:48:03
style nazi: Can you please make it more compact? I
Anton Muhin
2012/08/09 17:01:08
Done.
|
| + element, treeElements, |
| + typedefs) |
| + .collect(); |
| }); |
| ConflictingRenamer renamer = |
| @@ -95,6 +102,8 @@ class DartBackend extends Backend { |
| emitter.outputElement(element); |
| }); |
| + typedefs.forEach(emitter.outputElement); |
|
Roman
2012/08/09 16:48:03
I think we also want to traverse typedef nodes, be
Anton Muhin
2012/08/09 17:01:09
I believe we traverse those typedefs as a part of
|
| + |
| // Now output resolved classes with inner elements we met before. |
| resolvedClassMembers.forEach(emitter.outputClass); |
| compiler.assembledCode = emitter.toString(); |
| @@ -123,3 +132,29 @@ bool isDartCoreLib(Compiler compiler, LibraryElement libraryElement) { |
| } |
| return false; |
| } |
| + |
| +class AdditionalElementCollector extends AbstractVisitor { |
|
Roman
2012/08/09 16:48:03
Please think about better name. What is "additiona
Anton Muhin
2012/08/09 17:01:09
Ok, is it any better?
On 2012/08/09 16:48:03, Rom
|
| + final Compiler compiler; |
| + final Element element; |
| + final TreeElements treeElements; |
| + final Set<TypedefElement> typedefs; |
| + |
| + AdditionalElementCollector( |
| + this.compiler, |
| + this.element, this.treeElements, |
| + this.typedefs); |
| + |
| + visitNode(Node node) { node.visitChildren(this); } |
| + |
| + visitTypeAnnotation(TypeAnnotation typeAnnotation) { |
| + Element element = treeElements[typeAnnotation]; |
|
Roman
2012/08/09 16:48:03
I think canonically types should be resolved throu
Anton Muhin
2012/08/09 17:01:09
Right now I don't want to resolve types, meaning I
|
| + if (element !== null) { |
| + if (element.isTypedef()) typedefs.add(element as TypedefElement); |
|
ahe
2012/08/09 16:51:55
The cast is unnecessary. Dart is a dynamically typ
Anton Muhin
2012/08/09 17:01:09
Sure, I was just concerned if some tool will give
|
| + } |
| + typeAnnotation.visitChildren(this); |
| + } |
| + |
| + void collect() { |
| + element.parseNode(compiler).accept(this); |
| + } |
| +} |