| 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 List<Element> subtypes = subtypes.putIfAbsent( | 13 Set<Element> subtypes = subtypes.putIfAbsent( |
| 14 type.element, | 14 type.element, |
| 15 () => <ClassElement>[]); | 15 () => new Set<ClassElement>()); |
| 16 subtypes.add(cls); | 16 subtypes.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()) continue; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 void add(Element element) { | 68 void add(Element element) { |
| 69 elements.add(element); | 69 elements.add(element); |
| 70 } | 70 } |
| 71 | 71 |
| 72 bool isEmpty() => elements.isEmpty(); | 72 bool isEmpty() => elements.isEmpty(); |
| 73 | 73 |
| 74 bool hasJustFields() { | 74 bool hasJustFields() { |
| 75 return elements.every((Element element) => element.isField()); | 75 return elements.every((Element element) => element.isField()); |
| 76 } | 76 } |
| 77 } | 77 } |
| OLD | NEW |