diff --git a/spec.html b/spec.html index 470d505..3667c98 100644 --- a/spec.html +++ b/spec.html @@ -16,349 +16,222 @@
In addition, they provide late definition of export bindings at the execution phase, to support named exports compatibility with legacy module systems.
-- Method - | -- Purpose - | -
---|---|
- GetExportedNames(_exportStarSet_, _nsModule_) - | -- Return a list of all names that are either directly or indirectly exported from this module. - | -
- ResolveExport(_exportName_, _resolveSet_) - | -
- Return the binding of a name exported by this module. Bindings are represented by a ResolvedBinding Record, of the form { [[Module]]: Module Record, [[BindingName]]: String }. Return *null* if the name cannot be resolved, or `"ambiguous"` if multiple bindings were found. -This operation must be idempotent if it completes normally. Each time it is called with a specific _exportName_, _resolveSet_ pair as arguments it must return the same result. - |
-
- Instantiate() - | -
- Prepare the module for evaluation by transitively resolving all module dependencies and creating a module Environment Record. - |
-
- Evaluate() - | -
- If this module has already been evaluated successfully, return *undefined*; if it has already been evaluated unsuccessfully, throw the exception that was produced. Otherwise, transitively evaluate all module dependencies of this module and then evaluate this module. -Instantiate must have completed successfully prior to invoking this method. - |
-
The GetExportedNames concrete method of a Source Text Module Record implements the corresponding Module Record abstract method.
-It performs the following steps:
-GetExportedNames does not filter out or throw an exception for names that have ambiguous star export bindings.
-A Dynamic Module Record is used to represent information about a module that is defined programatically. Its fields contain digested information about the names that are exported by the module and its concrete methods use this digest to link, instantiate, and evaluate the module alongside other Abstract Module Records.
- -Dependency cycles with Source Text Module Records are avoided since these modules can only export, and not import from other Abstract Module Records.
- -Dynamic Module Records support late export binding, in that export names are only validated after execution.
- -In addition to the fields, defined in
- Field Name - | -- Value Type - | -- Meaning - | -
---|---|---|
- [[ExportNames]] - | -- A string List of exported names. - | -- The list of export bindings associated with this Dynamic Module Record. - | -
- [[PendingNamespaceModules]] - | -- A List of Module Record - | -- The list of module records whose module namespace objects are already created and require this dynamic module to execution for their finalization. - | -
- [[EvaluationError]] - | -- An abrupt completion | *undefined* - | -- A completion of type ~throw~ representing the exception that occurred during evaluation. *undefined* if no exception occurred or if [[Status]] is not `"evaluated"`. - | -
This method would be expected to be called by the host when constructing a Module Record in _HostResolveImportedModule_.
-The abstract operation CreateDynamicModule with arguments _realm_, and _hostDefined_ creates a new Dynamic Module Record performing the following steps:
-The following definitions specify the required concrete methods for Dynamic Module Records.
- -The GetExportedNames concrete method of a Dynamic Module Record implements the corresponding Module Record abstract method.
-Any modules exporting names from this Dynamic Module Record are stored so their exports can be amended on execution of this Dynamic Module.
-It performs the following steps:
-For each Module Namespace Exotic Object created that star exports from a Dynamic Module Record before that the dynamic module has executed, we track the number of these under [[HostDefined]] on the namespace. This way namespace finalization to set the exports can be performed by the last dynamic module to execute.
-The ResolveExport concrete method of a Dynamic Module Record implements the corresponding Module Record abstract method.
- -ResolveExport ensures that a binding is created for the dynamic Module Record, lazily creating a binding if needed.
- -This abstract method performs the following steps:
- -The Instantiate concrete method of a Dynamic Module Record implements the corresponding Module Record abstract method.
-On success, Instantiate transitions this module's [[Status]] from `"uninstantiated"` to `"instantiated"`. On failure, an exception is thrown and this module's [[Status]] remains `"uninstantiated"`.
- -This abstract method performs the following steps:
- -The Evaluate concrete method of a Dynamic Module Record implements the corresponding Module Record abstract method.
-Evaluate transitions this module's [[Status]] from `"instantiated"` to `"evaluated"`.
- -If execution results in an exception, that exception is recorded in the [[EvaluationError]] field and rethrown by future invocations of Evaluate.
+A Dynamic Module Record is used to represent information about a module that is defined programatically. Its fields contain digested information about the names that are exported by the module and its concrete methods use this digest to link, instantiate, and evaluate the module alongside other Abstract Module Records.
+ +Dependency cycles with Source Text Module Records are avoided since these modules can only export, and not import from other Abstract Module Records.
+ +Dynamic Module Records support late export binding, in that export names are only validated after execution.
+ +In addition to the fields, defined in
+ Field Name + | ++ Value Type + | ++ Meaning + | +
---|---|---|
+ [[ExportNames]] + | ++ A string List of exported names. + | ++ The list of export bindings associated with this Dynamic Module Record. + | +
+ [[EvaluationError]] + | ++ An abrupt completion | *undefined* + | ++ A completion of type ~throw~ representing the exception that occurred during evaluation. *undefined* if no exception occurred or if [[Status]] is not `"evaluated"`. + | +
This method would be expected to be called by the host when constructing a Module Record in _HostResolveImportedModule_.
+The abstract operation CreateDynamicModule with arguments _realm_, and _hostDefined_ creates a new Dynamic Module Record performing the following steps:
+Evaluation of dynamic modules calls out to _HostEvaluateDynamicModule_, before finalising the export names of the dynamic modules. Any uninitialized export bindings throw a reference error at this stage.
+The following definitions specify the required concrete methods for Dynamic Module Records.
+ +The GetExportedNames concrete method of a Dynamic Module Record implements the corresponding Module Record abstract method.
+Any modules exporting names from this Dynamic Module Record are stored so their exports can be amended on execution of this Dynamic Module.
+It performs the following steps:
+The *null* return results in an error being thrown for star exports from dynamic modules, and creating an "unfinalized" namespace in the case of an uninstantiated dynamic namespace creation in cycles.
+This abstract method performs the following steps:
+The ResolveExport concrete method of a Dynamic Module Record implements the corresponding Module Record abstract method.
+ +ResolveExport ensures that a binding is created for the dynamic Module Record, lazily creating a binding if needed.
+ +This abstract method performs the following steps:
+ +The Instantiate concrete method of a Dynamic Module Record implements the corresponding Module Record abstract method.
+On success, Instantiate transitions this module's [[Status]] from `"uninstantiated"` to `"instantiated"`. On failure, an exception is thrown and this module's [[Status]] remains `"uninstantiated"`.
+ +This abstract method performs the following steps:
+ +The SetDynamicExportBinding concrete method of a Dynamic Module Record implements the corresponding Module Record abstract method for a string _name_ and initialization value _value_.
-After execution completion, only binding mutation is supported.
-This method can return an error on abrupt completion.
-The Evaluate concrete method of a Dynamic Module Record implements the corresponding Module Record abstract method.
+Evaluate transitions this module's [[Status]] from `"instantiated"` to `"evaluated"`.
+ +If execution results in an exception, that exception is recorded in the [[EvaluationError]] field and rethrown by future invocations of Evaluate.
+ +Evaluation of dynamic modules calls out to _HostEvaluateDynamicModule_, before finalising the export names of the dynamic modules. Any uninitialized export bindings throw a reference error at this stage.
+ +This abstract method performs the following steps:
+ +HostEvaluateDynamicModule is an implementation-defined abstract operation that performs programmatic execution of a Dynamic Module Record, _dynamicModule_.
-The implementation of HostEvaluateDynamicModule must conform to the following requirements:
-HostEvaluateDynamicModule must not itself rely on checking what lexical bindings have already been initialized for the module. It is important that the bindings defined in evaluation are fully independent of what bindings are imported.
-The SetDynamicExportBinding concrete method of a Dynamic Module Record implements the corresponding Module Record abstract method for a string _name_ and initialization value _value_.
+After execution completion, only binding mutation is supported.
+This method can return an error on abrupt completion.
+HostEvaluateDynamicModule is an implementation-defined abstract operation that performs programmatic execution of a Dynamic Module Record, _dynamicModule_.
+The implementation of HostEvaluateDynamicModule must conform to the following requirements:
+HostEvaluateDynamicModule must not itself rely on checking what lexical bindings have already been initialized for the module. It is important that the bindings defined in evaluation are fully independent of what bindings are imported.
+