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 } | 80 } |
81 if (offset + newByteLength > bufferByteLength) { | 81 if (offset + newByteLength > bufferByteLength) { |
82 throw MakeRangeError("invalid_typed_array_length"); | 82 throw MakeRangeError("invalid_typed_array_length"); |
83 } | 83 } |
84 %TypedArrayInitialize(obj, ARRAY_ID, buffer, offset, newByteLength); | 84 %TypedArrayInitialize(obj, ARRAY_ID, buffer, offset, newByteLength); |
85 } | 85 } |
86 | 86 |
87 function NAMEConstructByLength(obj, length) { | 87 function NAMEConstructByLength(obj, length) { |
88 var l = IS_UNDEFINED(length) ? | 88 var l = IS_UNDEFINED(length) ? |
89 0 : ToPositiveInteger(length, "invalid_typed_array_length"); | 89 0 : ToPositiveInteger(length, "invalid_typed_array_length"); |
90 if (l > %MaxSmi()) | |
91 throw MakeRangeError(length, "invalid_typed_array_length"); | |
Jakob Kummerow
2013/11/15 15:13:08
nit: {} please
Dmitry Lomov (no reviews)
2013/11/15 16:03:07
Done.
| |
90 var byteLength = l * ELEMENT_SIZE; | 92 var byteLength = l * ELEMENT_SIZE; |
91 var buffer = new $ArrayBuffer(byteLength); | 93 var buffer = new $ArrayBuffer(byteLength); |
92 %TypedArrayInitialize(obj, ARRAY_ID, buffer, 0, byteLength); | 94 %TypedArrayInitialize(obj, ARRAY_ID, buffer, 0, byteLength); |
93 } | 95 } |
94 | 96 |
95 function NAMEConstructByArrayLike(obj, arrayLike) { | 97 function NAMEConstructByArrayLike(obj, arrayLike) { |
96 var length = arrayLike.length; | 98 var length = arrayLike.length; |
97 var l = ToPositiveInteger(length, "invalid_typed_array_length"); | 99 var l = ToPositiveInteger(length, "invalid_typed_array_length"); |
98 if(!%TypedArrayInitializeFromArrayLike(obj, ARRAY_ID, arrayLike, l)) { | 100 if(!%TypedArrayInitializeFromArrayLike(obj, ARRAY_ID, arrayLike, l)) { |
99 for (var i = 0; i < l; i++) { | 101 for (var i = 0; i < l; i++) { |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
429 | 431 |
430 "getFloat32", DataViewGetFloat32, | 432 "getFloat32", DataViewGetFloat32, |
431 "setFloat32", DataViewSetFloat32, | 433 "setFloat32", DataViewSetFloat32, |
432 | 434 |
433 "getFloat64", DataViewGetFloat64, | 435 "getFloat64", DataViewGetFloat64, |
434 "setFloat64", DataViewSetFloat64 | 436 "setFloat64", DataViewSetFloat64 |
435 )); | 437 )); |
436 } | 438 } |
437 | 439 |
438 SetupDataView(); | 440 SetupDataView(); |
OLD | NEW |