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 |
11 // ----------------------------------------------------------------------- | 11 // ----------------------------------------------------------------------- |
12 // Imports | 12 // Imports |
13 | 13 |
14 var arrayIterationKindSymbol = | 14 var arrayIterationKindSymbol = |
15 utils.ImportNow("array_iteration_kind_symbol"); | 15 utils.ImportNow("array_iteration_kind_symbol"); |
16 var arrayIteratorNextIndexSymbol = | 16 var arrayIteratorNextIndexSymbol = |
17 utils.ImportNow("array_iterator_next_symbol"); | 17 utils.ImportNow("array_iterator_next_symbol"); |
18 var arrayIteratorObjectSymbol = | 18 var arrayIteratorObjectSymbol = |
19 utils.ImportNow("array_iterator_object_symbol"); | 19 utils.ImportNow("array_iterator_object_symbol"); |
20 var GlobalArray = global.Array; | 20 var GlobalArray = global.Array; |
21 var IteratorPrototype = utils.ImportNow("IteratorPrototype"); | 21 var IteratorPrototype = utils.ImportNow("IteratorPrototype"); |
22 var iteratorSymbol = utils.ImportNow("iterator_symbol"); | 22 var iteratorSymbol = utils.ImportNow("iterator_symbol"); |
23 var MakeTypeError; | 23 var MakeTypeError; |
24 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); | 24 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); |
25 | 25 var GlobalTypedArray = global.Uint8Array.__proto__; |
26 macro TYPED_ARRAYS(FUNCTION) | |
27 FUNCTION(Uint8Array) | |
28 FUNCTION(Int8Array) | |
29 FUNCTION(Uint16Array) | |
30 FUNCTION(Int16Array) | |
31 FUNCTION(Uint32Array) | |
32 FUNCTION(Int32Array) | |
33 FUNCTION(Float32Array) | |
34 FUNCTION(Float64Array) | |
35 FUNCTION(Uint8ClampedArray) | |
36 endmacro | |
37 | |
38 macro COPY_FROM_GLOBAL(NAME) | |
39 var GlobalNAME = global.NAME; | |
40 endmacro | |
41 | |
42 TYPED_ARRAYS(COPY_FROM_GLOBAL) | |
43 | 26 |
44 utils.Import(function(from) { | 27 utils.Import(function(from) { |
45 MakeTypeError = from.MakeTypeError; | 28 MakeTypeError = from.MakeTypeError; |
46 }) | 29 }) |
47 | 30 |
48 // ----------------------------------------------------------------------- | 31 // ----------------------------------------------------------------------- |
49 | 32 |
50 function ArrayIterator() {} | 33 function ArrayIterator() {} |
51 | 34 |
52 | 35 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 'keys', ArrayKeys | 128 'keys', ArrayKeys |
146 ]); | 129 ]); |
147 | 130 |
148 // TODO(adam): Remove this call once 'values' is in the above | 131 // TODO(adam): Remove this call once 'values' is in the above |
149 // InstallFunctions block, as it'll be redundant. | 132 // InstallFunctions block, as it'll be redundant. |
150 utils.SetFunctionName(ArrayValues, 'values'); | 133 utils.SetFunctionName(ArrayValues, 'values'); |
151 | 134 |
152 %AddNamedProperty(GlobalArray.prototype, iteratorSymbol, ArrayValues, | 135 %AddNamedProperty(GlobalArray.prototype, iteratorSymbol, ArrayValues, |
153 DONT_ENUM); | 136 DONT_ENUM); |
154 | 137 |
155 macro EXTEND_TYPED_ARRAY(NAME) | 138 %AddNamedProperty(GlobalTypedArray.prototype, |
156 %AddNamedProperty(GlobalNAME.prototype, 'entries', ArrayEntries, DONT_ENUM); | 139 'entries', ArrayEntries, DONT_ENUM); |
157 %AddNamedProperty(GlobalNAME.prototype, 'values', ArrayValues, DONT_ENUM); | 140 %AddNamedProperty(GlobalTypedArray.prototype, 'values', ArrayValues, DONT_ENUM); |
158 %AddNamedProperty(GlobalNAME.prototype, 'keys', ArrayKeys, DONT_ENUM); | 141 %AddNamedProperty(GlobalTypedArray.prototype, 'keys', ArrayKeys, DONT_ENUM); |
159 %AddNamedProperty(GlobalNAME.prototype, iteratorSymbol, ArrayValues, | 142 %AddNamedProperty(GlobalTypedArray.prototype, |
160 DONT_ENUM); | 143 iteratorSymbol, ArrayValues, DONT_ENUM); |
161 endmacro | |
162 | |
163 TYPED_ARRAYS(EXTEND_TYPED_ARRAY) | |
164 | 144 |
165 // ------------------------------------------------------------------- | 145 // ------------------------------------------------------------------- |
166 // Exports | 146 // Exports |
167 | 147 |
168 utils.Export(function(to) { | 148 utils.Export(function(to) { |
169 to.ArrayValues = ArrayValues; | 149 to.ArrayValues = ArrayValues; |
170 }); | 150 }); |
171 | 151 |
172 %InstallToContext(["array_values_iterator", ArrayValues]); | 152 %InstallToContext(["array_values_iterator", ArrayValues]); |
173 | 153 |
174 }) | 154 }) |
OLD | NEW |