Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1266)

Unified Diff: src/typedarray.js

Issue 21924007: Make new Harmony constructors subclassing-friendly (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: CR feedback Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime.cc ('k') | test/mjsunit/harmony/collections.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/typedarray.js
diff --git a/src/typedarray.js b/src/typedarray.js
index 7bd16f670b4425b88319676a52374c480b5b2477..8637f6efa2363aea874c2d233a3ffd587d28e3d9 100644
--- a/src/typedarray.js
+++ b/src/typedarray.js
@@ -85,17 +85,13 @@ function CreateTypedArrayConstructor(name, elementSize, arrayId, constructor) {
}
return function (arg1, arg2, arg3) {
- if (%_IsConstructCall()) {
- if (IS_ARRAYBUFFER(arg1)) {
- ConstructByArrayBuffer(this, arg1, arg2, arg3);
- } else if (IS_NUMBER(arg1) || IS_STRING(arg1) ||
- IS_BOOLEAN(arg1) || IS_UNDEFINED(arg1)) {
- ConstructByLength(this, arg1);
- } else {
- ConstructByArrayLike(this, arg1);
- }
+ if (IS_ARRAYBUFFER(arg1)) {
+ ConstructByArrayBuffer(this, arg1, arg2, arg3);
+ } else if (IS_NUMBER(arg1) || IS_STRING(arg1) ||
+ IS_BOOLEAN(arg1) || IS_UNDEFINED(arg1)) {
+ ConstructByLength(this, arg1);
} else {
- throw MakeTypeError("constructor_not_function", [name])
+ ConstructByArrayLike(this, arg1);
}
}
}
@@ -287,24 +283,20 @@ SetupTypedArray(9, "Uint8ClampedArray", global.Uint8ClampedArray, 1);
var $DataView = global.DataView;
function DataViewConstructor(buffer, byteOffset, byteLength) { // length = 3
- if (%_IsConstructCall()) {
- if (!IS_ARRAYBUFFER(buffer)) {
- throw MakeTypeError('data_view_not_array_buffer', []);
- }
- var bufferByteLength = %ArrayBufferGetByteLength(buffer);
- var offset = ToPositiveInteger(byteOffset, 'invalid_data_view_offset');
- if (offset > bufferByteLength) {
- throw MakeRangeError('invalid_data_view_offset');
- }
- var length = IS_UNDEFINED(byteLength) ?
- bufferByteLength - offset : TO_INTEGER(byteLength);
- if (length < 0 || offset + length > bufferByteLength) {
- throw new MakeRangeError('invalid_data_view_length');
- }
- %DataViewInitialize(this, buffer, offset, length);
- } else {
- throw MakeTypeError('constructor_not_function', ["DataView"]);
+ if (!IS_ARRAYBUFFER(buffer)) {
+ throw MakeTypeError('data_view_not_array_buffer', []);
+ }
+ var bufferByteLength = %ArrayBufferGetByteLength(buffer);
+ var offset = ToPositiveInteger(byteOffset, 'invalid_data_view_offset');
+ if (offset > bufferByteLength) {
+ throw MakeRangeError('invalid_data_view_offset');
+ }
+ var length = IS_UNDEFINED(byteLength) ?
+ bufferByteLength - offset : TO_INTEGER(byteLength);
+ if (length < 0 || offset + length > bufferByteLength) {
+ throw new MakeRangeError('invalid_data_view_length');
}
+ %DataViewInitialize(this, buffer, offset, length);
}
function DataViewGetBuffer() {
« no previous file with comments | « src/runtime.cc ('k') | test/mjsunit/harmony/collections.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698