Skip to content

Commit

Permalink
spec feedback from @bakkot
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Jun 29, 2023
1 parent f1d263b commit cd75ff8
Showing 1 changed file with 140 additions and 8 deletions.
148 changes: 140 additions & 8 deletions spec.emu
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ contributors: Luca Casonato, Guy Bedford, Nicolò Ribaudo
<h1>
<ins>
EvaluateImportCall (
_specifierExpression_: a ParseNode,
_specifierExpression_: a Parse Node,
_phase_: ~source~ or ~evaluation~
): either a normal completion containing a Promise or a throw completion
</ins>
Expand All @@ -60,7 +60,7 @@ contributors: Luca Casonato, Guy Bedford, Nicolò Ribaudo
<emu-alg>
1. Let _referrer_ be GetActiveScriptOrModule().
1. If _referrer_ is *null*, set _referrer_ to the current Realm Record.
1. Let _specifierRef_ be the result of evaluating _specifierExpression_.
1. Let _specifierRef_ be ? Evaluation of evaluating _specifierExpression_.
1. Let _specifier_ be ? GetValue(_specifierRef_).
1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%).
1. Let _specifierString_ be Completion(ToString(_specifier_)).
Expand Down Expand Up @@ -133,7 +133,7 @@ contributors: Luca Casonato, Guy Bedford, Nicolò Ribaudo
<emu-clause id="sec-modulerequest-record">
<h1><ins>ModuleRequest Records</ins></h1>

<p>A <dfn id="modulerequest-record" variants="ModuleRequest Records">ModuleRequest Record</dfn> represents the request to import a module up to a given phase. It consists of the following fields:</p>
<p>A <dfn id="modulerequest-record" variants="ModuleRequest Records">ModuleRequest Record</dfn> represents a request to import a module up to a given phase. It consists of the following fields:</p>
<emu-table id="table-modulerequest-record-fields" caption="ModuleRequest Record fields">
<table>
<tbody>
Expand Down Expand Up @@ -376,7 +376,7 @@ contributors: Luca Casonato, Guy Bedford, Nicolò Ribaudo
<ins>GetModuleSource()</ins>
</td>
<td>
<p><ins>It returns either a normal completion completion for the ModuleSource Object corresponding to this source Module Record's source phase (<emu-xref href="#sec-module-source-objects"></emu-xref>), or a throw completion.</ins></p>
<p><ins>It returns either a normal completion completion for the Module Source Object corresponding to this source Module Record's source phase (<emu-xref href="#sec-module-source-objects"></emu-xref>), or a throw completion.</ins></p>
<ins>When called multiple times on the same Module Record, if GetModuleSource() returns a normal completion it must always return a normal completion containing the same object.</ins>
<ins>The returned object should be an instance of a subclass of %AbstractModuleSource%, and it must have an internal slot [[ModuleSourceClassName]].</ins>
</td>
Expand Down Expand Up @@ -840,6 +840,140 @@ contributors: Luca Casonato, Guy Bedford, Nicolò Ribaudo
</emu-alg>
</emu-clause>
</emu-clause>
<p>An <dfn id="importentry-record" variants="ImportEntry Records">ImportEntry Record</dfn> is a Record that digests information about a single declarative import. Each ImportEntry Record has the fields defined in <emu-xref href="#table-importentry-record-fields"></emu-xref>:</p>
<emu-table id="table-importentry-record-fields" caption="ImportEntry Record Fields" oldids="table-39">
<table>
<tr>
<th>
Field Name
</th>
<th>
Value Type
</th>
<th>
Meaning
</th>
</tr>
<tr>
<td>
[[ModuleRequest]]
</td>
<td>
a String
</td>
<td>
String value of the |ModuleSpecifier| of the |ImportDeclaration|.
</td>
</tr>
<tr>
<td>
[[ImportName]]
</td>
<td>
a String <del>or ~namespace-object~</del><ins>, ~namespace-object~ or ~source~</ins>
</td>
<td>
The name under which the desired binding is exported by the module identified by [[ModuleRequest]]. The value ~namespace-object~ indicates that the import request is for the target module's namespace object. <ins>The value ~source~ represents an import of the import phase representation at that phase name.</ins>
</td>
</tr>
<tr>
<td>
[[LocalName]]
</td>
<td>
a String
</td>
<td>
The name that is used to locally access the imported value from within the importing module.
</td>
</tr>
</table>
</emu-table>
<emu-note class="module-overflow-note">
<p><emu-xref href="#table-import-forms-mapping-to-importentry-records"></emu-xref> gives examples of ImportEntry records fields used to represent the syntactic import forms:</p>
<emu-table id="table-import-forms-mapping-to-importentry-records" caption="Import Forms Mappings to ImportEntry Records" informative oldids="table-40">
<table>
<tr>
<th>
Import Statement Form
</th>
<th>
[[ModuleRequest]]
</th>
<th>
[[ImportName]]
</th>
<th>
[[LocalName]]
</th>
</tr>
<tr>
<td>
`import v from "mod";`
</td>
<td>
*"mod"*
</td>
<td>
*"default"*
</td>
<td>
*"v"*
</td>
</tr>
<tr>
<td>
`import * as ns from "mod";`
</td>
<td>
*"mod"*
</td>
<td>
~namespace-object~
</td>
<td>
*"ns"*
</td>
</tr>
<tr>
<td>
`import {x} from "mod";`
</td>
<td>
*"mod"*
</td>
<td>
*"x"*
</td>
<td>
*"x"*
</td>
</tr>
<tr>
<td>
`import {x as v} from "mod";`
</td>
<td>
*"mod"*
</td>
<td>
*"x"*
</td>
<td>
*"v"*
</td>
</tr>
<tr>
<td>
`import "mod";`
</td>
<td colspan="3">
An ImportEntry Record is not created.
</td>
</tr>
</table>
</emu-table>
</emu-note>

