OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 FUNCTION(4, Int16Array, 2) | 42 FUNCTION(4, Int16Array, 2) |
43 FUNCTION(5, Uint32Array, 4) | 43 FUNCTION(5, Uint32Array, 4) |
44 FUNCTION(6, Int32Array, 4) | 44 FUNCTION(6, Int32Array, 4) |
45 FUNCTION(7, Float32Array, 4) | 45 FUNCTION(7, Float32Array, 4) |
46 FUNCTION(8, Float64Array, 8) | 46 FUNCTION(8, Float64Array, 8) |
47 FUNCTION(9, Uint8ClampedArray, 1) | 47 FUNCTION(9, Uint8ClampedArray, 1) |
48 endmacro | 48 endmacro |
49 | 49 |
50 macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE) | 50 macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE) |
51 function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) { | 51 function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) { |
52 var bufferByteLength = buffer.byteLength; | 52 var bufferByteLength = %ArrayBufferGetByteLength(buffer); |
53 var offset; | 53 var offset; |
54 if (IS_UNDEFINED(byteOffset)) { | 54 if (IS_UNDEFINED(byteOffset)) { |
55 offset = 0; | 55 offset = 0; |
56 } else { | 56 } else { |
57 offset = ToPositiveInteger(byteOffset, "invalid_typed_array_length"); | 57 offset = ToPositiveInteger(byteOffset, "invalid_typed_array_length"); |
58 | 58 |
59 if (offset % ELEMENT_SIZE !== 0) { | 59 if (offset % ELEMENT_SIZE !== 0) { |
60 throw MakeRangeError("invalid_typed_array_alignment", | 60 throw MakeRangeError("invalid_typed_array_alignment", |
61 ["start offset", "NAME", ELEMENT_SIZE]); | 61 ["start offset", "NAME", ELEMENT_SIZE]); |
62 } | 62 } |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 | 310 |
311 // --------------------------- DataView ----------------------------- | 311 // --------------------------- DataView ----------------------------- |
312 | 312 |
313 var $DataView = global.DataView; | 313 var $DataView = global.DataView; |
314 | 314 |
315 function DataViewConstructor(buffer, byteOffset, byteLength) { // length = 3 | 315 function DataViewConstructor(buffer, byteOffset, byteLength) { // length = 3 |
316 if (%_IsConstructCall()) { | 316 if (%_IsConstructCall()) { |
317 if (!IS_ARRAYBUFFER(buffer)) { | 317 if (!IS_ARRAYBUFFER(buffer)) { |
318 throw MakeTypeError('data_view_not_array_buffer', []); | 318 throw MakeTypeError('data_view_not_array_buffer', []); |
319 } | 319 } |
320 var bufferByteLength = buffer.byteLength; | 320 var bufferByteLength = %ArrayBufferGetByteLength(buffer); |
321 var offset = IS_UNDEFINED(byteOffset) ? | 321 var offset = IS_UNDEFINED(byteOffset) ? |
322 0 : ToPositiveInteger(byteOffset, 'invalid_data_view_offset'); | 322 0 : ToPositiveInteger(byteOffset, 'invalid_data_view_offset'); |
323 if (offset > bufferByteLength) { | 323 if (offset > bufferByteLength) { |
324 throw MakeRangeError('invalid_data_view_offset'); | 324 throw MakeRangeError('invalid_data_view_offset'); |
325 } | 325 } |
326 var length = IS_UNDEFINED(byteLength) ? | 326 var length = IS_UNDEFINED(byteLength) ? |
327 bufferByteLength - offset : TO_INTEGER(byteLength); | 327 bufferByteLength - offset : TO_INTEGER(byteLength); |
328 if (length < 0 || offset + length > bufferByteLength) { | 328 if (length < 0 || offset + length > bufferByteLength) { |
329 throw new MakeRangeError('invalid_data_view_length'); | 329 throw new MakeRangeError('invalid_data_view_length'); |
330 } | 330 } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 | 440 |
441 "getFloat32", DataViewGetFloat32, | 441 "getFloat32", DataViewGetFloat32, |
442 "setFloat32", DataViewSetFloat32, | 442 "setFloat32", DataViewSetFloat32, |
443 | 443 |
444 "getFloat64", DataViewGetFloat64, | 444 "getFloat64", DataViewGetFloat64, |
445 "setFloat64", DataViewSetFloat64 | 445 "setFloat64", DataViewSetFloat64 |
446 )); | 446 )); |
447 } | 447 } |
448 | 448 |
449 SetupDataView(); | 449 SetupDataView(); |
OLD | NEW |