diff --git a/spec.html b/spec.html index 2f1ff994d2..7b4c0a6450 100644 --- a/spec.html +++ b/spec.html @@ -30961,7 +30961,7 @@

%TypedArray%()

1. Let _super_ be ? _here_.[[GetPrototypeOf]](). 1. If IsConstructor (_super_) is *false*, throw a *TypeError* exception. 1. Let _argumentsList_ be the _argumentsList_ argument of the [[Construct]] internal method that invoked the active function. - 1. Return Construct(_super_, _argumentsList_, NewTarget). + 1. Return ? Construct(_super_, _argumentsList_, NewTarget). @@ -30980,25 +30980,30 @@

%TypedArray%.from ( _source_ [ , _mapfn_ [ , _thisArg_ ] ] )

1. Let _C_ be the *this* value. 1. If IsConstructor(_C_) is *false*, throw a *TypeError* exception. - 1. If _mapfn_ was supplied, let _f_ be _mapfn_; otherwise let _f_ be *undefined*. - 1. If _f_ is not *undefined*, then - 1. If IsCallable(_f_) is *false*, throw a *TypeError* exception. - 1. If _thisArg_ was supplied, let _t_ be _thisArg_; else let _t_ be *undefined*. - 1. Return TypedArrayFrom(_C_, _source_, _f_, _t_). + 1. If _mapfn_ was supplied and _mapfn_ is not *undefined*, then + 1. If IsCallable(_mapfn_) is *false*, throw a *TypeError* exception. + 1. Let _mapping_ be *true*. + 1. Else, let _mapping_ be *false*. + 1. If _thisArg_ was supplied, let _T_ be _thisArg_; else let _T_ be *undefined*. + 1. Let _arrayLike_ be ? IterableToArrayLike(_source_). + 1. Let _len_ be ? ToLength(? Get(_arrayLike_, `"length"`)). + 1. Let _targetObj_ be ? TypedArrayCreate(_C_, «_len_»). + 1. Let _k_ be 0. + 1. Repeat, while _k_ < _len_ + 1. Let _Pk_ be ! ToString(_k_). + 1. Let _kValue_ be ? Get(_arrayLike_, _Pk_). + 1. If _mapping_ is *true*, then + 1. Let _mappedValue_ be ? Call(_mapfn_, _T_, « _kValue_, _k_ »). + 1. Else, let _mappedValue_ be _kValue_. + 1. Perform ? Set(_targetObj_, _Pk_, _mappedValue_, *true*). + 1. Increase _k_ by 1. + 1. Return _targetObj_. - - -

Runtime Semantics: TypedArrayFrom( _constructor_, _items_, _mapfn_, _thisArg_ )

-

When the TypedArrayFrom abstract operation is called with arguments _constructor_, _items_, _mapfn_, and _thisArg_, the following steps are taken:

+ +

Runtime Semantics: IterableToArrayLike( _items_ )

+

The abstract operation IterableToArrayLike performs the following steps:

- 1. Let _C_ be _constructor_. - 1. Assert: IsConstructor(_C_) is *true*. - 1. Assert: _mapfn_ is either a callable Object or *undefined*. - 1. If _mapfn_ is *undefined*, let _mapping_ be *false*. - 1. Else, - 1. Let _T_ be _thisArg_. - 1. Let _mapping_ be *true*. 1. Let _usingIterator_ be ? GetMethod(_items_, @@iterator). 1. If _usingIterator_ is not *undefined*, then 1. Let _iterator_ be ? GetIterator(_items_, _usingIterator_). @@ -31009,33 +31014,9 @@

