- ExecuteModule ( [ _capability_ ] )
+ ExecuteModule ( [ _capability_ ] ) Concrete Method
The ExecuteModule concrete method of a Source Text Module Record implements the corresponding Cyclic Module Record abstract method.
@@ -684,22 +714,28 @@ ExecuteModule ( [ _capability_ ] )
1. Let _module_ be this Source Text Module Record.
- 1. Let _moduleCxt_ be a new ECMAScript code execution context.
- 1. Set the Function of _moduleCxt_ to *null*.
- 1. Assert: _module_.[[Realm]] is not *undefined*.
- 1. Set the Realm of _moduleCxt_ to _module_.[[Realm]].
- 1. Set the ScriptOrModule of _moduleCxt_ to _module_.
- 1. Assert: _module_ has been linked and declarations in its module environment have been linked.
- 1. Set the VariableEnvironment of _moduleCxt_ to _module_.[[Environment]].
- 1. Set the LexicalEnvironment of _moduleCxt_ to _module_.[[Environment]].
+ 1. Let _moduleCxt_ be a new ECMAScript code execution context.
+ 1. Set the Function of _moduleCxt_ to *null*.
+ 1. Assert: _module_.[[Realm]] is not *undefined*.
+ 1. Set the Realm of _moduleCxt_ to _module_.[[Realm]].
+ 1. Set the ScriptOrModule of _moduleCxt_ to _module_.
+ 1. Assert: _module_ has been linked and declarations in its module environment have been linked.
+ 1. Set the VariableEnvironment of _moduleCxt_ to _module_.[[Environment]].
+ 1. Set the LexicalEnvironment of _moduleCxt_ to _module_.[[Environment]].
1. Suspend the currently running execution context.
+ 1. Let moduleContext be module.[[Context]].
+ 1. Push moduleContext onto the execution context stack; moduleContext is now the running execution context.
+ 1. Let result be the result of evaluating module.[[ECMAScriptCode]].
+ 1. Suspend moduleContext and remove it from the execution context stack.
+ 1. Resume the context that is now on the top of the execution context stack as the running execution context.
+ 1. Return Completion(result).
1. If _module_.[[Async]] is *false*, then
1. Assert: _capability_ was not provided.
- 1. Push _moduleCxt_ on to the execution context stack; _moduleCxt_ is now the running execution context.
- 1. Let _result_ be the result of evaluating _module_.[[ECMAScriptCode]].
- 1. Suspend _moduleCxt_ and remove it from the execution context stack.
- 1. Resume the context that is now on the top of the execution context stack as the running execution context.
- 1. Return Completion(_result_).
+ 1. Push _moduleCxt_ on to the execution context stack; _moduleCxt_ is now the running execution context.
+ 1. Let _result_ be the result of evaluating _module_.[[ECMAScriptCode]].
+ 1. Suspend _moduleCxt_ and remove it from the execution context stack.
+ 1. Resume the context that is now on the top of the execution context stack as the running execution context.
+ 1. Return Completion(_result_).
1. Otherwise,
1. Assert: _capability_ is a PromiseCapability Record.
1. Perform ! AsyncBlockStart(_capability_, _module_.[[ECMAScriptCode]], _moduleCxt_).
@@ -709,7 +745,8 @@ ExecuteModule ( [ _capability_ ] )
- Example Source Text Module Record Graphs
+ Example Cyclic Module Record GraphsExample Source Text Module Record
+ Graphs
This non-normative section gives a series of examples of the linking and evaluation of a few common module graphs, with a specific focus on how errors can occur.