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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 throw MakeRangeError("invalid_typed_array_alignment", | 80 throw MakeRangeError("invalid_typed_array_alignment", |
81 ["byte length", "NAME", ELEMENT_SIZE]); | 81 ["byte length", "NAME", ELEMENT_SIZE]); |
82 } | 82 } |
83 newByteLength = bufferByteLength - offset; | 83 newByteLength = bufferByteLength - offset; |
84 newLength = newByteLength / ELEMENT_SIZE; | 84 newLength = newByteLength / ELEMENT_SIZE; |
85 } else { | 85 } else { |
86 var newLength = length; | 86 var newLength = length; |
87 newByteLength = newLength * ELEMENT_SIZE; | 87 newByteLength = newLength * ELEMENT_SIZE; |
88 } | 88 } |
89 if ((offset + newByteLength > bufferByteLength) | 89 if ((offset + newByteLength > bufferByteLength) |
90 || (newLength > %MaxSmi())) { | 90 || (newLength > %_MaxSmi())) { |
91 throw MakeRangeError("invalid_typed_array_length"); | 91 throw MakeRangeError("invalid_typed_array_length"); |
92 } | 92 } |
93 %TypedArrayInitialize(obj, ARRAY_ID, buffer, offset, newByteLength); | 93 %_TypedArrayInitialize(obj, ARRAY_ID, buffer, offset, newByteLength); |
94 } | 94 } |
95 | 95 |
96 function NAMEConstructByLength(obj, length) { | 96 function NAMEConstructByLength(obj, length) { |
97 var l = IS_UNDEFINED(length) ? | 97 var l = IS_UNDEFINED(length) ? |
98 0 : ToPositiveInteger(length, "invalid_typed_array_length"); | 98 0 : ToPositiveInteger(length, "invalid_typed_array_length"); |
99 if (l > %MaxSmi()) { | 99 if (l > %_MaxSmi()) { |
100 throw MakeRangeError("invalid_typed_array_length"); | 100 throw MakeRangeError("invalid_typed_array_length"); |
101 } | 101 } |
102 var byteLength = l * ELEMENT_SIZE; | 102 var byteLength = l * ELEMENT_SIZE; |
103 var buffer = new $ArrayBuffer(byteLength); | 103 var buffer = new $ArrayBuffer(byteLength); |
104 %TypedArrayInitialize(obj, ARRAY_ID, buffer, 0, byteLength); | 104 %_TypedArrayInitialize(obj, ARRAY_ID, buffer, 0, byteLength); |
105 } | 105 } |
106 | 106 |
107 function NAMEConstructByArrayLike(obj, arrayLike) { | 107 function NAMEConstructByArrayLike(obj, arrayLike) { |
108 var length = arrayLike.length; | 108 var length = arrayLike.length; |
109 var l = ToPositiveInteger(length, "invalid_typed_array_length"); | 109 var l = ToPositiveInteger(length, "invalid_typed_array_length"); |
110 | 110 |
111 if (l > %MaxSmi()) { | 111 if (l > %_MaxSmi()) { |
112 throw MakeRangeError("invalid_typed_array_length"); | 112 throw MakeRangeError("invalid_typed_array_length"); |
113 } | 113 } |
114 if(!%TypedArrayInitializeFromArrayLike(obj, ARRAY_ID, arrayLike, l)) { | 114 if(!%TypedArrayInitializeFromArrayLike(obj, ARRAY_ID, arrayLike, l)) { |
115 for (var i = 0; i < l; i++) { | 115 for (var i = 0; i < l; i++) { |
116 // It is crucial that we let any execptions from arrayLike[i] | 116 // It is crucial that we let any execptions from arrayLike[i] |
117 // propagate outside the function. | 117 // propagate outside the function. |
118 obj[i] = arrayLike[i]; | 118 obj[i] = arrayLike[i]; |
119 } | 119 } |
120 } | 120 } |
121 } | 121 } |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 if (offset > bufferByteLength) { | 343 if (offset > bufferByteLength) { |
344 throw MakeRangeError('invalid_data_view_offset'); | 344 throw MakeRangeError('invalid_data_view_offset'); |
345 } | 345 } |
346 | 346 |
347 var length = IS_UNDEFINED(byteLength) | 347 var length = IS_UNDEFINED(byteLength) |
348 ? bufferByteLength - offset | 348 ? bufferByteLength - offset |
349 : byteLength; | 349 : byteLength; |
350 if (length < 0 || offset + length > bufferByteLength) { | 350 if (length < 0 || offset + length > bufferByteLength) { |
351 throw new MakeRangeError('invalid_data_view_length'); | 351 throw new MakeRangeError('invalid_data_view_length'); |
352 } | 352 } |
353 %DataViewInitialize(this, buffer, offset, length); | 353 %_DataViewInitialize(this, buffer, offset, length); |
354 } else { | 354 } else { |
355 throw MakeTypeError('constructor_not_function', ["DataView"]); | 355 throw MakeTypeError('constructor_not_function', ["DataView"]); |
356 } | 356 } |
357 } | 357 } |
358 | 358 |
359 function DataViewGetBuffer() { | 359 function DataViewGetBuffer() { |
360 if (!IS_DATAVIEW(this)) { | 360 if (!IS_DATAVIEW(this)) { |
361 throw MakeTypeError('incompatible_method_receiver', | 361 throw MakeTypeError('incompatible_method_receiver', |
362 ['DataView.buffer', this]); | 362 ['DataView.buffer', this]); |
363 } | 363 } |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 | 462 |
463 "getFloat32", DataViewGetFloat32, | 463 "getFloat32", DataViewGetFloat32, |
464 "setFloat32", DataViewSetFloat32, | 464 "setFloat32", DataViewSetFloat32, |
465 | 465 |
466 "getFloat64", DataViewGetFloat64, | 466 "getFloat64", DataViewGetFloat64, |
467 "setFloat64", DataViewSetFloat64 | 467 "setFloat64", DataViewSetFloat64 |
468 )); | 468 )); |
469 } | 469 } |
470 | 470 |
471 SetupDataView(); | 471 SetupDataView(); |
OLD | NEW |