Chromium Code Reviews| 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 part of dart2js; | 5 part of dart2js; |
| 6 | 6 |
| 7 class World { | 7 class World { |
| 8 final Compiler compiler; | 8 final Compiler compiler; |
| 9 final Map<ClassElement, Set<MixinApplicationElement>> mixinUses; | 9 final Map<ClassElement, Set<MixinApplicationElement>> mixinUses; |
| 10 final Map<ClassElement, Set<ClassElement>> typesImplementedBySubclasses; | 10 final Map<ClassElement, Set<ClassElement>> typesImplementedBySubclasses; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 mixinUses.putIfAbsent(mixin, () => | 154 mixinUses.putIfAbsent(mixin, () => |
| 155 new Set<MixinApplicationElement>()); | 155 new Set<MixinApplicationElement>()); |
| 156 users.add(mixinApplication); | 156 users.add(mixinApplication); |
| 157 } | 157 } |
| 158 | 158 |
| 159 bool isUsedAsMixin(ClassElement cls) { | 159 bool isUsedAsMixin(ClassElement cls) { |
| 160 Set<MixinApplicationElement> uses = mixinUses[cls]; | 160 Set<MixinApplicationElement> uses = mixinUses[cls]; |
| 161 return uses != null && !uses.isEmpty; | 161 return uses != null && !uses.isEmpty; |
| 162 } | 162 } |
| 163 | 163 |
| 164 bool hasAnySubclass(ClassElement cls) { | |
| 165 return subclasses[cls] != null && !subclasses[cls].isEmpty; | |
|
kasperl
2013/03/08 11:39:30
Maybe avoid looking up in the hash map twice?
ngeoffray
2013/03/08 12:54:27
Done.
| |
| 166 } | |
| 167 | |
| 168 bool hasAnySubtype(ClassElement cls) { | |
| 169 return subtypes[cls] != null && !subtypes[cls].isEmpty; | |
|
kasperl
2013/03/08 11:39:30
Ditto.
ngeoffray
2013/03/08 12:54:27
Done.
| |
| 170 } | |
| 171 | |
| 164 void registerRtiDependency(Element element, Element dependency) { | 172 void registerRtiDependency(Element element, Element dependency) { |
| 165 // We're not dealing with typedef for now. | 173 // We're not dealing with typedef for now. |
| 166 if (!element.isClass() || !dependency.isClass()) return; | 174 if (!element.isClass() || !dependency.isClass()) return; |
| 167 Set<ClassElement> classes = | 175 Set<ClassElement> classes = |
| 168 rtiDependencies.putIfAbsent(element, () => new Set<ClassElement>()); | 176 rtiDependencies.putIfAbsent(element, () => new Set<ClassElement>()); |
| 169 classes.add(dependency); | 177 classes.add(dependency); |
| 170 } | 178 } |
| 171 | 179 |
| 172 bool needsRti(ClassElement cls) { | 180 bool needsRti(ClassElement cls) { |
| 173 return classesNeedingRti.contains(cls) || compiler.enabledRuntimeType; | 181 return classesNeedingRti.contains(cls) || compiler.enabledRuntimeType; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 230 if (mask != null) { | 238 if (mask != null) { |
| 231 noSuchMethodSelector = new TypedSelector(mask, noSuchMethodSelector); | 239 noSuchMethodSelector = new TypedSelector(mask, noSuchMethodSelector); |
| 232 } | 240 } |
| 233 ClassElement objectClass = compiler.objectClass; | 241 ClassElement objectClass = compiler.objectClass; |
| 234 return allFunctions | 242 return allFunctions |
| 235 .filter(noSuchMethodSelector) | 243 .filter(noSuchMethodSelector) |
| 236 .map((Element member) => member.getEnclosingClass()) | 244 .map((Element member) => member.getEnclosingClass()) |
| 237 .where((ClassElement holder) => !identical(holder, objectClass)); | 245 .where((ClassElement holder) => !identical(holder, objectClass)); |
| 238 } | 246 } |
| 239 } | 247 } |
| OLD | NEW |