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

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

Issue 10441071: Use the typedef arity to know how to invoke a closure given by the dom. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/
Patch Set: 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
Index: dart/lib/compiler/implementation/resolver.dart
===================================================================
--- dart/lib/compiler/implementation/resolver.dart (revision 8060)
+++ dart/lib/compiler/implementation/resolver.dart (working copy)
@@ -234,9 +234,37 @@
}
FunctionSignature resolveSignature(FunctionElement element) {
- return measure(() => SignatureResolver.analyze(compiler, element));
+ return compiler.withCurrentElement(element, () {
+ FunctionExpression node =
+ compiler.parser.measure(() => element.parseNode(compiler));
+ return measure(() => SignatureResolver.analyze(
+ compiler, node.parameters, node.returnType, element));
+ });
}
+ FunctionSignature resolveTypedef(TypedefElement element) {
+ return compiler.withCurrentElement(element, () {
+ Typedef node =
+ compiler.parser.measure(() => element.parseNode(compiler));
+ return measure(() => SignatureResolver.analyze(
+ compiler, node.formals, node.returnType, element));
+ });
+ }
+
+ FunctionType computeFunctionType(Element element,
+ FunctionSignature signature) {
+ LinkBuilder<Type> parameterTypes = new LinkBuilder<Type>();
+ for (Link<Element> link = signature.requiredParameters;
+ !link.isEmpty();
+ link = link.tail) {
+ parameterTypes.addLast(link.head.computeType(compiler));
+ // TODO(karlklose): optional parameters.
+ }
+ return new FunctionType(signature.returnType,
+ parameterTypes.toLink(),
+ element);
+ }
+
error(Node node, MessageKind kind, [arguments = const []]) {
ResolutionError message = new ResolutionError(kind, arguments);
compiler.reportError(node, message);
@@ -1130,12 +1158,7 @@
type = new InterfaceType(cls, arguments.toLink());
}
} else if (element.isTypedef()) {
- // TODO(ngeoffray): This is a hack to help us get support for the
- // DOM library.
- // TODO(ngeoffray): The list of types for the argument is wrong.
- type = new FunctionType(compiler.types.dynamicType,
- const EmptyLink<Type>(),
- element);
+ type = element.computeType(compiler);
} else if (element.isTypeVariable()) {
type = element.computeType(compiler);
} else {
@@ -1760,15 +1783,15 @@
}
static FunctionSignature analyze(Compiler compiler,
- FunctionElement element) {
- FunctionExpression node =
- compiler.parser.measure(() => element.parseNode(compiler));
+ NodeList formalParameters,
+ Node returnNode,
+ Element element) {
SignatureResolver visitor = new SignatureResolver(compiler, element);
- Link<Node> nodes = node.parameters.nodes;
- LinkBuilder<Element> parametersBuilder = visitor.analyzeNodes(nodes);
+ LinkBuilder<Element> parametersBuilder =
+ visitor.analyzeNodes(formalParameters.nodes);
Link<Element> parameters = parametersBuilder.toLink();
Type returnType =
- compiler.resolveTypeAnnotation(element, node.returnType);
+ compiler.resolveTypeAnnotation(element, returnNode);
return new FunctionSignature(parameters,
visitor.optionalParameters,
parametersBuilder.length,
« no previous file with comments | « dart/lib/compiler/implementation/native_handler.dart ('k') | dart/lib/compiler/implementation/scanner/listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698