-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathspec.emu
210 lines (193 loc) · 10 KB
/
spec.emu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<pre class="metadata">
title: Slice notation
status: proposal
stage: 1
location: https://github.com/tc39/proposal-slice-notation
copyright: false
contributors: Sathya Gunasekaran
</pre>
<emu-clause id="sec-well-known-symbols">
<h1>Well-Known Symbols</h1>
<p>Well-known symbols are built-in Symbol values that are explicitly referenced by algorithms of this specification. They are typically used as the keys of properties whose values serve as extension points of a specification algorithm. Unless otherwise specified, well-known symbols values are shared by all realms (<emu-xref href="#sec-code-realms"></emu-xref>).</p>
<p>Within this specification a well-known symbol is referred to by using a notation of the form @@name, where “name” is one of the values listed in <emu-xref href="#table-1"></emu-xref>.</p>
<emu-table id="table-1" caption="Well-known Symbols">
<table>
<tbody>
<tr>
<th>
Specification Name
</th>
<th>
[[Description]]
</th>
<th>
Value and Purpose
</th>
</tr>
<tr>
<td>
<ins><dfn>@@slice</dfn></ins>
</td>
<td>
<ins>*"Symbol.slice"*</ins>
</td>
<td>
<ins>A method that slices the receiver based on a start and end index.</ins>
</td>
</tr>
</tbody>
</table>
</emu-table>
</emu-clause>
<emu-clause id="sec-properties-of-the-symbol-constructor">
<h1>Properties of the Symbol Constructor</h1>
<ins class=block><emu-clause id="sec-symbol.slice">
<h1>Symbol.slice</h1>
<p>The initial value of `Symbol.slice` is the well known symbol @@slice (<emu-xref href="#table-1"></emu-xref>).</p>
<p>This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *false* }.</p>
</emu-clause></ins>
</emu-clause>
<emu-clause id="sec-properties-of-the-array-prototype-object">
<h1>Properties of the Array Prototype</h1>
<emu-clause id="sec-array.prototype-@@slice">
<h1>Array.prototype [ @@slice ] (start, end)</h1>
<p> The initial value of the @@slice property is the same function object as the initial value of the `Array.prototype.slice` property. </p>
</emu-clause>
</emu-clause>
<emu-clause id="sec-properties-of-the-%typedarrayprototype%-object">
<h1>Properties of the %TypedArray.prototype% Object</h1>
<emu-clause id="sec-properties-of-the-%typedarrayprototype%-@@slice">
<h1>%TypedArray%.prototype [ @@slice ] (start, end)</h1>
<p> The initial value of the @@slice property is the same function object as the initial value of the `%TypedArray%.prototype.slice` property. </p>
</emu-clause>
</emu-clause>
<emu-clause id="sec-properties-of-the-arraybuffer-prototype-object">
<h1>Properties of the ArrayBuffer Prototype Object</h1>
<emu-clause id="sec-properties-of-the-arraybuffer-prototype-@@slice">
<h1>ArrayBuffer.prototype [ @@slice ] (start, end)</h1>
<p> The initial value of the @@slice property is the same function object as the initial value of the `ArrayBuffer.prototype.slice` property. </p>
</emu-clause>
</emu-clause>
<emu-clause id="sec-properties-of-the-sharedarraybuffer-prototype-object">
<h1>Properties of the SharedArrayBuffer Prototype Object</h1>
<emu-clause id="sec-properties-of-the-sharedarraybuffer-prototype-@@slice">
<h1>SharedArrayBuffer.prototype [ @@slice ] (start, end)</h1>
<p> The initial value of the @@slice property is the same function object as the initial value of the `SharedArrayBuffer.prototype.slice` property. </p>
</emu-clause>
</emu-clause>
<emu-clause id="sec-left-hand-side-expressions">
<h1>Left-Hand-Side Expressions</h1>
<h2>Syntax</h2>
<emu-grammar>
MemberExpression[Yield, Await] :
PrimaryExpression[?Yield, ?Await]
MemberExpression[?Yield, ?Await] `[` Expression[+In, ?Yield, ?Await] `]`
MemberExpression[?Yield, ?Await] `.` IdentifierName
MemberExpression[?Yield, ?Await] TemplateLiteral[?Yield, ?Await]
SuperProperty[?Yield, ?Await]
MetaProperty
`new` MemberExpression[?Yield, ?Await] Arguments[?Yield, ?Await]
<ins>MemberExpression[?Yield, ?Await] `[` AssignmentExpression[+In, ?Yield, ?Await]? `:` AssignmentExpression[+In, ?Yield, ?Await]? `]` </ins>
</emu-grammar>
<emu-grammar>
CallExpression[Yield, Await] :
CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] #callcover
SuperCall[?Yield, ?Await]
ImportCall[?Yield, ?Await]
CallExpression[?Yield, ?Await] Arguments[?Yield, ?Await]
CallExpression[?Yield, ?Await] `[` Expression[+In, ?Yield, ?Await] `]`
CallExpression[?Yield, ?Await] `.` IdentifierName
CallExpression[?Yield, ?Await] TemplateLiteral[?Yield, ?Await, +Tagged]
<ins>CallExpression[?Yield, ?Await] `[` AssignmentExpression[+In, ?Yield, ?Await]? `:` AssignmentExpression[+In, ?Yield, ?Await]? `]`</ins>
</emu-grammar>
<emu-grammar>
OptionalExpression[Yield, Await] :
MemberExpression[?Yield, ?Await] OptionalChain[?Yield, ?Await]
CallExpression[?Yield, ?Await] OptionalChain[?Yield, ?Await]
OptionalExpression[?Yield, ?Await] OptionalChain[?Yield, ?Await]
OptionalChain[Yield, Await] :
`?.` `[` Expression[+In, ?Yield, ?Await] `]`
`?.` IdentifierName
`?.` Arguments[?Yield, ?Await]
`?.` TemplateLiteral[?Yield, ?Await, +Tagged]
<ins>`?.` `[` AssignmentExpression[+In, ?Yield, ?Await]? `:` AssignmentExpression[+In, ?Yield, ?Await]? `]`</ins>
OptionalChain[?Yield, ?Await] `[` Expression[+In, ?Yield, ?Await] `]`
OptionalChain[?Yield, ?Await] `.` IdentifierName
OptionalChain[?Yield, ?Await] Arguments[?Yield, ?Await]
OptionalChain[?Yield, ?Await] TemplateLiteral[?Yield, ?Await, +Tagged]
<ins>OptionalChain[?Yield, ?Await] `[` AssignmentExpression[+In, ?Yield, ?Await]? `:` AssignmentExpression[+In, ?Yield, ?Await]? `]`</ins>
</emu-grammar>
<emu-clause oldids="sec-static-semantics-static-semantics-isvalidsimpleassignmenttarget" id="sec-static-semantics-static-semantics-assignmenttargettype">
<h1>Static Semantics: AssignmentTargetType</h1>
<emu-see-also-para op="AssignmentTargetType"></emu-see-also-para>
<emu-grammar>
MemberExpression :
MemberExpression `[` AssignmentExpression? `:` AssignmentExpression? `]`
CallExpression :
CallExpression `[` AssignmentExpression? `:` AssignmentExpression? `]`
</emu-grammar>
<emu-alg>
1. Return ~invalid~.
</emu-alg>
</emu-clause>
<emu-clause id="sec-slice-notation-runtime-semantics-evaluation">
<h1>Runtime Semantics</h1>
<emu-clause id="sec-evaluate-slice-notation" aoid="EvaluateSliceNotation">
<h1>Runtime Semantics: EvaluateSliceNotation ( _baseValue_, _startExpression_, _endExpression_ )</h1>
<p>The abstract operation EvaluateSliceNotation takes as arguments a _baseValue_ (an ECMAScript langauge value), _startExpression_ (a Parse Node), and _endExpression_ (a Parse Node). It performs the following steps:</p>
<emu-alg>
1. If the _startExpression_ is present, then
1. Let _startRef_ be the result of evaluating the _startExpression_.
1. Let _start_ be ? GetValue(_startRef_).
1. Else,
1. Let _start_ be 0.
1. If the _endExpression_ is present, then
1. Let _endRef_ be the result of evaluating the _endExpression_.
1. Let _end_ be ? GetValue(_endRef_).
1. Else,
1. Let _end_ be *undefined*.
1. Let _base_ be ? ToObject(_baseValue_).
1. Let _method_ be ? GetMethod(_base_, @@slice).
1. Return ? Call(_method_, _base_, « _start_, _end_ »).
</emu-alg>
</emu-clause>
<emu-clause id="sec-member-expression-slice-notation">
<h1>Runtime Semantics: Evaluation</h1>
<emu-grammar> MemberExpression : MemberExpression `[` AssignmentExpression? `:` AssignmentExpression? `]`</emu-grammar>
<emu-alg>
1. Let _baseReference_ be the result of evaluating |MemberExpression|.
1. Let _baseValue_ be ? GetValue(_baseReference_).
1. Let _startExpression_ be the first |AssignmentExpression|.
1. Let _endExpression_ be the second |AssignmentExpression|.
1. Return ? EvaluateSliceNotation(_baseReference_, _startExpression_, _endExpression_).
</emu-alg>
<emu-grammar> CallExpression : CallExpression `[` AssignmentExpression? `:` AssignmentExpression? `]`</emu-grammar>
<emu-alg>
1. Let _baseReference_ be the result of evaluating |CallExpression|.
1. Let _baseValue_ be ? GetValue(_baseReference_).
1. Let _startExpression_ be the first |AssignmentExpression|.
1. Let _endExpression_ be the second |AssignmentExpression|.
1. Return ? EvaluateSliceNotation(_baseValue_, _startExpression_, _endExpression_).
</emu-alg>
</emu-clause>
<emu-clause id="sec-optional-chaining-chain-evaluation">
<h1>Runtime Semantics: ChainEvaluation</h1>
<p>With parameters _baseValue_ and _baseReference_.</p>
<emu-grammar> OptionalChain: `?.` `[` AssignmentExpression? `:` AssignmentExpression? `]`</emu-grammar>
<emu-alg>
1. Let _startExpression_ be the first |AssignmentExpression|.
1. Let _endExpression_ be the second |AssignmentExpression|.
1. Return ? EvaluateSliceNotation(_baseValue_, _startExpression_, _endExpression_).
</emu-alg>
<emu-grammar> OptionalChain: OptionalChain `[` AssignmentExpression? `:` AssignmentExpression? `]`</emu-grammar>
<emu-alg>
1. Let _optionalChain_ be |OptionalChain|.
1. Let _newBaseReference_ be ? ChainEvaluation of _optionalChain_ with arguments _baseValue_ and _baseReference_.
1. Let _newBaseValue_ be ? GetValue(_newBaseReference_).
1. Let _startExpression_ be the first |AssignmentExpression|.
1. Let _endExpression_ be the second |AssignmentExpression|.
1. Return ? EvaluateSliceNotation(_newBaseValue_, _startExpression_, _endExpression_).
</emu-alg>
</emu-clause>
</emu-clause>
</emu-clause>