Skip to content

Commit

Permalink
Editorial: Inline "Dynamic Function SourceText Prefixes" table (tc39#…
Browse files Browse the repository at this point in the history
…2367)

... into the if-else cascade in CreateDynamicFunction, suggested in tc39#2348 (comment)
  • Loading branch information
jmdyck authored and ljharb committed Jul 18, 2021
1 parent c8ee518 commit 6ca50dc
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -28411,7 +28411,7 @@ <h1>Function ( _p1_, _p2_, &hellip; , _pn_, _body_ )</h1>
</code></pre>
</emu-note>

<emu-clause id="sec-createdynamicfunction" type="abstract operation">
<emu-clause id="sec-createdynamicfunction" type="abstract operation" oldids="table-dynamic-function-sourcetext-prefixes">
<h1>
CreateDynamicFunction (
_constructor_: a constructor,
Expand All @@ -28432,22 +28432,26 @@ <h1>
1. Perform ? HostEnsureCanCompileStrings(_callerRealm_, _calleeRealm_).
1. If _newTarget_ is *undefined*, set _newTarget_ to _constructor_.
1. If _kind_ is ~normal~, then
1. Let _prefix_ be *"function"*.
1. Let _exprSym_ be the grammar symbol |FunctionExpression|.
1. Let _bodySym_ be the grammar symbol |FunctionBody[~Yield, ~Await]|.
1. Let _parameterSym_ be the grammar symbol |FormalParameters[~Yield, ~Await]|.
1. Let _fallbackProto_ be *"%Function.prototype%"*.
1. Else if _kind_ is ~generator~, then
1. Let _prefix_ be *"function\*"*.
1. Let _exprSym_ be the grammar symbol |GeneratorExpression|.
1. Let _bodySym_ be the grammar symbol |GeneratorBody|.
1. Let _parameterSym_ be the grammar symbol |FormalParameters[+Yield, ~Await]|.
1. Let _fallbackProto_ be *"%GeneratorFunction.prototype%"*.
1. Else if _kind_ is ~async~, then
1. Let _prefix_ be *"async function"*.
1. Let _exprSym_ be the grammar symbol |AsyncFunctionExpression|.
1. Let _bodySym_ be the grammar symbol |AsyncFunctionBody|.
1. Let _parameterSym_ be the grammar symbol |FormalParameters[~Yield, +Await]|.
1. Let _fallbackProto_ be *"%AsyncFunction.prototype%"*.
1. Else,
1. Assert: _kind_ is ~asyncGenerator~.
1. Let _prefix_ be *"async function\*"*.
1. Let _exprSym_ be the grammar symbol |AsyncGeneratorExpression|.
1. Let _bodySym_ be the grammar symbol |AsyncGeneratorBody|.
1. Let _parameterSym_ be the grammar symbol |FormalParameters[+Yield, +Await]|.
Expand All @@ -28468,7 +28472,6 @@ <h1>
1. Set _k_ to _k_ + 1.
1. Let _bodyArg_ be _args_[_k_].
1. Let _bodyString_ be the string-concatenation of 0x000A (LINE FEED), ? ToString(_bodyArg_), and 0x000A (LINE FEED).
1. Let _prefix_ be the prefix associated with _kind_ in <emu-xref href="#table-dynamic-function-sourcetext-prefixes"></emu-xref>.
1. Let _sourceString_ be the string-concatenation of _prefix_, *" anonymous("*, _P_, 0x000A (LINE FEED), *") {"*, _bodyString_, and *"}"*.
1. Let _sourceText_ be ! StringToCodePoints(_sourceString_).
1. Let _parameters_ be ParseText(! StringToCodePoints(_P_), _parameterSym_).
Expand Down Expand Up @@ -28498,18 +28501,6 @@ <h1>
<emu-note>
<p>CreateDynamicFunction defines a *"prototype"* property on any function it creates whose _kind_ is not ~async~ to provide for the possibility that the function will be used as a constructor.</p>
</emu-note>

<emu-table id="table-dynamic-function-sourcetext-prefixes" caption="Dynamic Function <emu-not-ref>SourceText</emu-not-ref> Prefixes">
<table>
<tbody>
<tr><th>Kind</th><th>Prefix</th></tr>
<tr><td>~normal~</td><td>*"function"*</td></tr>
<tr><td>~generator~</td><td>*"function\*"*</td></tr>
<tr><td>~async~</td><td>*"async function"*</td></tr>
<tr><td>~asyncGenerator~</td><td>*"async function\*"*</td></tr>
</tbody>
</table>
</emu-table>
</emu-clause>
</emu-clause>
</emu-clause>
Expand Down

0 comments on commit 6ca50dc

Please sign in to comment.