Chromium Code Reviews| Index: src/harmony-array.js |
| diff --git a/src/harmony-array.js b/src/harmony-array.js |
| index dbcb292a0876842e8d3a6d4c0d21d997cdf6d977..fee104ce7c14d5c27e1158297044a88215bf4d1a 100644 |
| --- a/src/harmony-array.js |
| +++ b/src/harmony-array.js |
| @@ -123,11 +123,33 @@ function ArrayFill(value /* [, start [, end ] ] */) { // length == 1 |
| return array; |
| } |
| +// ES6, draft 05-22-14, section 22.1.2.3 |
| +function ArrayOf() { |
| + var len = %_ArgumentsLength(); |
| + var C = this; |
| + // TODO: Implement IsConstructor (ES6 section 7.2.5) |
| + if (IS_SPEC_FUNCTION(C)) { |
| + var A = new C(len); |
|
rossberg
2014/07/21 16:07:07
Please don't make use of var scoping like that. Pr
|
| + } else { |
| + var A = []; |
| + } |
| + for (var k = 0; k < len; k++) { |
| + %AddProperty(A, k, %_Arguments(k)); |
|
rossberg
2014/07/21 16:07:07
Unfortunately, this runtime function has recently
|
| + } |
| + A.length = len; |
| + return A; |
| +} |
| + |
| // ------------------------------------------------------------------- |
| function HarmonyArrayExtendArrayPrototype() { |
| %CheckIsBootstrapping(); |
| + // Set up non-enumerable functions on the Array object. |
| + InstallFunctions($Array, DONT_ENUM, $Array( |
| + "of", ArrayOf |
| + )); |
| + |
| // Set up the non-enumerable functions on the Array prototype object. |
| InstallFunctions($Array.prototype, DONT_ENUM, $Array( |
| "find", ArrayFind, |