-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathspec.emu
250 lines (229 loc) · 11.6 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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
<!doctype html>
<meta charset="utf8">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/github.min.css">
<pre class="metadata">
title: Error Stacks
stage: 1
contributors: Jordan Harband, Mark Miller
</pre>
<emu-clause id="sec-system">
<h1>System</h1>
<emu-clause id="sec-system-get-stack">
<h1>System.getStack ( _error_ )</h1>
<p>When the `getStack` method is called with argument _error_, the following steps are taken:</p>
<emu-alg>
1. If _error_ does not have an [[ErrorData]] internal slot, throw a *TypeError* exception.
1. Return ? GetStack(_error_).
</emu-alg>
</emu-clause>
<emu-clause id="sec-system-get-stack-string">
<h1>System.getStackString ( _error_ )</h1>
<p>When the `getStackString` method is called with argument _error_, the following steps are taken:</p>
<emu-alg>
1. If _error_ does not have an [[ErrorData]] internal slot, throw a *TypeError* exception.
1. Return ? GetStackString(_error_).
</emu-alg>
</emu-clause>
</emu-clause>
<emu-clause id="sec-getstack" aoid="GetStack">
<h1>GetStack ( _error_ )</h1>
<p>When the abstract operation _GetStack_ is called with argument _error_, the following steps are performed:</p>
<emu-alg>
1. Assert: _error_ has an [[ErrorData]] internal slot.
1. Let _frames_ be ! GetStackFrames(_error_).
1. Let _string_ be ? GetStackString(_error_).
1. Let _obj_ be OrdinaryObjectCreate(%ObjectPrototype%).
1. Perform ! CreateDataPropertyOrThrow(_obj_, *"frames"*, _frames_).
1. Perform ! CreateDataPropertyOrThrow(_obj_, *"string"*, _string_).
1. Let _status_ be ! SetIntegrityLevel(_obj_, ~frozen~).
1. Assert: _status_ is *true*.
1. Return _obj_.
</emu-alg>
</emu-clause>
<emu-clause id="sec-getstackstring" aoid="GetStackString">
<h1>GetStackString ( _error_ )</h1>
<p>When the abstract operation _GetStackString_ is called with argument _error_, the following steps are performed:</p>
<emu-alg>
1. Assert: _error_ has an [[ErrorData]] internal slot.
1. Let _errorString_ be ? Call(%Error.prototype.toString%, _error_).
1. Let _frames_ be ! GetStackFrames(_error_).
1. Let _frameString_ be a String consisting solely of the code unit 0x0020 (SPACE).
1. For each Stack Frame _frame_ in _frames_, do
1. If _frameString_ does not consist solely of the code unit 0x0020 (SPACE), then
1. Set _frameString_ to the string-concatenation of _frameString_, the code unit 0x000A (LINE FEED), and the code unit 0x0020 (SPACE).
1. Set _frameString_ to the string-concatenation of _frameString_ and ! GetFrameString(_frame_).
1. Return the string-concatenation of _errorString_, the code unit 0x000A (LINE FEED), and _frameString_.
</emu-alg>
</emu-clause>
<emu-clause id="sec-getframestring" aoid="GetFrameString">
<h1>GetFrameString ( _frame_ )</h1>
<p>When the abstract operation _GetFrameString_ is called with argument _frame_, the following steps are performed:</p>
<emu-alg>
1. Assert: ! IsStackFrame(_frame_) is *true*.
1. Let _source_ be _frame_.[[Source]].
1. If _source_ is not a String, then
1. Assert: ! IsStackFrame(_source_) is *true*.
1. Set _source_ to the string-concatenation of *"eval"* and ! GetFrameString(_source_).
1. Assert: _source_ is a String.
1. Let _spanString_ be ! GetStackFrameSpanString(_frame_.[[Span]]).
1. Return the string-concatenation of the code unit 0x0020 (SPACE), *"at"*, the code unit 0x0020 (SPACE), _frame_.[[Name]], the code unit 0x0020 (SPACE), and *"("*, _source_, _spanString_, and *")"*.
</emu-alg>
</emu-clause>
<emu-clause id="sec-getstackframespanstring" aoid="GetStackFrameSpanString">
<h1>GetStackFrameSpanString ( _span_ )</h1>
<p>When the abstract operation _GetStackFrameSpanString_ is called with argument _span_, the following steps are performed:</p>
<emu-alg>
1. Assert: ! IsStackFrameSpan(_span_) is *true*.
1. Let _spanString_ be ! GetStackFramePositionString(_span_.[[StartPosition]]).
1. If _span_ has an [[EndPosition]] internal slot, then
1. Set _spanString_ to the string-concatenation of _spanString_, *"::"*, and ! GetStackFramePositionString(_span_.[[EndPosition]]).
1. Return _spanString_.
</emu-alg>
</emu-clause>
<emu-clause id="sec-getstackframepositionstring" aoid="GetStackFramePositionString">
<h1>GetStackFramePositionString ( _position_ )</h1>
<p>When the abstract operation _GetStackFramePositionString_ is called with argument _position_, the following steps are performed:</p>
<emu-alg>
1. Assert: ! IsStackFramePosition(_position_) is *true*.
1. Let _positionString_ be ! ToString(_position_.[[Line]]).
1. If _position_ has a [[Column]] internal slot, then
1. Set _positionString_ to the string-concatenation of _positionString_, *":"*, and ! ToString(_position_.[[Column]]).
1. Return _positionString_.
</emu-alg>
</emu-clause>
<emu-clause id="sec-getstackframes" aoid="GetStackFrames">
<h1>GetStackFrames ( _error_ )</h1>
<p>When the abstract operation _GetStackFrames_ is called with argument _error_, the following steps are performed:</p>
<emu-alg>
1. Assert: _error_ has an [[ErrorData]] internal slot.
1. Let _frames_ be a new empty List.
1. For each Stack Frame _frame_ in _error_.[[ErrorData]], do
1. Append ! FromStackFrame(_frame_) to _frames_.
1. Let _array_ be CreateArrayFromList(_frames_).
1. Let _status_ be ! SetIntegrityLevel(_array_, ~frozen~).
1. Assert: _status_ is *true*.
1. Return _array_.
</emu-alg>
</emu-clause>
<emu-clause id="sec-stack-frame-specification-type">
<h1>The Stack Frame Specification Type</h1>
<emu-clause id="sec-isstackframe" aoid="IsStackFrame">
<h1>IsStackFrame ( _frame_ )</h1>
<p>When the abstract operation IsStackFrame is called with Stack Frame _frame_, the following steps are performed:</p>
<emu-alg>
1. If Type(_frame_) is not Object, return *false*.
1. If _frame_ does not have a [[Name]] internal slot, return *false*.
1. If _frame_ does not have a [[Source]] internal slot, return *false*.
1. If _frame_ does not have a [[Span]] internal slot, return *false*.
1. If _frame_.[[Name]] is not a String, return *false*.
1. If _frame_.[[Source]] is not a String, and ! IsStackFrame(_frame_.[[Source]]) is not *true*, return *false*.
1. If ! IsStackFrameSpan(_frame_.[[Span]]) is not *true*, return *false*.
1. Return *true*.
</emu-alg>
</emu-clause>
<emu-clause id="sec-isstackspan" aoid="IsStackFrameSpan">
<h1>IsStackFrameSpan ( _span_ )</h1>
<p>When the abstract operation IsStackFrameSpan is called with argument _span_, the following steps are performed:</p>
<emu-alg>
1. If Type(_span_) is not Object, return *false*.
1. If _span_ does not have a [[StartPosition]] internal slot, return *false*.
1. If ! IsStackFramePosition(_span_.[[StartPosition]]) is not *true*, return *false*.
1. If _span_ has an [[EndPosition]] internal slot, then
1. If ! IsStackFramePosition(_span_.[[EndPosition]]) is not *true*, return *false*.
1. Return *true*.
</emu-alg>
</emu-clause>
<emu-clause id="sec-isstackposition" aoid="IsStackFramePosition">
<h1>IsStackFramePosition ( _position_ )</h1>
<p>When the abstract operation IsStackFramePosition is called with argument _position_, the following steps are performed:</p>
<emu-alg>
1. If Type(_position_) is not Object, return *false*.
1. If _position_ does not have a [[Line]] internal slot, return *false*.
1. If _position_.[[Line]] is not a positive integer ≤ 2<sup>53</sup>-1, return *false*.
1. If _position_ has a [[Column]] internal slot, then
1. If _position_.[[Column]] is not 𝔽(0) or a positive integer ≤ 2<sup>53</sup>-1, return *false*.
1. Return *true*.
</emu-alg>
</emu-clause>
<emu-clause id="sec-fromstackframe" aoid="FromStackFrame">
<h1>FromStackFrame ( _frame_ )</h1>
<p>When the abstract operation FromStackFrame is called with Stack Frame _frame_, the following steps are taken:</p>
<emu-alg>
1. Assert: ! IsStackFrame(_frame_) is *true*.
1. Let _obj_ be OrdinaryObjectCreate(%ObjectPrototype%).
1. Assert: _obj_ is an extensible ordinary object with no own properties.
1. Perform ! CreateDataPropertyOrThrow(_obj_, *"name"*, _frame_.[[Name]]).
1. Let _source_ be _frame_.[[Source]].
1. If _source_ is a String, then
1. Perform ! CreateDataPropertyOrThrow(_obj_, *"source"*, _source_).
1. Else,
1. Assert: ! IsStackFrame(_source_) is *true*.
1. Perform ! CreateDataPropertyOrThrow(_obj_, *"source*", ! FromStackFrame(_source_)).
1. Perform ! CreateDataPropertyOrThrow(_obj_, *"span"*, ! FromStackFrameSpan(_frame_.[[Span]])).
1. Let _status_ be ! SetIntegrityLevel(_obj_, ~frozen~).
1. Assert: _status_ is *true*.
1. Return _obj_.
</emu-alg>
</emu-clause>
<emu-clause id="sec-fromstackframespan" aoid="FromStackFrameSpan">
<h1>FromStackFrameSpan ( _span_ )</h1>
<p>When the abstract operation FromStackFrameSpan is called with argument _span_, the following steps are taken:</p>
<emu-alg>
1. Assert: ! IsStackFrameSpan(_span_) is *true*.
1. Let _list_ be a new empty List.
1. Append ! FromStackFramePosition(_span_.[[StartPosition]]) to _list_.
1. If _span_ has an [[EndPosition]] internal slot, append ! FromStackFramePosition(_span_.[[EndPosition]]) to _list_.
1. Let _array_ be CreateArrayFromList(_list_).
1. Let _status_ be ! SetIntegrityLevel(_array_, ~frozen~).
1. Assert: _status_ is *true*.
1. Return _array_.
</emu-alg>
</emu-clause>
<emu-clause id="sec-fromstackframeposition" aoid="FromStackFramePosition">
<h1>FromStackFramePosition ( _position_ )</h1>
<p>When the abstract operation FromStackFramePosition is called with argument _position_, the following steps are taken:</p>
<emu-alg>
1. Assert: ! IsStackFramePosition(_position_) is *true*.
1. Let _list_ be a new empty List.
1. Append _position_.[[Line]] to _list_.
1. If _position_ has a [[Column]] internal slot, append _position_.[[Column]] to _list_.
1. Let _array_ be CreateArrayFromList(_list_).
1. Let _status_ be ! SetIntegrityLevel(_array_, ~frozen~).
1. Assert: _status_ is *true*.
1. Return _array_.
</emu-alg>
</emu-clause>
</emu-clause>
<emu-annex id="sec-grammar-summary">
<h1>Placeholder to ensure correct annex lettering</h1>
</emu-annex>
<emu-annex id="sec-additional-built-in-properties">
<h1>Additional Built-in Properties</h1>
<p>When the ECMAScript host is a web browser the following additional properties of the standard built-in objects are defined.</p>
<emu-annex id="sec-additional-properties-of-the-error.prototype-object">
<h1>Additional Properties of the Error.prototype Object</h1>
<emu-annex id="sec-get-error.prototype-stack">
<h1>get Error.prototype.stack ( )</h1>
<p>*Error.prototype.stack* is an accessor property whose get accessor function performs the following steps:</p>
<emu-alg>
1. Let _E_ be the *this* value.
1. If Type(_E_) is not Object, throw a *TypeError* exception.
1. If _E_ does not have an [[ErrorData]] internal slot, return *undefined*.
1. Return ? GetStackString(_error_).
</emu-alg>
<p>The value of the *"name"* property of this function is *"get stack"*.</p>
</emu-annex>
<emu-annex id="sec-set-error.prototype-stack">
<h1>set Error.prototype.stack ( _value_ )</h1>
<p>Its set accessor function performs the following steps:</p>
<emu-alg>
1. Let _E_ be the *this* value.
1. If Type(_E_) is not Object, throw a *TypeError* exception.
1. Let _numberOfArgs_ be the number of arguments passed to this function call.
1. If _numberOfArgs_ is 0, throw a *TypeError* exception.
1. Return ? CreateDataPropertyOrThrow(_E_, *"stack"*, _value_).
</emu-alg>
<p>The value of the *"name"* property of this function is *"set stack"*.</p>
</emu-annex>
</emu-annex>
</emu-annex>