Skip to content

Commit

Permalink
Update Module Semantics to handle export * as ns...
Browse files Browse the repository at this point in the history
  • Loading branch information
Valerie R Young committed Apr 19, 2018
1 parent 2a06bf1 commit 5999e11
Showing 1 changed file with 54 additions and 37 deletions.
91 changes: 54 additions & 37 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -8814,6 +8814,13 @@ <h1>[[Get]] ( _P_, _Receiver_ )</h1>
1. Assert: _binding_ is a ResolvedBinding Record.
1. Let _targetModule_ be _binding_.[[Module]].
1. Assert: _targetModule_ is not *undefined*.
1. If _binding_.[[BindingName]] is `"*namespace*"`, then
1. Return ? GetModuleNamespace(_targetModule_).
1. Else,
1. Let _targetEnv_ be _targetModule_.[[Environment]].
1. If _targetEnv_ is *undefined*, throw a *ReferenceError* exception.
1. Let _targetEnvRec_ be _targetEnv_'s EnvironmentRecord.
1. Return ? _targetEnvRec_.GetBindingValue(_binding_.[[BindingName]], *true*).
1. Let _targetEnv_ be _targetModule_.[[Environment]].
1. If _targetEnv_ is *undefined*, throw a *ReferenceError* exception.
1. Let _targetEnvRec_ be _targetEnv_'s EnvironmentRecord.
Expand Down Expand Up @@ -22148,7 +22155,7 @@ <h1>Abstract Module Records</h1>
ResolveExport(_exportName_, _resolveSet_)
</td>
<td>
<p>Return the binding of a name exported by this module. Bindings are represented by a <dfn id="resolvedbinding-record">ResolvedBinding Record</dfn>, of the form {[[Module]]: Module Record, [[BindingName]]: String}. Return *null* if the name cannot be resolved, or `"ambiguous"` if multiple bindings were found.</p>
<p>Return the binding of a name exported by this module. Bindings are represented by a <dfn id="resolvedbinding-record">ResolvedBinding Record</dfn>, of the form {[[Module]]: Module Record, [[BindingName]]: String}. If the export is a Module Namespace Object without a direct binding in any module, [[BindingName]] will be set to `"*namespace*"`. Return *null* if the name cannot be resolved, or `"ambiguous"` if multiple bindings were found.</p>
<p>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.</p>
</td>
</tr>
Expand Down Expand Up @@ -22250,7 +22257,7 @@ <h1>Source Text Module Records</h1>
List of ExportEntry Records
</td>
<td>
A List of ExportEntry records derived from the code of this module that correspond to reexported imports that occur within the module.
A List of ExportEntry records derived from the code of this module that correspond to reexported imports that occur within the module or exports from export * as namespace declarations.
</td>
</tr>
<tr>
Expand All @@ -22261,7 +22268,7 @@ <h1>Source Text Module Records</h1>
List of ExportEntry Records
</td>
<td>
A List of ExportEntry records derived from the code of this module that correspond to export * declarations that occur within the module.
A List of ExportEntry records derived from the code of this module that correspond to export * declarations that occur within the module, not including export * as namespace declarations.
</td>
</tr>
<tr>
Expand Down Expand Up @@ -22470,7 +22477,7 @@ <h1>Source Text Module Records</h1>
[[ExportName]]
</td>
<td>
String
String | null
</td>
<td>
The name used to export this binding by this module.
Expand Down Expand Up @@ -22692,16 +22699,17 @@ <h1>Source Text Module Records</h1>
`export * as ns from "mod";`
</td>
<td>
*null*
`"ns"`
</td>
<td>
`"mod"`
</td>
<td>
`"*"`
</td>

<td>
`"ns"`
*null*
</td>
</tr>
</tbody>
Expand Down Expand Up @@ -22736,7 +22744,7 @@ <h1>ParseModule ( _sourceText_, _realm_, _hostDefined_ )</h1>
1. Append _ee_ to _localExportEntries_.
1. Else this is a re-export of a single name,
1. Append the ExportEntry Record {[[ModuleRequest]]: _ie_.[[ModuleRequest]], [[ImportName]]: _ie_.[[ImportName]], [[LocalName]]: *null*, [[ExportName]]: _ee_.[[ExportName]] } to _indirectExportEntries_.
1. Else if _ee_.[[ImportName]] is `"*"`, then
1. Else if _ee_.[[ImportName]] is `"*"` and _ee_.[[ExportName]] is *null*, then
1. Append _ee_ to _starExportEntries_.
1. Else,
1. Append _ee_ to _indirectExportEntries_.
Expand Down Expand Up @@ -22785,7 +22793,7 @@ <h1>ResolveExport( _exportName_, _resolveSet_ ) Concrete Method</h1>

