Chromium Code Reviews| Index: runtime/lib/function_patch.dart |
| =================================================================== |
| --- runtime/lib/function_patch.dart (revision 16147) |
| +++ runtime/lib/function_patch.dart (working copy) |
| @@ -3,9 +3,29 @@ |
| // 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 && (namedArguments != null)) ? |
|
siva
2012/12/14 18:30:25
would just a null check be sufficient for namedArg
regis
2012/12/14 18:49:49
Done.
|
| + 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); |
| } |
| } |