Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.

Address editor feedback #10

Merged
merged 2 commits into from
Jan 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 40 additions & 52 deletions spec.emu
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ contributors: Ron Buckton, Ecma International
InitializeReferencedBinding (
_V_: unknown,
_W_: unknown,
<ins>_hint_: either ~normal~, ~sync-dispose~, or ~async-dispose~,</ins>
<ins>_hint_: one of ~normal~, ~sync-dispose~, or ~async-dispose~,</ins>
): either a normal completion containing ~unused~ or an abrupt completion
</h1>
<dl class="header">
Expand Down Expand Up @@ -1011,23 +1011,23 @@ contributors: Ron Buckton, Ecma International
_V_ : an ECMAScript language value,
_hint_ : either ~sync-dispose~ or ~async-dispose~,
optional _method_ : a function object,
)
): either a normal completion containing ~unused~ or a throw completion
</h1>
<dl class="header">
</dl>
<emu-alg>
1. If _method_ is not present then,
1. If _V_ is either *null* or *undefined* and _hint_ is ~sync-dispose~, then
1. Return NormalCompletion(~empty~).
1. Return ~unused~.
1. Let _resource_ be ? CreateDisposableResource(_V_, _hint_).
1. Else,
1. If _V_ is either *null* or *undefined*, then
1. Let _resource_ be ? CreateDisposableResource(*undefined*, _hint_, _method_).
1. Else,
1. If Type(_V_) is not Object, throw a *TypeError* exception.
1. If _V_ is not an Object, throw a *TypeError* exception.
1. Let _resource_ be ? CreateDisposableResource(_V_, _hint_, _method_).
1. Append _resource_ to _disposeCapability_.[[DisposableResourceStack]].
1. Return NormalCompletion(~empty~).
1. Return ~unused~.
</emu-alg>
</emu-clause>

