Skip to content

Commit

Permalink
Editorial: use abstract closures in AsyncGeneratorResumeNext (tc39#2439)
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkot authored and mathiasbynens committed Oct 18, 2021
1 parent 51f665e commit 86d4442
Showing 1 changed file with 9 additions and 37 deletions.
46 changes: 9 additions & 37 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -40039,7 +40039,7 @@ <h1>AsyncGeneratorReject ( _generator_, _exception_ )</h1>
</emu-alg>
</emu-clause>

<emu-clause id="sec-asyncgeneratorresumenext" aoid="AsyncGeneratorResumeNext">
<emu-clause id="sec-asyncgeneratorresumenext" oldids="async-generator-resume-next-return-processor-fulfilled,async-generator-resume-next-return-processor-rejected" aoid="AsyncGeneratorResumeNext">
<h1>AsyncGeneratorResumeNext ( _generator_ )</h1>
<p>The abstract operation AsyncGeneratorResumeNext takes argument _generator_. It performs the following steps when called:</p>
<emu-alg>
Expand All @@ -40060,14 +40060,14 @@ <h1>AsyncGeneratorResumeNext ( _generator_ )</h1>
1. If _completion_.[[Type]] is ~return~, then
1. Set _generator_.[[AsyncGeneratorState]] to ~awaiting-return~.
1. Let _promise_ be ? PromiseResolve(%Promise%, _completion_.[[Value]]).
1. Let _stepsFulfilled_ be the algorithm steps defined in <emu-xref href="#async-generator-resume-next-return-processor-fulfilled" title></emu-xref>.
1. Let _lengthFulfilled_ be the number of non-optional parameters of the function definition in <emu-xref href="#async-generator-resume-next-return-processor-fulfilled" title></emu-xref>.
1. Let _onFulfilled_ be ! CreateBuiltinFunction(_stepsFulfilled_, _lengthFulfilled_, *""*, &laquo; [[Generator]] &raquo;).
1. Set _onFulfilled_.[[Generator]] to _generator_.
1. Let _stepsRejected_ be the algorithm steps defined in <emu-xref href="#async-generator-resume-next-return-processor-rejected" title></emu-xref>.
1. Let _lengthRejected_ be the number of non-optional parameters of the function definition in <emu-xref href="#async-generator-resume-next-return-processor-rejected" title></emu-xref>.
1. Let _onRejected_ be ! CreateBuiltinFunction(_stepsRejected_, _lengthRejected_, *""*, &laquo; [[Generator]] &raquo;).
1. Set _onRejected_.[[Generator]] to _generator_.
1. Let _fulfilledClosure_ be a new Abstract Closure with parameters (_value_) that captures _generator_ and performs the following steps when called:
1. Set _generator_.[[AsyncGeneratorState]] to ~completed~.
1. Return ! AsyncGeneratorResolve(_generator_, _value_, *true*).
1. Let _onFulfilled_ be ! CreateBuiltinFunction(_fulfilledClosure_, 1, *""*, &laquo; &raquo;).
1. Let _rejectedClosure_ be a new Abstract Closure with parameters (_reason_) that captures _generator_ and performs the following steps when called:
1. Set _generator_.[[AsyncGeneratorState]] to ~completed~.
1. Return ! AsyncGeneratorReject(_generator_, _reason_).
1. Let _onRejected_ be ! CreateBuiltinFunction(_rejectedClosure_, 1, *""*, &laquo; &raquo;).
1. Perform ! PerformPromiseThen(_promise_, _onFulfilled_, _onRejected_).
1. Return *undefined*.
1. Else,
Expand All @@ -40086,34 +40086,6 @@ <h1>AsyncGeneratorResumeNext ( _generator_ )</h1>
1. Assert: When we return here, _genContext_ has already been removed from the execution context stack and _callerContext_ is the currently running execution context.
1. Return *undefined*.
</emu-alg>

<emu-clause id="async-generator-resume-next-return-processor-fulfilled">
<h1>AsyncGeneratorResumeNext Return Processor Fulfilled Functions</h1>
<p>An AsyncGeneratorResumeNext return processor fulfilled function is an anonymous built-in function that is used as part of the AsyncGeneratorResumeNext specification device to unwrap promises passed in to the <emu-xref href="#sec-asyncgenerator-prototype-return" title></emu-xref> method. Each AsyncGeneratorResumeNext return processor fulfilled function has a [[Generator]] internal slot.</p>
<p>When an AsyncGeneratorResumeNext return processor fulfilled function is called with argument _value_, the following steps are taken:</p>

<emu-alg>
1. Let _F_ be the active function object.
1. Set _F_.[[Generator]].[[AsyncGeneratorState]] to ~completed~.
1. Return ! AsyncGeneratorResolve(_F_.[[Generator]], _value_, *true*).
</emu-alg>

<p>The *"length"* property of an AsyncGeneratorResumeNext return processor fulfilled function is *1*<sub>𝔽</sub>.</p>
</emu-clause>

<emu-clause id="async-generator-resume-next-return-processor-rejected">
<h1>AsyncGeneratorResumeNext Return Processor Rejected Functions</h1>
<p>An AsyncGeneratorResumeNext return processor rejected function is an anonymous built-in function that is used as part of the AsyncGeneratorResumeNext specification device to unwrap promises passed in to the <emu-xref href="#sec-asyncgenerator-prototype-return" title></emu-xref> method. Each AsyncGeneratorResumeNext return processor rejected function has a [[Generator]] internal slot.</p>
<p>When an AsyncGeneratorResumeNext return processor rejected function is called with argument _reason_, the following steps are taken:</p>

<emu-alg>
1. Let _F_ be the active function object.
1. Set _F_.[[Generator]].[[AsyncGeneratorState]] to ~completed~.
1. Return ! AsyncGeneratorReject(_F_.[[Generator]], _reason_).
</emu-alg>

<p>The *"length"* property of an AsyncGeneratorResumeNext return processor rejected function is *1*<sub>𝔽</sub>.</p>
</emu-clause>
</emu-clause>

<emu-clause id="sec-asyncgeneratorenqueue" aoid="AsyncGeneratorEnqueue">
Expand Down

0 comments on commit 86d4442

Please sign in to comment.