Chromium Code Reviews| Index: lib/compiler/implementation/universe.dart |
| =================================================================== |
| --- lib/compiler/implementation/universe.dart (revision 6835) |
| +++ lib/compiler/implementation/universe.dart (working copy) |
| @@ -78,7 +78,8 @@ |
| static final Selector INVOCATION_2 = |
| const Selector(SelectorKind.INVOCATION, 2); |
| - bool applies(FunctionParameters parameters) { |
| + bool applies(FunctionElement element, Compiler compiler) { |
|
kasperl
2012/04/23 12:34:45
Not sure I understand the name of this method.
ngeoffray
2012/04/23 13:48:18
The method is whether the selector applies to this
|
| + FunctionParameters parameters = element.computeParameters(compiler); |
| if (argumentCount > parameters.parameterCount) return false; |
| int requiredParameterCount = parameters.requiredParameterCount; |
| int optionalParameterCount = parameters.optionalParameterCount; |
| @@ -121,13 +122,15 @@ |
| */ |
| bool addArgumentsToList(Link<Node> arguments, |
| List list, |
| - FunctionParameters parameters, |
| + FunctionElement element, |
| compileArgument(Node argument), |
| - compileConstant(Element element)) { |
| - void addMatchingArgumentsToList(Link<Node> link) { |
| - } |
| + compileConstant(Element element), |
| + Compiler compiler) { |
| + if (!this.applies(element, compiler)) return false; |
| - if (!this.applies(parameters)) return false; |
| + void addMatchingArgumentsToList(Link<Node> link) {} |
| + |
| + FunctionParameters parameters = element.computeParameters(compiler); |
| if (this.positionalArgumentCount == parameters.parameterCount) { |
| for (Link<Node> link = arguments; !link.isEmpty(); link = link.tail) { |
| list.add(compileArgument(link.head)); |
| @@ -230,3 +233,27 @@ |
| return orderedNamedArguments; |
| } |
| } |
| + |
| +class TypedInvocation extends Invocation { |
|
kasperl
2012/04/23 12:34:45
So this is a special invocation where we know some
ngeoffray
2012/04/23 13:48:18
Done.
|
| + final Type type; |
|
kasperl
2012/04/23 12:34:45
type -> receiverType?
ngeoffray
2012/04/23 13:48:18
Done.
|
| + |
| + TypedInvocation(this.type, Selector selector) |
| + : super(selector.argumentCount, selector.namedArguments); |
| + |
| + bool applies(FunctionElement element, Compiler compiler) { |
| + if (!element.enclosingElement.isClass()) return false; |
| + |
| + ClassElement other = element.enclosingElement; |
| + ClassElement self = type.element; |
| + if (other === self || other.isSubclassOf(self)) { |
| + return super.applies(element, compiler); |
| + } |
| + return false; |
| + } |
| + |
| + bool operator ==(other) { |
| + if (other is !TypedInvocation) return false; |
| + if (other.type !== type) return false; |
| + return super == other; |
| + } |
| +} |