<emu-clause id="sec-HostLoadImportedModule" type="host-defined abstract operation">
<h1>
Expand Down Expand Up @@ -883,7 +1017,7 @@ contributors: Luca Casonato, Guy Bedford, Nicolò Ribaudo
<p>The actual process performed is host-defined, but typically consists of performing whatever I/O operations are necessary to load the appropriate Module Record. Multiple different (_referrer_, <del>_specifier_</del><ins>_moduleRequest_.[[Specifier]]</ins>) pairs may map to the same Module Record instance. The actual mapping semantics is host-defined but typically a normalization process is applied to _specifier_ as part of the mapping process. A typical normalization process would include actions such as expansion of relative and abbreviated path specifiers.</p>

<emu-note>
<p><ins><emu-xref href="#sec-hosts-and-implementations">Implementations</emu-xref> may provide unobservable module loading optimizations, such as speculative preloading of modules that are likely to be requested next. When doing so, they should consider whether the module is being imported for its ~source~ phase, which won't cause calls to the HostLoadImportedModule hook for its transitive dependencies, or for its ~evaluation~ phase.</ins></p>
<p><ins><emu-xref href="#sec-hosts-and-implementations">Implementations</emu-xref> may provide unobservable module loading optimizations, such as speculative preloading of modules that are likely to be requested next. When doing so, they should consider whether the module is being imported for its ~source~ phase, which won't cause calls to the HostLoadImportedModule hook for its transitive dependencies, or for its ~evaluation~ phase, which will.</ins></p>
</emu-note>
</emu-clause>

Expand Down Expand Up @@ -1026,7 +1160,6 @@ contributors: Luca Casonato, Guy Bedford, Nicolò Ribaudo
<emu-alg>
1. Throw a *TypeError* exception.
</emu-alg>
<p>The *"length"* property of this function is *+0*<sub>𝔽</sub>.</p>
</emu-clause>
</emu-clause>

Expand Down Expand Up @@ -1054,7 +1187,6 @@ contributors: Luca Casonato, Guy Bedford, Nicolò Ribaudo
<li>is <dfn>%AbstractModuleSource.prototype%</dfn>.</li>
<li>is an ordinary object.</li>
<li>does not have a global name or appear as a property of the global object.</li>
<li>does not have a [[ModuleSourceClassName]] slot that is specific to _AbstractModuleSource_ and _AbstractModuleSource_ subclass instance objects.</li>
<li>has the following properties:</li>
</ul>

Expand All @@ -1064,7 +1196,7 @@ contributors: Luca Casonato, Guy Bedford, Nicolò Ribaudo
</emu-clause>

<emu-clause id="sec-get-%abstractmodulesource%.prototype.@@tostringtag">
<h1>get %AbstractModuleSource%.prototype [ @@toStringTag ]</h1>
<h1>get %AbstractModuleSource%.prototype [ @@toStringTag ] ( )</h1>
<p>%AbstractModuleSource%.prototype `[@@toStringTag]` is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps when called:</p>
<emu-alg>
1. Let _O_ be the *this* value.
Expand Down

0 comments on commit cd75ff8

Please sign in to comment.