| Index: src/array-iterator.js
|
| diff --git a/src/array-iterator.js b/src/array-iterator.js
|
| index 8e4f5c7bbc6bb78e51e31ade882173aa09b724d1..95635cd4bf7ed7ee51b7366540cd8dde2d7e36e2 100644
|
| --- a/src/array-iterator.js
|
| +++ b/src/array-iterator.js
|
| @@ -2,13 +2,35 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +var $iteratorCreateResultObject;
|
| +var $arrayValues;
|
| +
|
| +(function() {
|
| +
|
| "use strict";
|
|
|
| +%CheckIsBootstrapping();
|
|
|
| -// This file relies on the fact that the following declaration has been made
|
| -// in runtime.js:
|
| -// var $Array = global.Array;
|
| +var GlobalArray = global.Array;
|
| +var GlobalObject = global.Object;
|
|
|
| +macro TYPED_ARRAYS(FUNCTION)
|
| + FUNCTION(Uint8Array)
|
| + FUNCTION(Int8Array)
|
| + FUNCTION(Uint16Array)
|
| + FUNCTION(Int16Array)
|
| + FUNCTION(Uint32Array)
|
| + FUNCTION(Int32Array)
|
| + FUNCTION(Float32Array)
|
| + FUNCTION(Float64Array)
|
| + FUNCTION(Uint8ClampedArray)
|
| +endmacro
|
| +
|
| +macro COPY_FROM_GLOBAL(NAME)
|
| + var GlobalNAME = global.NAME;
|
| +endmacro
|
| +
|
| +TYPED_ARRAYS(COPY_FROM_GLOBAL)
|
|
|
| var arrayIteratorObjectSymbol = GLOBAL_PRIVATE("ArrayIterator#object");
|
| var arrayIteratorNextIndexSymbol = GLOBAL_PRIVATE("ArrayIterator#next");
|
| @@ -100,60 +122,38 @@ function ArrayKeys() {
|
| }
|
|
|
|
|
| -function SetUpArrayIterator() {
|
| - %CheckIsBootstrapping();
|
| -
|
| - %FunctionSetPrototype(ArrayIterator, new $Object());
|
| - %FunctionSetInstanceClassName(ArrayIterator, 'Array Iterator');
|
| -
|
| - InstallFunctions(ArrayIterator.prototype, DONT_ENUM, [
|
| - 'next', ArrayIteratorNext
|
| - ]);
|
| - %FunctionSetName(ArrayIteratorIterator, '[Symbol.iterator]');
|
| - %AddNamedProperty(ArrayIterator.prototype, symbolIterator,
|
| - ArrayIteratorIterator, DONT_ENUM);
|
| - %AddNamedProperty(ArrayIterator.prototype, symbolToStringTag,
|
| - "Array Iterator", READ_ONLY | DONT_ENUM);
|
| -}
|
| -SetUpArrayIterator();
|
| -
|
| -
|
| -function ExtendArrayPrototype() {
|
| - %CheckIsBootstrapping();
|
| +%FunctionSetPrototype(ArrayIterator, new GlobalObject());
|
| +%FunctionSetInstanceClassName(ArrayIterator, 'Array Iterator');
|
|
|
| - InstallFunctions($Array.prototype, DONT_ENUM, [
|
| - // No 'values' since it breaks webcompat: http://crbug.com/409858
|
| - 'entries', ArrayEntries,
|
| - 'keys', ArrayKeys
|
| - ]);
|
| +InstallFunctions(ArrayIterator.prototype, DONT_ENUM, [
|
| + 'next', ArrayIteratorNext
|
| +]);
|
| +%FunctionSetName(ArrayIteratorIterator, '[Symbol.iterator]');
|
| +%AddNamedProperty(ArrayIterator.prototype, symbolIterator,
|
| + ArrayIteratorIterator, DONT_ENUM);
|
| +%AddNamedProperty(ArrayIterator.prototype, symbolToStringTag,
|
| + "Array Iterator", READ_ONLY | DONT_ENUM);
|
|
|
| - %AddNamedProperty($Array.prototype, symbolIterator, ArrayValues, DONT_ENUM);
|
| -}
|
| -ExtendArrayPrototype();
|
| +InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
|
| + // No 'values' since it breaks webcompat: http://crbug.com/409858
|
| + 'entries', ArrayEntries,
|
| + 'keys', ArrayKeys
|
| +]);
|
|
|
| -
|
| -function ExtendTypedArrayPrototypes() {
|
| - %CheckIsBootstrapping();
|
| -
|
| -macro TYPED_ARRAYS(FUNCTION)
|
| - FUNCTION(Uint8Array)
|
| - FUNCTION(Int8Array)
|
| - FUNCTION(Uint16Array)
|
| - FUNCTION(Int16Array)
|
| - FUNCTION(Uint32Array)
|
| - FUNCTION(Int32Array)
|
| - FUNCTION(Float32Array)
|
| - FUNCTION(Float64Array)
|
| - FUNCTION(Uint8ClampedArray)
|
| -endmacro
|
| +%AddNamedProperty(GlobalArray.prototype, symbolIterator, ArrayValues,
|
| + DONT_ENUM);
|
|
|
| macro EXTEND_TYPED_ARRAY(NAME)
|
| - %AddNamedProperty($NAME.prototype, 'entries', ArrayEntries, DONT_ENUM);
|
| - %AddNamedProperty($NAME.prototype, 'values', ArrayValues, DONT_ENUM);
|
| - %AddNamedProperty($NAME.prototype, 'keys', ArrayKeys, DONT_ENUM);
|
| - %AddNamedProperty($NAME.prototype, symbolIterator, ArrayValues, DONT_ENUM);
|
| + %AddNamedProperty(GlobalNAME.prototype, 'entries', ArrayEntries, DONT_ENUM);
|
| + %AddNamedProperty(GlobalNAME.prototype, 'values', ArrayValues, DONT_ENUM);
|
| + %AddNamedProperty(GlobalNAME.prototype, 'keys', ArrayKeys, DONT_ENUM);
|
| + %AddNamedProperty(GlobalNAME.prototype, symbolIterator, ArrayValues,
|
| + DONT_ENUM);
|
| endmacro
|
|
|
| - TYPED_ARRAYS(EXTEND_TYPED_ARRAY)
|
| -}
|
| -ExtendTypedArrayPrototypes();
|
| +TYPED_ARRAYS(EXTEND_TYPED_ARRAY)
|
| +
|
| +$iteratorCreateResultObject = CreateIteratorResultObject;
|
| +$arrayValues = ArrayValues;
|
| +
|
| +})();
|
|
|