Skip to content

Commit 203c773

Browse files
committed
HostGetModuleSourceModuleRecord (tc39/proposal-source-phase-imports#70)
1 parent 30a6c11 commit 203c773

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

spec.html

+23-13
Original file line numberDiff line numberDiff line change
@@ -26660,6 +26660,15 @@ <h1>Abstract Module Records</h1>
2666026660
<p>Returns a promise for the evaluation of this module and its dependencies, resolving on successful evaluation or if it has already been evaluated successfully, and rejecting for an evaluation error or if it has already been evaluated unsuccessfully. If the promise is rejected, hosts are expected to handle the promise rejection and rethrow the evaluation error.</p>
2666126661
<p>Link must have completed successfully prior to invoking this method.</p>
2666226662
</td>
26663+
<tr>
26664+
<td>
26665+
GetModuleSourceKind()
26666+
</td>
26667+
<td>
26668+
<p>Returns a constant string for each concrete module record that exposes a source representation through their [[ModuleSource]] field, to be used as the return value of the %Symbol.toStringTag% getter on %AbstractModuleSource%.</p>
26669+
<p>For Module Records that do not have a source representation (currently all ECMA-262-defined Module Records), GetModuleSourceKind() is never called.</p>
26670+
</td>
26671+
</tr>
2666326672
</tr>
2666426673
</table>
2666526674
</emu-table>
@@ -28677,26 +28686,27 @@ <h1>
2867728686
</emu-alg>
2867828687
</emu-clause>
2867928688

28680-
<emu-clause id="sec-HostGetModuleSourceName" type="host-defined abstract operation">
28689+
<emu-clause id="sec-HostGetModuleSourceModuleRecord" type="host-defined abstract operation">
2868128690
<h1>
28682-
HostGetModuleSourceName (
28683-
_moduleSource_: an Object,
28684-
): either a normal completion containing a String or a throw completion
28691+
HostGetModuleSourceModuleRecord (
28692+
_specifier_: an Object,
28693+
): either a Module Record or ~not-a-source~
2868528694
</h1>
2868628695
<dl class="header">
2868728696
<dt>description</dt>
28688-
<dd></dd>
28697+
<dd>Allows hosts to provide the concrete Module Record for a non-ECMA-262 module source object.</dd>
2868928698
</dl>
2869028699

28691-
<p>An implementation of HostGetModuleSourceName must conform to the following requirements:</p>
28700+
<p>An implementation of HostGetModuleSourceModuleRecord must conform to the following requirements:</p>
2869228701
<ul>
2869328702
<li>
28694-
For any object that is a Module Source Object, returns a normal completion for a String corresponding to the source record type to be used as the strongly branded return value of the @@toStringTag getter on %AbstractModuleSource%.
28703+
Defines any host-specific module sources, by returning their concrete Module Record.
2869528704
</li>
2869628705
<li>
28697-
For any object which is not a Module Source Object, returns a throw completion.
28706+
For all other objects, returns ~not-a-source~.
2869828707
</li>
2869928708
</ul>
28709+
<p>The default implementation of HostGetModuleSourceModuleRecord is to return ~not-a-source~.</p>
2870028710
</emu-clause>
2870128711

2870228712
<emu-clause id="sec-AllImportAttributesSupported" type="abstract operation">
@@ -49658,7 +49668,7 @@ <h1>%Symbol.toStringTag%</h1>
4965849668
<emu-clause id="sec-module-source-objects">
4965949669
<h1>Module Source Objects</h1>
4966049670
<p>Module Source Objects represent modules in their source import phase, which are not linked, instantiated or executed.</p>
49661-
<p>A <dfn>Module Source Object</dfn> is an object for which HostGetModuleSourceName returns a normal completion.</p>
49671+
<p>A <dfn>Module Source Object</dfn> is an object for which HostGetModuleSourceModuleRecord returns a Module Record.</p>
4966249672
<p>All Module Source Objects must be initialized with a prototype of %AbstractModuleSource%.prototype.</p>
4966349673
<p>Hosts may define their own %AbstractModuleSource% subclasses for custom module types.</p>
4966449674

@@ -49719,9 +49729,9 @@ <h1>get %AbstractModuleSource%.prototype [ @@toStringTag ]</h1>
4971949729
<emu-alg>
4972049730
1. Let _O_ be the *this* value.
4972149731
1. If _O_ is not an Object, return *undefined*.
49722-
1. Let _sourceNameResult_ be Completion(HostGetModuleSourceName(_O_)).
49723-
1. If _sourceNameResult_ is an abrupt completion, return *undefined*.
49724-
1. Let _name_ be ! _sourceNameResult_.
49732+
1. Let _module_ be HostGetModuleSourceModuleRecord(_O_).
49733+
1. If _module_ is ~not-a-source~, return *undefined*.
49734+
1. Let _name_ be _module_.GetModuleSourceKind().
4972549735
1. Assert: _name_ is a String.
4972649736
1. Return _name_.
4972749737
</emu-alg>
@@ -51983,7 +51993,7 @@ <h1>Host Hooks</h1>
5198351993
<p><b>HostEnsureCanCompileStrings(...)</b></p>
5198451994
<p><b>HostFinalizeImportMeta(...)</b></p>
5198551995
<p><b>HostGetImportMetaProperties(...)</b></p>
51986-
<p><b>HostGetModuleSourceName(...)</b></p>
51996+
<p><b>HostGetModuleSourceModuleRecord(...)</b></p>
5198751997
<p><b>HostGrowSharedArrayBuffer(...)</b></p>
5198851998
<p><b>HostHasSourceTextAvailable(...)</b></p>
5198951999
<p><b>HostLoadImportedModule(...)</b></p>

0 commit comments

Comments
 (0)