| 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 var $arrayValues; | 5 var $arrayValues; |
| 6 | 6 |
| 7 (function(global, utils) { | 7 (function(global, utils) { |
| 8 | 8 |
| 9 "use strict"; | 9 "use strict"; |
| 10 | 10 |
| 11 %CheckIsBootstrapping(); | 11 %CheckIsBootstrapping(); |
| 12 | 12 |
| 13 // ----------------------------------------------------------------------- | 13 // ----------------------------------------------------------------------- |
| 14 // Imports | 14 // Imports |
| 15 | 15 |
| 16 var arrayIterationKindSymbol = | 16 var arrayIterationKindSymbol = |
| 17 utils.GetPrivateSymbol("array_iteration_kind_symbol"); | 17 utils.ImportNow("array_iteration_kind_symbol"); |
| 18 var arrayIteratorNextIndexSymbol = | 18 var arrayIteratorNextIndexSymbol = |
| 19 utils.GetPrivateSymbol("array_iterator_next_symbol"); | 19 utils.ImportNow("array_iterator_next_symbol"); |
| 20 var arrayIteratorObjectSymbol = | 20 var arrayIteratorObjectSymbol = |
| 21 utils.GetPrivateSymbol("array_iterator_object_symbol"); | 21 utils.ImportNow("array_iterator_object_symbol"); |
| 22 var GlobalArray = global.Array; | 22 var GlobalArray = global.Array; |
| 23 var iteratorSymbol = utils.ImportNow("iterator_symbol"); |
| 24 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); |
| 23 | 25 |
| 24 macro TYPED_ARRAYS(FUNCTION) | 26 macro TYPED_ARRAYS(FUNCTION) |
| 25 FUNCTION(Uint8Array) | 27 FUNCTION(Uint8Array) |
| 26 FUNCTION(Int8Array) | 28 FUNCTION(Int8Array) |
| 27 FUNCTION(Uint16Array) | 29 FUNCTION(Uint16Array) |
| 28 FUNCTION(Int16Array) | 30 FUNCTION(Int16Array) |
| 29 FUNCTION(Uint32Array) | 31 FUNCTION(Uint32Array) |
| 30 FUNCTION(Int32Array) | 32 FUNCTION(Int32Array) |
| 31 FUNCTION(Float32Array) | 33 FUNCTION(Float32Array) |
| 32 FUNCTION(Float64Array) | 34 FUNCTION(Float64Array) |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 return CreateArrayIterator(this, ITERATOR_KIND_KEYS); | 127 return CreateArrayIterator(this, ITERATOR_KIND_KEYS); |
| 126 } | 128 } |
| 127 | 129 |
| 128 | 130 |
| 129 %FunctionSetPrototype(ArrayIterator, {__proto__: $iteratorPrototype}); | 131 %FunctionSetPrototype(ArrayIterator, {__proto__: $iteratorPrototype}); |
| 130 %FunctionSetInstanceClassName(ArrayIterator, 'Array Iterator'); | 132 %FunctionSetInstanceClassName(ArrayIterator, 'Array Iterator'); |
| 131 | 133 |
| 132 utils.InstallFunctions(ArrayIterator.prototype, DONT_ENUM, [ | 134 utils.InstallFunctions(ArrayIterator.prototype, DONT_ENUM, [ |
| 133 'next', ArrayIteratorNext | 135 'next', ArrayIteratorNext |
| 134 ]); | 136 ]); |
| 135 utils.SetFunctionName(ArrayIteratorIterator, symbolIterator); | 137 utils.SetFunctionName(ArrayIteratorIterator, iteratorSymbol); |
| 136 %AddNamedProperty(ArrayIterator.prototype, symbolIterator, | 138 %AddNamedProperty(ArrayIterator.prototype, iteratorSymbol, |
| 137 ArrayIteratorIterator, DONT_ENUM); | 139 ArrayIteratorIterator, DONT_ENUM); |
| 138 %AddNamedProperty(ArrayIterator.prototype, symbolToStringTag, | 140 %AddNamedProperty(ArrayIterator.prototype, toStringTagSymbol, |
| 139 "Array Iterator", READ_ONLY | DONT_ENUM); | 141 "Array Iterator", READ_ONLY | DONT_ENUM); |
| 140 | 142 |
| 141 utils.InstallFunctions(GlobalArray.prototype, DONT_ENUM, [ | 143 utils.InstallFunctions(GlobalArray.prototype, DONT_ENUM, [ |
| 142 // No 'values' since it breaks webcompat: http://crbug.com/409858 | 144 // No 'values' since it breaks webcompat: http://crbug.com/409858 |
| 143 'entries', ArrayEntries, | 145 'entries', ArrayEntries, |
| 144 'keys', ArrayKeys | 146 'keys', ArrayKeys |
| 145 ]); | 147 ]); |
| 146 | 148 |
| 147 // TODO(adam): Remove this call once 'values' is in the above | 149 // TODO(adam): Remove this call once 'values' is in the above |
| 148 // InstallFunctions block, as it'll be redundant. | 150 // InstallFunctions block, as it'll be redundant. |
| 149 utils.SetFunctionName(ArrayValues, 'values'); | 151 utils.SetFunctionName(ArrayValues, 'values'); |
| 150 | 152 |
| 151 %AddNamedProperty(GlobalArray.prototype, symbolIterator, ArrayValues, | 153 %AddNamedProperty(GlobalArray.prototype, iteratorSymbol, ArrayValues, |
| 152 DONT_ENUM); | 154 DONT_ENUM); |
| 153 | 155 |
| 154 macro EXTEND_TYPED_ARRAY(NAME) | 156 macro EXTEND_TYPED_ARRAY(NAME) |
| 155 %AddNamedProperty(GlobalNAME.prototype, 'entries', ArrayEntries, DONT_ENUM); | 157 %AddNamedProperty(GlobalNAME.prototype, 'entries', ArrayEntries, DONT_ENUM); |
| 156 %AddNamedProperty(GlobalNAME.prototype, 'values', ArrayValues, DONT_ENUM); | 158 %AddNamedProperty(GlobalNAME.prototype, 'values', ArrayValues, DONT_ENUM); |
| 157 %AddNamedProperty(GlobalNAME.prototype, 'keys', ArrayKeys, DONT_ENUM); | 159 %AddNamedProperty(GlobalNAME.prototype, 'keys', ArrayKeys, DONT_ENUM); |
| 158 %AddNamedProperty(GlobalNAME.prototype, symbolIterator, ArrayValues, | 160 %AddNamedProperty(GlobalNAME.prototype, iteratorSymbol, ArrayValues, |
| 159 DONT_ENUM); | 161 DONT_ENUM); |
| 160 endmacro | 162 endmacro |
| 161 | 163 |
| 162 TYPED_ARRAYS(EXTEND_TYPED_ARRAY) | 164 TYPED_ARRAYS(EXTEND_TYPED_ARRAY) |
| 163 | 165 |
| 164 // ------------------------------------------------------------------- | 166 // ------------------------------------------------------------------- |
| 165 // Exports | 167 // Exports |
| 166 | 168 |
| 167 utils.Export(function(to) { | 169 utils.Export(function(to) { |
| 168 to.ArrayIteratorCreateResultObject = CreateIteratorResultObject; | 170 to.ArrayIteratorCreateResultObject = CreateIteratorResultObject; |
| 169 }); | 171 }); |
| 170 | 172 |
| 171 $arrayValues = ArrayValues; | 173 $arrayValues = ArrayValues; |
| 172 | 174 |
| 173 %InstallToContext(["array_values_iterator", ArrayValues]); | 175 %InstallToContext(["array_values_iterator", ArrayValues]); |
| 174 | 176 |
| 175 }) | 177 }) |
| OLD | NEW |