| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 return query(selector, constraint).computeMask(closedWorld); | 76 return query(selector, constraint).computeMask(closedWorld); |
| 77 } | 77 } |
| 78 | 78 |
| 79 SelectorMask _createSelectorMask(Selector selector, | 79 SelectorMask _createSelectorMask(Selector selector, |
| 80 ReceiverConstraint constraint, ClosedWorld closedWorld) { | 80 ReceiverConstraint constraint, ClosedWorld closedWorld) { |
| 81 return constraint != null | 81 return constraint != null |
| 82 ? new SelectorMask(selector, constraint) | 82 ? new SelectorMask(selector, constraint) |
| 83 : new SelectorMask( | 83 : new SelectorMask( |
| 84 selector, | 84 selector, |
| 85 new TypeMask.subclass( | 85 new TypeMask.subclass( |
| 86 closedWorld.coreClasses.objectClass, closedWorld)); | 86 closedWorld.commonElements.objectClass, closedWorld)); |
| 87 } | 87 } |
| 88 | 88 |
| 89 /// Returns the set of functions that can be the target of a call to | 89 /// Returns the set of functions that can be the target of a call to |
| 90 /// [selector] on a receiver constrained by [constraint] including | 90 /// [selector] on a receiver constrained by [constraint] including |
| 91 /// 'noSuchMethod' methods where applicable. | 91 /// 'noSuchMethod' methods where applicable. |
| 92 FunctionSetQuery query(Selector selector, ReceiverConstraint constraint) { | 92 FunctionSetQuery query(Selector selector, ReceiverConstraint constraint) { |
| 93 String name = selector.name; | 93 String name = selector.name; |
| 94 SelectorMask selectorMask = | 94 SelectorMask selectorMask = |
| 95 _createSelectorMask(selector, constraint, closedWorld); | 95 _createSelectorMask(selector, constraint, closedWorld); |
| 96 SelectorMask noSuchMethodMask = | 96 SelectorMask noSuchMethodMask = |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 class FullFunctionSetQuery implements FunctionSetQuery { | 281 class FullFunctionSetQuery implements FunctionSetQuery { |
| 282 @override | 282 @override |
| 283 final Iterable<Element> functions; | 283 final Iterable<Element> functions; |
| 284 | 284 |
| 285 TypeMask _mask; | 285 TypeMask _mask; |
| 286 | 286 |
| 287 FullFunctionSetQuery(this.functions); | 287 FullFunctionSetQuery(this.functions); |
| 288 | 288 |
| 289 @override | 289 @override |
| 290 TypeMask computeMask(ClosedWorld closedWorld) { | 290 TypeMask computeMask(ClosedWorld closedWorld) { |
| 291 assert( | 291 assert(closedWorld |
| 292 closedWorld.hasAnyStrictSubclass(closedWorld.coreClasses.objectClass)); | 292 .hasAnyStrictSubclass(closedWorld.commonElements.objectClass)); |
| 293 if (_mask != null) return _mask; | 293 if (_mask != null) return _mask; |
| 294 return _mask = new TypeMask.unionOf( | 294 return _mask = new TypeMask.unionOf( |
| 295 functions.expand((element) { | 295 functions.expand((element) { |
| 296 ClassElement cls = element.enclosingClass; | 296 ClassElement cls = element.enclosingClass; |
| 297 return [cls]..addAll(closedWorld.mixinUsesOf(cls)); | 297 return [cls]..addAll(closedWorld.mixinUsesOf(cls)); |
| 298 }).map((cls) { | 298 }).map((cls) { |
| 299 if (closedWorld.backendClasses.nullImplementation == cls) { | 299 if (closedWorld.backendClasses.nullImplementation == cls) { |
| 300 return const TypeMask.empty(); | 300 return const TypeMask.empty(); |
| 301 } else if (closedWorld.isInstantiated(cls.declaration)) { | 301 } else if (closedWorld.isInstantiated(cls.declaration)) { |
| 302 return new TypeMask.nonNullSubclass(cls.declaration, closedWorld); | 302 return new TypeMask.nonNullSubclass(cls.declaration, closedWorld); |
| 303 } else { | 303 } else { |
| 304 // TODO(johnniwinther): Avoid the need for this case. | 304 // TODO(johnniwinther): Avoid the need for this case. |
| 305 return const TypeMask.empty(); | 305 return const TypeMask.empty(); |
| 306 } | 306 } |
| 307 }), | 307 }), |
| 308 closedWorld); | 308 closedWorld); |
| 309 } | 309 } |
| 310 } | 310 } |
| OLD | NEW |