Index: runtime/lib/function_patch.dart |
=================================================================== |
--- runtime/lib/function_patch.dart (revision 16173) |
+++ runtime/lib/function_patch.dart (working copy) |
@@ -3,9 +3,28 @@ |
// BSD-style license that can be found in the LICENSE file. |
patch class Function { |
+ static _apply(List arguments, List names) |
+ native "Function_apply"; |
+ |
/* patch */ static apply(Function function, |
List positionalArguments, |
[Map<String,dynamic> namedArguments]) { |
- throw new UnimplementedError('Function.apply not implemented'); |
+ int numPositionalArguments = 1 + // Function is first implicit argument. |
+ (positionalArguments != null ? positionalArguments.length : 0); |
+ int numNamedArguments = namedArguments != null ? namedArguments.length : 0; |
+ int numArguments = numPositionalArguments + numNamedArguments; |
+ List arguments = new List(numArguments); |
+ arguments[0] = function; |
+ arguments.setRange(1, numPositionalArguments - 1, positionalArguments); |
+ List names = new List(numNamedArguments); |
+ int argumentIndex = numPositionalArguments; |
+ int nameIndex = 0; |
+ if (numNamedArguments > 0) { |
+ namedArguments.forEach((name, value) { |
+ arguments[argumentIndex++] = value; |
+ names[nameIndex++] = name; |
+ }); |
+ } |
+ return _apply(arguments, names); |
} |
} |