Chromium Code Reviews| Index: lib/compiler/implementation/elements/elements.dart |
| diff --git a/lib/compiler/implementation/elements/elements.dart b/lib/compiler/implementation/elements/elements.dart |
| index e18f1888a16f531db3e7006d9a7af637d43eaa05..a22394399223626a6d1dc7fea4d5cc8c9dfa86d7 100644 |
| --- a/lib/compiler/implementation/elements/elements.dart |
| +++ b/lib/compiler/implementation/elements/elements.dart |
| @@ -500,15 +500,19 @@ class AbstractFieldElement extends Element { |
| } |
| } |
| -class FunctionParameters { |
| +class FunctionSignature { |
| Link<Element> requiredParameters; |
| Link<Element> optionalParameters; |
| + Link<Type> parameterTypes; |
|
ngeoffray
2012/05/07 08:36:09
As discussed, we can avoid having this Link object
karlklose
2012/05/07 09:08:29
Done.
|
| + Type returnType; |
| int requiredParameterCount; |
| int optionalParameterCount; |
| - FunctionParameters(this.requiredParameters, |
| - this.optionalParameters, |
| - this.requiredParameterCount, |
| - this.optionalParameterCount); |
| + FunctionSignature(this.requiredParameters, |
| + this.optionalParameters, |
| + this.requiredParameterCount, |
| + this.optionalParameterCount, |
| + this.parameterTypes, |
| + this.returnType); |
| void forEachParameter(void function(Element parameter)) { |
| for (Link<Element> link = requiredParameters; |
| @@ -531,7 +535,7 @@ class FunctionElement extends Element { |
| Type type; |
| final Modifiers modifiers; |
| - FunctionParameters functionParameters; |
| + FunctionSignature functionSignature; |
| /** |
| * If this is an interface constructor, [defaultImplementation] will |
| @@ -558,14 +562,14 @@ class FunctionElement extends Element { |
| Element enclosing) |
| : this.tooMuchOverloading(name, other.cachedNode, other.kind, |
| other.modifiers, enclosing, |
| - other.functionParameters); |
| + other.functionSignature); |
| FunctionElement.tooMuchOverloading(SourceString name, |
| FunctionExpression this.cachedNode, |
| ElementKind kind, |
| Modifiers this.modifiers, |
| Element enclosing, |
| - FunctionParameters this.functionParameters) |
| + FunctionSignature this.functionSignature) |
| : super(name, kind, enclosing) |
| { |
| defaultImplementation = this; |
| @@ -578,42 +582,34 @@ class FunctionElement extends Element { |
| && !modifiers.isStatic(); |
| } |
| - FunctionParameters computeParameters(Compiler compiler) { |
| - if (functionParameters !== null) return functionParameters; |
| - functionParameters = compiler.resolveSignature(this); |
| - return functionParameters; |
| + FunctionSignature computeSignature(Compiler compiler) { |
| + if (functionSignature !== null) return functionSignature; |
| + compiler.withCurrentElement(this, () { |
| + functionSignature = compiler.resolveSignature(this); |
| + }); |
| + return functionSignature; |
| } |
| int requiredParameterCount(Compiler compiler) { |
| - return computeParameters(compiler).requiredParameterCount; |
| + return computeSignature(compiler).requiredParameterCount; |
| } |
| int optionalParameterCount(Compiler compiler) { |
| - return computeParameters(compiler).optionalParameterCount; |
| + return computeSignature(compiler).optionalParameterCount; |
| } |
| int parameterCount(Compiler compiler) { |
| - return computeParameters(compiler).parameterCount; |
| + return computeSignature(compiler).parameterCount; |
| } |
| FunctionType computeType(Compiler compiler) { |
| if (type != null) return type; |
| - return compiler.withCurrentElement(this, () { |
| - FunctionParameters parameters = computeParameters(compiler); |
| - Types types = compiler.types; |
| - FunctionExpression node = |
| - compiler.parser.measure(() => parseNode(compiler)); |
| - Type returnType = compiler.resolveTypeAnnotation(this, node.returnType); |
| - |
| - LinkBuilder<Type> parameterTypes = new LinkBuilder<Type>(); |
| - for (Link<Element> link = parameters.requiredParameters; |
| - !link.isEmpty(); |
| - link = link.tail) { |
| - parameterTypes.addLast(link.head.computeType(compiler)); |
| - } |
| - type = new FunctionType(returnType, parameterTypes.toLink(), this); |
| - return type; |
| - }); |
| + FunctionSignature signature = computeSignature(compiler); |
| + // TODO(karlklose): optional parameters. |
| + type = new FunctionType(signature.returnType, |
| + signature.parameterTypes, |
| + this); |
| + return type; |
| } |
| Node parseNode(DiagnosticListener listener) => cachedNode; |
| @@ -630,7 +626,7 @@ class ConstructorBodyElement extends FunctionElement { |
| ElementKind.GENERATIVE_CONSTRUCTOR_BODY, |
| null, |
| constructor.enclosingElement) { |
| - functionParameters = constructor.functionParameters; |
| + functionSignature = constructor.functionSignature; |
| } |
| bool isInstanceMember() => true; |