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