Chromium Code Reviews| Index: src/typedarray.js |
| diff --git a/src/typedarray.js b/src/typedarray.js |
| index 1a4f46ca65d460dc516a0542fa279443ad92ae4b..707e1f41c6b8b902a814f7be8e004fba4134527f 100644 |
| --- a/src/typedarray.js |
| +++ b/src/typedarray.js |
| @@ -145,6 +145,22 @@ function CreateSubArray(elementSize, constructor) { |
| } |
| } |
| +function TypedArraySet(obj, offset) { |
| + var intOffset = IS_UNDEFINED(offset) ? 0 : TO_POSITIVE_INTEGER(offset); |
| + if (%TypedArraySetSpecialCases(this, obj, intOffset)) |
| + return; |
| + |
| + var l = obj.length; |
| + if (IS_UNDEFINED(l)) { |
| + throw MakeTypeError("invalid_argument"); |
| + } |
| + if (intOffset + l > this.length) { |
| + throw MakeRangeError("typed_array_set_source_too_long"); |
| + } |
| + for (var i = 0; i < l; i++) { |
|
rossberg
2013/05/07 13:53:23
Is this function supposed to work with non-typed-a
Dmitry Lomov (no reviews)
2013/05/07 14:20:00
Done. No non-typed-array receivers
On 2013/05/07 1
|
| + this[intOffset+i] = obj[i]; |
|
rossberg
2013/05/07 13:53:23
Style nit: space around +
Dmitry Lomov (no reviews)
2013/05/07 14:20:00
Done.
|
| + } |
| +} |
| // ------------------------------------------------------------------- |
| @@ -166,7 +182,8 @@ function SetupTypedArray(arrayId, name, constructor, elementSize) { |
| InstallGetter(constructor.prototype, "length", TypedArrayGetLength); |
| InstallFunctions(constructor.prototype, DONT_ENUM, $Array( |
| - "subarray", CreateSubArray(elementSize, constructor) |
| + "subarray", CreateSubArray(elementSize, constructor), |
| + "set", TypedArraySet |
| )); |
| } |