Expand All @@ -1037,7 +1037,7 @@ contributors: Ron Buckton, Ecma International
_V_ : an ECMAScript language value,
_hint_ : either ~sync-dispose~ or ~async-dispose~,
optional _method_ : a function object,
)
): either a normal completion containing a DisposableResource Record or a throw completion
</h1>
<dl class="header"></dl>
<emu-alg>
Expand All @@ -1046,7 +1046,7 @@ contributors: Ron Buckton, Ecma International
1. Set _V_ to *undefined*.
1. Set _method_ to *undefined*.
1. Else,
1. If Type(_V_) is not Object, throw a *TypeError* exception.
1. If _V_ is not an Object, throw a *TypeError* exception.
1. Set _method_ to ? GetDisposeMethod(_V_, _hint_).
1. If _method_ is *undefined*, throw a *TypeError* exception.
1. Else,
Expand All @@ -1060,7 +1060,7 @@ contributors: Ron Buckton, Ecma International
GetDisposeMethod (
_V_ : an Object,
_hint_ : either ~sync-dispose~ or ~async-dispose~,
)
): either a normal completion containing either a function object or *undefined*, or a throw completion
</h1>
<dl class="header"></dl>
<emu-alg>
Expand All @@ -1080,7 +1080,7 @@ contributors: Ron Buckton, Ecma International
_V_ : an Object or *undefined*,
_hint_ : either ~sync-dispose~ or ~async-dispose~,
_method_ : a function object or *undefined*,
)
): either a normal completion containing *undefined* or a throw completion
</h1>
<dl class="header"></dl>
<emu-alg>
Expand All @@ -1096,12 +1096,12 @@ contributors: Ron Buckton, Ecma International
<h1>
DisposeResources (
_disposeCapability_ : a DisposeCapability Record,
_completion_ : a Completion Record,
): a Completion Record
_completion_: either a normal completion containing either an ECMAScript language value or ~empty~, or an abrupt completion,
): either a normal completion containing either an ECMAScript language value or ~empty~, or an abrupt completion
</h1>
<dl class="header"></dl>
<emu-alg>
1. For each _resource_ of _disposeCapability_.[[DisposableResourceStack]], in reverse list order, do
1. For each _resource_ of _disposeCapability_.[[DisposableResourceStack]], in reverse List order, do
1. Let _result_ be Dispose(_resource_.[[ResourceValue]], _resource_.[[Hint]], _resource_.[[DisposeMethod]]).
1. If _result_.[[Type]] is ~throw~, then
1. If _completion_.[[Type]] is ~throw~, then
Expand Down Expand Up @@ -1459,7 +1459,11 @@ contributors: Ron Buckton, Ecma International
<emu-alg>
1. Return *false*.
</emu-alg>
<emu-grammar>LexicalDeclaration : UsingDeclaration</emu-grammar>
<emu-grammar>
UsingDeclaration :
`using` BindingList `;`
`using` `await` BindingList `;`
</emu-grammar>
<emu-alg>
1. Return *true*.
</emu-alg>
Expand Down Expand Up @@ -1530,6 +1534,10 @@ contributors: Ron Buckton, Ecma International
<emu-alg>
1. Return *true*.
</emu-alg>
<emu-grammar>ForDeclaration : LetOrConst ForBinding</emu-grammar>
<emu-alg>
1. Return *false*.
</emu-alg>
<emu-grammar>ForDeclaration : `using` ForBinding</emu-grammar>
<emu-alg>
1. Return *false*.
Expand Down Expand Up @@ -1879,7 +1887,7 @@ contributors: Ron Buckton, Ecma International
InitializeBinding (
_N_: a String,
_V_: an ECMAScript language value,
<ins>_hint_: either ~normal~, ~sync-dispose~, or ~async-dispose~,</ins>
<ins>_hint_: one of ~normal~, ~sync-dispose~, or ~async-dispose~,</ins>
): a normal completion containing ~unused~
</h1>
<dl class="header">
Expand Down Expand Up @@ -1907,7 +1915,7 @@ contributors: Ron Buckton, Ecma International
InitializeBinding (
_N_: a String,
_V_: an ECMAScript language value,
<ins>_hint_: either ~normal~, ~sync-dispose~, or ~async-dispose~,</ins>
<ins>_hint_: one of ~normal~, ~sync-dispose~, or ~async-dispose~,</ins>
): either a normal completion containing ~unused~ or a throw completion
</h1>
<dl class="header">
Expand Down Expand Up @@ -1937,7 +1945,7 @@ contributors: Ron Buckton, Ecma International
InitializeBinding (
_N_: a String,
_V_: an ECMAScript language value,
<ins>_hint_: either ~normal~, ~sync-dispose~, or ~async-dispose~,</ins>
<ins>_hint_: one of ~normal~, ~sync-dispose~, or ~async-dispose~,</ins>
): either a normal completion containing ~unused~ or a throw completion
</h1>
<dl class="header">
Expand Down Expand Up @@ -2297,7 +2305,7 @@ contributors: Ron Buckton, Ecma International
<emu-clause id="sec-let-and-const-declarations-runtime-semantics-bindingevaluation" type="sdo">
<h1>
Runtime Semantics: BindingEvaluation (
_hint_: either ~normal~, ~sync-dispose~, or ~async-dispose~.
_hint_: one of ~normal~, ~sync-dispose~, or ~async-dispose~.
): either a normal completion containing ~unused~ or an abrupt completion
</h1>
<dl class="header">
Expand Down Expand Up @@ -2580,7 +2588,8 @@ contributors: Ron Buckton, Ecma International
1. Assert: _lhs_ is a |ForDeclaration|.
1. Let _status_ be Completion(ForDeclarationBindingInitialization of _lhs_ with arguments _nextValue_ and _iterationEnv_).
1. If _status_ is an abrupt completion, then
1. <ins>Set _status_ to DisposeResources(_iterationEnv_, _status_).</ins>
1. <ins>If _iterationEnv_ is not *undefined*, then</ins>
1. <ins>Set _status_ to DisposeResources(_iterationEnv_, _status_).</ins>
1. Set the running execution context's LexicalEnvironment to _oldEnv_.
1. If _iteratorKind_ is ~async~, return ? AsyncIteratorClose(_iteratorRecord_, _status_).
1. If _iterationKind_ is ~enumerate~, then
Expand All @@ -2589,7 +2598,8 @@ contributors: Ron Buckton, Ecma International
1. Assert: _iterationKind_ is ~iterate~.
1. Return ? IteratorClose(_iteratorRecord_, _status_).
1. Let _result_ be the result of evaluating _stmt_.
1. <ins>Set _result_ to DisposeResources(_iterationEnv_, _result_).</ins>
1. <ins>If _iterationEnv_ is not *undefined*, then</ins>
1. <ins>Set _result_ to DisposeResources(_iterationEnv_, _result_).</ins>
1. Set the running execution context's LexicalEnvironment to _oldEnv_.
1. If LoopContinues(_result_, _labelSet_) is *false*, then
1. If _iterationKind_ is ~enumerate~, then
Expand Down Expand Up @@ -3342,7 +3352,7 @@ contributors: Ron Buckton, Ecma International
`export` ExportFromClause FromClause `;`
`export` NamedExports `;`
`export` VariableStatement[~Yield, +Await]
`export` <ins>[lookahead &notin; { `using` }]</ins> Declaration[~Yield, +Await]
`export` <ins>[lookahead != `using`]</ins> Declaration[~Yield, +Await]
`export` `default` HoistableDeclaration[~Yield, +Await, +Default]
`export` `default` ClassDeclaration[~Yield, +Await, +Default]
`export` `default` [lookahead &notin; {`function`, `async` [no |LineTerminator| here] `function`, `class`}] AssignmentExpression[+In, ~Yield, +Await] `;`
Expand Down Expand Up @@ -3539,11 +3549,11 @@ contributors: Ron Buckton, Ecma International
1. If NewTarget is *undefined*, let _newTarget_ be the active function object; else let _newTarget_ be NewTarget.
1. Let _O_ be ? OrdinaryCreateFromConstructor(_newTarget_, *"%SuppressedError.prototype%"*, « [[ErrorData]] »).
1. If _message_ is not *undefined*, then
1. Let _msg_ be ? ToString(_message_).
1. Perform CreateNonEnumerableDataPropertyOrThrow(_O_, *"message"*, _msg_).
1. Let _messageString_ be ? ToString(_message_).
1. Perform CreateNonEnumerableDataPropertyOrThrow(_O_, *"message"*, _messageString_).
1. Perform ? InstallErrorCause(_O_, _options_).
1. Perform ! CreateNonEnumerableDataPropertyOrThrow(_O_, *"error"*, _error_).
1. Perform ! CreateNonEnumerableDataPropertyOrThrow(_O_, *"suppressed"*, _suppressed_).
1. Perform CreateNonEnumerableDataPropertyOrThrow(_O_, *"error"*, _error_).
1. Perform CreateNonEnumerableDataPropertyOrThrow(_O_, *"suppressed"*, _suppressed_).
1. Return _O_.
</emu-alg>
</emu-clause>
Expand Down Expand Up @@ -3832,23 +3842,12 @@ contributors: Ron Buckton, Ecma International
1. Perform ? RequireInternalSlot(_disposableStack_, [[DisposableState]]).
1. If _disposableStack_.[[DisposableState]] is ~disposed~, throw a *ReferenceError* exception.
1. If IsCallable(_onDispose_) is *false*, throw a *TypeError* exception.
1. Let _F_ be a new built-in function object as defined in <emu-xref href="#sec-disposablestack-adopt-callback-functions"></emu-xref>.
1. Set _F_.[[Argument]] to _value_.
1. Set _F_.[[OnDisposeCallback]] to _onDispose_.
1. Let _closure_ be a new Abstract Closure with no parameters that captures _value_ and _onDispose_ and performs the following steps when called:
1. Return ? Call(_onDispose_, *undefined*, &laquo; _value_ &raquo;).
1. Let _F_ be CreateBuiltinFunction(_closure_, 0, *""*, « »).
1. Perform ? AddDisposableResource(_disposableStack_.[[DisposeCapability]], *undefined*, ~sync-dispose~, _F_).
1. Return _value_.
</emu-alg>

