You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spec.emu
+27-94
Original file line number
Diff line number
Diff line change
@@ -105,8 +105,11 @@ contributors: Mark S. Miller, Richard Gibson
105
105
1. If _Desc_ has an [[Enumerable]] field and _Desc_.[[Enumerable]] is *false*, return *false*.
106
106
1. If IsAccessorDescriptor(_Desc_) is *true*, return *false*.
107
107
1. If _Desc_ has a [[Writable]] field and _Desc_.[[Writable]] is <del>*false*</del> <ins>not _mutable_</ins>, return *false*.
108
-
1. <ins>If _Desc_ has a [[Value]] field and _mutable_ is *false* and SameValue(_Desc_.[[Value]], TypedArrayGetElement(_O_, _numericIndex_)) is *false*, return *false*.</ins>
109
-
1. If _Desc_ has a [[Value]] field <ins>and _mutable_ is *true*</ins>, perform ? TypedArraySetElement(_O_, _numericIndex_, _Desc_.[[Value]]).
108
+
1. <del>If _Desc_ has a [[Value]] field, perform ? TypedArraySetElement(_O_, _numericIndex_, _Desc_.[[Value]]).</del>
109
+
1. <ins>If _Desc_ has a [[Value]] field, then</ins>
110
+
1. <ins>NOTE: Attempting to redefine an immutable value always fails, even if the new value would be cast to the current value.</ins>
111
+
1. <ins>If _mutable_ is *false* and SameValue(_Desc_.[[Value]], TypedArrayGetElement(_O_, _numericIndex_)) is *false*, return *false*.</ins>
112
+
1. <ins>If _mutable_ is *true*, perform ? TypedArraySetElement(_O_, _numericIndex_, _Desc_.[[Value]]).</ins>
@@ -128,8 +131,9 @@ contributors: Mark S. Miller, Richard Gibson
128
131
1. If _P_ is a String, then
129
132
1. Let _numericIndex_ be CanonicalNumericIndexString(_P_).
130
133
1. If _numericIndex_ is not *undefined*, then
134
+
1. <ins>NOTE: TypedArray instances restrict own and inherited canonical numeric string properties to integer indices valid for their backing buffers, but assignment failures for canonical numeric string properties are only reported when the buffer is immutable.</ins>
135
+
1. <ins>If IsImmutableBuffer(_O_.[[ViewedArrayBuffer]]) is *true*, return *false*.</ins>
131
136
1. If SameValue(_O_, _Receiver_) is *true*, then
132
-
1. <ins>IsValidIntegerIndex(_O_, _numericIndex_) is *true* and IsImmutableBuffer(_O_.[[ViewedArrayBuffer]]) is *true*, return *false*.</ins>
1. If IsValidIntegerIndex(_O_, _numericIndex_) is *false*, return *true*.
@@ -148,9 +152,10 @@ contributors: Mark S. Miller, Richard Gibson
148
152
<dl class="header">
149
153
</dl>
150
154
<emu-alg>
155
+
1. <ins>Assert: IsImmutableBuffer(_O_.[[ViewedArrayBuffer]]) is *false*.</ins>
151
156
1. If _O_.[[ContentType]] is ~bigint~, let _numValue_ be ? ToBigInt(_value_).
152
157
1. Otherwise, let _numValue_ be ? ToNumber(_value_).
153
-
1. If IsValidIntegerIndex(_O_, _index_) is *true* <ins>and IsImmutableBuffer(_O_.[[ViewedArrayBuffer]]) is *false*</ins>, then
158
+
1. If IsValidIntegerIndex(_O_, _index_) is *true*, then
154
159
1. Let _offset_ be _O_.[[ByteOffset]].
155
160
1. Let _elementSize_ be TypedArrayElementSize(_O_).
156
161
1. Let _byteIndexInBuffer_ be (ℝ(_index_) × _elementSize_) + _offset_.
@@ -159,7 +164,7 @@ contributors: Mark S. Miller, Richard Gibson
159
164
1. Return ~unused~.
160
165
</emu-alg>
161
166
<emu-note>
162
-
<p>This operation always appears to succeed, but it has no effect when attempting to write past the end of a TypedArray or to a TypedArray which is backed by a detached <ins>or immutable</ins> ArrayBuffer.</p>
167
+
<p>This operation always appears to succeed, but it has no effect when attempting to write past the end of a TypedArray or to a TypedArray which is backed by a detached ArrayBuffer.</p>
163
168
</emu-note>
164
169
</emu-clause>
165
170
</emu-clause>
@@ -284,95 +289,23 @@ contributors: Mark S. Miller, Richard Gibson
_targetOffset_: a non-negative integer or +∞,
293
-
_source_: a TypedArray,
294
-
): either a normal completion containing ~unused~ or a throw completion
295
-
</h1>
296
-
<dl class="header">
297
-
<dt>description</dt>
298
-
<dd>It sets multiple values in _target_, starting at index _targetOffset_, reading the values from _source_.</dd>
299
-
</dl>
300
-
<emu-alg>
301
-
1. Let _targetBuffer_ be _target_.[[ViewedArrayBuffer]].
302
-
1. Let _targetRecord_ be MakeTypedArrayWithBufferWitnessRecord(_target_, ~seq-cst~).
303
-
1. If IsTypedArrayOutOfBounds(_targetRecord_) is *true*, throw a *TypeError* exception.
304
-
1. <ins>If IsImmutableBuffer(_target_.[[ViewedArrayBuffer]]) is *true*, throw a *TypeError* exception.</ins>
305
-
1. Let _targetLength_ be TypedArrayLength(_targetRecord_).
306
-
1. Let _srcBuffer_ be _source_.[[ViewedArrayBuffer]].
307
-
1. Let _srcRecord_ be MakeTypedArrayWithBufferWitnessRecord(_source_, ~seq-cst~).
308
-
1. If IsTypedArrayOutOfBounds(_srcRecord_) is *true*, throw a *TypeError* exception.
309
-
1. Let _srcLength_ be TypedArrayLength(_srcRecord_).
310
-
1. Let _targetType_ be TypedArrayElementType(_target_).
311
-
1. Let _targetElementSize_ be TypedArrayElementSize(_target_).
312
-
1. Let _targetByteOffset_ be _target_.[[ByteOffset]].
313
-
1. Let _srcType_ be TypedArrayElementType(_source_).
314
-
1. Let _srcElementSize_ be TypedArrayElementSize(_source_).
315
-
1. Let _srcByteOffset_ be _source_.[[ByteOffset]].
316
-
1. If _targetOffset_ = +∞, throw a *RangeError* exception.
317
-
1. If _srcLength_ + _targetOffset_ > _targetLength_, throw a *RangeError* exception.
318
-
1. If _target_.[[ContentType]] is not _source_.[[ContentType]], throw a *TypeError* exception.
319
-
1. If IsSharedArrayBuffer(_srcBuffer_) is *true*, IsSharedArrayBuffer(_targetBuffer_) is *true*, and _srcBuffer_.[[ArrayBufferData]] is _targetBuffer_.[[ArrayBufferData]], let _sameSharedArrayBuffer_ be *true*; otherwise, let _sameSharedArrayBuffer_ be *false*.
320
-
1. If SameValue(_srcBuffer_, _targetBuffer_) is *true* or _sameSharedArrayBuffer_ is *true*, then
321
-
1. Let _srcByteLength_ be TypedArrayByteLength(_srcRecord_).
322
-
1. Set _srcBuffer_ to ? CloneArrayBuffer(_srcBuffer_, _srcByteOffset_, _srcByteLength_).
323
-
1. Let _srcByteIndex_ be 0.
324
-
1. Else,
325
-
1. Let _srcByteIndex_ be _srcByteOffset_.
326
-
1. Let _targetByteIndex_ be (_targetOffset_ × _targetElementSize_) + _targetByteOffset_.
327
-
1. Let _limit_ be _targetByteIndex_ + (_targetElementSize_ × _srcLength_).
328
-
1. If _srcType_ is _targetType_, then
329
-
1. NOTE: The transfer must be performed in a manner that preserves the bit-level encoding of the source data.
330
-
1. Repeat, while _targetByteIndex_ < _limit_,
331
-
1. Let _value_ be GetValueFromBuffer(_srcBuffer_, _srcByteIndex_, ~uint8~, *true*, ~unordered~).
<p>This method sets multiple values in this _TypedArray_, reading the values from _source_. The details differ based upon the type of _source_. The optional _offset_ value indicates the first element index in this _TypedArray_ where values are written. If omitted, it is assumed to be 0.</p>
293
+
<p>It performs the following steps when called:</p>
294
+
<emu-alg>
295
+
1. Let _target_ be the *this* value.
296
+
1. <ins>NOTE: The following steps could be simplified by using ? ValidateTypedArray(_target_, ~seq-cst~, ~write~) and refactoring SetTypedArrayFromTypedArray and SetTypedArrayFromArrayLike to accept the result as input, but that would observably change the calls into user code and thrown error when IsTypedArrayOutOfBounds returns *true* and _offset_ is negative. Regardless, such a change is still worth pursuing if possible.</ins>
0 commit comments