OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 (function(global, utils) { | 5 (function(global, utils) { |
6 | 6 |
7 "use strict"; | 7 "use strict"; |
8 | 8 |
9 %CheckIsBootstrapping(); | 9 %CheckIsBootstrapping(); |
10 | 10 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 for (var i = 0; i < l; i++) { | 120 for (var i = 0; i < l; i++) { |
121 // It is crucial that we let any execptions from arrayLike[i] | 121 // It is crucial that we let any execptions from arrayLike[i] |
122 // propagate outside the function. | 122 // propagate outside the function. |
123 obj[i] = arrayLike[i]; | 123 obj[i] = arrayLike[i]; |
124 } | 124 } |
125 } | 125 } |
126 } | 126 } |
127 | 127 |
128 function NAMEConstructor(arg1, arg2, arg3) { | 128 function NAMEConstructor(arg1, arg2, arg3) { |
129 if (%_IsConstructCall()) { | 129 if (%_IsConstructCall()) { |
130 if (IS_ARRAYBUFFER(arg1) || IS_SHAREDARRAYBUFFER(arg1)) { | 130 if (IS_ARRAYBUFFER(arg1)) { |
131 NAMEConstructByArrayBuffer(this, arg1, arg2, arg3); | 131 NAMEConstructByArrayBuffer(this, arg1, arg2, arg3); |
132 } else if (IS_NUMBER(arg1) || IS_STRING(arg1) || | 132 } else if (IS_NUMBER(arg1) || IS_STRING(arg1) || |
133 IS_BOOLEAN(arg1) || IS_UNDEFINED(arg1)) { | 133 IS_BOOLEAN(arg1) || IS_UNDEFINED(arg1)) { |
134 NAMEConstructByLength(this, arg1); | 134 NAMEConstructByLength(this, arg1); |
135 } else { | 135 } else { |
136 NAMEConstructByArrayLike(this, arg1); | 136 NAMEConstructByArrayLike(this, arg1); |
137 } | 137 } |
138 } else { | 138 } else { |
139 throw MakeTypeError(kConstructorNotFunction, "NAME") | 139 throw MakeTypeError(kConstructorNotFunction, "NAME") |
140 } | 140 } |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 "set", TypedArraySet | 340 "set", TypedArraySet |
341 ]); | 341 ]); |
342 endmacro | 342 endmacro |
343 | 343 |
344 TYPED_ARRAYS(SETUP_TYPED_ARRAY) | 344 TYPED_ARRAYS(SETUP_TYPED_ARRAY) |
345 | 345 |
346 // --------------------------- DataView ----------------------------- | 346 // --------------------------- DataView ----------------------------- |
347 | 347 |
348 function DataViewConstructor(buffer, byteOffset, byteLength) { // length = 3 | 348 function DataViewConstructor(buffer, byteOffset, byteLength) { // length = 3 |
349 if (%_IsConstructCall()) { | 349 if (%_IsConstructCall()) { |
350 // TODO(binji): support SharedArrayBuffers? | |
351 if (!IS_ARRAYBUFFER(buffer)) throw MakeTypeError(kDataViewNotArrayBuffer); | 350 if (!IS_ARRAYBUFFER(buffer)) throw MakeTypeError(kDataViewNotArrayBuffer); |
352 if (!IS_UNDEFINED(byteOffset)) { | 351 if (!IS_UNDEFINED(byteOffset)) { |
353 byteOffset = $toPositiveInteger(byteOffset, kInvalidDataViewOffset); | 352 byteOffset = $toPositiveInteger(byteOffset, kInvalidDataViewOffset); |
354 } | 353 } |
355 if (!IS_UNDEFINED(byteLength)) { | 354 if (!IS_UNDEFINED(byteLength)) { |
356 byteLength = TO_INTEGER(byteLength); | 355 byteLength = TO_INTEGER(byteLength); |
357 } | 356 } |
358 | 357 |
359 var bufferByteLength = %_ArrayBufferGetByteLength(buffer); | 358 var bufferByteLength = %_ArrayBufferGetByteLength(buffer); |
360 | 359 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 "setUint32", DataViewSetUint32JS, | 465 "setUint32", DataViewSetUint32JS, |
467 | 466 |
468 "getFloat32", DataViewGetFloat32JS, | 467 "getFloat32", DataViewGetFloat32JS, |
469 "setFloat32", DataViewSetFloat32JS, | 468 "setFloat32", DataViewSetFloat32JS, |
470 | 469 |
471 "getFloat64", DataViewGetFloat64JS, | 470 "getFloat64", DataViewGetFloat64JS, |
472 "setFloat64", DataViewSetFloat64JS | 471 "setFloat64", DataViewSetFloat64JS |
473 ]); | 472 ]); |
474 | 473 |
475 }) | 474 }) |
OLD | NEW |