<p>ResolveExport attempts to resolve an imported binding to the actual defining module and local binding name. The defining module may be the module represented by the Module Record this method was invoked on or some other module that is imported by that module. The parameter _resolveSet_ is used to detect unresolved circular import/export paths. If a pair consisting of specific Module Record and _exportName_ is reached that is already in _resolveSet_, an import circularity has been encountered. Before recursively calling ResolveExport, a pair consisting of _module_ and _exportName_ is added to _resolveSet_.</p>

<p>If a defining module is found, a ResolvedBinding Record {[[Module]], [[BindingName]]} is returned. This record identifies the resolved binding of the originally requested export. If no definition was found or the request is found to be circular, *null* is returned. If the request is found to be ambiguous, the string `"ambiguous"` is returned.</p>
<p>If a defining module is found, a ResolvedBinding Record {[[Module]], [[BindingName]]} is returned. This record identifies the resolved binding of the originally requested export, unless this is the export of a namespace with no local binding. In this case, [[BindingName]] will be set to `"*namespace*"`. If no definition was found or the request is found to be circular, *null* is returned. If the request is found to be ambiguous, the string `"ambiguous"` is returned.</p>

<p>This abstract method performs the following steps:</p>

Expand All @@ -22802,13 +22810,17 @@ <h1>ResolveExport( _exportName_, _resolveSet_ ) Concrete Method</h1>
1. Return ResolvedBinding Record {[[Module]]: _module_, [[BindingName]]: _e_.[[LocalName]]}.
1. For each ExportEntry Record _e_ in _module_.[[IndirectExportEntries]], do
1. If SameValue(_exportName_, _e_.[[ExportName]]) is *true*, then
1. Assert: _module_ imports a specific binding for this export.
1. Let _importedModule_ be ? HostResolveImportedModule(_module_, _e_.[[ModuleRequest]]).
1. Return _importedModule_.ResolveExport(_e_.[[ImportName]], _resolveSet_).
1. If _e_.[[ImportName]] is `"*"`, then
1. NOTE: _module_ does not provide the direct binding for this export.
1. Return ResolvedBinding Record {[[Module]]: _e_.[[ModuleRequest]], [[BindingName]]: `"*namespace*"`}.
1. Else,
1. Assert: _module_ imports a specific binding for this export.
1. Let _importedModule_ be ? HostResolveImportedModule(_module_, _e_.[[ModuleRequest]]).
1. Return _importedModule_.ResolveExport(_e_.[[ImportName]], _resolveSet_)
1. If SameValue(_exportName_, `"default"`) is *true*, then
1. Assert: A `default` export was not explicitly defined by this module.
1. Return *null*.
1. NOTE: A `default` export cannot be provided by an `export *`.
1. NOTE: A `default` export cannot be provided by an `export * from "mod"` declaration.
1. Let _starResolution_ be *null*.
1. For each ExportEntry Record _e_ in _module_.[[StarExportEntries]], do
1. Let _importedModule_ be ? HostResolveImportedModule(_module_, _e_.[[ModuleRequest]]).
Expand Down Expand Up @@ -22921,7 +22933,12 @@ <h1>ModuleDeclarationEnvironmentSetup( _module_ )</h1>
1. Else,
1. Let _resolution_ be ? _importedModule_.ResolveExport(_in_.[[ImportName]], &laquo; &raquo;).
1. If _resolution_ is *null* or `"ambiguous"`, throw a *SyntaxError* exception.
1. Call _envRec_.CreateImportBinding(_in_.[[LocalName]], _resolution_.[[Module]], _resolution_.[[BindingName]]).
1. If _resolution_.[[BindingName]] is `"*namespace*"`, then
1. Let _namespace_ be ? GetModuleNamespace(_resolution_.[[Module]]).
1. Perform ! _envRec_.CreateImmutableBinding(_in_.[[LocalName]], *true*).
1. Call _envRec_.InitializeBinding(_in_.[[LocalName]], _namespace_).
1. Else,
1. Call _envRec_.CreateImportBinding(_in_.[[LocalName]], _resolution_.[[Module]], _resolution_.[[BindingName]]).
1. Let _code_ be _module_.[[ECMAScriptCode]].
1. Let _varDeclarations_ be the VarScopedDeclarations of _code_.
1. Let _declaredVarNames_ be a new empty List.
Expand Down Expand Up @@ -23368,7 +23385,7 @@ <h2>Syntax</h2>
<emu-grammar type="definition">
ExportDeclaration :
`export` ExportFromClause FromClause `;`
`export` ExportClause `;`
`export` NamedExports `;`
`export` VariableStatement[~Yield, ~Await]
`export` Declaration[~Yield, ~Await]
`export` `default` HoistableDeclaration[~Yield, ~Await, +Default]
Expand All @@ -23377,13 +23394,13 @@ <h2>Syntax</h2>

