Skip to content

Commit ff2be4b

Browse files
Allow implementation-defined choice of property or accessor (#10)
* Allow implementation-defined choice of property or accessor * Make non-enumerable * Use field in Agent Record to control data/accessor behaviour * Use closures for getter and setter * Apply review suggestions * Apply further review fixes * Apply suggestions from TG3 discussion * Fixup realm access Co-authored-by: Michael Ficarra <[email protected]> * Use private symbol to store stack trace * Revert "Use private symbol to store stack trace" This reverts commit 9bbfb59. --------- Co-authored-by: Michael Ficarra <[email protected]>
1 parent 700bb57 commit ff2be4b

File tree

1 file changed

+44
-5
lines changed

1 file changed

+44
-5
lines changed

spec.emu

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,32 @@ markEffects: true
1515
<p></p>
1616
</emu-intro>
1717

18+
<emu-clause id="sec-code-realms">
19+
<h1>Realms</h1>
20+
<emu-table id="table-realm-record-fields" caption="Realm Record Fields" oldids="table-21">
21+
<table>
22+
<thead>
23+
<tr>
24+
<th>
25+
Field Name
26+
</th>
27+
<th>
28+
Value
29+
</th>
30+
<th>
31+
Meaning
32+
</th>
33+
</tr>
34+
</thead>
35+
<tr>
36+
<td>[[ErrorCaptureStackTraceStrategy]]</td>
37+
<td>~data-property~ or ~accessor~</td>
38+
<td>Whether to use a data property or an accessor property for the "stack" property installed by Error.captureStackTrace.</td>
39+
</tr>
40+
</table>
41+
</emu-table>
42+
</emu-clause>
43+
1844
<emu-clause id="sec-fundamental-objects" number="20">
1945
<h1>Fundamental Objects</h1>
2046

@@ -25,16 +51,29 @@ markEffects: true
2551
<h1>Properties of the Error Constructor</h1>
2652

2753
<emu-clause id="sec-error.capturestacktrace">
28-
<h1>Error.captureStackTrace ( _error_ [ , _constructor_ ] )</h1>
54+
<h1>Error.captureStackTrace ( _O_ [ , _limit_ ] )</h1>
2955
<emu-alg>
30-
1. If _error_ is not an Object, throw a *TypeError* exception.
31-
1. If IsCallable(_constructor_) is *true*, then
56+
1. If _O_ is not an Object, throw a *TypeError* exception.
57+
1. If IsCallable(_limit_) is *true*, then
3258
1. Let _string_ be an implementation-defined string that represents the current stack trace, with all stack
33-
frames above the topmost call to _constructor_, including that call, omitted from the stack trace.
59+
frames above the topmost call to _limit_, including that call, omitted from the stack trace.
3460
1. NOTE: This can be used to hide implementation details on the stack trace that aren't useful to user.
3561
1. Else,
3662
1. Let _string_ be an implementation-defined string that represents the current stack trace.
37-
1. Perform ? SetterThatIgnoresPrototypeProperties(_error_, OrdinaryObjectCreate(*null*), *"stack"*, _string_).
63+
1. Let _realm_ be the current Realm Record.
64+
1. Let _strategy_ be _realm_.[[ErrorCaptureStackTraceStrategy]].
65+
1. If _strategy_ is ~data-property~, then
66+
1. Perform ? DefinePropertyOrThrow(_O_, *"stack"*, PropertyDescriptor { [[Value]]: _string_, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true }).
67+
1. Else,
68+
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 }).
3877
1. Return *undefined*.
3978
</emu-alg>
4079
</emu-clause>

0 commit comments

Comments
 (0)