Chromium Code Reviews| Index: sdk/lib/_internal/compiler/implementation/universe/function_set.dart |
| =================================================================== |
| --- sdk/lib/_internal/compiler/implementation/universe/function_set.dart (revision 26305) |
| +++ sdk/lib/_internal/compiler/implementation/universe/function_set.dart (working copy) |
| @@ -49,20 +49,28 @@ |
| * that may be invoked with the given [selector]. |
| */ |
| Iterable<Element> filter(Selector selector) { |
| + return query(selector).functions; |
| + } |
| + |
| + TypeMask receiverType(Selector selector) { |
| + return query(selector).computeMask(compiler); |
| + } |
| + |
| + FunctionSetQuery query(Selector selector) { |
| SourceString name = selector.name; |
| FunctionSetNode node = nodes[name]; |
| FunctionSetNode noSuchMethods = nodes[Compiler.NO_SUCH_METHOD]; |
| if (node != null) { |
| - return node.query(selector, compiler, noSuchMethods).functions; |
| + return node.query(selector, compiler, noSuchMethods); |
| } |
| // If there is no method that matches [selector] we know we can |
| // only hit [:noSuchMethod:]. |
| - if (noSuchMethods == null) return const <Element>[]; |
| + if (noSuchMethods == null) return const FunctionSetQuery(const <Element>[]); |
| selector = (selector.mask == null) |
| ? compiler.noSuchMethodSelector |
| : new TypedSelector(selector.mask, compiler.noSuchMethodSelector); |
| - return noSuchMethods.query(selector, compiler, null).functions; |
| + return noSuchMethods.query(selector, compiler, null); |
| } |
| void forEach(Function action) { |
| @@ -186,11 +194,36 @@ |
| FunctionSetQuery newQuery(Iterable<Element> functions, |
| Selector selector, |
| Compiler compiler) { |
| - return new FunctionSetQuery(functions); |
| + return new FullFunctionSetQuery(functions); |
| } |
| } |
| class FunctionSetQuery { |
| final Iterable<Element> functions; |
| + TypeMask computeMask(Compiler compiler) => const TypeMask.nonNullEmpty(); |
| const FunctionSetQuery(this.functions); |
| } |
| + |
| +class FullFunctionSetQuery extends FunctionSetQuery { |
| + TypeMask _mask; |
| + |
| + TypeMask computeMask(Compiler compiler) { |
|
karlklose
2013/08/19 10:52:33
Please add a comment to describe what this functio
ngeoffray
2013/08/20 08:00:48
Done.
|
| + if (_mask != null) return _mask; |
| + return _mask = new TypeMask.unionOf(functions |
| + .map((element) => element.getEnclosingClass()) |
| + .expand((cls) { |
| + return compiler.world.isUsedAsMixin(cls) |
| + ? [[cls], compiler.world.mixinUses[cls]].expand((x) => x) |
|
karlklose
2013/08/19 10:52:33
How about writing this as
'new List.from(compile
ngeoffray
2013/08/20 08:00:48
I did not want to create a new list again. By usin
ngeoffray
2013/08/20 09:13:34
After further discussions and talking to the libra
|
| + : [cls]; |
| + }) |
| + .map((cls) { |
| + Set<ClassElement> subclasses = compiler.world.subclassesOf(cls); |
|
karlklose
2013/08/19 10:52:33
Consider adding a helper for this test:
hasSubcla
ngeoffray
2013/08/20 08:00:48
Done.
|
| + return subclasses == null || subclasses.isEmpty |
| + ? new TypeMask.nonNullExact(cls.rawType) |
| + : new TypeMask.nonNullSubclass(cls.rawType); |
| + }), |
| + compiler); |
| + } |
| + |
| + FullFunctionSetQuery(functions) : super(functions); |
| +} |