| Index: src/typedarray.js
|
| diff --git a/src/typedarray.js b/src/typedarray.js
|
| index c0f07eda85623defe627fa5f7d834bfb5f2ba6e5..f52f8f8fb7930518b10cf238699367d36519c4e8 100644
|
| --- a/src/typedarray.js
|
| +++ b/src/typedarray.js
|
| @@ -34,100 +34,6 @@ var $ArrayBuffer = global.ArrayBuffer;
|
|
|
|
|
| // --------------- Typed Arrays ---------------------
|
| -macro TYPED_ARRAYS(FUNCTION)
|
| -// arrayIds below should be synchronized with Runtime_TypedArrayInitialize.
|
| -FUNCTION(1, Uint8Array, 1)
|
| -FUNCTION(2, Int8Array, 1)
|
| -FUNCTION(3, Uint16Array, 2)
|
| -FUNCTION(4, Int16Array, 2)
|
| -FUNCTION(5, Uint32Array, 4)
|
| -FUNCTION(6, Int32Array, 4)
|
| -FUNCTION(7, Float32Array, 4)
|
| -FUNCTION(8, Float64Array, 8)
|
| -FUNCTION(9, Uint8ClampedArray, 1)
|
| -endmacro
|
| -
|
| -macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE)
|
| - function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) {
|
| - var bufferByteLength = buffer.byteLength;
|
| - var offset;
|
| - if (IS_UNDEFINED(byteOffset)) {
|
| - offset = 0;
|
| - } else {
|
| - offset = ToPositiveInteger(byteOffset, "invalid_typed_array_length");
|
| -
|
| - if (offset % ELEMENT_SIZE !== 0) {
|
| - throw MakeRangeError("invalid_typed_array_alignment",
|
| - "start offset", "NAME", ELEMENT_SIZE);
|
| - }
|
| - if (offset > bufferByteLength) {
|
| - throw MakeRangeError("invalid_typed_array_offset");
|
| - }
|
| - }
|
| -
|
| - var newByteLength;
|
| - var newLength;
|
| - if (IS_UNDEFINED(length)) {
|
| - if (bufferByteLength % ELEMENT_SIZE !== 0) {
|
| - throw MakeRangeError("invalid_typed_array_alignment",
|
| - "byte length", "NAME", ELEMENT_SIZE);
|
| - }
|
| - newByteLength = bufferByteLength - offset;
|
| - newLength = newByteLength / ELEMENT_SIZE;
|
| - } else {
|
| - var newLength = ToPositiveInteger(length, "invalid_typed_array_length");
|
| - newByteLength = newLength * ELEMENT_SIZE;
|
| - }
|
| - if ((offset + newByteLength > bufferByteLength)
|
| - || (newLength > %MaxSmi())) {
|
| - throw MakeRangeError("invalid_typed_array_length");
|
| - }
|
| - %TypedArrayInitialize(obj, ARRAY_ID, buffer, offset, newByteLength);
|
| - }
|
| -
|
| - function NAMEConstructByLength(obj, length) {
|
| - var l = IS_UNDEFINED(length) ?
|
| - 0 : ToPositiveInteger(length, "invalid_typed_array_length");
|
| - if (l > %MaxSmi()) {
|
| - throw MakeRangeError("invalid_typed_array_length");
|
| - }
|
| - var byteLength = l * ELEMENT_SIZE;
|
| - var buffer = new $ArrayBuffer(byteLength);
|
| - %TypedArrayInitialize(obj, ARRAY_ID, buffer, 0, byteLength);
|
| - }
|
| -
|
| - function NAMEConstructByArrayLike(obj, arrayLike) {
|
| - var length = arrayLike.length;
|
| - var l = ToPositiveInteger(length, "invalid_typed_array_length");
|
| - if (l > %MaxSmi()) {
|
| - throw MakeRangeError("invalid_typed_array_length");
|
| - }
|
| - if(!%TypedArrayInitializeFromArrayLike(obj, ARRAY_ID, arrayLike, l)) {
|
| - for (var i = 0; i < l; i++) {
|
| - // It is crucial that we let any execptions from arrayLike[i]
|
| - // propagate outside the function.
|
| - obj[i] = arrayLike[i];
|
| - }
|
| - }
|
| - }
|
| -
|
| - function NAMEConstructor(arg1, arg2, arg3) {
|
| -
|
| - if (%_IsConstructCall()) {
|
| - if (IS_ARRAYBUFFER(arg1)) {
|
| - NAMEConstructByArrayBuffer(this, arg1, arg2, arg3);
|
| - } else if (IS_NUMBER(arg1) || IS_STRING(arg1) ||
|
| - IS_BOOLEAN(arg1) || IS_UNDEFINED(arg1)) {
|
| - NAMEConstructByLength(this, arg1);
|
| - } else {
|
| - NAMEConstructByArrayLike(this, arg1);
|
| - }
|
| - } else {
|
| - throw MakeTypeError("constructor_not_function", ["NAME"])
|
| - }
|
| - }
|
| -endmacro
|
| -
|
| TYPED_ARRAYS(TYPED_ARRAY_CONSTRUCTOR)
|
|
|
| function TypedArrayGetBuffer() {
|
| @@ -302,10 +208,6 @@ function SetupTypedArray(constructor, fun, elementSize) {
|
| ));
|
| }
|
|
|
| -macro SETUP_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE)
|
| - SetupTypedArray (global.NAME, NAMEConstructor, ELEMENT_SIZE);
|
| -endmacro
|
| -
|
| TYPED_ARRAYS(SETUP_TYPED_ARRAY)
|
|
|
| // --------------------------- DataView -----------------------------
|
| @@ -358,51 +260,10 @@ function DataViewGetByteLength() {
|
| return %DataViewGetByteLength(this);
|
| }
|
|
|
| -macro DATA_VIEW_TYPES(FUNCTION)
|
| - FUNCTION(Int8)
|
| - FUNCTION(Uint8)
|
| - FUNCTION(Int16)
|
| - FUNCTION(Uint16)
|
| - FUNCTION(Int32)
|
| - FUNCTION(Uint32)
|
| - FUNCTION(Float32)
|
| - FUNCTION(Float64)
|
| -endmacro
|
| -
|
| function ToPositiveDataViewOffset(offset) {
|
| return ToPositiveInteger(offset, 'invalid_data_view_accessor_offset');
|
| }
|
|
|
| -
|
| -macro DATA_VIEW_GETTER_SETTER(TYPENAME)
|
| -function DataViewGetTYPENAME(offset, little_endian) {
|
| - if (!IS_DATAVIEW(this)) {
|
| - throw MakeTypeError('incompatible_method_receiver',
|
| - ['DataView.getTYPENAME', this]);
|
| - }
|
| - if (%_ArgumentsLength() < 1) {
|
| - throw MakeTypeError('invalid_argument');
|
| - }
|
| - return %DataViewGetTYPENAME(this,
|
| - ToPositiveDataViewOffset(offset),
|
| - !!little_endian);
|
| -}
|
| -
|
| -function DataViewSetTYPENAME(offset, value, little_endian) {
|
| - if (!IS_DATAVIEW(this)) {
|
| - throw MakeTypeError('incompatible_method_receiver',
|
| - ['DataView.setTYPENAME', this]);
|
| - }
|
| - if (%_ArgumentsLength() < 2) {
|
| - throw MakeTypeError('invalid_argument');
|
| - }
|
| - %DataViewSetTYPENAME(this,
|
| - ToPositiveDataViewOffset(offset),
|
| - TO_NUMBER_INLINE(value),
|
| - !!little_endian);
|
| -}
|
| -endmacro
|
| -
|
| DATA_VIEW_TYPES(DATA_VIEW_GETTER_SETTER)
|
|
|
| function SetupDataView() {
|
|
|