Skip to content

Commit 2e3b335

Browse files
committed
Define module root level context
1 parent 5dae578 commit 2e3b335

File tree

1 file changed

+96
-1
lines changed

1 file changed

+96
-1
lines changed

spec.html

+96-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ <h1>Agents</h1>
123123
<ins>a List of Async Context Mapping Records</ins>
124124
</td>
125125
<td>
126-
<ins>A map from the AsyncContext.Variable instances to the saved ECMAScript language value. Every Record in the List contains a unique [[AsyncContextKey]]. The map is initially empty.</ins>
126+
<ins>A map from the AsyncContext.Variable instances to the saved ECMAScript language value. Every Record in the List contains a unique [[AsyncContextKey]]. The map is initially the return value of GetHostDefinedAsyncContextMapping().</ins>
127127
</td>
128128
</tr>
129129
</table>
@@ -255,6 +255,59 @@ <h1>
255255
</emu-clause>
256256
</emu-clause>
257257

258+
<emu-clause id="sec-ecmascript-language-scripts-and-modules">
259+
<h1>ECMAScript Language: Scripts and Modules</h1>
260+
261+
<emu-clause id="sec-modules">
262+
<h1>Modules</h1>
263+
264+
<emu-clause id="sec-module-semantics">
265+
<h1>Module Semantics</h1>
266+
267+
<emu-clause id="sec-source-text-module-records">
268+
<h1>Source Text Module Records</h1>
269+
<emu-clause id="sec-source-text-module-record-execute-module" type="concrete method">
270+
<h1>
271+
ExecuteModule (
272+
optional _capability_: a PromiseCapability Record,
273+
): either a normal completion containing ~unused~ or a throw completion
274+
</h1>
275+
<dl class="header">
276+
<dt>for</dt>
277+
<dd>a Source Text Module Record _module_</dd>
278+
</dl>
279+
280+
<emu-alg>
281+
1. Let _moduleContext_ be a new ECMAScript code execution context.
282+
1. Set the Function of _moduleContext_ to *null*.
283+
1. Set the Realm of _moduleContext_ to _module_.[[Realm]].
284+
1. Set the ScriptOrModule of _moduleContext_ to _module_.
285+
1. Assert: _module_ has been linked and declarations in its module environment have been instantiated.
286+
1. Set the VariableEnvironment of _moduleContext_ to _module_.[[Environment]].
287+
1. Set the LexicalEnvironment of _moduleContext_ to _module_.[[Environment]].
288+
1. Suspend the running execution context.
289+
1. <ins>Let _previousContextMapping_ be AsyncContextSwap(GetHostDefinedAsyncContextMapping()).</ins>
290+
1. If _module_.[[HasTLA]] is *false*, then
291+
1. Assert: _capability_ is not present.
292+
1. Push _moduleContext_ onto the execution context stack; _moduleContext_ is now the running execution context.
293+
1. Let _result_ be Completion(Evaluation of _module_.[[ECMAScriptCode]]).
294+
1. <ins>AsyncContextSwap(_previousContextMapping_).</ins>
295+
1. Suspend _moduleContext_ and remove it from the execution context stack.
296+
1. Resume the context that is now on the top of the execution context stack as the running execution context.
297+
1. If _result_ is an abrupt completion, then
298+
1. Return ? _result_.
299+
1. Else,
300+
1. Assert: _capability_ is a PromiseCapability Record.
301+
1. Perform AsyncBlockStart(_capability_, _module_.[[ECMAScriptCode]], _moduleContext_).
302+
1. <ins>AsyncContextSwap(_previousContextMapping_).</ins>
303+
1. Return ~unused~.
304+
</emu-alg>
305+
</emu-clause>
306+
</emu-clause>
307+
</emu-clause>
308+
</emu-clause>
309+
</emu-clause>
310+
258311
<emu-clause id="sec-control-abstraction-objects">
259312
<h1>Control Abstraction Objects</h1>
260313

@@ -936,6 +989,24 @@ <h1>The AsyncContext Object</h1>
936989

937990
<emu-clause id="sec-asynccontext-abstract-operations">
938991
<h1>AsyncContext Abstract Operations</h1>
992+
993+
<emu-clause id="sec-gethostdefinedasynccontextmapping" type="abstract operation">
994+
<h1>GetHostDefinedAsyncContextMapping ( ): a List of Async Context Mapping Records</h1>
995+
<dl class="header">
996+
</dl>
997+
<p>An implementation of GetHostDefinedAsyncContextMapping must conform to the following requirements:</p>
998+
<ul>
999+
<li>It must perform and return a List of Async Context Mapping Records.</li>
1000+
</ul>
1001+
<p>The default implementation of GetHostDefinedAsyncContextMapping performs the following steps when called:</p>
1002+
<emu-alg>
1003+
1. Return a new empty List.
1004+
</emu-alg>
1005+
<emu-note>
1006+
<p>ECMAScript hosts may add host defined async context mapping entries to the list.</p>
1007+
</emu-note>
1008+
</emu-clause>
1009+
9391010
<emu-clause id="sec-asynccontextsnapshot" type="abstract operation">
9401011
<h1>
9411012
AsyncContextSnapshot (
@@ -1358,3 +1429,27 @@ <h1>FinalizationRegistry ( _cleanupCallback_ )</h1>
13581429
</emu-clause>
13591430
</emu-clause>
13601431
</emu-clause>
1432+
1433+
<emu-annex id="sec-host-layering-points">
1434+
<h1>Host Layering Points</h1>
1435+
1436+
<emu-annex id="sec-host-hooks-summary">
1437+
<h1>Host Hooks</h1>
1438+
<p><b><ins>GetHostDefinedAsyncContextMapping(...)</ins></b></p>
1439+
<p><b>HostCallJobCallback(...)</b></p>
1440+
<p><b>HostEnqueueFinalizationRegistryCleanupJob(...)</b></p>
1441+
<p><b>HostEnqueueGenericJob(...)</b></p>
1442+
<p><b>HostEnqueuePromiseJob(...)</b></p>
1443+
<p><b>HostEnqueueTimeoutJob(...)</b></p>
1444+
<p><b>HostEnsureCanCompileStrings(...)</b></p>
1445+
<p><b>HostFinalizeImportMeta(...)</b></p>
1446+
<p><b>HostGetImportMetaProperties(...)</b></p>
1447+
<p><b>HostGrowSharedArrayBuffer(...)</b></p>
1448+
<p><b>HostHasSourceTextAvailable(...)</b></p>
1449+
<p><b>HostLoadImportedModule(...)</b></p>
1450+
<p><b>HostMakeJobCallback(...)</b></p>
1451+
<p><b>HostPromiseRejectionTracker(...)</b></p>
1452+
<p><b>HostResizeArrayBuffer(...)</b></p>
1453+
<p><b>InitializeHostDefinedRealm(...)</b></p>
1454+
</emu-annex>
1455+
</emu-annex>

0 commit comments

Comments
 (0)