Chromium Code Reviews| Index: src/typedarray.js |
| diff --git a/src/typedarray.js b/src/typedarray.js |
| index 926920427275132efa4ead35d2a634b1d1dd656c..372dd511bee72ea0febc9b406da88f6516c2457f 100644 |
| --- a/src/typedarray.js |
| +++ b/src/typedarray.js |
| @@ -153,10 +153,11 @@ function NAME_GetLength() { |
| } |
| return %_TypedArrayGetLength(this); |
| } |
| +endmacro |
| -function NAMESubArray(begin, end) { |
| - if (!(%_ClassOf(this) === 'NAME')) { |
| - throw MakeTypeError(kIncompatibleMethodReceiver, "NAME.subarray", this); |
| +function TypedArraySubArray(begin, end) { |
|
adamk
2015/05/08 01:13:34
We probably want to change this in the future, but
|
| + if (!%IsTypedArray(this)) { |
| + throw MakeTypeError('not_typed_array', []); |
| } |
| var beginInt = TO_INTEGER(begin); |
| if (!IS_UNDEFINED(end)) { |
| @@ -181,11 +182,10 @@ function NAMESubArray(begin, end) { |
| } |
| var newLength = endInt - beginInt; |
| var beginByteOffset = |
| - %_ArrayBufferViewGetByteOffset(this) + beginInt * ELEMENT_SIZE; |
| - return new GlobalNAME(%TypedArrayGetBuffer(this), |
| - beginByteOffset, newLength); |
| + %_ArrayBufferViewGetByteOffset(this) + beginInt * this.BYTES_PER_ELEMENT; |
| + return new this.constructor(%TypedArrayGetBuffer(this), |
| + beginByteOffset, newLength); |
| } |
| -endmacro |
| TYPED_ARRAYS(TYPED_ARRAY_CONSTRUCTOR) |
| @@ -322,7 +322,7 @@ macro SETUP_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE) |
| $installGetter(GlobalNAME.prototype, symbolToStringTag, |
| TypedArrayGetToStringTag); |
| $installFunctions(GlobalNAME.prototype, DONT_ENUM, [ |
| - "subarray", NAMESubArray, |
| + "subarray", TypedArraySubArray, |
| "set", TypedArraySet |
| ]); |
| endmacro |