Skip to content

Commit d606a6c

Browse files
Normative: Define module root level context (#98)
Co-authored-by: Andreu Botella <abotella@igalia.com>
1 parent 782a6ec commit d606a6c

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

spec.html

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,60 @@ <h1>Runtime Semantics: Evaluation</h1>
305305
</emu-clause>
306306
</emu-clause>
307307

308+
<emu-clause id="sec-ecmascript-language-scripts-and-modules">
309+
<h1>ECMAScript Language: Scripts and Modules</h1>
310+
311+
<emu-clause id="sec-modules">
312+
<h1>Modules</h1>
313+
314+
<emu-clause id="sec-module-semantics">
315+
<h1>Module Semantics</h1>
316+
317+
<emu-clause id="sec-source-text-module-records">
318+
<h1>Source Text Module Records</h1>
319+
<emu-clause id="sec-source-text-module-record-execute-module" type="concrete method">
320+
<h1>
321+
ExecuteModule (
322+
optional _capability_: a PromiseCapability Record,
323+
): either a normal completion containing ~unused~ or a throw completion
324+
</h1>
325+
<dl class="header">
326+
<dt>for</dt>
327+
<dd>a Source Text Module Record _module_</dd>
328+
</dl>
329+
330+
<emu-alg>
331+
1. Let _moduleContext_ be a new ECMAScript code execution context.
332+
1. Set the Function of _moduleContext_ to *null*.
333+
1. Set the Realm of _moduleContext_ to _module_.[[Realm]].
334+
1. Set the ScriptOrModule of _moduleContext_ to _module_.
335+
1. Assert: _module_ has been linked and declarations in its module environment have been instantiated.
336+
1. Set the VariableEnvironment of _moduleContext_ to _module_.[[Environment]].
337+
1. Set the LexicalEnvironment of _moduleContext_ to _module_.[[Environment]].
338+
1. Suspend the running execution context.
339+
1. <ins>Let _moduleContextMapping_ be a new empty list.</ins>
340+
1. <ins>Let _previousContextMapping_ be AsyncContextSwap(_moduleContextMapping_).</ins>
341+
1. If _module_.[[HasTLA]] is *false*, then
342+
1. Assert: _capability_ is not present.
343+
1. Push _moduleContext_ onto the execution context stack; _moduleContext_ is now the running execution context.
344+
1. Let _result_ be Completion(Evaluation of _module_.[[ECMAScriptCode]]).
345+
1. Suspend _moduleContext_ and remove it from the execution context stack.
346+
1. Resume the context that is now on the top of the execution context stack as the running execution context.
347+
1. <ins>AsyncContextSwap(_previousContextMapping_).</ins>
348+
1. If _result_ is an abrupt completion, then
349+
1. Return ? _result_.
350+
1. Else,
351+
1. Assert: _capability_ is a PromiseCapability Record.
352+
1. Perform AsyncBlockStart(_capability_, _module_.[[ECMAScriptCode]], _moduleContext_).
353+
1. <ins>AsyncContextSwap(_previousContextMapping_).</ins>
354+
1. Return ~unused~.
355+
</emu-alg>
356+
</emu-clause>
357+
</emu-clause>
358+
</emu-clause>
359+
</emu-clause>
360+
</emu-clause>
361+
308362
<emu-clause id="sec-control-abstraction-objects">
309363
<h1>Control Abstraction Objects</h1>
310364

0 commit comments

Comments
 (0)