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

Unified Diff: runtime/lib/function_patch.dart

Issue 11564029: Implement Function.apply in vm (issue 5670). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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 | « runtime/lib/function.cc ('k') | runtime/lib/lib_sources.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
}
« no previous file with comments | « runtime/lib/function.cc ('k') | runtime/lib/lib_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698