| 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 24 matching lines...) Expand all Loading... |
| 35 * Tells whether we should output given element. Corelib classes like | 35 * Tells whether we should output given element. Corelib classes like |
| 36 * Object should not be in the resulting code. | 36 * Object should not be in the resulting code. |
| 37 */ | 37 */ |
| 38 final LIBS_TO_IGNORE = [ | 38 final LIBS_TO_IGNORE = [ |
| 39 compiler.jsHelperLibrary, | 39 compiler.jsHelperLibrary, |
| 40 compiler.interceptorsLibrary, | 40 compiler.interceptorsLibrary, |
| 41 ]; | 41 ]; |
| 42 bool shouldOutput(Element element) => | 42 bool shouldOutput(Element element) => |
| 43 element.kind !== ElementKind.VOID && | 43 element.kind !== ElementKind.VOID && |
| 44 LIBS_TO_IGNORE.indexOf(element.getLibrary()) == -1 && | 44 LIBS_TO_IGNORE.indexOf(element.getLibrary()) == -1 && |
| 45 !isDartCoreLib(compiler, element.getLibrary()); | 45 !isDartCoreLib(compiler, element.getLibrary()) && |
| 46 element is !AbstractFieldElement; |
| 46 | 47 |
| 47 // TODO(smok): Refactor this traverse/collect mess. | 48 // TODO(smok): Refactor this traverse/collect mess. |
| 48 Set<TypedefElement> typedefs = new Set<TypedefElement>(); | 49 Set<TypedefElement> typedefs = new Set<TypedefElement>(); |
| 49 Set<ClassElement> classes = new Set<ClassElement>(); | 50 Set<ClassElement> classes = new Set<ClassElement>(); |
| 50 Set<Element> elements = new Set<Element>(); | 51 Set<Element> elements = new Set<Element>(); |
| 51 Map<ClassElement, Set<Element>> resolvedClassMembers = | 52 Map<ClassElement, Set<Element>> resolvedClassMembers = |
| 52 new Map<ClassElement, Set<Element>>(); | 53 new Map<ClassElement, Set<Element>>(); |
| 53 PlaceholderCollector collector = new PlaceholderCollector(compiler); | 54 PlaceholderCollector collector = new PlaceholderCollector(compiler); |
| 54 resolvedElements.forEach((element, treeElements) { | 55 resolvedElements.forEach((element, treeElements) { |
| 55 if (!shouldOutput(element)) return; | 56 if (!shouldOutput(element)) return; |
| 56 if (element.isMember()) { | 57 if (element.isMember()) { |
| 57 ClassElement enclosingClass = element.getEnclosingClass(); | 58 ClassElement enclosingClass = element.getEnclosingClass(); |
| 58 assert(enclosingClass.isClass()); | 59 assert(enclosingClass.isClass()); |
| 59 assert(enclosingClass.isTopLevel()); | 60 assert(enclosingClass.isTopLevel()); |
| 60 resolvedClassMembers | 61 resolvedClassMembers |
| 61 .putIfAbsent(enclosingClass, () => new Set<Element>()) | 62 .putIfAbsent(enclosingClass, () => new Set<Element>()) |
| 62 .add(element); | 63 .add(element); |
| 63 return; | 64 return; |
| 64 } | 65 } |
| 65 if (!element.isTopLevel()) { | 66 if (!element.isTopLevel()) { |
| 66 compiler.cancel(reason: 'Cannot process $element', element: element); | 67 compiler.cancel(reason: 'Cannot process $element', element: element); |
| 67 } | 68 } |
| 68 | 69 |
| 69 elements.add(element); | 70 elements.add(element); |
| 70 }); | 71 }); |
| 71 resolvedElements.forEach((element, treeElements) { | 72 resolvedElements.forEach((element, treeElements) { |
| 72 if (!shouldOutput(element)) return; | 73 if (!shouldOutput(element)) return; |
| 73 if (element is AbstractFieldElement) return; | |
| 74 collector.collect(element, treeElements); | 74 collector.collect(element, treeElements); |
| 75 new ReferencedElementCollector( | 75 new ReferencedElementCollector( |
| 76 compiler, element, treeElements, typedefs, classes) | 76 compiler, element, treeElements, typedefs, classes) |
| 77 .collect(); | 77 .collect(); |
| 78 }); | 78 }); |
| 79 | 79 |
| 80 final emptyTreeElements = new TreeElementMapping(); | 80 final emptyTreeElements = new TreeElementMapping(); |
| 81 collectElement(element) { collector.collect(element, emptyTreeElements); } | 81 collectElement(element) { collector.collect(element, emptyTreeElements); } |
| 82 typedefs.forEach(collectElement); | 82 typedefs.forEach(collectElement); |
| 83 classes.forEach(collectElement); | 83 classes.forEach(collectElement); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 } | 171 } |
| 172 typeAnnotation.visitChildren(this); | 172 typeAnnotation.visitChildren(this); |
| 173 } | 173 } |
| 174 | 174 |
| 175 void collect() { | 175 void collect() { |
| 176 compiler.withCurrentElement(rootElement, () { | 176 compiler.withCurrentElement(rootElement, () { |
| 177 rootElement.parseNode(compiler).accept(this); | 177 rootElement.parseNode(compiler).accept(this); |
| 178 }); | 178 }); |
| 179 } | 179 } |
| 180 } | 180 } |
| OLD | NEW |