Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 patch class Function { | 5 patch class Function { |
| 6 static _apply(List arguments, List names) | |
| 7 native "Function_apply"; | |
| 8 | |
| 6 /* patch */ static apply(Function function, | 9 /* patch */ static apply(Function function, |
| 7 List positionalArguments, | 10 List positionalArguments, |
| 8 [Map<String,dynamic> namedArguments]) { | 11 [Map<String,dynamic> namedArguments]) { |
| 9 throw new UnimplementedError('Function.apply not implemented'); | 12 int numPositionalArguments = 1 + // Function is first implicit argument. |
| 13 ((positionalArguments != null) ? positionalArguments.length : 0); | |
| 14 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.
| |
| 15 namedArguments.length : 0; | |
| 16 int numArguments = numPositionalArguments + numNamedArguments; | |
| 17 List arguments = new List(numArguments); | |
| 18 arguments[0] = function; | |
| 19 arguments.setRange(1, numPositionalArguments - 1, positionalArguments); | |
| 20 List names = new List(numNamedArguments); | |
| 21 int argumentIndex = numPositionalArguments; | |
| 22 int nameIndex = 0; | |
| 23 if (numNamedArguments > 0) { | |
| 24 namedArguments.forEach((name, value) { | |
| 25 arguments[argumentIndex++] = value; | |
| 26 names[nameIndex++] = name; | |
| 27 }); | |
| 28 } | |
| 29 return _apply(arguments, names); | |
| 10 } | 30 } |
| 11 } | 31 } |
| OLD | NEW |