| 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 World { | 5 class World { |
| 6 Compiler compiler; // Set in populate(). | 6 Compiler compiler; // Set in populate(). |
| 7 final Map<ClassElement, Set<ClassElement>> subtypes; | 7 final Map<ClassElement, Set<ClassElement>> subtypes; |
| 8 | 8 |
| 9 World() : subtypes = new Map<ClassElement, Set<ClassElement>>(); | 9 World() : subtypes = new Map<ClassElement, Set<ClassElement>>(); |
| 10 | 10 |
| 11 void populate(Compiler compiler, Collection<LibraryElement> libraries) { | 11 void populate(Compiler compiler, Collection<LibraryElement> libraries) { |
| 12 void addSubtypes(ClassElement cls) { | 12 void addSubtypes(ClassElement cls) { |
| 13 for (Type type in cls.allSupertypes) { | 13 for (Type type in cls.allSupertypes) { |
| 14 Set<Element> subtypesOfCls = subtypes.putIfAbsent( | 14 Set<Element> subtypesOfCls = subtypes.putIfAbsent( |
| 15 type.element, | 15 type.element, |
| 16 () => new Set<ClassElement>()); | 16 () => new Set<ClassElement>()); |
| 17 subtypesOfCls.add(cls); | 17 subtypesOfCls.add(cls); |
| 18 } | 18 } |
| 19 } | 19 } |
| 20 | 20 |
| 21 libraries.forEach((LibraryElement library) { | 21 libraries.forEach((LibraryElement library) { |
| 22 for (Link<Element> link = library.topLevelElements; | 22 for (Link<Element> link = library.topLevelElements; |
| 23 !link.isEmpty(); | 23 !link.isEmpty(); |
| 24 link = link.tail) { | 24 link = link.tail) { |
| 25 Element element = link.head; | 25 Element element = link.head; |
| 26 if (!element.isClass()) continue; | 26 if (!element.isClass()) continue; |
| 27 ClassElement cls = element; | 27 ClassElement cls = element; |
| 28 compiler.resolveClass(cls); | 28 cls.ensureResolved(compiler); |
| 29 addSubtypes(cls); | 29 addSubtypes(cls); |
| 30 } | 30 } |
| 31 }); | 31 }); |
| 32 | 32 |
| 33 // Mark the world as populated. | 33 // Mark the world as populated. |
| 34 assert(compiler !== null); | 34 assert(compiler !== null); |
| 35 this.compiler = compiler; | 35 this.compiler = compiler; |
| 36 } | 36 } |
| 37 | 37 |
| 38 /** | 38 /** |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 final SourceString name; | 98 final SourceString name; |
| 99 | 99 |
| 100 MemberSet(SourceString this.name) : elements = new Set<Element>(); | 100 MemberSet(SourceString this.name) : elements = new Set<Element>(); |
| 101 | 101 |
| 102 void add(Element element) { | 102 void add(Element element) { |
| 103 elements.add(element); | 103 elements.add(element); |
| 104 } | 104 } |
| 105 | 105 |
| 106 bool isEmpty() => elements.isEmpty(); | 106 bool isEmpty() => elements.isEmpty(); |
| 107 } | 107 } |
| OLD | NEW |