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 universe; | 5 library universe; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import '../common.dart'; | 9 import '../common.dart'; |
10 import '../compiler.dart' show | 10 import '../compiler.dart' show |
(...skipping 21 matching lines...) Expand all Loading... |
32 /// class Bar { | 32 /// class Bar { |
33 /// void foo() {} | 33 /// void foo() {} |
34 /// } | 34 /// } |
35 /// main() => new Bar().foo(); | 35 /// main() => new Bar().foo(); |
36 /// | 36 /// |
37 abstract class ReceiverConstraint { | 37 abstract class ReceiverConstraint { |
38 /// Returns whether [element] is a potential target when being | 38 /// Returns whether [element] is a potential target when being |
39 /// invoked on a receiver with this constraint. [selector] is used to ensure | 39 /// invoked on a receiver with this constraint. [selector] is used to ensure |
40 /// library privacy is taken into account. | 40 /// library privacy is taken into account. |
41 bool canHit(Element element, Selector selector, ClassWorld classWorld); | 41 bool canHit(Element element, Selector selector, ClassWorld classWorld); |
| 42 |
| 43 /// Returns whether this [TypeMask] applied to [selector] can hit a |
| 44 /// [noSuchMethod]. |
| 45 bool needsNoSuchMethodHandling(Selector selector, ClassWorld classWorld); |
42 } | 46 } |
43 | 47 |
44 /// The combined constraints on receivers all the dynamic call sites of the same | 48 /// The combined constraints on receivers all the dynamic call sites of the same |
45 /// selector. | 49 /// selector. |
46 /// | 50 /// |
47 /// For instance for these calls | 51 /// For instance for these calls |
48 /// | 52 /// |
49 /// class A { | 53 /// class A { |
50 /// foo(a, b) {} | 54 /// foo(a, b) {} |
51 /// } | 55 /// } |
52 /// class B { | 56 /// class B { |
53 /// foo(a, b) {} | 57 /// foo(a, b) {} |
54 /// } | 58 /// } |
55 /// class C { | 59 /// class C { |
56 /// foo(a, b) {} | 60 /// foo(a, b) {} |
57 /// } | 61 /// } |
58 /// new A().foo(a, b); | 62 /// new A().foo(a, b); |
59 /// new B().foo(0, 42); | 63 /// new B().foo(0, 42); |
60 /// | 64 /// |
61 /// the selector constaints for dynamic calls to 'foo' with two positional | 65 /// the selector constraints for dynamic calls to 'foo' with two positional |
62 /// arguments could be 'receiver of exact instance `A` or `B`'. | 66 /// arguments could be 'receiver of exact instance `A` or `B`'. |
63 abstract class SelectorConstraints { | 67 abstract class SelectorConstraints { |
64 /// Returns `true` if [selector] applies to [element] under these constraints | 68 /// Returns `true` if [selector] applies to [element] under these constraints |
65 /// given the closed [world]. | 69 /// given the closed [world]. |
66 /// | 70 /// |
67 /// Consider for instance in this world: | 71 /// Consider for instance in this world: |
68 /// | 72 /// |
69 /// class A { | 73 /// class A { |
70 /// foo(a, b) {} | 74 /// foo(a, b) {} |
71 /// } | 75 /// } |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 // TODO(ahe): Replace this method with something that is O(1), for example, | 398 // TODO(ahe): Replace this method with something that is O(1), for example, |
395 // by using a map. | 399 // by using a map. |
396 List<LocalFunctionElement> slowDirectlyNestedClosures(Element element) { | 400 List<LocalFunctionElement> slowDirectlyNestedClosures(Element element) { |
397 // Return new list to guard against concurrent modifications. | 401 // Return new list to guard against concurrent modifications. |
398 return new List<LocalFunctionElement>.from( | 402 return new List<LocalFunctionElement>.from( |
399 allClosures.where((LocalFunctionElement closure) { | 403 allClosures.where((LocalFunctionElement closure) { |
400 return closure.executableContext == element; | 404 return closure.executableContext == element; |
401 })); | 405 })); |
402 } | 406 } |
403 } | 407 } |
OLD | NEW |