| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.class_set; | 5 library dart2js.world.class_set; |
| 6 | 6 |
| 7 import 'dart:collection' show IterableBase; | 7 import 'dart:collection' show IterableBase; |
| 8 | 8 |
| 9 import '../elements/elements.dart' show ClassElement; | 9 import '../elements/elements.dart' show ClassElement; |
| 10 import '../util/enumset.dart' show EnumSet; | 10 import '../util/enumset.dart' show EnumSet; |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 /// | 207 /// |
| 208 /// [predicate] is applied to subclasses if their instantiation properties | 208 /// [predicate] is applied to subclasses if their instantiation properties |
| 209 /// intersect with their corresponding [Instantiation] values in [mask]. If | 209 /// intersect with their corresponding [Instantiation] values in [mask]. If |
| 210 /// [strict] is `true`, [predicate] is _not_ called on [cls] itself. | 210 /// [strict] is `true`, [predicate] is _not_ called on [cls] itself. |
| 211 bool anySubclass( | 211 bool anySubclass( |
| 212 bool predicate(ClassElement cls), EnumSet<Instantiation> mask, | 212 bool predicate(ClassElement cls), EnumSet<Instantiation> mask, |
| 213 {bool strict: false}) { | 213 {bool strict: false}) { |
| 214 IterationStep wrapper(ClassElement cls) { | 214 IterationStep wrapper(ClassElement cls) { |
| 215 return predicate(cls) ? IterationStep.STOP : IterationStep.CONTINUE; | 215 return predicate(cls) ? IterationStep.STOP : IterationStep.CONTINUE; |
| 216 } | 216 } |
| 217 |
| 217 return forEachSubclass(wrapper, mask, strict: strict) == IterationStep.STOP; | 218 return forEachSubclass(wrapper, mask, strict: strict) == IterationStep.STOP; |
| 218 } | 219 } |
| 219 | 220 |
| 220 /// Applies [f] to each subclass of [cls] matching the criteria specified by | 221 /// Applies [f] to each subclass of [cls] matching the criteria specified by |
| 221 /// [mask] and [strict]. | 222 /// [mask] and [strict]. |
| 222 /// | 223 /// |
| 223 /// [f] is a applied to subclasses if their instantiation properties intersect | 224 /// [f] is a applied to subclasses if their instantiation properties intersect |
| 224 /// with their corresponding [Instantiation] values in [mask]. If [strict] is | 225 /// with their corresponding [Instantiation] values in [mask]. If [strict] is |
| 225 /// `true`, [f] is _not_ called on [cls] itself. | 226 /// `true`, [f] is _not_ called on [cls] itself. |
| 226 /// | 227 /// |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 /// class, visitation is stopped immediately and the function returns `true`. | 541 /// class, visitation is stopped immediately and the function returns `true`. |
| 541 /// | 542 /// |
| 542 /// [predicate] is applied to subtypes if their instantiation properties | 543 /// [predicate] is applied to subtypes if their instantiation properties |
| 543 /// intersect with their corresponding [Instantiation] values in [mask]. If | 544 /// intersect with their corresponding [Instantiation] values in [mask]. If |
| 544 /// [strict] is `true`, [predicate] is _not_ called on [cls] itself. | 545 /// [strict] is `true`, [predicate] is _not_ called on [cls] itself. |
| 545 bool anySubtype(bool predicate(ClassElement cls), EnumSet<Instantiation> mask, | 546 bool anySubtype(bool predicate(ClassElement cls), EnumSet<Instantiation> mask, |
| 546 {bool strict: false}) { | 547 {bool strict: false}) { |
| 547 IterationStep wrapper(ClassElement cls) { | 548 IterationStep wrapper(ClassElement cls) { |
| 548 return predicate(cls) ? IterationStep.STOP : IterationStep.CONTINUE; | 549 return predicate(cls) ? IterationStep.STOP : IterationStep.CONTINUE; |
| 549 } | 550 } |
| 551 |
| 550 return forEachSubtype(wrapper, mask, strict: strict) == IterationStep.STOP; | 552 return forEachSubtype(wrapper, mask, strict: strict) == IterationStep.STOP; |
| 551 } | 553 } |
| 552 | 554 |
| 553 /// Applies [f] to each subtype of [cls] matching the criteria specified by | 555 /// Applies [f] to each subtype of [cls] matching the criteria specified by |
| 554 /// [mask] and [strict]. | 556 /// [mask] and [strict]. |
| 555 /// | 557 /// |
| 556 /// [f] is a applied to subtypes if their instantiation properties intersect | 558 /// [f] is a applied to subtypes if their instantiation properties intersect |
| 557 /// with their corresponding [Instantiation] values in [mask]. If [strict] is | 559 /// with their corresponding [Instantiation] values in [mask]. If [strict] is |
| 558 /// `true`, [f] is _not_ called on [cls] itself. | 560 /// `true`, [f] is _not_ called on [cls] itself. |
| 559 /// | 561 /// |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 STOP, | 850 STOP, |
| 849 | 851 |
| 850 /// Iteration skips the subclasses of the current class. | 852 /// Iteration skips the subclasses of the current class. |
| 851 SKIP_SUBCLASSES, | 853 SKIP_SUBCLASSES, |
| 852 } | 854 } |
| 853 | 855 |
| 854 /// Visiting function used for the `forEachX` functions of [ClassHierarchyNode] | 856 /// Visiting function used for the `forEachX` functions of [ClassHierarchyNode] |
| 855 /// and [ClassSet]. The return value controls the continued iteration. If `null` | 857 /// and [ClassSet]. The return value controls the continued iteration. If `null` |
| 856 /// is returned, iteration continues to the end. | 858 /// is returned, iteration continues to the end. |
| 857 typedef IterationStep ForEachFunction(ClassElement cls); | 859 typedef IterationStep ForEachFunction(ClassElement cls); |
| OLD | NEW |