ExportFromClause :
`*`
ExportClause
NamedExports
NameSpaceExport

NameSpaceExport:
`*` `as` IdentifierName

ExportClause :
NamedExports :
`{` `}`
`{` ExportsList `}`
`{` ExportsList `,` `}`
Expand All @@ -23400,14 +23417,14 @@ <h2>Syntax</h2>
<!-- es6num="15.2.3.1" -->
<emu-clause id="sec-exports-static-semantics-early-errors">
<h1>Static Semantics: Early Errors</h1>
<emu-grammar>ExportDeclaration : `export` ExportClause `;`</emu-grammar>
<emu-grammar>ExportDeclaration : `export` NamedExports `;`</emu-grammar>
<ul>
<li>
For each |IdentifierName| _n_ in ReferencedBindings of |ExportClause|: It is a Syntax Error if StringValue of _n_ is a |ReservedWord| or if the StringValue of _n_ is one of: `"implements"`, `"interface"`, `"let"`, `"package"`, `"private"`, `"protected"`, `"public"`, or `"static"`.
For each |IdentifierName| _n_ in ReferencedBindings of |NamedExports|: It is a Syntax Error if StringValue of _n_ is a |ReservedWord| or if the StringValue of _n_ is one of: `"implements"`, `"interface"`, `"let"`, `"package"`, `"private"`, `"protected"`, `"public"`, or `"static"`.
</li>
</ul>
<emu-note>
<p>The above rule means that each ReferencedBindings of |ExportClause| is treated as an |IdentifierReference|.</p>
<p>The above rule means that each ReferencedBindings of |NamedExports| is treated as an |IdentifierReference|.</p>
</emu-note>
</emu-clause>

