Chromium Code Reviews| Index: src/harmony-array.js |
| diff --git a/src/harmony-array.js b/src/harmony-array.js |
| index 51e2d01b50147ded30436174685b23aca3484ac9..fad6d0566a74d69f36aca82e214b3f0d69aca1bb 100644 |
| --- a/src/harmony-array.js |
| +++ b/src/harmony-array.js |
| @@ -19,6 +19,7 @@ var GetMethod; |
| var MathMax; |
| var MathMin; |
| var ObjectIsFrozen; |
| +var ObjectDefineProperty; |
| utils.Import(function(from) { |
| GetIterator = from.GetIterator; |
| @@ -26,6 +27,7 @@ utils.Import(function(from) { |
| MathMax = from.MathMax; |
| MathMin = from.MathMin; |
| ObjectIsFrozen = from.ObjectIsFrozen; |
| + ObjectDefineProperty = from.ObjectDefineProperty; |
| }); |
| // ------------------------------------------------------------------- |
| @@ -191,6 +193,14 @@ function ArrayFill(value, start, end) { |
| return InnerArrayFill(value, start, end, array, length); |
| } |
| +function AddArrayElement(constructor, array, i, value) { |
| + if (constructor === GlobalArray) { |
|
Toon Verwaest
2015/06/11 08:03:14
Is this enough? A constructor could return an arra
arv (Not doing code reviews)
2015/06/11 13:04:01
I believe this is fine.
constructor here is the r
Toon Verwaest
2015/06/11 13:09:23
(d8):1: illegal access
adamk
2015/06/11 15:12:10
Do you have Dan's patch patched in? This should go
arv (Not doing code reviews)
2015/06/11 15:19:37
Once we add support for @@species then we will hav
adamk
2015/06/11 15:26:40
Not sure I follow, Array.from/of only look at the
arv (Not doing code reviews)
2015/06/11 15:30:01
You are right. nm.
Toon Verwaest
2015/06/11 15:35:33
Arg, ok, I see. Nevermind ;)
However, shouldn't w
Dan Ehrenberg
2015/06/11 16:27:25
I think GlobalArray will remain a constructor, so
|
| + %AddElement(array, i, value, NONE); |
| + } else { |
| + ObjectDefineProperty(array, i, { value: value }); |
|
arv (Not doing code reviews)
2015/06/11 13:04:01
non enum? non writable? non configurable?
We real
Dan Ehrenberg
2015/06/11 16:27:25
Fixed the descriptor and added tests.
|
| + } |
| +} |
| + |
| // ES6, draft 10-14-14, section 22.1.2.1 |
| function ArrayFrom(arrayLike, mapfn, receiver) { |
| var items = $toObject(arrayLike); |
| @@ -238,7 +248,8 @@ function ArrayFrom(arrayLike, mapfn, receiver) { |
| } else { |
| mappedValue = nextValue; |
| } |
| - %AddElement(result, k++, mappedValue, NONE); |
| + AddArrayElement(this, result, k, mappedValue); |
| + k++; |
| } |
| } else { |
| var len = $toLength(items.length); |
| @@ -251,7 +262,7 @@ function ArrayFrom(arrayLike, mapfn, receiver) { |
| } else { |
| mappedValue = nextValue; |
| } |
| - %AddElement(result, k, mappedValue, NONE); |
| + AddArrayElement(this, result, k, mappedValue); |
| } |
| result.length = k; |
| @@ -266,7 +277,7 @@ function ArrayOf() { |
| // TODO: Implement IsConstructor (ES6 section 7.2.5) |
| var array = %IsConstructor(constructor) ? new constructor(length) : []; |
| for (var i = 0; i < length; i++) { |
| - %AddElement(array, i, %_Arguments(i), NONE); |
| + AddArrayElement(constructor, array, i, %_Arguments(i)); |
| } |
| array.length = length; |
| return array; |