Skip to content

Commit bd26e8a

Browse files
authored
Use internal slot to store the stack trace (#14)
* Use internal slot to store the stack trace Fixes #12 * Fix [[ErrorStack]]. * Make data property non-enumerable
1 parent ff2be4b commit bd26e8a

File tree

1 file changed

+65
-9
lines changed

1 file changed

+65
-9
lines changed

spec.emu

Lines changed: 65 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,48 @@ markEffects: true
4141
</emu-table>
4242
</emu-clause>
4343

44+
<emu-clause id="sec-well-known-intrinsic-objects">
45+
<h1>Well-Known Intrinsic Objects</h1>
46+
47+
<emu-table id="table-well-known-intrinsic-objects" caption="Well-Known Intrinsic Objects" oldids="table-7">
48+
<table>
49+
<thead>
50+
<tr>
51+
<th>
52+
Intrinsic Name
53+
</th>
54+
<th>
55+
Global Name
56+
</th>
57+
<th>
58+
ECMAScript Language Association
59+
</th>
60+
</tr>
61+
</thead>
62+
<tr>
63+
<td>
64+
%ErrorCaptureStackTraceGetter%
65+
</td>
66+
<td>
67+
</td>
68+
<td>
69+
The getter installed by `Error.captureStackTrace` (<emu-xref href="#sec-error.capturestacktrace-getter"></emu-xref>)
70+
</td>
71+
</tr>
72+
<tr>
73+
<td>
74+
%ErrorCaptureStackTraceSetter%
75+
</td>
76+
<td>
77+
</td>
78+
<td>
79+
The setter installed by `Error.captureStackTrace` (<emu-xref href="#sec-error.capturestacktrace-setter"></emu-xref>)
80+
</td>
81+
</tr>
82+
</table>
83+
</emu-table>
84+
</emu-clause>
85+
4486
<emu-clause id="sec-fundamental-objects" number="20">
4587
<h1>Fundamental Objects</h1>
4688

@@ -63,20 +105,34 @@ markEffects: true
63105
1. Let _realm_ be the current Realm Record.
64106
1. Let _strategy_ be _realm_.[[ErrorCaptureStackTraceStrategy]].
65107
1. If _strategy_ is ~data-property~, then
66-
1. Perform ? DefinePropertyOrThrow(_O_, *"stack"*, PropertyDescriptor { [[Value]]: _string_, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true }).
108+
1. Perform ? DefinePropertyOrThrow(_O_, *"stack"*, PropertyDescriptor { [[Value]]: _string_, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }).
67109
1. Else,
68110
1. Assert: _strategy_ is ~accessor~.
69-
1. Let _getterClosure_ be a new Abstract Closure with no parameters that captures _string_ and performs the following steps when called:
70-
1. Return NormalCompletion(_string_).
71-
1. Let _getter_ be CreateBuiltinFunction(_getterClosure_, 0, "", « »).
72-
1. Let _setterClosure_ be a new Abstract Closure with parameters (_value_) that captures _O_ and performs the following steps when called:
73-
1. Perform ? DefinePropertyOrThrow(_O_, *"stack"*, PropertyDescriptor { [[Value]]: _value_, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true }).
74-
1. Return NormalCompletion(*undefined*).
75-
1. Let _setter_ be CreateBuiltinFunction(_setterClosure_, 1, "", « »).
76-
1. Perform ? DefinePropertyOrThrow(_O_, *"stack"*, PropertyDescriptor { [[Get]]: _getter_, [[Set]]: _setter_, [[Enumerable]]: false, [[Configurable]]: true }).
111+
1. If ? IsExtensible(_O_) is *false*, throw a *TypeError* exception.
112+
1. Define a new [[StackTrace]] internal slot on _O_.
113+
1. Perform ? DefinePropertyOrThrow(_O_, *"stack"*, PropertyDescriptor { [[Get]]: %ErrorCaptureStackTraceGetter%, [[Set]]: %ErrorCaptureStackTraceSetter%, [[Enumerable]]: false, [[Configurable]]: true }).
77114
1. Return *undefined*.
78115
</emu-alg>
79116
</emu-clause>
117+
<emu-clause id="sec-error.capturestacktrace-getter">
118+
<h1>%ErrorCaptureStackTraceGetter% ( )</h1>
119+
<p>The value of %ErrorCaptureStackTraceGetter% is a built-in function that takes no arguments. It performs the following steps when called:</p>
120+
<emu-alg>
121+
1. Let _O_ be the *this* value.
122+
1. If _O_ has a [[StackTrace]] internal slot, then
123+
1. Return _O_.[[StackTrace]].
124+
1. Else,
125+
1. Return *undefined*.
126+
</emu-alg>
127+
</emu-clause>
128+
<emu-clause id="sec-error.capturestacktrace-setter">
129+
<h1>%ErrorCaptureStackTraceSetter% ( _value_ )</h1>
130+
<p>The value of %ErrorCaptureStackTraceSetter% is a built-in function that takes an argument _value_. It performs the following steps when called:</p>
131+
<emu-alg>
132+
1. Perform ? DefinePropertyOrThrow(*this* value, *"stack"*, PropertyDescriptor { [[Value]]: _value_, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true }).
133+
1. Return *undefined*.
134+
</emu-alg>
135+
</emu-clause>
80136
</emu-clause>
81137
</emu-clause>
82138
</emu-clause>

0 commit comments

Comments
 (0)