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 iteratorSymbol = utils.ImportNow("iterator_symbol"); | 22 var iteratorSymbol = utils.ImportNow("iterator_symbol"); |
22 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); | 23 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); |
23 | 24 |
24 macro TYPED_ARRAYS(FUNCTION) | 25 macro TYPED_ARRAYS(FUNCTION) |
25 FUNCTION(Uint8Array) | 26 FUNCTION(Uint8Array) |
26 FUNCTION(Int8Array) | 27 FUNCTION(Int8Array) |
27 FUNCTION(Uint16Array) | 28 FUNCTION(Uint16Array) |
28 FUNCTION(Int16Array) | 29 FUNCTION(Int16Array) |
29 FUNCTION(Uint32Array) | 30 FUNCTION(Uint32Array) |
30 FUNCTION(Int32Array) | 31 FUNCTION(Int32Array) |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 function ArrayValues() { | 115 function ArrayValues() { |
115 return CreateArrayIterator(this, ITERATOR_KIND_VALUES); | 116 return CreateArrayIterator(this, ITERATOR_KIND_VALUES); |
116 } | 117 } |
117 | 118 |
118 | 119 |
119 function ArrayKeys() { | 120 function ArrayKeys() { |
120 return CreateArrayIterator(this, ITERATOR_KIND_KEYS); | 121 return CreateArrayIterator(this, ITERATOR_KIND_KEYS); |
121 } | 122 } |
122 | 123 |
123 | 124 |
124 %FunctionSetPrototype(ArrayIterator, {__proto__: $iteratorPrototype}); | 125 %FunctionSetPrototype(ArrayIterator, {__proto__: IteratorPrototype}); |
125 %FunctionSetInstanceClassName(ArrayIterator, 'Array Iterator'); | 126 %FunctionSetInstanceClassName(ArrayIterator, 'Array Iterator'); |
126 | 127 |
127 utils.InstallFunctions(ArrayIterator.prototype, DONT_ENUM, [ | 128 utils.InstallFunctions(ArrayIterator.prototype, DONT_ENUM, [ |
128 'next', ArrayIteratorNext | 129 'next', ArrayIteratorNext |
129 ]); | 130 ]); |
130 utils.SetFunctionName(ArrayIteratorIterator, iteratorSymbol); | 131 utils.SetFunctionName(ArrayIteratorIterator, iteratorSymbol); |
131 %AddNamedProperty(ArrayIterator.prototype, iteratorSymbol, | 132 %AddNamedProperty(ArrayIterator.prototype, iteratorSymbol, |
132 ArrayIteratorIterator, DONT_ENUM); | 133 ArrayIteratorIterator, DONT_ENUM); |
133 %AddNamedProperty(ArrayIterator.prototype, toStringTagSymbol, | 134 %AddNamedProperty(ArrayIterator.prototype, toStringTagSymbol, |
134 "Array Iterator", READ_ONLY | DONT_ENUM); | 135 "Array Iterator", READ_ONLY | DONT_ENUM); |
(...skipping 28 matching lines...) Expand all Loading... |
163 to.ArrayValues = ArrayValues; | 164 to.ArrayValues = ArrayValues; |
164 }); | 165 }); |
165 | 166 |
166 %InstallToContext([ | 167 %InstallToContext([ |
167 "array_keys_iterator", ArrayKeys, | 168 "array_keys_iterator", ArrayKeys, |
168 "array_values_iterator", ArrayValues, | 169 "array_values_iterator", ArrayValues, |
169 "array_entries_iterator", ArrayEntries | 170 "array_entries_iterator", ArrayEntries |
170 ]); | 171 ]); |
171 | 172 |
172 }) | 173 }) |
OLD | NEW |