Chromium Code Reviews| Index: lib/compiler/implementation/compiler.dart |
| =================================================================== |
| --- lib/compiler/implementation/compiler.dart (revision 7442) |
| +++ lib/compiler/implementation/compiler.dart (working copy) |
| @@ -33,6 +33,7 @@ |
| class Compiler implements DiagnosticListener { |
| Queue<WorkItem> worklist; |
| Universe universe; |
| + World world; |
| String assembledCode; |
| Namer namer; |
| Types types; |
| @@ -100,6 +101,7 @@ |
| Compiler([this.tracer = const Tracer()]) |
| : universe = new Universe(), |
| + world = new World(), |
| worklist = new Queue<WorkItem>(), |
| codegenProgress = new Stopwatch.start() { |
| namer = new Namer(this); |
| @@ -300,6 +302,7 @@ |
| }); |
| } |
| native.processNativeClasses(this, universe.libraries.getValues()); |
| + computeSubclasses(); |
|
kasperl
2012/05/09 11:13:03
Could we move this code to world? That would seem
ngeoffray
2012/05/09 11:34:22
Done.
|
| enqueue(new WorkItem.toCompile(main)); |
| codegenProgress.reset(); |
| while (!worklist.isEmpty()) { |
| @@ -316,6 +319,29 @@ |
| } |
| } |
| + void addSubtypes(ClassElement cls) { |
| + for (Type type in cls.allSupertypes) { |
| + List<Element> subtypes = world.subtypes.putIfAbsent( |
| + type.element, |
| + () => <ClassElement>[]); |
| + subtypes.add(cls); |
| + } |
| + } |
| + |
| + void computeSubclasses() { |
| + universe.libraries.getValues().forEach((LibraryElement library) { |
| + for (Link<Element> link = library.topLevelElements; |
| + !link.isEmpty(); |
| + link = link.tail) { |
| + Element element = link.head; |
| + if (!element.isClass()) continue; |
| + ClassElement cls = element; |
| + resolveClass(cls); |
| + addSubtypes(cls); |
| + } |
| + }); |
| + } |
| + |
| TreeElements analyzeElement(Element element) { |
| assert(parser !== null); |
| Node tree = parser.parse(element); |