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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 /// Returns an iterable over the live classes that extend [cls] _not_ | 92 /// Returns an iterable over the live classes that extend [cls] _not_ |
93 /// including [cls] itself. | 93 /// including [cls] itself. |
94 Iterable<ClassElement> strictSubclassesOf(ClassElement cls); | 94 Iterable<ClassElement> strictSubclassesOf(ClassElement cls); |
95 | 95 |
96 /// Returns the number of live classes that extend [cls] _not_ | 96 /// Returns the number of live classes that extend [cls] _not_ |
97 /// including [cls] itself. | 97 /// including [cls] itself. |
98 int strictSubclassCount(ClassElement cls); | 98 int strictSubclassCount(ClassElement cls); |
99 | 99 |
100 /// Applies [f] to each live class that extend [cls] _not_ including [cls] | 100 /// Applies [f] to each live class that extend [cls] _not_ including [cls] |
101 /// itself. | 101 /// itself. |
102 void forEachStrictSubclassOf(ClassElement cls, ForEach f(ClassElement cls)); | 102 void forEachStrictSubclassOf(ClassElement cls, |
| 103 IterationStep f(ClassElement cls)); |
103 | 104 |
104 /// Returns `true` if [predicate] applies to any live class that extend [cls] | 105 /// Returns `true` if [predicate] applies to any live class that extend [cls] |
105 /// _not_ including [cls] itself. | 106 /// _not_ including [cls] itself. |
106 bool anyStrictSubclassOf(ClassElement cls, bool predicate(ClassElement cls)); | 107 bool anyStrictSubclassOf(ClassElement cls, bool predicate(ClassElement cls)); |
107 | 108 |
108 /// Returns an iterable over the directly instantiated that implement [cls] | 109 /// Returns an iterable over the directly instantiated that implement [cls] |
109 /// possibly including [cls] itself, if it is live. | 110 /// possibly including [cls] itself, if it is live. |
110 Iterable<ClassElement> subtypesOf(ClassElement cls); | 111 Iterable<ClassElement> subtypesOf(ClassElement cls); |
111 | 112 |
112 /// Returns an iterable over the live classes that implement [cls] _not_ | 113 /// Returns an iterable over the live classes that implement [cls] _not_ |
113 /// including [cls] if it is live. | 114 /// including [cls] if it is live. |
114 Iterable<ClassElement> strictSubtypesOf(ClassElement cls); | 115 Iterable<ClassElement> strictSubtypesOf(ClassElement cls); |
115 | 116 |
116 /// Returns the number of live classes that implement [cls] _not_ | 117 /// Returns the number of live classes that implement [cls] _not_ |
117 /// including [cls] itself. | 118 /// including [cls] itself. |
118 int strictSubtypeCount(ClassElement cls); | 119 int strictSubtypeCount(ClassElement cls); |
119 | 120 |
120 /// Applies [f] to each live class that implements [cls] _not_ including [cls] | 121 /// Applies [f] to each live class that implements [cls] _not_ including [cls] |
121 /// itself. | 122 /// itself. |
122 void forEachStrictSubtypeOf(ClassElement cls, ForEach f(ClassElement cls)); | 123 void forEachStrictSubtypeOf(ClassElement cls, |
| 124 IterationStep f(ClassElement cls)); |
123 | 125 |
124 /// Returns `true` if [predicate] applies to any live class that implements | 126 /// Returns `true` if [predicate] applies to any live class that implements |
125 /// [cls] _not_ including [cls] itself. | 127 /// [cls] _not_ including [cls] itself. |
126 bool anyStrictSubtypeOf(ClassElement cls, bool predicate(ClassElement cls)); | 128 bool anyStrictSubtypeOf(ClassElement cls, bool predicate(ClassElement cls)); |
127 | 129 |
128 /// Returns `true` if [a] and [b] have any known common subtypes. | 130 /// Returns `true` if [a] and [b] have any known common subtypes. |
129 bool haveAnyCommonSubtypes(ClassElement a, ClassElement b); | 131 bool haveAnyCommonSubtypes(ClassElement a, ClassElement b); |
130 | 132 |
131 /// Returns `true` if any live class other than [cls] extends [cls]. | 133 /// Returns `true` if any live class other than [cls] extends [cls]. |
132 bool hasAnyStrictSubclass(ClassElement cls); | 134 bool hasAnyStrictSubclass(ClassElement cls); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 /// Returns the number of live classes that extend [cls] _not_ | 277 /// Returns the number of live classes that extend [cls] _not_ |
276 /// including [cls] itself. | 278 /// including [cls] itself. |
277 int strictSubclassCount(ClassElement cls) { | 279 int strictSubclassCount(ClassElement cls) { |
278 ClassHierarchyNode subclasses = _classHierarchyNodes[cls.declaration]; | 280 ClassHierarchyNode subclasses = _classHierarchyNodes[cls.declaration]; |
279 if (subclasses == null) return 0; | 281 if (subclasses == null) return 0; |
280 return subclasses.instantiatedSubclassCount; | 282 return subclasses.instantiatedSubclassCount; |
281 } | 283 } |
282 | 284 |
283 /// Applies [f] to each live class that extend [cls] _not_ including [cls] | 285 /// Applies [f] to each live class that extend [cls] _not_ including [cls] |
284 /// itself. | 286 /// itself. |
285 void forEachStrictSubclassOf(ClassElement cls, ForEach f(ClassElement cls)) { | 287 void forEachStrictSubclassOf(ClassElement cls, |
| 288 IterationStep f(ClassElement cls)) { |
286 ClassHierarchyNode subclasses = _classHierarchyNodes[cls.declaration]; | 289 ClassHierarchyNode subclasses = _classHierarchyNodes[cls.declaration]; |
287 if (subclasses == null) return; | 290 if (subclasses == null) return; |
288 subclasses.forEachSubclass( | 291 subclasses.forEachSubclass( |
289 f, | 292 f, |
290 ClassHierarchyNode.DIRECTLY_INSTANTIATED, | 293 ClassHierarchyNode.DIRECTLY_INSTANTIATED, |
291 strict: true); | 294 strict: true); |
292 } | 295 } |
293 | 296 |
294 /// Returns `true` if [predicate] applies to any live class that extend [cls] | 297 /// Returns `true` if [predicate] applies to any live class that extend [cls] |
295 /// _not_ including [cls] itself. | 298 /// _not_ including [cls] itself. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 /// Returns the number of live classes that implement [cls] _not_ | 332 /// Returns the number of live classes that implement [cls] _not_ |
330 /// including [cls] itself. | 333 /// including [cls] itself. |
331 int strictSubtypeCount(ClassElement cls) { | 334 int strictSubtypeCount(ClassElement cls) { |
332 ClassSet classSet = _classSets[cls.declaration]; | 335 ClassSet classSet = _classSets[cls.declaration]; |
333 if (classSet == null) return 0; | 336 if (classSet == null) return 0; |
334 return classSet.instantiatedSubtypeCount; | 337 return classSet.instantiatedSubtypeCount; |
335 } | 338 } |
336 | 339 |
337 /// Applies [f] to each live class that implements [cls] _not_ including [cls] | 340 /// Applies [f] to each live class that implements [cls] _not_ including [cls] |
338 /// itself. | 341 /// itself. |
339 void forEachStrictSubtypeOf(ClassElement cls, ForEach f(ClassElement cls)) { | 342 void forEachStrictSubtypeOf(ClassElement cls, |
| 343 IterationStep f(ClassElement cls)) { |
340 ClassSet classSet = _classSets[cls.declaration]; | 344 ClassSet classSet = _classSets[cls.declaration]; |
341 if (classSet == null) return; | 345 if (classSet == null) return; |
342 classSet.forEachSubtype( | 346 classSet.forEachSubtype( |
343 f, | 347 f, |
344 ClassHierarchyNode.DIRECTLY_INSTANTIATED, | 348 ClassHierarchyNode.DIRECTLY_INSTANTIATED, |
345 strict: true); | 349 strict: true); |
346 } | 350 } |
347 | 351 |
348 /// Returns `true` if [predicate] applies to any live class that extend [cls] | 352 /// Returns `true` if [predicate] applies to any live class that extend [cls] |
349 /// _not_ including [cls] itself. | 353 /// _not_ including [cls] itself. |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 // function expressions's element. | 836 // function expressions's element. |
833 // TODO(herhut): Generate classes for function expressions earlier. | 837 // TODO(herhut): Generate classes for function expressions earlier. |
834 if (element is SynthesizedCallMethodElementX) { | 838 if (element is SynthesizedCallMethodElementX) { |
835 return getMightBePassedToApply(element.expression); | 839 return getMightBePassedToApply(element.expression); |
836 } | 840 } |
837 return functionsThatMightBePassedToApply.contains(element); | 841 return functionsThatMightBePassedToApply.contains(element); |
838 } | 842 } |
839 | 843 |
840 bool get hasClosedWorldAssumption => !compiler.hasIncrementalSupport; | 844 bool get hasClosedWorldAssumption => !compiler.hasIncrementalSupport; |
841 } | 845 } |
OLD | NEW |