Skip to content

Commit 629223c

Browse files
Guy Bedfordguybedford
authored andcommitted
HostGetModuleSourceModuleRecord (tc39/proposal-source-phase-imports#70)
1 parent c6b3a3f commit 629223c

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

spec.html

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26714,6 +26714,15 @@ <h1>Abstract Module Records</h1>
2671426714
<p>Link must have completed successfully prior to invoking this method.</p>
2671526715
</td>
2671626716
</tr>
26717+
<tr>
26718+
<td>
26719+
GetModuleSourceKind()
26720+
</td>
26721+
<td>
26722+
<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>
26723+
<p>For Module Records that do not have a source representation (currently all ECMA-262-defined Module Records), GetModuleSourceKind() is never called.</p>
26724+
</td>
26725+
</tr>
2671726726
</table>
2671826727
</emu-table>
2671926728

@@ -28957,26 +28966,27 @@ <h1>
2895728966
</emu-alg>
2895828967
</emu-clause>
2895928968

28960-
<emu-clause id="sec-HostGetModuleSourceName" type="host-defined abstract operation">
28969+
<emu-clause id="sec-HostGetModuleSourceModuleRecord" type="host-defined abstract operation">
2896128970
<h1>
28962-
HostGetModuleSourceName (
28963-
_moduleSource_: an Object,
28964-
): either a normal completion containing a String or a throw completion
28971+
HostGetModuleSourceModuleRecord (
28972+
_specifier_: an Object,
28973+
): either a Module Record or ~not-a-source~
2896528974
</h1>
2896628975
<dl class="header">
2896728976
<dt>description</dt>
28968-
<dd></dd>
28977+
<dd>Allows hosts to provide the concrete Module Record for a non-ECMA-262 module source object.</dd>
2896928978
</dl>
2897028979

28971-
<p>An implementation of HostGetModuleSourceName must conform to the following requirements:</p>
28980+
<p>An implementation of HostGetModuleSourceModuleRecord must conform to the following requirements:</p>
2897228981
<ul>
2897328982
<li>
28974-
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%.
28983+
Defines any host-specific module sources, by returning their concrete Module Record.
2897528984
</li>
2897628985
<li>
28977-
For any object which is not a Module Source Object, returns a throw completion.
28986+
For all other objects, returns ~not-a-source~.
2897828987
</li>
2897928988
</ul>
28989+
<p>The default implementation of HostGetModuleSourceModuleRecord is to return ~not-a-source~.</p>
2898028990
</emu-clause>
2898128991

2898228992
<emu-clause id="sec-AllImportAttributesSupported" type="abstract operation">
@@ -51312,7 +51322,7 @@ <h1>%Symbol.toStringTag%</h1>
5131251322
<emu-clause id="sec-module-source-objects">
5131351323
<h1>Module Source Objects</h1>
5131451324
<p>Module Source Objects represent modules in their source import phase, which are not linked, instantiated or executed.</p>
51315-
<p>A <dfn>Module Source Object</dfn> is an object for which HostGetModuleSourceName returns a normal completion.</p>
51325+
<p>A <dfn>Module Source Object</dfn> is an object for which HostGetModuleSourceModuleRecord returns a Module Record.</p>
5131651326
<p>All Module Source Objects must be initialized with a prototype of %AbstractModuleSource%.prototype.</p>
5131751327
<p>Hosts may define their own %AbstractModuleSource% subclasses for custom module types.</p>
5131851328

@@ -51373,9 +51383,9 @@ <h1>get %AbstractModuleSource%.prototype [ @@toStringTag ]</h1>
5137351383
<emu-alg>
5137451384
1. Let _O_ be the *this* value.
5137551385
1. If _O_ is not an Object, return *undefined*.
51376-
1. Let _sourceNameResult_ be Completion(HostGetModuleSourceName(_O_)).
51377-
1. If _sourceNameResult_ is an abrupt completion, return *undefined*.
51378-
1. Let _name_ be ! _sourceNameResult_.
51386+
1. Let _module_ be HostGetModuleSourceModuleRecord(_O_).
51387+
1. If _module_ is ~not-a-source~, return *undefined*.
51388+
1. Let _name_ be _module_.GetModuleSourceKind().
5137951389
1. Assert: _name_ is a String.
5138051390
1. Return _name_.
5138151391
</emu-alg>
@@ -53478,7 +53488,7 @@ <h1>Host Hooks</h1>
5347853488
<p><b>HostEnsureCanCompileStrings(...)</b></p>
5347953489
<p><b>HostFinalizeImportMeta(...)</b></p>
5348053490
<p><b>HostGetImportMetaProperties(...)</b></p>
53481-
<p><b>HostGetModuleSourceName(...)</b></p>
53491+
<p><b>HostGetModuleSourceModuleRecord(...)</b></p>
5348253492
<p><b>HostGrowSharedArrayBuffer(...)</b></p>
5348353493
<p><b>HostHasSourceTextAvailable(...)</b></p>
5348453494
<p><b>HostLoadImportedModule(...)</b></p>

0 commit comments

Comments
 (0)