| 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 world_builder; | 5 library world_builder; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import '../common.dart'; | 9 import '../common.dart'; |
| 10 import '../common/names.dart' show Identifiers; | 10 import '../common/names.dart' show Identifiers; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 /// | 50 /// |
| 51 /// class Bar { | 51 /// class Bar { |
| 52 /// void foo() {} | 52 /// void foo() {} |
| 53 /// } | 53 /// } |
| 54 /// main() => new Bar().foo(); | 54 /// main() => new Bar().foo(); |
| 55 /// | 55 /// |
| 56 abstract class ReceiverConstraint { | 56 abstract class ReceiverConstraint { |
| 57 /// Returns whether [element] is a potential target when being | 57 /// Returns whether [element] is a potential target when being |
| 58 /// invoked on a receiver with this constraint. [selector] is used to ensure | 58 /// invoked on a receiver with this constraint. [selector] is used to ensure |
| 59 /// library privacy is taken into account. | 59 /// library privacy is taken into account. |
| 60 bool canHit(MemberElement element, Selector selector, World world); | 60 bool canHit(MemberEntity element, Selector selector, covariant World world); |
| 61 | 61 |
| 62 /// Returns whether this [TypeMask] applied to [selector] can hit a | 62 /// Returns whether this [TypeMask] applied to [selector] can hit a |
| 63 /// [noSuchMethod]. | 63 /// [noSuchMethod]. |
| 64 bool needsNoSuchMethodHandling(Selector selector, World world); | 64 bool needsNoSuchMethodHandling(Selector selector, covariant World world); |
| 65 } | 65 } |
| 66 | 66 |
| 67 /// The combined constraints on receivers all the dynamic call sites of the same | 67 /// The combined constraints on receivers all the dynamic call sites of the same |
| 68 /// selector. | 68 /// selector. |
| 69 /// | 69 /// |
| 70 /// For instance for these calls | 70 /// For instance for these calls |
| 71 /// | 71 /// |
| 72 /// class A { | 72 /// class A { |
| 73 /// foo(a, b) {} | 73 /// foo(a, b) {} |
| 74 /// } | 74 /// } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 92 /// class A { | 92 /// class A { |
| 93 /// foo(a, b) {} | 93 /// foo(a, b) {} |
| 94 /// } | 94 /// } |
| 95 /// class B { | 95 /// class B { |
| 96 /// foo(a, b) {} | 96 /// foo(a, b) {} |
| 97 /// } | 97 /// } |
| 98 /// new A().foo(a, b); | 98 /// new A().foo(a, b); |
| 99 /// | 99 /// |
| 100 /// Ideally the selector constraints for calls `foo` with two positional | 100 /// Ideally the selector constraints for calls `foo` with two positional |
| 101 /// arguments apply to `A.foo` but `B.foo`. | 101 /// arguments apply to `A.foo` but `B.foo`. |
| 102 bool applies(MemberEntity element, Selector selector, World world); | 102 bool applies(MemberEntity element, Selector selector, covariant World world); |
| 103 | 103 |
| 104 /// Returns `true` if at least one of the receivers matching these constraints | 104 /// Returns `true` if at least one of the receivers matching these constraints |
| 105 /// in the closed [world] have no implementation matching [selector]. | 105 /// in the closed [world] have no implementation matching [selector]. |
| 106 /// | 106 /// |
| 107 /// For instance for this code snippet | 107 /// For instance for this code snippet |
| 108 /// | 108 /// |
| 109 /// class A {} | 109 /// class A {} |
| 110 /// class B { foo() {} } | 110 /// class B { foo() {} } |
| 111 /// m(b) => (b ? new A() : new B()).foo(); | 111 /// m(b) => (b ? new A() : new B()).foo(); |
| 112 /// | 112 /// |
| 113 /// the potential receiver `new A()` has no implementation of `foo` and thus | 113 /// the potential receiver `new A()` has no implementation of `foo` and thus |
| 114 /// needs to handle the call through its `noSuchMethod` handler. | 114 /// needs to handle the call through its `noSuchMethod` handler. |
| 115 bool needsNoSuchMethodHandling(Selector selector, World world); | 115 bool needsNoSuchMethodHandling(Selector selector, covariant World world); |
| 116 } | 116 } |
| 117 | 117 |
| 118 /// A mutable [SelectorConstraints] used in [WorldBuilder]. | 118 /// A mutable [SelectorConstraints] used in [WorldBuilder]. |
| 119 abstract class UniverseSelectorConstraints extends SelectorConstraints { | 119 abstract class UniverseSelectorConstraints extends SelectorConstraints { |
| 120 /// Adds [constraint] to these selector constraints. Return `true` if the set | 120 /// Adds [constraint] to these selector constraints. Return `true` if the set |
| 121 /// of potential receivers expanded due to the new constraint. | 121 /// of potential receivers expanded due to the new constraint. |
| 122 bool addReceiverConstraint(ReceiverConstraint constraint); | 122 bool addReceiverConstraint(covariant ReceiverConstraint constraint); |
| 123 } | 123 } |
| 124 | 124 |
| 125 /// Strategy for computing the constraints on potential receivers of dynamic | 125 /// Strategy for computing the constraints on potential receivers of dynamic |
| 126 /// call sites. | 126 /// call sites. |
| 127 abstract class SelectorConstraintsStrategy { | 127 abstract class SelectorConstraintsStrategy { |
| 128 /// Create a [UniverseSelectorConstraints] to represent the global receiver | 128 /// Create a [UniverseSelectorConstraints] to represent the global receiver |
| 129 /// constraints for dynamic call sites with [selector]. | 129 /// constraints for dynamic call sites with [selector]. |
| 130 UniverseSelectorConstraints createSelectorConstraints(Selector selector); | 130 UniverseSelectorConstraints createSelectorConstraints(Selector selector); |
| 131 } | 131 } |
| 132 | 132 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 | 179 |
| 180 /// All directly instantiated types, that is, the types of the directly | 180 /// All directly instantiated types, that is, the types of the directly |
| 181 /// instantiated classes. | 181 /// instantiated classes. |
| 182 // TODO(johnniwinther): Improve semantic precision. | 182 // TODO(johnniwinther): Improve semantic precision. |
| 183 Iterable<InterfaceType> get instantiatedTypes; | 183 Iterable<InterfaceType> get instantiatedTypes; |
| 184 | 184 |
| 185 /// Registers that [type] is checked in this world builder. The unaliased type | 185 /// Registers that [type] is checked in this world builder. The unaliased type |
| 186 /// is returned. | 186 /// is returned. |
| 187 void registerIsCheck(DartType type); | 187 void registerIsCheck(DartType type); |
| 188 } | 188 } |
| OLD | NEW |