| 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 final Map<ClassElement, Set<ClassElement>> subtypes; | 6 final Map<ClassElement, Set<ClassElement>> subtypes; |
| 7 | 7 |
| 8 World() : subtypes = new Map<ClassElement, Set<ClassElement>>(); | 8 World() : subtypes = new Map<ClassElement, Set<ClassElement>>(); |
| 9 | 9 |
| 10 void populate(Compiler compiler, Collection<LibraryElement> libraries) { | 10 void populate(Compiler compiler, Collection<LibraryElement> libraries) { |
| 11 void addSubtypes(ClassElement cls) { | 11 void addSubtypes(ClassElement cls) { |
| 12 for (Type type in cls.allSupertypes) { | 12 for (Type type in cls.allSupertypes) { |
| 13 Set<Element> subtypesOfCls = subtypes.putIfAbsent( | 13 Set<Element> subtypesOfCls = subtypes.putIfAbsent( |
| 14 type.element, | 14 type.element, |
| 15 () => new Set<ClassElement>()); | 15 () => new Set<ClassElement>()); |
| 16 subtypesOfCls.add(cls); | 16 subtypesOfCls.add(cls); |
| 17 } | 17 } |
| 18 } | 18 } |
| 19 | 19 |
| 20 libraries.forEach((LibraryElement library) { | 20 libraries.forEach((LibraryElement library) { |
| 21 for (Link<Element> link = library.topLevelElements; | 21 for (Link<Element> link = library.topLevelElements; |
| 22 !link.isEmpty(); | 22 !link.isEmpty(); |
| 23 link = link.tail) { | 23 link = link.tail) { |
| 24 Element element = link.head; | 24 Element element = link.head; |
| 25 if (!element.isClass()) continue; | 25 if (!element.isClass() || compiler.isPatchElement(element)) continue; |
| 26 ClassElement cls = element; | 26 ClassElement cls = element; |
| 27 compiler.resolveClass(cls); | 27 compiler.resolveClass(cls); |
| 28 addSubtypes(cls); | 28 addSubtypes(cls); |
| 29 } | 29 } |
| 30 }); | 30 }); |
| 31 } | 31 } |
| 32 | 32 |
| 33 /** | 33 /** |
| 34 * Returns a [MemberSet] that contains the possible targets of a | 34 * Returns a [MemberSet] that contains the possible targets of a |
| 35 * selector named [member] on a receiver whose type is [type]. | 35 * selector named [member] on a receiver whose type is [type]. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 final SourceString name; | 79 final SourceString name; |
| 80 | 80 |
| 81 MemberSet(SourceString this.name) : elements = new Set<Element>(); | 81 MemberSet(SourceString this.name) : elements = new Set<Element>(); |
| 82 | 82 |
| 83 void add(Element element) { | 83 void add(Element element) { |
| 84 elements.add(element); | 84 elements.add(element); |
| 85 } | 85 } |
| 86 | 86 |
| 87 bool isEmpty() => elements.isEmpty(); | 87 bool isEmpty() => elements.isEmpty(); |
| 88 } | 88 } |
| OLD | NEW |