Index: src/js/typedarray.js |
diff --git a/src/js/typedarray.js b/src/js/typedarray.js |
index db8dabe867dd15793a5b2f0381bb2a1e7afae03b..c25966ce992f8a8a0e34f696d6e42d57d212fe07 100644 |
--- a/src/js/typedarray.js |
+++ b/src/js/typedarray.js |
@@ -765,31 +765,33 @@ TYPED_ARRAYS(SETUP_TYPED_ARRAY) |
// --------------------------- DataView ----------------------------- |
function DataViewConstructor(buffer, byteOffset, byteLength) { // length = 3 |
- if (%_IsConstructCall()) { |
- // TODO(binji): support SharedArrayBuffers? |
- if (!IS_ARRAYBUFFER(buffer)) throw MakeTypeError(kDataViewNotArrayBuffer); |
- if (!IS_UNDEFINED(byteOffset)) { |
- byteOffset = ToPositiveInteger(byteOffset, kInvalidDataViewOffset); |
- } |
- if (!IS_UNDEFINED(byteLength)) { |
- byteLength = TO_INTEGER(byteLength); |
- } |
+ if (IS_UNDEFINED(new.target)) { |
+ throw MakeTypeError(kConstructorNotFunction, "DataView"); |
+ } |
- var bufferByteLength = %_ArrayBufferGetByteLength(buffer); |
+ // TODO(binji): support SharedArrayBuffers? |
+ if (!IS_ARRAYBUFFER(buffer)) throw MakeTypeError(kDataViewNotArrayBuffer); |
+ if (!IS_UNDEFINED(byteOffset)) { |
+ byteOffset = ToPositiveInteger(byteOffset, kInvalidDataViewOffset); |
+ } |
+ if (!IS_UNDEFINED(byteLength)) { |
+ byteLength = TO_INTEGER(byteLength); |
+ } |
- var offset = IS_UNDEFINED(byteOffset) ? 0 : byteOffset; |
- if (offset > bufferByteLength) throw MakeRangeError(kInvalidDataViewOffset); |
+ var bufferByteLength = %_ArrayBufferGetByteLength(buffer); |
- var length = IS_UNDEFINED(byteLength) |
- ? bufferByteLength - offset |
- : byteLength; |
- if (length < 0 || offset + length > bufferByteLength) { |
- throw new MakeRangeError(kInvalidDataViewLength); |
- } |
- %_DataViewInitialize(this, buffer, offset, length); |
- } else { |
- throw MakeTypeError(kConstructorNotFunction, "DataView"); |
+ var offset = IS_UNDEFINED(byteOffset) ? 0 : byteOffset; |
+ if (offset > bufferByteLength) throw MakeRangeError(kInvalidDataViewOffset); |
+ |
+ var length = IS_UNDEFINED(byteLength) |
+ ? bufferByteLength - offset |
+ : byteLength; |
+ if (length < 0 || offset + length > bufferByteLength) { |
+ throw new MakeRangeError(kInvalidDataViewLength); |
} |
+ var result = %NewObject(GlobalDataView, new.target); |
+ %_DataViewInitialize(result, buffer, offset, length); |
+ return result; |
} |
function DataViewGetBufferJS() { |