Skip to content

Commit eb02b12

Browse files
Move [[OptionalIndirectExportEntries]] to STMR
1 parent 50acd76 commit eb02b12

1 file changed

Lines changed: 191 additions & 73 deletions

File tree

spec.emu

Lines changed: 191 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -624,17 +624,6 @@ contributors: Nicolò Ribaudo
624624
A map from the specifier strings used by the module represented by this record to request the importation of a module with the relative import attributes to the resolved Module Record. The list does not contain two different Records _r1_ and _r2_ such that ModuleRequestsEqual(_r1_, _r2_) is *true*.
625625
</td>
626626
</tr>
627-
<tr>
628-
<td>
629-
<ins>[[OptionalIndirectExportEntries]]</ins>
630-
</td>
631-
<td>
632-
<ins>a List of ExportEntry Records whose [[LocalName]] is *null*.</ins>
633-
</td>
634-
<td>
635-
<ins>A list of all the bindings re-exported through `export defer { ... } from "..."`. The List is in source text occurrence order.</ins>
636-
</td>
637-
</tr>
638627
<tr>
639628
<td>
640629
[[CycleRoot]]
@@ -732,6 +721,19 @@ contributors: Nicolò Ribaudo
732721
Evaluate the module's code within its execution context. If this module has *true* in [[HasTLA]], then a PromiseCapability Record is passed as an argument, and the method is expected to resolve or reject the given capability. In this case, the method must not throw an exception, but instead reject the PromiseCapability Record if necessary.
733722
</td>
734723
</tr>
724+
<tr>
725+
<td>
726+
<ins>GetOptionalIndirectExportsModuleRequests( [ _importedNames_ ])</ins>
727+
</td>
728+
<td>
729+
<p><ins>Returns a list of ModuleRequest Records describing the additional dependencies (not already listed in this module's [[RequestedModules]]) needed to be able to import _importedNames_ from this module. In case of a Source Text Module Record, these would be the dependencies specified through `export defer`. _importedNames_ is either ~all~ or a List of Strings.</ins></p>
730+
731+
<p><ins>This abstract method has the following default implementation:</ins></p>
732+
<emu-alg>
733+
1. <ins>Return a new empty List.</ins>
734+
</emu-alg>
735+
</td>
736+
</tr>
735737
</table>
736738
</emu-table>
737739

@@ -940,7 +942,7 @@ contributors: Nicolò Ribaudo
940942
1. Return ? _result_.
941943
1. Assert: _module_.[[Status]] is one of ~linked~, ~evaluating-async~, or ~evaluated~.
942944
1. Assert: _stack_ is empty.
943-
1. <ins>Let _indirectRequests_ be GetOptionalIndirectExportsModuleRequests(_module_, _importedNames_).</ins>
945+
1. <ins>Let _indirectRequests_ be _module_.GetOptionalIndirectExportsModuleRequests(_importedNames_).</ins>
944946
1. <ins>For each ModuleRequest Record _request_ of _indirectRequests_, do</ins>
945947
1. <ins>Let _requiredModule_ be GetImportedModule(_module_, _request_).</ins>
946948
1. <ins>Assert: _requiredModule_.[[Status]] is one of ~unlinked~, ~linked~, ~evaluating-async~, or ~evaluated~.</ins>
@@ -1172,7 +1174,7 @@ contributors: Nicolò Ribaudo
11721174
1. If _requiredModule_ is a Cyclic Module Record, then
11731175
1. Let _importedNames_ be _request_.[[ImportedNames]].
11741176
1. [id="step-BuildEvaluationList-reset-importedNames"] If _importedNames_ = ~all~, set _importedNames_ to « ».
1175-
1. Let _indirectRequests_ be GetOptionalIndirectExportsModuleRequests(_requiredModule_, _importedNames_).
1177+
1. Let _indirectRequests_ be _requiredModule_.GetOptionalIndirectExportsModuleRequests(_importedNames_).
11761178
1. Perform BuildEvaluationList(_evaluationList_, _requiredModule_, _indirectRequests_).
11771179
1. Return ~unused~.
11781180
</emu-alg>
@@ -1254,18 +1256,153 @@ contributors: Nicolò Ribaudo
12541256
1. For each ModuleRequest Record _request_ of _moduleRequests_, do
12551257
1. Let _requiredModule_ be GetImportedModule(_referrer_, _request_).
12561258
1. Perform ListAppendUnique(_result_, GatherAsynchronousTransitiveDependencies(_requiredModule_, _seen_)).
1257-
1. Let _indirectRequests_ be GetOptionalIndirectExportsModuleRequests(_requiredModule_, _request_.[[ImportedNames]]).
1259+
1. Let _indirectRequests_ be _requiredModule_.GetOptionalIndirectExportsModuleRequests(_request_.[[ImportedNames]]).
12581260
1. Perform ListAppendUnique(_result_, InnerGatherAsynchronousTransitiveDependencies(_requiredModule_, _indirectRequests_, _seen_)).
12591261
1. Return _result_.
12601262
</emu-alg>
12611263
</emu-clause>
12621264
</emu-clause>
12631265
</emu-clause>
1266+
1267+
<emu-clause id="sec-GetNewOptionalIndirectExportsModuleRequests" type="abstract operation" number="100">
1268+
<h1>
1269+
<ins>
1270+
GetNewOptionalIndirectExportsModuleRequests (
1271+
_module_: a Cyclic Module Record,
1272+
_importedNames_: ~all~ or a List of Strings,
1273+
_previouslyImportedNames_: a List of Records with fields [[Module]] (a Cyclic Module Record) and [[ImportedNames]] (~all~ or a List of Strings),
1274+
): a List of ModuleRequest Records
1275+
</ins>
1276+
</h1>
1277+
<dl class="header">
1278+
<dt>description</dt>
1279+
<dd></dd>
1280+
</dl>
1281+
1282+
<emu-alg>
1283+
1. Assert: _previouslyImportedNames_ contains a Record whose [[Module]] field is _module_.
1284+
1. Let _previous_ be the Record in _previouslyImportedNames_ whose [[Module]] field is _module_.
1285+
1. Let _newImportedNames_ be ExcludeImportedNames(_importedNames_, _previous_.[[ImportedNames]]).
1286+
1. Set _previous_.[[ImportedNames]] to MergeImportedNames(_previous_.[[ImportedNames]], _newImportedNames_).
1287+
1. Return _module_.GetOptionalIndirectExportsModuleRequests(_newImportedNames_).
1288+
</emu-alg>
1289+
</emu-clause>
12641290
</emu-clause>
12651291

12661292
<emu-clause id="sec-source-text-module-records" number="7">
12671293
<h1>Source Text Module Records</h1>
12681294

1295+
<p>A <dfn id="sourctextmodule-record" variants="Source Text Module Records">Source Text Module Record</dfn> is used to represent information about a module that was defined from ECMAScript source text (<emu-xref href="#sec-ecmascript-language-source-code"></emu-xref>) that was parsed using the goal symbol |Module|. Its fields contain digested information about the names that are imported and exported by the module, and its concrete methods use these digests to link and evaluate the module.</p>
1296+
1297+
<p>A Source Text Module Record can exist in a module graph with other subclasses of the abstract Module Record type, and can participate in cycles with other subclasses of the Cyclic Module Record type.</p>
1298+
1299+
<p>In addition to the fields defined in <emu-xref href="#table-cyclic-module-fields"></emu-xref>, Source Text Module Records have the additional fields listed in <emu-xref href="#table-additional-fields-of-source-text-module-records"></emu-xref>. Each of these fields is initially set in ParseModule.</p>
1300+
<emu-table id="table-additional-fields-of-source-text-module-records" caption="Additional Fields of Source Text Module Records" oldids="table-38">
1301+
<table>
1302+
<thead>
1303+
<tr>
1304+
<th>
1305+
Field Name
1306+
</th>
1307+
<th>
1308+
Value Type
1309+
</th>
1310+
<th>
1311+
Meaning
1312+
</th>
1313+
</tr>
1314+
</thead>
1315+
<tr>
1316+
<td>
1317+
[[ECMAScriptCode]]
1318+
</td>
1319+
<td>
1320+
a Parse Node
1321+
</td>
1322+
<td>
1323+
The result of parsing the source text of this module using |Module| as the goal symbol.
1324+
</td>
1325+
</tr>
1326+
<tr>
1327+
<td>
1328+
[[Context]]
1329+
</td>
1330+
<td>
1331+
an ECMAScript code execution context or ~empty~
1332+
</td>
1333+
<td>
1334+
The execution context associated with this module. It is ~empty~ until the module's environment has been initialized.
1335+
</td>
1336+
</tr>
1337+
<tr>
1338+
<td>
1339+
[[ImportMeta]]
1340+
</td>
1341+
<td>
1342+
an Object or ~empty~
1343+
</td>
1344+
<td>
1345+
An object exposed through the `import.meta` meta property. It is ~empty~ until it is accessed by ECMAScript code.
1346+
</td>
1347+
</tr>
1348+
<tr>
1349+
<td>
1350+
[[ImportEntries]]
1351+
</td>
1352+
<td>
1353+
a List of ImportEntry Records
1354+
</td>
1355+
<td>
1356+
A List of ImportEntry records derived from the code of this module.
1357+
</td>
1358+
</tr>
1359+
<tr>
1360+
<td>
1361+
[[LocalExportEntries]]
1362+
</td>
1363+
<td>
1364+
a List of ExportEntry Records
1365+
</td>
1366+
<td>
1367+
A List of ExportEntry records derived from the code of this module that correspond to declarations that occur within the module.
1368+
</td>
1369+
</tr>
1370+
<tr>
1371+
<td>
1372+
[[IndirectExportEntries]]
1373+
</td>
1374+
<td>
1375+
a List of ExportEntry Records
1376+
</td>
1377+
<td>
1378+
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.
1379+
</td>
1380+
</tr>
1381+
<tr>
1382+
<td>
1383+
[[StarExportEntries]]
1384+
</td>
1385+
<td>
1386+
a List of ExportEntry Records
1387+
</td>
1388+
<td>
1389+
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.
1390+
</td>
1391+
</tr>
1392+
<tr>
1393+
<td>
1394+
<ins>[[OptionalIndirectExportEntries]]</ins>
1395+
</td>
1396+
<td>
1397+
<ins>a List of ExportEntry Records whose [[LocalName]] is *null*.</ins>
1398+
</td>
1399+
<td>
1400+
<ins>A list of all the bindings re-exported through `export defer { ... } from "..."`. The List is in source text occurrence order.</ins>
1401+
</td>
1402+
</tr>
1403+
</table>
1404+
</emu-table>
1405+
12691406
<emu-clause id="sec-parsemodule" type="abstract operation">
12701407
<h1>
12711408
ParseModule (
@@ -1430,6 +1567,46 @@ contributors: Nicolò Ribaudo
14301567
</emu-alg>
14311568
</emu-clause>
14321569
</emu-clause>
1570+
1571+
<emu-clause id="sec-source-text-module-record-cyclic-module-record-methods">
1572+
<h1>Implementation of Cyclic Module Record Abstract Methods</h1>
1573+
1574+
<p>The following are the concrete methods for Source Text Module Record that implement the corresponding Cyclic Module Record abstract methods defined in <emu-xref href="#table-cyclic-module-methods"></emu-xref>.</p>
1575+
1576+
<emu-clause id="sec-GetOptionalIndirectExportsModuleRequests" type="concrete method" number="3">
1577+
<h1>
1578+
<ins>
1579+
GetOptionalIndirectExportsModuleRequests (
1580+
_importedNames_: ~all~ or a List of Strings,
1581+
): a List of ModuleRequest Records
1582+
</ins>
1583+
</h1>
1584+
<dl class="header">
1585+
<dt>for</dt>
1586+
<dd>a Source Text Module Record _module_</dd>
1587+
</dl>
1588+
1589+
<emu-alg>
1590+
1. Let _requests_ be a new empty List.
1591+
1. For each ExportEntry Record _oie_ of _module_.[[OptionalIndirectExportEntries]], do
1592+
1. If _importedNames_ is ~all~ or _importedNames_ contains _oie_.[[ExportName]], then
1593+
1. Let _nextRequest_ be _oie_.[[ModuleRequest]].
1594+
1. Let _existingRequest_ be ~empty~.
1595+
1. For each ModuleRequest Record _r_ in _requests_, do
1596+
1. If _existingRequest_ is ~empty~ and ModuleRequestsEqual(_r_, _nextRequest_) is *true* and _r_.[[Phase]] is _nextRequest_.[[Phase]], then
1597+
1. Set _existingRequest_ to _r_.
1598+
1. Let _newImportedNames_ be ~all~.
1599+
1. Assert: _oie_.[[ImportName]] is a String or ~all~.
1600+
1. If _oie_.[[ImportName]] is a String, set _newImportedNames_ to « _oie_.[[ImportName]] ».
1601+
1. If _existingRequest_ is ~empty~, then
1602+
1. Let _request_ be the ModuleRequest Record { [[Specifier]]: _nextRequest_.[[Specifier]], [[Attributes]]: _nextRequest_.[[Attributes]], [[Phase]]: _nextRequest_.[[Phase]], [[ImportedNames]]: _newImportedNames_ }.
1603+
1. Append _request_ to _requests_.
1604+
1. Else,
1605+
1. Set _existingRequest_.[[ImportedNames]] to MergeImportedNames(_existingRequest_.[[ImportedNames]], _newImportedNames_).
1606+
1. Return _requests_.
1607+
</emu-alg>
1608+
</emu-clause>
1609+
</emu-clause>
14331610
</emu-clause>
14341611

14351612
<emu-clause id="sec-FinishLoadingImportedModule" type="abstract operation" oldids="sec-finishdynamicimport" number="11">
@@ -1458,65 +1635,6 @@ contributors: Nicolò Ribaudo
14581635
1. Return ~unused~.
14591636
</emu-alg>
14601637
</emu-clause>
1461-
1462-
<emu-clause id="sec-GetOptionalIndirectExportsModuleRequests" type="abstract operation" number="100">
1463-
<h1>
1464-
<ins>
1465-
GetOptionalIndirectExportsModuleRequests (
1466-
_module_: a Cyclic Module Record,
1467-
_importedNames_: ~all~ or a List of Strings,
1468-
): a List of ModuleRequest Records
1469-
</ins>
1470-
</h1>
1471-
<dl class="header">
1472-
<dt>description</dt>
1473-
<dd></dd>
1474-
</dl>
1475-
1476-
<emu-alg>
1477-
1. Let _requests_ be a new empty List.
1478-
1. For each ExportEntry Record _oie_ of _module_.[[OptionalIndirectExportEntries]], do
1479-
1. If _importedNames_ is ~all~ or _importedNames_ contains _oie_.[[ExportName]], then
1480-
1. Let _nextRequest_ be _oie_.[[ModuleRequest]].
1481-
1. Let _existingRequest_ be ~empty~.
1482-
1. For each ModuleRequest Record _r_ in _requests_, do
1483-
1. If _existingRequest_ is ~empty~ and ModuleRequestsEqual(_r_, _nextRequest_) is *true* and _r_.[[Phase]] is _nextRequest_.[[Phase]], then
1484-
1. Set _existingRequest_ to _r_.
1485-
1. Let _newImportedNames_ be ~all~.
1486-
1. Assert: _oie_.[[ImportName]] is a String or ~all~.
1487-
1. If _oie_.[[ImportName]] is a String, set _newImportedNames_ to « _oie_.[[ImportName]] ».
1488-
1. If _existingRequest_ is ~empty~, then
1489-
1. Let _request_ be the ModuleRequest Record { [[Specifier]]: _nextRequest_.[[Specifier]], [[Attributes]]: _nextRequest_.[[Attributes]], [[Phase]]: _nextRequest_.[[Phase]], [[ImportedNames]]: _newImportedNames_ }.
1490-
1. Append _request_ to _requests_.
1491-
1. Else,
1492-
1. Set _existingRequest_.[[ImportedNames]] to MergeImportedNames(_existingRequest_.[[ImportedNames]], _newImportedNames_).
1493-
1. Return _requests_.
1494-
</emu-alg>
1495-
</emu-clause>
1496-
1497-
<emu-clause id="sec-GetNewOptionalIndirectExportsModuleRequests" type="abstract operation">
1498-
<h1>
1499-
<ins>
1500-
GetNewOptionalIndirectExportsModuleRequests (
1501-
_module_: a Cyclic Module Record,
1502-
_importedNames_: ~all~ or a List of Strings,
1503-
_previouslyImportedNames_: a List of Records with fields [[Module]] (a Cyclic Module Record) and [[ImportedNames]] (~all~ or a List of Strings),
1504-
): a List of ModuleRequest Records
1505-
</ins>
1506-
</h1>
1507-
<dl class="header">
1508-
<dt>description</dt>
1509-
<dd></dd>
1510-
</dl>
1511-
1512-
<emu-alg>
1513-
1. Assert: _previouslyImportedNames_ contains a Record whose [[Module]] field is _module_.
1514-
1. Let _previous_ be the Record in _previouslyImportedNames_ whose [[Module]] field is _module_.
1515-
1. Let _newImportedNames_ be ExcludeImportedNames(_importedNames_, _previous_.[[ImportedNames]]).
1516-
1. Set _previous_.[[ImportedNames]] to MergeImportedNames(_previous_.[[ImportedNames]], _newImportedNames_).
1517-
1. Return GetOptionalIndirectExportsModuleRequests(_module_, _newImportedNames_).
1518-
</emu-alg>
1519-
</emu-clause>
15201638
</emu-clause>
15211639

15221640
<emu-clause id="sec-imports">

0 commit comments

Comments
 (0)