Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
168 changes: 0 additions & 168 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -236,15 +236,6 @@ urlPrefix: https://tc39.github.io/ecma262/; spec: ECMA-262
text: running execution context; url: running-execution-context
</pre>

<pre class=biblio>
{
"JSSTDLIB": {
"href": "https://github.com/tc39/proposal-javascript-standard-library/",
"title": "Standard Library Proposal"
}
}
</pre>

<style>
pre.set {
font-size: 80%;
Expand Down Expand Up @@ -14248,165 +14239,6 @@ the exact steps to take if <dfn>an exception was thrown</dfn>, or by explicitly
</div>


<h3 id="synthetic-module-records">Synthetic module records</h3>

A <dfn export>Synthetic Module Record</dfn> is used to represent information about a module that is
defined by specifications.
The set of exported names is static, and determined at creation time (as an argument to
[$CreateSyntheticModule$]), while the set of exported values can be changed over time using
[$SetSyntheticModuleExport$].
It has no imports or dependencies.

Note: A [=Synthetic Module Record=] could be used for defining a variety of module types: for
example, built-in modules, or JSON modules, or CSS modules.

Note: [=Synthetic Module Records=] are being developed in concert with the authors of the
<cite>JavaScript Standard Library</cite> proposal, and might eventually move to the ECMAScript
specification. [[JSSTDLIB]] [[ECMA-262]].

In addition to the [=Module Record Fields=], Synthetic Module Records have the additional fields
listed below.
Each of these fields is initially set in [$CreateSyntheticModule$].

<table id="table-synthetic-module-record-fields" class="data">
<caption>Additional Fields of Synthetic Module Records</caption>
<thead>
<tr>
<th>Field Name
<th>Value Type
<th>Meaning
<tbody>
<tr>
<td>\[[ExportNames]]
<td>List of String
<td>A List of all names that are exported.
<tr>
<td>\[[EvaluationSteps]]
<td>An abstract operation
<td>An abstract operation that will be performed upon evaluation of the module, taking the
[=Synthetic Module Record=] as its sole argument.
These will usually set up the exported values, by using [$SetSyntheticModuleExport$].
They must not modify \[[ExportNames]].
They may return an abrupt completion.
</table>

<h4 id="createsyntheticmodule">CreateSyntheticModule</h4>

<div algorithm>
The abstract operation <dfn abstract-op>CreateSyntheticModule</dfn>(|exportNames|, |evaluationSteps|, |realm|, |hostDefined|) creates a [=Synthetic Module Record=] based upon
the given exported names and evaluation steps.
It performs the following steps:

1. Return [=Synthetic Module Record=] {
\[[Realm]]: |realm|,
\[[Environment]]: <emu-val>undefined</emu-val>,
\[[Namespace]]: <emu-val>undefined</emu-val>,
\[[HostDefined]]: |hostDefined|,
\[[ExportNames]]: |exportNames|,
\[[EvaluationSteps]]: |evaluationSteps|
}.
</div>

Note: we could set up \[[Environment]] either here or in [$Synthetic Module Record/Link$]().
It is done in [$Synthetic Module Record/Link$]() for symmetry with [=Source Text Module Records=],
but there is no observable difference.

<h4 id="setsyntheticmoduleexport">SetSyntheticModuleExport</h4>

<div algorithm>
The abstract operation <dfn abstract-op>SetSyntheticModuleExport</dfn>(|module|, |exportName|,
|exportValue|) can be used to set or change the exported value for a pre-established export of a
Synthetic Module Record.
It performs the following steps:

1. Let |envRec| be |module|.\[[Environment]]'s [=Lexical Environment/EnvironmentRecord=].
1. Perform |envRec|.[$Environment Record/SetMutableBinding$](|exportName|, |exportValue|,
<emu-val>true</emu-val>).
</div>

<h4 id="smr-concrete-methods">Concrete Methods</h4>

The following are the concrete methods for [=Synthetic Module Record=] that implement the
corresponding [=Module Record=] abstract methods.

<h5 id="smr-getexportednames">GetExportedNames</h5>

<div algorithm>
The <dfn abstract-op for="Synthetic Module Record">GetExportedNames</dfn>(<var
ignore>exportStarSet</var>) concrete method of a [=Synthetic Module Record=] implements the
corresponding [=Module Record=] abstract method.

It performs the following steps:

1. Let |module| be this [=Synthetic Module Record=].
1. Return |module|.\[[ExportNames]].
</div>

<h5 id="smr-resolveexport">ResolveExport</h5>

<div algorithm>
The <dfn abstract-op for="Synthetic Module Record">ResolveExport</dfn>(|exportName|, <var
ignore>resolveSet</var>) concrete method of a [=Synthetic Module Record=] implements the
corresponding [=Module Record=] abstract method.

It performs the following steps:

1. Let |module| be this [=Synthetic Module Record=].
1. If |module|.\[[ExportNames]] does not contain |exportName|, return <emu-val>null</emu-val>.
1. Return [=ResolvedBinding Record=] { \[[Module]]: |module|, \[[BindingName]]: |exportName| }.
</div>

<h5 id="smr-Link">Link</h5>

<div algorithm>
The <dfn abstract-op for="Synthetic Module Record">Link</dfn>() concrete method of a
[=Synthetic Module Record=] implements the corresponding [=Module Record=] abstract method.

It performs the following steps:

1. Let |module| be this [=Synthetic Module Record=].
1. Let |realm| be |module|.\[[Realm]].
1. Assert: |realm| is not <emu-val>undefined</emu-val>.
1. Let |env| be [$NewModuleEnvironment$](|realm|.\[[GlobalEnv]]).
1. Set |module|.\[[Environment]] to |env|.
1. Let |envRec| be |env|'s [=Lexical Environment/EnvironmentRecord=].
1. For each |exportName| in |module|.\[[ExportNames]],
1. Perform [=!=] |envRec|.[$Environment Record/CreateMutableBinding$](|exportName|,
<emu-val>false</emu-val>).
1. Perform [=!=] |envRec|.[$Environment Record/InitializeBinding$](|exportName|,
<emu-val>undefined</emu-val>).
1. Return <emu-val>undefined</emu-val>.
</div>

<h5 id="smr-evaluate">Evaluate</h5>

<div algorithm>
The <dfn abstract-op for="Synthetic Module Record">Evaluate</dfn>() concrete method of a
[=Synthetic Module Record=] implements the corresponding [=Module Record=] abstract method.

It performs the following steps:

1. Let |module| be this [=Synthetic Module Record=].
1. Let |moduleCxt| be a new [=ECMAScript code execution context=].
1. Set the [=Execution context/Function=] of |moduleCxt| to <emu-val>null</emu-val>.
1. Assert: |module|.\[[Realm]] is not <emu-val>undefined</emu-val>.
1. Set the [=Execution context/Realm=] of |moduleCxt| to |module|.\[[Realm]].
1. Set the [=Execution context/ScriptOrModule=] of |moduleCxt| to |module|.
1. Set the [=ECMAScript code execution context/VariableEnvironment=] of |moduleCxt| to
|module|.\[[Environment]].
1. Set the [=ECMAScript code execution context/LexicalEnvironment=] of |moduleCxt| to
|module|.\[[Environment]].
1. Suspend the currently [=running execution context=].
1. Push |moduleCxt| on to the [=execution context stack=]; |moduleCxt| is now the
[=running execution context=].
1. Let |completion| be the result of performing |module|.\[[EvaluationSteps]](|module|).
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$](|completion|).
</div>


<h2 id="common">Common definitions</h2>

This section specifies some common definitions that all
Expand Down