Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(557)

Unified Diff: lib/compiler/implementation/elements/elements.dart

Issue 10363003: Compute function types together with the parameters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Move computation of function type. Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/compiler/implementation/compiler.dart ('k') | lib/compiler/implementation/emitter.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..11d0cc6f92d50967fb87eb89dfbc39f6a0e332f7 100644
--- a/lib/compiler/implementation/elements/elements.dart
+++ b/lib/compiler/implementation/elements/elements.dart
@@ -500,15 +500,17 @@ class AbstractFieldElement extends Element {
}
}
-class FunctionParameters {
+class FunctionSignature {
Link<Element> requiredParameters;
Link<Element> optionalParameters;
+ 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.returnType);
void forEachParameter(void function(Element parameter)) {
for (Link<Element> link = requiredParameters;
@@ -531,7 +533,7 @@ class FunctionElement extends Element {
Type type;
final Modifiers modifiers;
- FunctionParameters functionParameters;
+ FunctionSignature functionSignature;
/**
* If this is an interface constructor, [defaultImplementation] will
@@ -558,14 +560,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 +580,42 @@ 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);
-
+ compiler.withCurrentElement(this, () {
+ FunctionSignature signature = computeSignature(compiler);
LinkBuilder<Type> parameterTypes = new LinkBuilder<Type>();
- for (Link<Element> link = parameters.requiredParameters;
+ for (Link<Element> link = signature.requiredParameters;
!link.isEmpty();
link = link.tail) {
- parameterTypes.addLast(link.head.computeType(compiler));
+ parameterTypes.addLast(link.head.computeType(compiler));
+ // TODO(karlklose): optional parameters.
}
- type = new FunctionType(returnType, parameterTypes.toLink(), this);
- return type;
+ type = new FunctionType(signature.returnType,
+ parameterTypes.toLink(),
+ this);
});
+ return type;
}
Node parseNode(DiagnosticListener listener) => cachedNode;
@@ -630,7 +632,7 @@ class ConstructorBodyElement extends FunctionElement {
ElementKind.GENERATIVE_CONSTRUCTOR_BODY,
null,
constructor.enclosingElement) {
- functionParameters = constructor.functionParameters;
+ functionSignature = constructor.functionSignature;
}
bool isInstanceMember() => true;
« no previous file with comments | « lib/compiler/implementation/compiler.dart ('k') | lib/compiler/implementation/emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698