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)) throw MakeTypeError(kNotTypedArray); | 36 if (!%IsTypedArray(this)) throw MakeTypeError(kNotTypedArray); |
32 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); | 37 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); |
33 | 38 |
34 var length = %_TypedArrayGetLength(this); | 39 var length = %_TypedArrayGetLength(this); |
35 var receiver; | 40 var receiver; |
(...skipping 29 matching lines...) Expand all Loading... |
65 return array; | 70 return array; |
66 } | 71 } |
67 | 72 |
68 endmacro | 73 endmacro |
69 | 74 |
70 TYPED_ARRAYS(TYPED_ARRAY_HARMONY_ADDITIONS) | 75 TYPED_ARRAYS(TYPED_ARRAY_HARMONY_ADDITIONS) |
71 | 76 |
72 | 77 |
73 macro EXTEND_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE) | 78 macro EXTEND_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE) |
74 // Set up non-enumerable functions on the object. | 79 // Set up non-enumerable functions on the object. |
75 InstallFunctions(global.NAME, DONT_ENUM | DONT_DELETE | READ_ONLY, [ | 80 $installFunctions(GlobalNAME, DONT_ENUM | DONT_DELETE | READ_ONLY, [ |
76 "of", NAMEOf | 81 "of", NAMEOf |
77 ]); | 82 ]); |
78 | 83 |
79 // Set up non-enumerable functions on the prototype object. | 84 // Set up non-enumerable functions on the prototype object. |
80 InstallFunctions(global.NAME.prototype, DONT_ENUM, [ | 85 $installFunctions(GlobalNAME.prototype, DONT_ENUM, [ |
81 "forEach", NAMEForEach | 86 "forEach", NAMEForEach |
82 ]); | 87 ]); |
83 endmacro | 88 endmacro |
84 | 89 |
85 TYPED_ARRAYS(EXTEND_TYPED_ARRAY) | 90 TYPED_ARRAYS(EXTEND_TYPED_ARRAY) |
86 | 91 |
87 })(); | 92 })(); |
OLD | NEW |