| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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() { | 5 (function() { |
| 6 | 6 |
| 7 "use strict"; | 7 "use strict"; |
| 8 | 8 |
| 9 %CheckIsBootstrapping(); | 9 %CheckIsBootstrapping(); |
| 10 | 10 |
| 11 // ------------------------------------------------------------------- |
| 12 |
| 11 macro TYPED_ARRAYS(FUNCTION) | 13 macro TYPED_ARRAYS(FUNCTION) |
| 12 // arrayIds below should be synchronized with Runtime_TypedArrayInitialize. | 14 // arrayIds below should be synchronized with Runtime_TypedArrayInitialize. |
| 13 FUNCTION(1, Uint8Array, 1) | 15 FUNCTION(1, Uint8Array, 1) |
| 14 FUNCTION(2, Int8Array, 1) | 16 FUNCTION(2, Int8Array, 1) |
| 15 FUNCTION(3, Uint16Array, 2) | 17 FUNCTION(3, Uint16Array, 2) |
| 16 FUNCTION(4, Int16Array, 2) | 18 FUNCTION(4, Int16Array, 2) |
| 17 FUNCTION(5, Uint32Array, 4) | 19 FUNCTION(5, Uint32Array, 4) |
| 18 FUNCTION(6, Int32Array, 4) | 20 FUNCTION(6, Int32Array, 4) |
| 19 FUNCTION(7, Float32Array, 4) | 21 FUNCTION(7, Float32Array, 4) |
| 20 FUNCTION(8, Float64Array, 8) | 22 FUNCTION(8, Float64Array, 8) |
| 21 FUNCTION(9, Uint8ClampedArray, 1) | 23 FUNCTION(9, Uint8ClampedArray, 1) |
| 22 endmacro | 24 endmacro |
| 23 | 25 |
| 24 macro DECLARE_GLOBALS(INDEX, NAME, SIZE) | |
| 25 var GlobalNAME = global.NAME; | |
| 26 endmacro | |
| 27 | |
| 28 TYPED_ARRAYS(DECLARE_GLOBALS) | |
| 29 | |
| 30 // ------------------------------------------------------------------- | |
| 31 | 26 |
| 32 macro TYPED_ARRAY_HARMONY_ADDITIONS(ARRAY_ID, NAME, ELEMENT_SIZE) | 27 macro TYPED_ARRAY_HARMONY_ADDITIONS(ARRAY_ID, NAME, ELEMENT_SIZE) |
| 33 | 28 |
| 34 // ES6 draft 08-24-14, section 22.2.3.12 | 29 // ES6 draft 08-24-14, section 22.2.3.12 |
| 35 function NAMEForEach(f /* thisArg */) { // length == 1 | 30 function NAMEForEach(f /* thisArg */) { // length == 1 |
| 36 if (!%IsTypedArray(this)) { | 31 if (!%IsTypedArray(this)) { |
| 37 throw MakeTypeError('not_typed_array', []); | 32 throw MakeTypeError('not_typed_array', []); |
| 38 } | 33 } |
| 39 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); | 34 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); |
| 40 | 35 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 return array; | 67 return array; |
| 73 } | 68 } |
| 74 | 69 |
| 75 endmacro | 70 endmacro |
| 76 | 71 |
| 77 TYPED_ARRAYS(TYPED_ARRAY_HARMONY_ADDITIONS) | 72 TYPED_ARRAYS(TYPED_ARRAY_HARMONY_ADDITIONS) |
| 78 | 73 |
| 79 | 74 |
| 80 macro EXTEND_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE) | 75 macro EXTEND_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE) |
| 81 // Set up non-enumerable functions on the object. | 76 // Set up non-enumerable functions on the object. |
| 82 $installFunctions(GlobalNAME, DONT_ENUM | DONT_DELETE | READ_ONLY, [ | 77 InstallFunctions(global.NAME, DONT_ENUM | DONT_DELETE | READ_ONLY, [ |
| 83 "of", NAMEOf | 78 "of", NAMEOf |
| 84 ]); | 79 ]); |
| 85 | 80 |
| 86 // Set up non-enumerable functions on the prototype object. | 81 // Set up non-enumerable functions on the prototype object. |
| 87 $installFunctions(GlobalNAME.prototype, DONT_ENUM, [ | 82 InstallFunctions(global.NAME.prototype, DONT_ENUM, [ |
| 88 "forEach", NAMEForEach | 83 "forEach", NAMEForEach |
| 89 ]); | 84 ]); |
| 90 endmacro | 85 endmacro |
| 91 | 86 |
| 92 TYPED_ARRAYS(EXTEND_TYPED_ARRAY) | 87 TYPED_ARRAYS(EXTEND_TYPED_ARRAY) |
| 93 | 88 |
| 94 })(); | 89 })(); |
| OLD | NEW |