| 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 (Element element in library.localMembers) { |
| 23 !link.isEmpty(); | |
| 24 link = link.tail) { | |
| 25 Element element = link.head; | |
| 26 if (!element.isClass()) continue; | 23 if (!element.isClass()) continue; |
| 27 ClassElement cls = element; | 24 ClassElement cls = element; |
| 28 compiler.resolveClass(cls); | 25 compiler.resolveClass(cls); |
| 29 addSubtypes(cls); | 26 addSubtypes(cls); |
| 30 } | 27 } |
| 31 }); | 28 }); |
| 32 | 29 |
| 33 // Mark the world as populated. | 30 // Mark the world as populated. |
| 34 assert(compiler !== null); | 31 assert(compiler !== null); |
| 35 this.compiler = compiler; | 32 this.compiler = compiler; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 final SourceString name; | 95 final SourceString name; |
| 99 | 96 |
| 100 MemberSet(SourceString this.name) : elements = new Set<Element>(); | 97 MemberSet(SourceString this.name) : elements = new Set<Element>(); |
| 101 | 98 |
| 102 void add(Element element) { | 99 void add(Element element) { |
| 103 elements.add(element); | 100 elements.add(element); |
| 104 } | 101 } |
| 105 | 102 |
| 106 bool isEmpty() => elements.isEmpty(); | 103 bool isEmpty() => elements.isEmpty(); |
| 107 } | 104 } |
| OLD | NEW |