<emu-clause id="sec-disposablestack-adopt-callback-functions">
<h1>DisposableStack Adopt Callback Functions</h1>
<p>A <dfn>DisposableStack adopt callback function</dfn> is an anonymous built-in function object that has [[Argument]] and [[OnDisposeCallback]] internal slots.</p>
<p>When a DisposableStack adopt callback function is called, the following steps are taken:</p>
<emu-alg>
1. Let _F_ be the active function object.
1. Assert: IsCallable(_F_.[[OnDisposeCallback]]) is *true*.
1. Return Call(_F_.[[OnDisposeCallback]], *undefined*, &laquo; _F_.[[Argument]] &raquo;).
</emu-alg>
</emu-clause>
</emu-clause>

<emu-clause id="sec-disposablestack.prototype.defer">
Expand Down Expand Up @@ -4039,23 +4038,12 @@ contributors: Ron Buckton, Ecma International
1. Perform ? RequireInternalSlot(_asyncDisposableStack_, [[AsyncDisposableState]]).
1. If _asyncDisposableStack_.[[AsyncDisposableState]] is ~disposed~, throw a *ReferenceError* exception.
1. If IsCallable(_onDisposeAsync_) is *false*, throw a *TypeError* exception.
1. Let _F_ be a new built-in function object as defined in <emu-xref href="#sec-asyncdisposablestack-adopt-callback-functions"></emu-xref>.
1. Set _F_.[[Argument]] to _value_.
1. Set _F_.[[OnDisposeAsyncCallback]] to _onDisposeAsync_.
1. Let _closure_ be a new Abstract Closure with no parameters that captures _value_ and _onDisposeAsync_ and performs the following steps when called:
1. Return ? Call(_onDisposeAsync_, *undefined*, &laquo; _value_ &raquo;).
1. Let _F_ be CreateBuiltinFunction(_closure_, 0, *""*, « »).
1. Perform ? AddDisposableResource(_asyncDisposableStack_.[[DisposeCapability]], *undefined*, ~async-dispose~, _F_).
1. Return _value_.
</emu-alg>

<emu-clause id="sec-asyncdisposablestack-adopt-callback-functions">
<h1>AsyncDisposableStack Adopt Callback Functions</h1>
<p>An <dfn>AsyncDisposableStack adopt callback function</dfn> is an anonymous built-in function that has [[Argument]] and [[OnDisposeAsyncCallback]] internal slots.</p>
<p>When an AsyncDisposableStack adopt callback function is called, the following steps are taken:</p>
<emu-alg>
1. Let _F_ be the active function object.
1. Assert: IsCallable(_F_.[[OnDisposeAsyncCallback]]) is *true*.
1. Return Call(_F_.[[OnDisposeAsyncCallback]], *undefined*, &laquo; _F_.[[Argument]] &raquo;).
</emu-alg>
</emu-clause>
</emu-clause>

<emu-clause id="sec-asyncdisposablestack.prototype.defer">
Expand Down