Runtime Semantics: TypedArrayFrom( _constructor_, _items_, _mapfn_, _thisArg 1. If _next_ is not *false*, then 1. Let _nextValue_ be ? IteratorValue(_next_). 1. Append _nextValue_ to the end of the List _values_. - 1. Let _len_ be the number of elements in _values_. - 1. Let _targetObj_ be ? TypedArrayCreate(_C_, «_len_»). - 1. Let _k_ be 0. - 1. Repeat, while _k_ < _len_ - 1. Let _Pk_ be ! ToString(_k_). - 1. Let _kValue_ be the first element of _values_ and remove that element from _values_. - 1. If _mapping_ is *true*, then - 1. Let _mappedValue_ be ? Call(_mapfn_, _T_, « _kValue_, _k_ »). - 1. Else, let _mappedValue_ be _kValue_. - 1. Perform ? Set(_targetObj_, _Pk_, _mappedValue_, *true*). - 1. Increase _k_ by 1. - 1. Assert: _values_ is now an empty List. - 1. Return _targetObj_. - 1. Assert: _items_ is not an Iterable so assume it is an array-like object. - 1. Let _arrayLike_ be ? ToObject(_items_). - 1. Let _len_ be ? ToLength(? Get(_arrayLike_, `"length"`)). - 1. Let _targetObj_ be ? TypedArrayCreate(_C_, «_len_»). - 1. Let _k_ be 0. - 1. Repeat, while _k_ < _len_ - 1. Let _Pk_ be ! ToString(_k_). - 1. Let _kValue_ be ? Get(_arrayLike_, _Pk_). - 1. If _mapping_ is *true*, then - 1. Let _mappedValue_ be ? Call(_mapfn_, _T_, « _kValue_, _k_ »). - 1. Else, let _mappedValue_ be _kValue_. - 1. Perform ? Set(_targetObj_, _Pk_, _mappedValue_, *true*). - 1. Increase _k_ by 1. - 1. Return _targetObj_. + 1. Return CreateArrayFromList(_values_). + 1. Assert: _items_ is not an Iterable so assume it is already an array-like object. + 1. Return ? ToObject(_items_). @@ -31545,7 +31526,7 @@

%TypedArray%.prototype.subarray( [ _begin_ [ , _end_ ] ] )

1. Let _srcByteOffset_ be the value of _O_'s [[ByteOffset]] internal slot. 1. Let _beginByteOffset_ be _srcByteOffset_ + _beginIndex_ × _elementSize_. 1. Let _argumentsList_ be «_buffer_, _beginByteOffset_, _newLength_». - 1. Return TypedArraySpeciesCreate(_O_, _argumentsList_). + 1. Return ? TypedArraySpeciesCreate(_O_, _argumentsList_).

The `length` property of the `subarray` method is 2.

This function is not generic. The *this* value must be an object with a [[TypedArrayName]] internal slot.

@@ -31615,7 +31596,7 @@

_TypedArray_ ( )

This description applies only if the _TypedArray_ function is called with no arguments.

1. If NewTarget is *undefined*, throw a *TypeError* exception. - 1. Return AllocateTypedArray(_TypedArray_.[[TypedArrayConstructorName]], NewTarget, %TypedArrayPrototype%, 0). + 1. Return ? AllocateTypedArray(_TypedArray_.[[TypedArrayConstructorName]], NewTarget, "%TypedArrayPrototype%", 0).
@@ -31631,15 +31612,15 @@

_TypedArray_ ( _length_ )

1. Let _numberLength_ be ToNumber(_length_). 1. Let _elementLength_ be ? ToLength(_numberLength_). 1. If SameValueZero(_numberLength_, _elementLength_) is *false*, throw a *RangeError* exception. - 1. Return AllocateTypedArray(_TypedArray_.[[TypedArrayConstructorName]], NewTarget, %TypedArrayPrototype%, _elementLength_). + 1. Return ? AllocateTypedArray(_TypedArray_.[[TypedArrayConstructorName]], NewTarget, "%TypedArrayPrototype%", _elementLength_).

Runtime Semantics: AllocateTypedArray (_constructorName_, _newTarget_, _defaultProto_, _length_ )

-

The abstract operation AllocateTypedArray with arguments _constructorName_, _newTarget_, _defaultProto_ and optional argument _length_ is used to validate and create an instance of a TypedArray constructor. _constructorName_ is required to be the name of a TypedArray in . If the _length_ argument is passed an ArrayBuffer of that length is also allocated and associated with the new TypedArray instance. AllocateTypedArray provides common semantics that is used by all of the _TypeArray_ overloads and other methods. AllocateTypedArray performs the following steps:

+

The abstract operation AllocateTypedArray with arguments _constructorName_, _newTarget_, _defaultProto_ and optional argument _length_ is used to validate and create an instance of a TypedArray constructor. _constructorName_ is required to be the name of a TypedArray constructor in . If the _length_ argument is passed an ArrayBuffer of that length is also allocated and associated with the new TypedArray instance. AllocateTypedArray provides common semantics that is used by all of the _TypedArray_ overloads. AllocateTypedArray performs the following steps:

- 1. Let _proto_ be GetPrototypeFromConstructor(_newTarget_, _defaultProto_). + 1. Let _proto_ be ? GetPrototypeFromConstructor(_newTarget_, _defaultProto_). 1. Let _obj_ be IntegerIndexedObjectCreate (_proto_, «[[ViewedArrayBuffer]], [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). 1. Assert: The [[ViewedArrayBuffer]] internal slot of _obj_ is *undefined*. 1. Set _obj_'s [[TypedArrayName]] internal slot to _constructorName_. @@ -31648,16 +31629,29 @@

Runtime Semantics: AllocateTypedArray (_constructorName_, _newTarget_, _defa 1. Set _obj_'s [[ByteOffset]] internal slot to 0. 1. Set _obj_'s [[ArrayLength]] internal slot to 0. 1. Else, - 1. Let _elementSize_ be the Element Size value in for _constructorName_. - 1. Let _byteLength_ be _elementSize_ × _length_. - 1. Let _data_ be ? AllocateArrayBuffer(%ArrayBuffer%, _byteLength_). - 1. Set _obj_'s [[ViewedArrayBuffer]] internal slot to _data_. - 1. Set _obj_'s [[ByteLength]] internal slot to _byteLength_. - 1. Set _obj_'s [[ByteOffset]] internal slot to 0. - 1. Set _obj_'s [[ArrayLength]] internal slot to _length_. + 1. Perform ? AllocateTypedArrayBuffer(_obj_, _length_). 1. Return _obj_. + + +

Runtime Semantics: AllocateTypedArrayBuffer ( _O_, _length_ )

+

The abstract operation AllocateTypedArrayBuffer with arguments _O_ and _length_ allocates and associates an ArrayBuffer with the TypedArray instance _O_. It performs the following steps:

+ + 1. Assert: _O_ is an Object that has a [[ViewedArrayBuffer]] internal slot. + 1. Assert: The [[ViewedArrayBuffer]] internal slot of _O_ is *undefined*. + 1. Assert: _length_ ≥ 0. + 1. Let _constructorName_ be the String value of _O_'s [[TypedArrayName]] internal slot. + 1. Let _elementSize_ be the Element Size value in for _constructorName_. + 1. Let _byteLength_ be _elementSize_ × _length_. + 1. Let _data_ be ? AllocateArrayBuffer(%ArrayBuffer%, _byteLength_). + 1. Set _O_'s [[ViewedArrayBuffer]] internal slot to _data_. + 1. Set _O_'s [[ByteLength]] internal slot to _byteLength_. + 1. Set _O_'s [[ByteOffset]] internal slot to 0. + 1. Set _O_'s [[ArrayLength]] internal slot to _length_. + 1. Return _O_. + +
@@ -31668,7 +31662,7 @@

_TypedArray_ ( _typedArray_ )

1. Assert: Type(_typedArray_) is Object and _typedArray_ has a [[TypedArrayName]] internal slot. 1. If NewTarget is *undefined*, throw a *TypeError* exception. - 1. Let _O_ be ? AllocateTypedArray(_TypedArray_.[[TypedArrayConstructorName]], NewTarget, %TypedArrayPrototype%). + 1. Let _O_ be ? AllocateTypedArray(_TypedArray_.[[TypedArrayConstructorName]], NewTarget, "%TypedArrayPrototype%"). 1. Let _srcArray_ be _typedArray_. 1. Let _srcData_ be the value of _srcArray_'s [[ViewedArrayBuffer]] internal slot. 1. If IsDetachedBuffer(_srcData_) is *true*, throw a *TypeError* exception. @@ -31712,7 +31706,17 @@

_TypedArray_ ( _object_ )

1. Assert: Type(_object_) is Object and _object_ does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] internal slot. 1. If NewTarget is *undefined*, throw a *TypeError* exception. - 1. Return TypedArrayFrom(NewTarget, _object_, *undefined*, *undefined*). + 1. Let _O_ be ? AllocateTypedArray(_TypedArray_.[[TypedArrayConstructorName]], NewTarget, "%TypedArrayPrototype%"). + 1. Let _arrayLike_ be ? IterableToArrayLike(_object_). + 1. Let _len_ be ? ToLength(? Get(_arrayLike_, `"length"`)). + 1. Perform ? AllocateTypedArrayBuffer(_O_, _len_). + 1. Let _k_ be 0. + 1. Repeat, while _k_ < _len_ + 1. Let _Pk_ be ! ToString(_k_). + 1. Let _kValue_ be ? Get(_arrayLike_, _Pk_). + 1. Perform ? Set(_O_, _Pk_, _kValue_, *true*). + 1. Increase _k_ by 1. + 1. Return _O_.
@@ -31724,7 +31728,7 @@

_TypedArray_ ( _buffer_ [ , _byteOffset_ [ , _length_ ] ] )

1. Assert: Type(_buffer_) is Object and _buffer_ has an [[ArrayBufferData]] internal slot. 1. If NewTarget is *undefined*, throw a *TypeError* exception. - 1. Let _O_ be ? AllocateTypedArray(_TypedArray_.[[TypedArrayConstructorName]], NewTarget, %TypedArrayPrototype%). + 1. Let _O_ be ? AllocateTypedArray(_TypedArray_.[[TypedArrayConstructorName]], NewTarget, "%TypedArrayPrototype%"). 1. Let _constructorName_ be the String value of _O_'s [[TypedArrayName]] internal slot. 1. Let _elementSize_ be the Number value of the Element Size value in for _constructorName_. 1. Let _offset_ be ? ToInteger(_byteOffset_). @@ -31749,8 +31753,9 @@

_TypedArray_ ( _buffer_ [ , _byteOffset_ [ , _length_ ] ] )

- +

TypedArrayCreate( _constructor_, _argumentList_ )

+

The abstract operation TypedArrayCreate with arguments _constructor_ and _argumentList_ is used to specify the creation of a new TypedArray object using a constructor function. It performs the following steps:

1. Let _newTypedArray_ be ? Construct(_constructor_, _argumentList_). 1. Perform ? ValidateTypedArray(_newTypedArray_). @@ -31760,10 +31765,11 @@

TypedArrayCreate( _constructor_, _argumentList_ )

- +

TypedArraySpeciesCreate( _exemplar_, _argumentList_ )

+

The abstract operation TypedArraySpeciesCreate with arguments _exemplar_ and _argumentList_ is used to specify the creation of a new TypedArray object using a constructor function that is derived from _exemplar_. It performs the following steps:

- 1. Assert: _exemplar_ has a [[TypedArrayName]] internal slot. + 1. Assert: _exemplar_ is an Object that has a [[TypedArrayName]] internal slot. 1. Let _defaultConstructor_ be the intrinsic object listed in column one of for the value of _exemplar_'s [[TypedArrayName]] internal slot. 1. Let _constructor_ be ? SpeciesConstructor(_exemplar_, _defaultConstructor_). 1. Return ? TypedArrayCreate(_constructor_, _argumentList_).