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.function_set; | 5 library universe.function_set; |
6 | 6 |
7 import '../common/names.dart' show Identifiers, Selectors; | 7 import '../common/names.dart' show Identifiers, Selectors; |
8 import '../compiler.dart' show Compiler; | 8 import '../compiler.dart' show Compiler; |
9 import '../elements/elements.dart'; | 9 import '../elements/elements.dart'; |
10 import '../types/types.dart'; | 10 import '../types/types.dart'; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 } | 44 } |
45 | 45 |
46 bool contains(Element element) { | 46 bool contains(Element element) { |
47 assert(element.isInstanceMember); | 47 assert(element.isInstanceMember); |
48 assert(!element.isAbstract); | 48 assert(!element.isAbstract); |
49 String name = element.name; | 49 String name = element.name; |
50 FunctionSetNode node = nodes[name]; | 50 FunctionSetNode node = nodes[name]; |
51 return (node != null) ? node.contains(element) : false; | 51 return (node != null) ? node.contains(element) : false; |
52 } | 52 } |
53 | 53 |
54 /// Returns an object that allows iterating over all the functions | 54 /// Returns all the functions that may be invoked with the [selector] on a |
55 /// that may be invoked with the given [selector]. | 55 /// receiver with the given [constraint]. The returned elements may include |
| 56 /// noSuchMethod handlers that are potential targets indirectly through the |
| 57 /// noSuchMethod mechanism. |
56 Iterable<Element> filter(Selector selector, ReceiverConstraint constraint) { | 58 Iterable<Element> filter(Selector selector, ReceiverConstraint constraint) { |
57 return query(selector, constraint).functions; | 59 return query(selector, constraint).functions; |
58 } | 60 } |
59 | 61 |
60 /// Returns the mask for the potential receivers of a dynamic call to | 62 /// Returns the mask for the potential receivers of a dynamic call to |
61 /// [selector] on [constraint]. | 63 /// [selector] on [constraint]. |
62 /// | 64 /// |
63 /// This will narrow the constraints of [constraint] to a [TypeMask] of the | 65 /// This will narrow the constraints of [constraint] to a [TypeMask] of the |
64 /// set of classes that actually implement the selected member or implement | 66 /// set of classes that actually implement the selected member or implement |
65 /// the handling 'noSuchMethod' where the selected member is unimplemented. | 67 /// the handling 'noSuchMethod' where the selected member is unimplemented. |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 } else if (closedWorld.isInstantiated(cls.declaration)) { | 294 } else if (closedWorld.isInstantiated(cls.declaration)) { |
293 return new TypeMask.nonNullSubclass(cls.declaration, closedWorld); | 295 return new TypeMask.nonNullSubclass(cls.declaration, closedWorld); |
294 } else { | 296 } else { |
295 // TODO(johnniwinther): Avoid the need for this case. | 297 // TODO(johnniwinther): Avoid the need for this case. |
296 return const TypeMask.empty(); | 298 return const TypeMask.empty(); |
297 } | 299 } |
298 }), | 300 }), |
299 closedWorld); | 301 closedWorld); |
300 } | 302 } |
301 } | 303 } |
OLD | NEW |