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 "use strict"; | 5 "use strict"; |
6 | 6 |
7 // This file relies on the fact that the following declaration has been made | 7 // This file relies on the fact that the following declaration has been made |
8 // in runtime.js: | 8 // in runtime.js: |
9 // var $Array = global.Array; | 9 // var $Array = global.Array; |
10 var $ArrayBuffer = global.ArrayBuffer; | 10 var $ArrayBuffer = global.ArrayBuffer; |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
284 return; | 284 return; |
285 } | 285 } |
286 if (intOffset + l > this.length) { | 286 if (intOffset + l > this.length) { |
287 throw MakeRangeError("typed_array_set_source_too_large"); | 287 throw MakeRangeError("typed_array_set_source_too_large"); |
288 } | 288 } |
289 TypedArraySetFromArrayLike(this, obj, l, intOffset); | 289 TypedArraySetFromArrayLike(this, obj, l, intOffset); |
290 return; | 290 return; |
291 } | 291 } |
292 } | 292 } |
293 | 293 |
294 function TypedArrayGetToStringTag() { | |
295 if (!%IsTypedArray(this)) return; | |
296 var name = %_ClassOf(this); | |
297 if (IS_UNDEFINED(name)) return; | |
298 return name; | |
caitp (gmail)
2014/10/24 12:44:34
admittedly the above if statement doesn't really m
| |
299 } | |
300 | |
294 // ------------------------------------------------------------------- | 301 // ------------------------------------------------------------------- |
295 | 302 |
296 function SetupTypedArrays() { | 303 function SetupTypedArrays() { |
297 macro SETUP_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE) | 304 macro SETUP_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE) |
298 %CheckIsBootstrapping(); | 305 %CheckIsBootstrapping(); |
299 %SetCode(global.NAME, NAMEConstructor); | 306 %SetCode(global.NAME, NAMEConstructor); |
300 %FunctionSetPrototype(global.NAME, new $Object()); | 307 %FunctionSetPrototype(global.NAME, new $Object()); |
301 | 308 |
302 %AddNamedProperty(global.NAME, "BYTES_PER_ELEMENT", ELEMENT_SIZE, | 309 %AddNamedProperty(global.NAME, "BYTES_PER_ELEMENT", ELEMENT_SIZE, |
303 READ_ONLY | DONT_ENUM | DONT_DELETE); | 310 READ_ONLY | DONT_ENUM | DONT_DELETE); |
304 %AddNamedProperty(global.NAME.prototype, | 311 %AddNamedProperty(global.NAME.prototype, |
305 "constructor", global.NAME, DONT_ENUM); | 312 "constructor", global.NAME, DONT_ENUM); |
306 %AddNamedProperty(global.NAME.prototype, | 313 %AddNamedProperty(global.NAME.prototype, |
307 "BYTES_PER_ELEMENT", ELEMENT_SIZE, | 314 "BYTES_PER_ELEMENT", ELEMENT_SIZE, |
308 READ_ONLY | DONT_ENUM | DONT_DELETE); | 315 READ_ONLY | DONT_ENUM | DONT_DELETE); |
309 InstallGetter(global.NAME.prototype, "buffer", NAME_GetBuffer); | 316 InstallGetter(global.NAME.prototype, "buffer", NAME_GetBuffer); |
310 InstallGetter(global.NAME.prototype, "byteOffset", NAME_GetByteOffset); | 317 InstallGetter(global.NAME.prototype, "byteOffset", NAME_GetByteOffset); |
311 InstallGetter(global.NAME.prototype, "byteLength", NAME_GetByteLength); | 318 InstallGetter(global.NAME.prototype, "byteLength", NAME_GetByteLength); |
312 InstallGetter(global.NAME.prototype, "length", NAME_GetLength); | 319 InstallGetter(global.NAME.prototype, "length", NAME_GetLength); |
313 | 320 InstallGetter(global.NAME.prototype, symbolToStringTag, TypedArrayGetToStringT ag); |
Dmitry Lomov (no reviews)
2014/10/24 12:38:55
line length
| |
314 InstallFunctions(global.NAME.prototype, DONT_ENUM, $Array( | 321 InstallFunctions(global.NAME.prototype, DONT_ENUM, $Array( |
315 "subarray", NAMESubArray, | 322 "subarray", NAMESubArray, |
316 "set", TypedArraySet | 323 "set", TypedArraySet |
317 )); | 324 )); |
318 endmacro | 325 endmacro |
319 | 326 |
320 TYPED_ARRAYS(SETUP_TYPED_ARRAY) | 327 TYPED_ARRAYS(SETUP_TYPED_ARRAY) |
321 } | 328 } |
322 | 329 |
323 SetupTypedArrays(); | 330 SetupTypedArrays(); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
430 | 437 |
431 function SetupDataView() { | 438 function SetupDataView() { |
432 %CheckIsBootstrapping(); | 439 %CheckIsBootstrapping(); |
433 | 440 |
434 // Setup the DataView constructor. | 441 // Setup the DataView constructor. |
435 %SetCode($DataView, DataViewConstructor); | 442 %SetCode($DataView, DataViewConstructor); |
436 %FunctionSetPrototype($DataView, new $Object); | 443 %FunctionSetPrototype($DataView, new $Object); |
437 | 444 |
438 // Set up constructor property on the DataView prototype. | 445 // Set up constructor property on the DataView prototype. |
439 %AddNamedProperty($DataView.prototype, "constructor", $DataView, DONT_ENUM); | 446 %AddNamedProperty($DataView.prototype, "constructor", $DataView, DONT_ENUM); |
447 %AddNamedProperty( | |
448 $DataView.prototype, symbolToStringTag, "DataView", READ_ONLY|DONT_ENUM); | |
440 | 449 |
441 InstallGetter($DataView.prototype, "buffer", DataViewGetBufferJS); | 450 InstallGetter($DataView.prototype, "buffer", DataViewGetBufferJS); |
442 InstallGetter($DataView.prototype, "byteOffset", DataViewGetByteOffset); | 451 InstallGetter($DataView.prototype, "byteOffset", DataViewGetByteOffset); |
443 InstallGetter($DataView.prototype, "byteLength", DataViewGetByteLength); | 452 InstallGetter($DataView.prototype, "byteLength", DataViewGetByteLength); |
444 | 453 |
445 InstallFunctions($DataView.prototype, DONT_ENUM, $Array( | 454 InstallFunctions($DataView.prototype, DONT_ENUM, $Array( |
446 "getInt8", DataViewGetInt8JS, | 455 "getInt8", DataViewGetInt8JS, |
447 "setInt8", DataViewSetInt8JS, | 456 "setInt8", DataViewSetInt8JS, |
448 | 457 |
449 "getUint8", DataViewGetUint8JS, | 458 "getUint8", DataViewGetUint8JS, |
(...skipping 13 matching lines...) Expand all Loading... | |
463 | 472 |
464 "getFloat32", DataViewGetFloat32JS, | 473 "getFloat32", DataViewGetFloat32JS, |
465 "setFloat32", DataViewSetFloat32JS, | 474 "setFloat32", DataViewSetFloat32JS, |
466 | 475 |
467 "getFloat64", DataViewGetFloat64JS, | 476 "getFloat64", DataViewGetFloat64JS, |
468 "setFloat64", DataViewSetFloat64JS | 477 "setFloat64", DataViewSetFloat64JS |
469 )); | 478 )); |
470 } | 479 } |
471 | 480 |
472 SetupDataView(); | 481 SetupDataView(); |
OLD | NEW |