| 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 library dart2js.world; | 5 library dart2js.world; |
| 6 | 6 |
| 7 import 'closure.dart' show | 7 import 'closure.dart' show |
| 8 SynthesizedCallMethodElementX; | 8 SynthesizedCallMethodElementX; |
| 9 import 'common.dart'; | 9 import 'common.dart'; |
| 10 import 'common/backend_api.dart' show | 10 import 'common/backend_api.dart' show |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 /// Returns `true` if [cls] is implemented by an instantiated class. | 228 /// Returns `true` if [cls] is implemented by an instantiated class. |
| 229 bool isImplemented(ClassElement cls) { | 229 bool isImplemented(ClassElement cls) { |
| 230 return compiler.resolverWorld.isImplemented(cls); | 230 return compiler.resolverWorld.isImplemented(cls); |
| 231 } | 231 } |
| 232 | 232 |
| 233 /// Returns an iterable over the directly instantiated classes that extend | 233 /// Returns an iterable over the directly instantiated classes that extend |
| 234 /// [cls] possibly including [cls] itself, if it is live. | 234 /// [cls] possibly including [cls] itself, if it is live. |
| 235 Iterable<ClassElement> subclassesOf(ClassElement cls) { | 235 Iterable<ClassElement> subclassesOf(ClassElement cls) { |
| 236 ClassHierarchyNode hierarchy = _classHierarchyNodes[cls.declaration]; | 236 ClassHierarchyNode hierarchy = _classHierarchyNodes[cls.declaration]; |
| 237 if (hierarchy == null) return const <ClassElement>[]; | 237 if (hierarchy == null) return const <ClassElement>[]; |
| 238 return hierarchy.subclasses( | 238 return hierarchy.subclassesByMask( |
| 239 includeIndirectlyInstantiated: false, | 239 ClassHierarchyNode.DIRECTLY_INSTANTIATED); |
| 240 includeUninstantiated: false); | |
| 241 } | 240 } |
| 242 | 241 |
| 243 /// Returns an iterable over the directly instantiated classes that extend | 242 /// Returns an iterable over the directly instantiated classes that extend |
| 244 /// [cls] _not_ including [cls] itself. | 243 /// [cls] _not_ including [cls] itself. |
| 245 Iterable<ClassElement> strictSubclassesOf(ClassElement cls) { | 244 Iterable<ClassElement> strictSubclassesOf(ClassElement cls) { |
| 246 ClassHierarchyNode subclasses = _classHierarchyNodes[cls.declaration]; | 245 ClassHierarchyNode subclasses = _classHierarchyNodes[cls.declaration]; |
| 247 if (subclasses == null) return const <ClassElement>[]; | 246 if (subclasses == null) return const <ClassElement>[]; |
| 248 return subclasses.subclasses( | 247 return subclasses.subclassesByMask( |
| 249 strict: true, | 248 ClassHierarchyNode.DIRECTLY_INSTANTIATED, strict: true); |
| 250 includeIndirectlyInstantiated: false, | |
| 251 includeUninstantiated: false); | |
| 252 } | 249 } |
| 253 | 250 |
| 254 /// Returns an iterable over the directly instantiated that implement [cls] | 251 /// Returns an iterable over the directly instantiated that implement [cls] |
| 255 /// possibly including [cls] itself, if it is live. | 252 /// possibly including [cls] itself, if it is live. |
| 256 Iterable<ClassElement> subtypesOf(ClassElement cls) { | 253 Iterable<ClassElement> subtypesOf(ClassElement cls) { |
| 257 ClassSet classSet = _classSets[cls.declaration]; | 254 ClassSet classSet = _classSets[cls.declaration]; |
| 258 if (classSet == null) { | 255 if (classSet == null) { |
| 259 return const <ClassElement>[]; | 256 return const <ClassElement>[]; |
| 260 } else { | 257 } else { |
| 261 return classSet.subtypes( | 258 return classSet.subtypesByMask(ClassHierarchyNode.DIRECTLY_INSTANTIATED); |
| 262 includeIndirectlyInstantiated: false, | |
| 263 includeUninstantiated: false); | |
| 264 } | 259 } |
| 265 } | 260 } |
| 266 | 261 |
| 267 /// Returns an iterable over the directly instantiated that implement [cls] | 262 /// Returns an iterable over the directly instantiated that implement [cls] |
| 268 /// _not_ including [cls]. | 263 /// _not_ including [cls]. |
| 269 Iterable<ClassElement> strictSubtypesOf(ClassElement cls) { | 264 Iterable<ClassElement> strictSubtypesOf(ClassElement cls) { |
| 270 ClassSet classSet = _classSets[cls.declaration]; | 265 ClassSet classSet = _classSets[cls.declaration]; |
| 271 if (classSet == null) { | 266 if (classSet == null) { |
| 272 return const <ClassElement>[]; | 267 return const <ClassElement>[]; |
| 273 } else { | 268 } else { |
| 274 return classSet.subtypes( | 269 return classSet.subtypesByMask( |
| 275 strict: true, | 270 ClassHierarchyNode.DIRECTLY_INSTANTIATED, |
| 276 includeIndirectlyInstantiated: false, | 271 strict: true); |
| 277 includeUninstantiated: false); | |
| 278 } | 272 } |
| 279 } | 273 } |
| 280 | 274 |
| 281 /// Returns `true` if [a] and [b] have any known common subtypes. | 275 /// Returns `true` if [a] and [b] have any known common subtypes. |
| 282 bool haveAnyCommonSubtypes(ClassElement a, ClassElement b) { | 276 bool haveAnyCommonSubtypes(ClassElement a, ClassElement b) { |
| 283 ClassSet classSetA = _classSets[a.declaration]; | 277 ClassSet classSetA = _classSets[a.declaration]; |
| 284 ClassSet classSetB = _classSets[b.declaration]; | 278 ClassSet classSetB = _classSets[b.declaration]; |
| 285 if (classSetA == null || classSetB == null) return false; | 279 if (classSetA == null || classSetB == null) return false; |
| 286 // TODO(johnniwinther): Implement an optimized query on [ClassSet]. | 280 // TODO(johnniwinther): Implement an optimized query on [ClassSet]. |
| 287 Set<ClassElement> subtypesOfB = classSetB.subtypes().toSet(); | 281 Set<ClassElement> subtypesOfB = classSetB.subtypes().toSet(); |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 // function expressions's element. | 749 // function expressions's element. |
| 756 // TODO(herhut): Generate classes for function expressions earlier. | 750 // TODO(herhut): Generate classes for function expressions earlier. |
| 757 if (element is SynthesizedCallMethodElementX) { | 751 if (element is SynthesizedCallMethodElementX) { |
| 758 return getMightBePassedToApply(element.expression); | 752 return getMightBePassedToApply(element.expression); |
| 759 } | 753 } |
| 760 return functionsThatMightBePassedToApply.contains(element); | 754 return functionsThatMightBePassedToApply.contains(element); |
| 761 } | 755 } |
| 762 | 756 |
| 763 bool get hasClosedWorldAssumption => !compiler.hasIncrementalSupport; | 757 bool get hasClosedWorldAssumption => !compiler.hasIncrementalSupport; |
| 764 } | 758 } |
| OLD | NEW |