Skip to content

Commit f27e735

Browse files
committed
Normative: Make index properties for immutable-backed TypedArrays non-configurable and non-writable
1 parent 4a264f2 commit f27e735

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

spec.emu

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,83 @@ contributors: Mark S. Miller, Richard Gibson
2020
<emu-clause id="sec-typedarray-exotic-objects" oldids="sec-integer-indexed-exotic-objects" number="5">
2121
<h1>TypedArray Exotic Objects</h1>
2222

23+
<emu-clause id="sec-typedarray-getownproperty" oldids="sec-integer-indexed-exotic-objects-getownproperty-p" type="internal method" number="1">
24+
<h1>
25+
[[GetOwnProperty]] (
26+
_P_: a property key,
27+
): a normal completion containing either a Property Descriptor or *undefined*
28+
</h1>
29+
<dl class="header">
30+
<dt>for</dt>
31+
<dd>a TypedArray _O_</dd>
32+
</dl>
33+
<emu-alg>
34+
1. If _P_ is a String, then
35+
1. Let _numericIndex_ be CanonicalNumericIndexString(_P_).
36+
1. If _numericIndex_ is not *undefined*, then
37+
1. Let _value_ be TypedArrayGetElement(_O_, _numericIndex_).
38+
1. If _value_ is *undefined*, return *undefined*.
39+
1. <ins>Let _mutable_ be *true*.</ins>
40+
1. <ins>If IsImmutableBuffer(_O_.[[ViewedArrayBuffer]]) is *true*, set _mutable_ to *false*.</ins>
41+
1. Return the PropertyDescriptor { [[Value]]: _value_, [[Writable]]: <del>*true*</del> <ins>_mutable_</ins>, [[Enumerable]]: *true*, [[Configurable]]: <del>*true*</del> <ins>_mutable_</ins> }.
42+
1. Return OrdinaryGetOwnProperty(_O_, _P_).
43+
</emu-alg>
44+
</emu-clause>
45+
46+
<emu-clause id="sec-typedarray-defineownproperty" oldids="sec-integer-indexed-exotic-objects-defineownproperty-p-desc" type="internal method" number="3">
47+
<h1>
48+
[[DefineOwnProperty]] (
49+
_P_: a property key,
50+
_Desc_: a Property Descriptor,
51+
): either a normal completion containing a Boolean or a throw completion
52+
</h1>
53+
<dl class="header">
54+
<dt>for</dt>
55+
<dd>a TypedArray _O_</dd>
56+
</dl>
57+
<emu-alg>
58+
1. If _P_ is a String, then
59+
1. Let _numericIndex_ be CanonicalNumericIndexString(_P_).
60+
1. If _numericIndex_ is not *undefined*, then
61+
1. If IsValidIntegerIndex(_O_, _numericIndex_) is *false*, return *false*.
62+
1. <ins>Let _mutable_ be *true*.</ins>
63+
1. <ins>If IsImmutableBuffer(_O_.[[ViewedArrayBuffer]]) is *true*, set _mutable_ to *false*.</ins>
64+
1. If _Desc_ has a [[Configurable]] field and _Desc_.[[Configurable]] is <del>*false*</del> <ins>not _mutable_</ins>, return *false*.
65+
1. If _Desc_ has an [[Enumerable]] field and _Desc_.[[Enumerable]] is *false*, return *false*.
66+
1. If IsAccessorDescriptor(_Desc_) is *true*, return *false*.
67+
1. If _Desc_ has a [[Writable]] field and _Desc_.[[Writable]] is <del>*false*</del> <ins>not _mutable_</ins>, return *false*.
68+
1. <ins>If _Desc_ has a [[Value]] field and _mutable_ is *false* and SameValue(_Desc_.[[Value]], TypedArrayGetElement(_O_, _numericIndex_)) is *false*, return *false*.</ins>
69+
1. If _Desc_ has a [[Value]] field <ins>and _mutable_ is *true*</ins>, perform ? TypedArraySetElement(_O_, _numericIndex_, _Desc_.[[Value]]).
70+
1. Return *true*.
71+
1. Return ! OrdinaryDefineOwnProperty(_O_, _P_, _Desc_).
72+
</emu-alg>
73+
</emu-clause>
74+
75+
<emu-clause id="sec-typedarray-set" oldids="sec-integer-indexed-exotic-objects-set-p-v-receiver" type="internal method" number="5">
76+
<h1>
77+
[[Set]] (
78+
_P_: a property key,
79+
_V_: an ECMAScript language value,
80+
_Receiver_: an ECMAScript language value,
81+
): either a normal completion containing a Boolean or a throw completion
82+
</h1>
83+
<dl class="header">
84+
<dt>for</dt>
85+
<dd>a TypedArray _O_</dd>
86+
</dl>
87+
<emu-alg>
88+
1. If _P_ is a String, then
89+
1. Let _numericIndex_ be CanonicalNumericIndexString(_P_).
90+
1. If _numericIndex_ is not *undefined*, then
91+
1. If SameValue(_O_, _Receiver_) is *true*, then
92+
1. <ins>IsValidIntegerIndex(_O_, _numericIndex_) is *true* and IsImmutableBuffer(_O_.[[ViewedArrayBuffer]]) is *true*, return *false*.</ins>
93+
1. Perform ? TypedArraySetElement(_O_, _numericIndex_, _V_).
94+
1. Return *true*.
95+
1. If IsValidIntegerIndex(_O_, _numericIndex_) is *false*, return *true*.
96+
1. Return ? OrdinarySet(_O_, _P_, _V_, _Receiver_).
97+
</emu-alg>
98+
</emu-clause>
99+
23100
<emu-clause id="sec-typedarraysetelement" oldids="sec-integerindexedelementset" type="abstract operation" number="16">
24101
<h1>
25102
TypedArraySetElement (

0 commit comments

Comments
 (0)