Skip to content

Commit

Permalink
Ensure both non-empty paths throw in TypedArray slice.
Browse files Browse the repository at this point in the history
  • Loading branch information
rkirsling committed Sep 9, 2020
1 parent 5262628 commit 7a4127f
Showing 1 changed file with 28 additions and 27 deletions.
55 changes: 28 additions & 27 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -35129,33 +35129,34 @@ <h1>%TypedArray%.prototype.slice ( _start_, _end_ )</h1>
1. If _relativeEnd_ &lt; 0, let _final_ be max((_len_ + _relativeEnd_), 0); else let _final_ be min(_relativeEnd_, _len_).
1. Let _count_ be max(_final_ - _k_, 0).
1. Let _A_ be ? TypedArraySpeciesCreate(_O_, &laquo; _count_ &raquo;).
1. Let _srcName_ be the String value of _O_.[[TypedArrayName]].
1. Let _srcType_ be the Element Type value in <emu-xref href="#table-the-typedarray-constructors"></emu-xref> for _srcName_.
1. Let _targetName_ be the String value of _A_.[[TypedArrayName]].
1. Let _targetType_ be the Element Type value in <emu-xref href="#table-the-typedarray-constructors"></emu-xref> for _targetName_.
1. If _srcType_ is different from _targetType_, then
1. Let _n_ be 0.
1. Repeat, while _k_ &lt; _final_,
1. Let _Pk_ be ! ToString(_k_).
1. Let _kValue_ be ! Get(_O_, _Pk_).
1. Perform ! Set(_A_, ! ToString(_n_), _kValue_, *true*).
1. Set _k_ to _k_ + 1.
1. Set _n_ to _n_ + 1.
1. Else if _count_ &gt; 0, then
1. Let _srcBuffer_ be _O_.[[ViewedArrayBuffer]].
1. If IsDetachedBuffer(_srcBuffer_) is *true*, throw a *TypeError* exception.
1. Let _targetBuffer_ be _A_.[[ViewedArrayBuffer]].
1. Let _elementSize_ be the Element Size value specified in <emu-xref href="#table-the-typedarray-constructors"></emu-xref> for Element Type _srcType_.
1. NOTE: If _srcType_ and _targetType_ are the same, the transfer must be performed in a manner that preserves the bit-level encoding of the source data.
1. Let _srcByteOffset_ be _O_.[[ByteOffset]].
1. Let _targetByteIndex_ be _A_.[[ByteOffset]].
1. Let _srcByteIndex_ be (_k_ &times; _elementSize_) + _srcByteOffset_.
1. Let _limit_ be _targetByteIndex_ + _count_ &times; _elementSize_.
1. Repeat, while _targetByteIndex_ &lt; _limit_,
1. Let _value_ be GetValueFromBuffer(_srcBuffer_, _srcByteIndex_, ~Uint8~, *true*, ~Unordered~).
1. Perform SetValueInBuffer(_targetBuffer_, _targetByteIndex_, ~Uint8~, _value_, *true*, ~Unordered~).
1. Set _srcByteIndex_ to _srcByteIndex_ + 1.
1. Set _targetByteIndex_ to _targetByteIndex_ + 1.
1. If _count_ &gt; 0, then
1. If IsDetachedBuffer(_O_.[[ViewedArrayBuffer]]) is *true*, throw a *TypeError* exception.
1. Let _srcName_ be the String value of _O_.[[TypedArrayName]].
1. Let _srcType_ be the Element Type value in <emu-xref href="#table-the-typedarray-constructors"></emu-xref> for _srcName_.
1. Let _targetName_ be the String value of _A_.[[TypedArrayName]].
1. Let _targetType_ be the Element Type value in <emu-xref href="#table-the-typedarray-constructors"></emu-xref> for _targetName_.
1. If _srcType_ is different from _targetType_, then
1. Let _n_ be 0.
1. Repeat, while _k_ &lt; _final_,
1. Let _Pk_ be ! ToString(_k_).
1. Let _kValue_ be ! Get(_O_, _Pk_).
1. Perform ! Set(_A_, ! ToString(_n_), _kValue_, *true*).
1. Set _k_ to _k_ + 1.
1. Set _n_ to _n_ + 1.
1. Else,
1. Let _srcBuffer_ be _O_.[[ViewedArrayBuffer]].
1. Let _targetBuffer_ be _A_.[[ViewedArrayBuffer]].
1. Let _elementSize_ be the Element Size value specified in <emu-xref href="#table-the-typedarray-constructors"></emu-xref> for Element Type _srcType_.
1. NOTE: If _srcType_ and _targetType_ are the same, the transfer must be performed in a manner that preserves the bit-level encoding of the source data.
1. Let _srcByteOffset_ be _O_.[[ByteOffset]].
1. Let _targetByteIndex_ be _A_.[[ByteOffset]].
1. Let _srcByteIndex_ be (_k_ &times; _elementSize_) + _srcByteOffset_.
1. Let _limit_ be _targetByteIndex_ + _count_ &times; _elementSize_.
1. Repeat, while _targetByteIndex_ &lt; _limit_,
1. Let _value_ be GetValueFromBuffer(_srcBuffer_, _srcByteIndex_, ~Uint8~, *true*, ~Unordered~).
1. Perform SetValueInBuffer(_targetBuffer_, _targetByteIndex_, ~Uint8~, _value_, *true*, ~Unordered~).
1. Set _srcByteIndex_ to _srcByteIndex_ + 1.
1. Set _targetByteIndex_ to _targetByteIndex_ + 1.
1. Return _A_.
</emu-alg>
<p>This function is not generic. The *this* value must be an object with a [[TypedArrayName]] internal slot.</p>
Expand Down

0 comments on commit 7a4127f

Please sign in to comment.