Expand All @@ -23418,7 +23435,7 @@ <h1>Static Semantics: BoundNames</h1>
<emu-grammar>
ExportDeclaration :
`export` ExportFromClause FromClause `;`
`export` ExportClause `;`
`export` NamedExports `;`
</emu-grammar>
<emu-alg>
1. Return a new empty List.
Expand Down Expand Up @@ -23460,9 +23477,9 @@ <h1>Static Semantics: ExportedBindings</h1>
<emu-alg>
1. Return a new empty List.
</emu-alg>
<emu-grammar>ExportDeclaration : `export` ExportClause `;`</emu-grammar>
<emu-grammar>ExportDeclaration : `export` NamedExports `;`</emu-grammar>
<emu-alg>
1. Return the ExportedBindings of |ExportClause|.
1. Return the ExportedBindings of |NamedExports|.
</emu-alg>
<emu-grammar>ExportDeclaration : `export` VariableStatement</emu-grammar>
<emu-alg>
Expand All @@ -23482,7 +23499,7 @@ <h1>Static Semantics: ExportedBindings</h1>
<emu-alg>
1. Return the BoundNames of this |ExportDeclaration|.
</emu-alg>
<emu-grammar>ExportClause : `{` `}`</emu-grammar>
<emu-grammar>NamedExports : `{` `}`</emu-grammar>
<emu-alg>
1. Return a new empty List.
</emu-alg>
Expand Down Expand Up @@ -23514,13 +23531,13 @@ <h1>Static Semantics: ExportedNames</h1>
<emu-alg>
1. Return a new empty List.
</emu-alg>
<emu-grammar>ExportFromClause : ExportClause</emu-grammar>
<emu-grammar>ExportFromClause : NamedExports</emu-grammar>
<emu-alg>
1. Return the ExportedNames of ExportClause.
1. Return the ExportedNames of NamedExports.
</emu-alg>
<emu-grammar>ExportFromClause : NameSpaceExport</emu-grammar>
<emu-grammar>NameSpaceExport : `*` `as` IdentifierName </emu-grammar>
<emu-alg>
1. Return the ExportedNames of NameSpaceExport.
1. Return a List containing the StringValue of |IdentifierName|.
</emu-alg>
<emu-grammar>ExportDeclaration : `export` VariableStatement</emu-grammar>
<emu-alg>
Expand All @@ -23540,7 +23557,7 @@ <h1>Static Semantics: ExportedNames</h1>
<emu-alg>
1. Return &laquo; `"default"` &raquo;.
</emu-alg>
<emu-grammar>ExportClause : `{` `}`</emu-grammar>
<emu-grammar>NamedExports : `{` `}`</emu-grammar>
<emu-alg>
1. Return a new empty List.
</emu-alg>
Expand Down Expand Up @@ -23569,9 +23586,9 @@ <h1>Static Semantics: ExportEntries</h1>
1. Let _module_ be the sole element of ModuleRequests of |FromClause|.
1. Return ExportEntriesForModule of |ExportFromClause| with argument _module_.
</emu-alg>
<emu-grammar>ExportDeclaration : `export` ExportClause `;`</emu-grammar>
<emu-grammar>ExportDeclaration : `export` NamedExports `;`</emu-grammar>
<emu-alg>
1. Return ExportEntriesForModule of |ExportClause| with argument *null*.
1. Return ExportEntriesForModule of |NamedExports| with argument *null*.
</emu-alg>
<emu-grammar>ExportDeclaration : `export` VariableStatement</emu-grammar>
<emu-alg>
Expand Down Expand Up @@ -23626,7 +23643,7 @@ <h1>Static Semantics: ExportEntriesForModule</h1>
1. Let _entry_ be the ExportEntry Record {[[ModuleRequest]]: _module_, [[ImportName]]: `"*"`, [[LocalName]]: *null*, [[ExportName]]: _exportName_ }.
1. Return a new List containing _entry_.
</emu-alg>
<emu-grammar>ExportClause : `{` `}`</emu-grammar>
<emu-grammar>NamedExports : `{` `}`</emu-grammar>
<emu-alg>
1. Return a new empty List.
</emu-alg>
Expand Down Expand Up @@ -23668,7 +23685,7 @@ <h1>Static Semantics: IsConstantDeclaration</h1>
<emu-grammar>
ExportDeclaration :
`export` ExportFromClause FromClause `;`
`export` ExportClause `;`
`export` NamedExports `;`
`export` `default` AssignmentExpression `;`
</emu-grammar>
<emu-alg>
Expand All @@ -23686,7 +23703,7 @@ <h1>Static Semantics: LexicallyScopedDeclarations</h1>
<emu-grammar>
ExportDeclaration :
`export` ExportFromClause FromClause `;`
`export` ExportClause `;`
`export` NamedExports `;`
`export` VariableStatement
</emu-grammar>
<emu-alg>
Expand Down Expand Up @@ -23722,7 +23739,7 @@ <h1>Static Semantics: ModuleRequests</h1>
</emu-alg>
<emu-grammar>
ExportDeclaration :
`export` ExportClause `;`
`export` NamedExports `;`
`export` VariableStatement
`export` Declaration
`export` `default` HoistableDeclaration
Expand All @@ -23737,7 +23754,7 @@ <h1>Static Semantics: ModuleRequests</h1>
<!-- es6num="15.2.3.10" -->
<emu-clause id="sec-static-semantics-referencedbindings">
<h1>Static Semantics: ReferencedBindings</h1>
<emu-grammar>ExportClause : `{` `}`</emu-grammar>
<emu-grammar>NamedExports : `{` `}`</emu-grammar>
<emu-alg>
1. Return a new empty List.
</emu-alg>
Expand All @@ -23763,7 +23780,7 @@ <h1>Runtime Semantics: Evaluation</h1>
<emu-grammar>
ExportDeclaration :
`export` ExportFromClause FromClause `;`
`export` ExportClause `;`
`export` NamedExports `;`
</emu-grammar>
<emu-alg>
1. Return NormalCompletion(~empty~).
Expand Down Expand Up @@ -40504,7 +40521,7 @@ <h1>Scripts and Modules</h1>
<emu-prodref name=ModuleSpecifier></emu-prodref>
<emu-prodref name=ImportedBinding></emu-prodref>
<emu-prodref name=ExportDeclaration></emu-prodref>
<emu-prodref name=ExportClause></emu-prodref>
<emu-prodref name=NamedExports></emu-prodref>
<emu-prodref name=ExportsList></emu-prodref>
<emu-prodref name=ExportSpecifier></emu-prodref>
</emu-annex>
Expand Down

0 comments on commit 5999e11

Please sign in to comment.