Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 part of dart.core; | 5 part of dart.core; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * The base class for all function types. | 8 * The base class for all function types. |
| 9 * | 9 * |
| 10 * A function value, or an instance of a class with a "call" method, is a | 10 * A function value, or an instance of a class with a "call" method, is a |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 * namedArguments[const Symbol("f")] = 4; | 26 * namedArguments[const Symbol("f")] = 4; |
| 27 * namedArguments[const Symbol("g")] = 5; | 27 * namedArguments[const Symbol("g")] = 5; |
| 28 * Function.apply(foo, [1,2,3], namedArguments); | 28 * Function.apply(foo, [1,2,3], namedArguments); |
| 29 * | 29 * |
| 30 * gives exactly the same result as | 30 * gives exactly the same result as |
| 31 * foo(1, 2, 3, f: 4, g: 5). | 31 * foo(1, 2, 3, f: 4, g: 5). |
| 32 * | 32 * |
| 33 * If [positionalArguments] is null, it's considered an empty list. | 33 * If [positionalArguments] is null, it's considered an empty list. |
| 34 * If [namedArguments] is omitted or null, it is considered an empty map. | 34 * If [namedArguments] is omitted or null, it is considered an empty map. |
| 35 */ | 35 */ |
| 36 static apply(Function function, | 36 static apply(Function f, |
|
Siggi Cherem (dart-lang)
2015/03/19 23:11:14
I assume this wont be needed after fixing https://
Jennifer Messerly
2015/03/20 16:36:45
yup
| |
| 37 List positionalArguments, | 37 List positionalArguments, |
| 38 [Map<Symbol, dynamic> namedArguments]) { | 38 [Map<Symbol, dynamic> namedArguments]) { |
| 39 return Primitives.applyFunction( | 39 return Primitives.applyFunction( |
| 40 function, positionalArguments, | 40 f, positionalArguments, |
| 41 namedArguments == null ? null : _toMangledNames(namedArguments)); | 41 namedArguments == null ? null : _toMangledNames(namedArguments)); |
| 42 } | 42 } |
| 43 | 43 |
| 44 /** | 44 /** |
| 45 * Returns a hash code value that is compatible with `operator==`. | 45 * Returns a hash code value that is compatible with `operator==`. |
| 46 */ | 46 */ |
| 47 int get hashCode; | 47 int get hashCode; |
| 48 | 48 |
| 49 /** | 49 /** |
| 50 * Test whether another object is equal to this function. | 50 * Test whether another object is equal to this function. |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 71 | 71 |
| 72 static Map<String, dynamic> _toMangledNames( | 72 static Map<String, dynamic> _toMangledNames( |
| 73 Map<Symbol, dynamic> namedArguments) { | 73 Map<Symbol, dynamic> namedArguments) { |
| 74 Map<String, dynamic> result = {}; | 74 Map<String, dynamic> result = {}; |
| 75 namedArguments.forEach((symbol, value) { | 75 namedArguments.forEach((symbol, value) { |
| 76 result[_symbolToString(symbol)] = value; | 76 result[_symbolToString(symbol)] = value; |
| 77 }); | 77 }); |
| 78 return result; | 78 return result; |
| 79 } | 79 } |
| 80 } | 80 } |
| OLD | NEW |