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 12 matching lines...) Expand all Loading... |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 "use strict"; | 28 "use strict"; |
29 | 29 |
30 // This file relies on the fact that the following declaration has been made | 30 // This file relies on the fact that the following declaration has been made |
31 // in runtime.js: | 31 // in runtime.js: |
32 // var $Array = global.Array; | 32 // var $Array = global.Array; |
33 | 33 var $ArrayBuffer = global.ArrayBuffer; |
34 | 34 |
35 | 35 |
36 // --------------- Typed Arrays --------------------- | 36 // --------------- Typed Arrays --------------------- |
37 | 37 |
38 function CreateTypedArrayConstructor(name, elementSize, arrayId, constructor) { | 38 function CreateTypedArrayConstructor(name, elementSize, arrayId, constructor) { |
39 function ConstructByArrayBuffer(obj, buffer, byteOffset, length) { | 39 function ConstructByArrayBuffer(obj, buffer, byteOffset, length) { |
40 var offset = ToPositiveInteger(byteOffset, "invalid_typed_array_length") | 40 var offset = ToPositiveInteger(byteOffset, "invalid_typed_array_length") |
41 | 41 |
42 if (offset % elementSize !== 0) { | 42 if (offset % elementSize !== 0) { |
43 throw MakeRangeError("invalid_typed_array_alignment", | 43 throw MakeRangeError("invalid_typed_array_alignment", |
(...skipping 19 matching lines...) Expand all Loading... |
63 } | 63 } |
64 if (offset + newByteLength > bufferByteLength) { | 64 if (offset + newByteLength > bufferByteLength) { |
65 throw MakeRangeError("invalid_typed_array_length"); | 65 throw MakeRangeError("invalid_typed_array_length"); |
66 } | 66 } |
67 %TypedArrayInitialize(obj, arrayId, buffer, offset, newByteLength); | 67 %TypedArrayInitialize(obj, arrayId, buffer, offset, newByteLength); |
68 } | 68 } |
69 | 69 |
70 function ConstructByLength(obj, length) { | 70 function ConstructByLength(obj, length) { |
71 var l = ToPositiveInteger(length, "invalid_typed_array_length"); | 71 var l = ToPositiveInteger(length, "invalid_typed_array_length"); |
72 var byteLength = l * elementSize; | 72 var byteLength = l * elementSize; |
73 var buffer = new global.ArrayBuffer(byteLength); | 73 var buffer = new $ArrayBuffer(byteLength); |
74 %TypedArrayInitialize(obj, arrayId, buffer, 0, byteLength); | 74 %TypedArrayInitialize(obj, arrayId, buffer, 0, byteLength); |
75 } | 75 } |
76 | 76 |
77 function ConstructByArrayLike(obj, arrayLike) { | 77 function ConstructByArrayLike(obj, arrayLike) { |
78 var length = arrayLike.length; | 78 var length = arrayLike.length; |
79 var l = ToPositiveInteger(length, "invalid_typed_array_length"); | 79 var l = ToPositiveInteger(length, "invalid_typed_array_length"); |
80 if(!%TypedArrayInitializeFromArrayLike(obj, arrayId, arrayLike, l)) { | 80 if(!%TypedArrayInitializeFromArrayLike(obj, arrayId, arrayLike, l)) { |
81 for (var i = 0; i < l; i++) { | 81 for (var i = 0; i < l; i++) { |
82 // It is crucial that we let any execptions from arrayLike[i] | 82 // It is crucial that we let any execptions from arrayLike[i] |
83 // propagate outside the function. | 83 // propagate outside the function. |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 | 588 |
589 "getFloat32", DataViewGetFloat32, | 589 "getFloat32", DataViewGetFloat32, |
590 "setFloat32", DataViewSetFloat32, | 590 "setFloat32", DataViewSetFloat32, |
591 | 591 |
592 "getFloat64", DataViewGetFloat64, | 592 "getFloat64", DataViewGetFloat64, |
593 "setFloat64", DataViewSetFloat64 | 593 "setFloat64", DataViewSetFloat64 |
594 )); | 594 )); |
595 } | 595 } |
596 | 596 |
597 SetupDataView(); | 597 SetupDataView(); |
OLD | NEW |