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

Unified Diff: dart/lib/compiler/implementation/native_handler.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/native_handler.dart
===================================================================
--- dart/lib/compiler/implementation/native_handler.dart (revision 8049)
+++ dart/lib/compiler/implementation/native_handler.dart (working copy)
@@ -215,12 +215,13 @@
return;
}
- HInstruction convertDartClosure(Element parameter) {
+ HInstruction convertDartClosure(Element parameter, Type type) {
HInstruction local = builder.localsHandler.readLocal(parameter);
- // TODO(ngeoffray): by better analyzing the function type and
- // its formal parameters, we could pass a method with a defined arity.
+ // TODO(ngeoffray): For static methods, we could pass a method with a
+ // defined arity.
builder.push(new HStatic(builder.interceptors.getClosureConverter()));
- List<HInstruction> callInputs = <HInstruction>[builder.pop(), local];
+ HInstruction arity = builder.graph.addConstantInt(type.computeArity());
+ List<HInstruction> callInputs = <HInstruction>[builder.pop(), local, arity];
HInstruction closure = new HInvokeStatic(Selector.INVOCATION_1, callInputs);
builder.add(closure);
return closure;
@@ -265,7 +266,7 @@
parameters.forEachParameter((Element parameter) {
Type type = parameter.computeType(compiler);
HInstruction input = builder.localsHandler.readLocal(parameter);
- if (type is FunctionType) input = convertDartClosure(parameter);
+ if (type is FunctionType) input = convertDartClosure(parameter, type);
inputs.add(input);
arguments.add('#');
});
@@ -296,7 +297,7 @@
parameters.forEachParameter((Element parameter) {
Type type = parameter.computeType(compiler);
if (type is FunctionType) {
- HInstruction jsClosure = convertDartClosure(parameter);
+ HInstruction jsClosure = convertDartClosure(parameter, type);
// Because the JS code references the argument name directly,
// we must keep the name and assign the JS closure to it.
builder.add(new HForeign(

Powered by Google App Engine
This is Rietveld 408576698