| 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/backend_api.dart' show | 9 import 'common/backend_api.dart' show |
| 10 Backend; | 10 Backend; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 Iterable<ClassElement> subclassesOf(ClassElement cls); | 82 Iterable<ClassElement> subclassesOf(ClassElement cls); |
| 83 | 83 |
| 84 /// Returns an iterable over the live classes that extend [cls] _not_ | 84 /// Returns an iterable over the live classes that extend [cls] _not_ |
| 85 /// including [cls] itself. | 85 /// including [cls] itself. |
| 86 Iterable<ClassElement> strictSubclassesOf(ClassElement cls); | 86 Iterable<ClassElement> strictSubclassesOf(ClassElement cls); |
| 87 | 87 |
| 88 /// Returns an iterable over the live classes that implement [cls] _not_ | 88 /// Returns an iterable over the live classes that implement [cls] _not_ |
| 89 /// including [cls] if it is live. | 89 /// including [cls] if it is live. |
| 90 Iterable<ClassElement> strictSubtypesOf(ClassElement cls); | 90 Iterable<ClassElement> strictSubtypesOf(ClassElement cls); |
| 91 | 91 |
| 92 /// Returns `true` if [a] and [b] have any known common subtypes. |
| 93 bool haveAnyCommonSubtypes(ClassElement a, ClassElement b); |
| 94 |
| 92 /// Returns `true` if any live class other than [cls] extends [cls]. | 95 /// Returns `true` if any live class other than [cls] extends [cls]. |
| 93 bool hasAnyStrictSubclass(ClassElement cls); | 96 bool hasAnyStrictSubclass(ClassElement cls); |
| 94 | 97 |
| 95 /// Returns `true` if any live class other than [cls] implements [cls]. | 98 /// Returns `true` if any live class other than [cls] implements [cls]. |
| 96 bool hasAnyStrictSubtype(ClassElement cls); | 99 bool hasAnyStrictSubtype(ClassElement cls); |
| 97 | 100 |
| 98 /// Returns `true` if all live classes that implement [cls] extend it. | 101 /// Returns `true` if all live classes that implement [cls] extend it. |
| 99 bool hasOnlySubclasses(ClassElement cls); | 102 bool hasOnlySubclasses(ClassElement cls); |
| 100 | 103 |
| 101 /// Returns an iterable over the common supertypes of the [classes]. | 104 /// Returns an iterable over the common supertypes of the [classes]. |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 if (classSet == null) { | 212 if (classSet == null) { |
| 210 return const <ClassElement>[]; | 213 return const <ClassElement>[]; |
| 211 } else { | 214 } else { |
| 212 return classSet.subtypes( | 215 return classSet.subtypes( |
| 213 strict: true, | 216 strict: true, |
| 214 includeIndirectlyInstantiated: false, | 217 includeIndirectlyInstantiated: false, |
| 215 includeUninstantiated: false); | 218 includeUninstantiated: false); |
| 216 } | 219 } |
| 217 } | 220 } |
| 218 | 221 |
| 222 /// Returns `true` if [a] and [b] have any known common subtypes. |
| 223 bool haveAnyCommonSubtypes(ClassElement a, ClassElement b) { |
| 224 ClassSet classSetA = _classSets[a.declaration]; |
| 225 ClassSet classSetB = _classSets[b.declaration]; |
| 226 if (classSetA == null || classSetB == null) return false; |
| 227 // TODO(johnniwinther): Implement an optimized query on [ClassSet]. |
| 228 Set<ClassElement> subtypesOfB = classSetB.subtypes().toSet(); |
| 229 for (ClassElement subtypeOfA in classSetA.subtypes()) { |
| 230 if (subtypesOfB.contains(subtypeOfA)) { |
| 231 return true; |
| 232 } |
| 233 } |
| 234 return false; |
| 235 } |
| 236 |
| 219 /// Returns `true` if any directly instantiated class other than [cls] extends | 237 /// Returns `true` if any directly instantiated class other than [cls] extends |
| 220 /// [cls]. | 238 /// [cls]. |
| 221 bool hasAnyStrictSubclass(ClassElement cls) { | 239 bool hasAnyStrictSubclass(ClassElement cls) { |
| 222 ClassHierarchyNode subclasses = _classHierarchyNodes[cls.declaration]; | 240 ClassHierarchyNode subclasses = _classHierarchyNodes[cls.declaration]; |
| 223 if (subclasses == null) return false; | 241 if (subclasses == null) return false; |
| 224 return subclasses.isIndirectlyInstantiated; | 242 return subclasses.isIndirectlyInstantiated; |
| 225 } | 243 } |
| 226 | 244 |
| 227 /// Returns `true` if any directly instantiated class other than [cls] | 245 /// Returns `true` if any directly instantiated class other than [cls] |
| 228 /// implements [cls]. | 246 /// implements [cls]. |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 // function expressions's element. | 645 // function expressions's element. |
| 628 // TODO(herhut): Generate classes for function expressions earlier. | 646 // TODO(herhut): Generate classes for function expressions earlier. |
| 629 if (element is SynthesizedCallMethodElementX) { | 647 if (element is SynthesizedCallMethodElementX) { |
| 630 return getMightBePassedToApply(element.expression); | 648 return getMightBePassedToApply(element.expression); |
| 631 } | 649 } |
| 632 return functionsThatMightBePassedToApply.contains(element); | 650 return functionsThatMightBePassedToApply.contains(element); |
| 633 } | 651 } |
| 634 | 652 |
| 635 bool get hasClosedWorldAssumption => !compiler.hasIncrementalSupport; | 653 bool get hasClosedWorldAssumption => !compiler.hasIncrementalSupport; |
| 636 } | 654 } |
| OLD | NEW |