Skip to content

Commit 2521cf5

Browse files
nicolo-ribaudoljharb
authored andcommitted
Updates from review
1 parent 1ac2bb4 commit 2521cf5

File tree

1 file changed

+79
-49
lines changed

1 file changed

+79
-49
lines changed

spec.html

+79-49
Original file line numberDiff line numberDiff line change
@@ -11538,10 +11538,10 @@ <h1>Realms</h1>
1153811538
[[LoadedModules]]
1153911539
</td>
1154011540
<td>
11541-
a List of Records with fields [[Specifier]] (a String), [[Attributes]] (a List of ImportAttribute Records) and [[Module]] (a Module Record)
11541+
a List of LoadedModuleRequest Records
1154211542
</td>
1154311543
<td>
11544-
<p>A map from the specifier strings imported by this realm to the resolved Module Record. The list does not contain two different Records with the same [[Specifier]].</p>
11544+
<p>A map from the specifier strings imported by this realm to the resolved Module Record. The list does not contain two different Records _r1_ and _r2_ such that ModuleRequestsEqual(_r1_, _r2_) is *true*.</p>
1154511545
<emu-note>
1154611546
As mentioned in HostLoadImportedModule (<emu-xref href="#note-HostLoadImportedModule-referrer-Realm-Record"></emu-xref>), [[LoadedModules]] in Realm Records is only used when running an `import()` expression in a context where there is no active script or module.
1154711547
</emu-note>
@@ -19334,18 +19334,18 @@ <h1>Runtime Semantics: Evaluation</h1>
1933419334
<emu-clause id="sec-evaluate-import-call" type="abstract operation">
1933519335
<h1>
1933619336
EvaluateImportCall (
19337-
_specifierExpression_: a ParseNode,
19338-
optional _optionsExpression_: a ParseNode,
19337+
_specifierExpression_: a Parse Node,
19338+
optional _optionsExpression_: a Parse Node,
1933919339
): either a normal completion containing a Promise or a throw completion
1934019340
</h1>
1934119341
<dl class="header"></dl>
1934219342
<emu-alg>
1934319343
1. Let _referrer_ be GetActiveScriptOrModule().
1934419344
1. If _referrer_ is *null*, set _referrer_ to the current Realm Record.
19345-
1. Let _specifierRef_ be the result of evaluating _specifierExpression_.
19345+
1. Let _specifierRef_ be ? Evaluation of _specifierExpression_.
1934619346
1. Let _specifier_ be ? GetValue(_specifierRef_).
1934719347
1. If _optionsExpression_ is present, then
19348-
1. Let _optionsRef_ be the result of evaluating _optionsExpression_.
19348+
1. Let _optionsRef_ be ? Evaluation of _optionsExpression_.
1934919349
1. Let _options_ be ? GetValue(_optionsRef_).
1935019350
1. Else,
1935119351
1. Let _options_ be *undefined*.
@@ -19354,7 +19354,7 @@ <h1>
1935419354
1. IfAbruptRejectPromise(_specifierString_, _promiseCapability_).
1935519355
1. Let _attributes_ be a new empty List.
1935619356
1. If _options_ is not *undefined*, then
19357-
1. If Type(_options_) is not Object, then
19357+
1. If _options_ is not an Object, then
1935819358
1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « a newly created *TypeError* object »).
1935919359
1. Return _promiseCapability_.[[Promise]].
1936019360
1. Let _attributesObj_ be Completion(Get(_options_, *"with"*)).
@@ -19363,15 +19363,15 @@ <h1>
1936319363
1. Let _attributesObj_ be Completion(Get(_options_, *"assert"*)).
1936419364
1. IfAbruptRejectPromise(_attributesObj_, _promiseCapability_).
1936519365
1. If _attributesObj_ is not *undefined*, then
19366-
1. If Type(_attributesObj_) is not Object, then
19366+
1. If _attributesObj_ is not an Object, then
1936719367
1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « a newly created *TypeError* object »).
1936819368
1. Return _promiseCapability_.[[Promise]].
1936919369
1. Let _entries_ be Completion(EnumerableOwnProperties(_attributesObj_, ~key+value~)).
1937019370
1. IfAbruptRejectPromise(_entries_, _promiseCapability_).
1937119371
1. For each element _entry_ of _entries_, do
1937219372
1. Let _key_ be ! <emu-meta suppress-effects="user-code">Get(_entry_, *"0"*)</emu-meta>.
1937319373
1. Let _value_ be ! <emu-meta suppress-effects="user-code">Get(_entry_, *"1"*)</emu-meta>.
19374-
1. If Type(_value_) is not String, then
19374+
1. If _value_ is not a String, then
1937519375
1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « a newly created *TypeError* object »).
1937619376
1. Return _promiseCapability_.[[Promise]].
1937719377
1. Append the ImportAttribute Record { [[Key]]: _key_, [[Value]]: _value_ } to _attributes_.
@@ -25712,10 +25712,10 @@ <h1>Script Records</h1>
2571225712
[[LoadedModules]]
2571325713
</td>
2571425714
<td>
25715-
a List of Records with fields [[Specifier]] (a String), [[Attributes]] (a List of ImportAttribute Records) and [[Module]] (a Module Record)
25715+
a List of LoadedModuleRequest Records
2571625716
</td>
2571725717
<td>
25718-
A map from the specifier strings imported by this script to the resolved Module Record. The list does not contain two different Records with the same [[Specifier]].
25718+
A map from the specifier strings imported by this script to the resolved Module Record. The list does not contain two different Records _r1_ and _r2_ such that ModuleRequestsEqual(_r1_, _r2_) is *true*.
2571925719
</td>
2572025720
</tr>
2572125721
<tr>
@@ -25957,7 +25957,7 @@ <h1>
2595725957
</emu-clause>
2595825958

2595925959
<emu-clause id="sec-modulerequest-record">
25960-
<h1>ModuleRequest and ImportAttribute Records</h1>
25960+
<h1>ModuleRequest Records</h1>
2596125961

2596225962
<p>A <dfn id="modulerequest-record" variants="ModuleRequest Records">ModuleRequest Record</dfn> represents the request to import a module with given import attributes. It consists of the following fields:</p>
2596325963
<emu-table id="table-modulerequest-fields" caption="ModuleRequest Record fields">
@@ -25998,6 +25998,34 @@ <h1>ModuleRequest and ImportAttribute Records</h1>
2599825998
</table>
2599925999
</emu-table>
2600026000

26001+
<p>A <dfn id="loadedmodulerequest-record" variants="LoadedModuleRequest Records">LoadedModuleRequest Record</dfn> represents the request to import a module together with the resulting Module Record. It consists of the fields defined in table <emu-xref href="#table-modulerequest-fields"></emu-xref>, alongside with the following additions:</p>
26002+
<emu-table id="table-loadedmodulerequest-fields" caption="Additional fields of LoadedModuleRequest Records">
26003+
<table>
26004+
<tr>
26005+
<th>
26006+
Field Name
26007+
</th>
26008+
<th>
26009+
Value Type
26010+
</th>
26011+
<th>
26012+
Meaning
26013+
</th>
26014+
</tr>
26015+
<tr>
26016+
<td>
26017+
[[Module]]
26018+
</td>
26019+
<td>
26020+
a Module Record
26021+
</td>
26022+
<td>
26023+
The loaded module corresponding to this module request
26024+
</td>
26025+
</tr>
26026+
</table>
26027+
</emu-table>
26028+
2600126029
<p>An <dfn id="importattribute-record" variants="ImportAttribute Records">ImportAttribute Record</dfn> consists of the following fields:</p>
2600226030
<emu-table id="table-importattribute-fields" caption="ImportAttribute Record fields">
2600326031
<table>
@@ -26036,6 +26064,36 @@ <h1>ModuleRequest and ImportAttribute Records</h1>
2603626064
</tr>
2603726065
</table>
2603826066
</emu-table>
26067+
26068+
<emu-clause id="sec-ModuleRequestsEqual" type="abstract operation">
26069+
<h1>
26070+
ModuleRequestsEqual (
26071+
_left_: a ModuleRequest Record or a LoadedModuleRequest Record,
26072+
_right_: a ModuleRequest Record or a LoadedModuleRequest Record,
26073+
): a Boolean
26074+
</h1>
26075+
<dl class="header">
26076+
<dt>description</dt>
26077+
<dd></dd>
26078+
</dl>
26079+
26080+
<emu-alg>
26081+
1. If _left_.[[Specifier]] is not _right_.[[Specifier]], return *false*.
26082+
1. Let _leftAttrs_ be _left_.[[Attributes]].
26083+
1. Let _rightAttrs_ be _right_.[[Attributes]].
26084+
1. If the number of elements in _leftAttrs_ is not the number of elements in _rightAttrs_, return *false*.
26085+
1. For each ImportAttribute Record _l_ of _leftAttrs_, do
26086+
1. Let _found_ be *false*.
26087+
1. For each ImportAttribute Record _r_ of _rightAttrs_, do
26088+
1. If _l_.[[Key]] is _r_.[[Key]], then
26089+
1. If _l_.[[Value]] is _r_.[[Value]], then
26090+
1. Set _found_ to *true*.
26091+
1. Else,
26092+
1. Return *false*.
26093+
1. If _found_ is *false*, return *false*.
26094+
1. Return *true*.
26095+
</emu-alg>
26096+
</emu-clause>
2603926097
</emu-clause>
2604026098

2604126099
<emu-clause id="sec-static-semantics-modulerequests" oldids="sec-module-semantics-static-semantics-modulerequests,sec-imports-static-semantics-modulerequests,sec-exports-static-semantics-modulerequests" type="sdo">
@@ -26055,7 +26113,7 @@ <h1>Static Semantics: ModuleRequests ( ): a List of ModuleRequest Records</h1>
2605526113
1. Let _requests_ be ModuleRequests of |ModuleItemList|.
2605626114
1. Let _additionalRequests_ be ModuleRequests of |ModuleItem|.
2605726115
1. For each ModuleRequest Record _mr_ of _additionalRequests_, do
26058-
1. If _requests_ does not contain a ModuleRequest Record _mr2_ such that _mr_.[[Specifier]] is _mr2_.[[Specifier]] and ImportAttributesEqual(_mr_.[[Attributes]], _mr2_.[[Attributes]]) is *true*, then
26116+
1. If _requests_ does not contain a ModuleRequest Record _mr2_ such that ModuleRequestsEqual(_mr_, _mr2_) is *true*, then
2605926117
1. Append _mr_ to _requests_.
2606026118
1. Return _requests_.
2606126119
</emu-alg>
@@ -26307,10 +26365,10 @@ <h1>Cyclic Module Records</h1>
2630726365
[[LoadedModules]]
2630826366
</td>
2630926367
<td>
26310-
a List of Records with fields [[Specifier]] (a String), [[Attributes]] (a List of ImportAttribute Records) and [[Module]] (a Module Record)
26368+
a List of LoadedModuleRequest Records
2631126369
</td>
2631226370
<td>
26313-
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 with the same ([[Specifier]], [[Attributes]]) pair.
26371+
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*.
2631426372
</td>
2631526373
</tr>
2631626374
<tr>
@@ -26529,7 +26587,7 @@ <h1>
2652926587
1. Let _requestedModulesCount_ be the number of elements in _module_.[[RequestedModules]].
2653026588
1. Set _state_.[[PendingModulesCount]] to _state_.[[PendingModulesCount]] + _requestedModulesCount_.
2653126589
1. For each ModuleRequest Record _request_ of _module_.[[RequestedModules]], do
26532-
1. If _module_.[[LoadedModules]] contains a Record _record_ such that _record_.[[Specifier]] is _request_.[[Specifier]] and ImportAttributesEqual(_record_.[[Attributes]], _request_.[[Attributes]]) is *true*, then
26590+
1. If _module_.[[LoadedModules]] contains a LoadedModuleRequest Record _record_ such that ModuleRequestsEqual(_record_, _request_) is *true*, then
2653326591
1. Perform InnerModuleLoading(_state_, _record_.[[Module]]).
2653426592
1. Else,
2653526593
1. Perform HostLoadImportedModule(_module_, _request_, _state_.[[HostDefined]], _state_).
@@ -28039,8 +28097,8 @@ <h1>
2803928097
</dl>
2804028098

2804128099
<emu-alg>
28042-
1. Assert: Exactly one element of _referrer_.[[LoadedModules]] is a Record _record_ such that _record_.[[Specifier]] is _request_.[[Specifier]] and ImportAttributesEqual(_record_.[[Attributes]], _request_.[[Attributes]]) is *true*, since LoadRequestedModules has completed successfully on _referrer_ prior to invoking this abstract operation.
28043-
1. Let _record_ be the Record in _referrer_.[[LoadedModules]] such that _record_.[[Specifier]] is _request_.[[Specifier]] and ImportAttributesEqual(_record_.[[Attributes]], _request_.[[Attributes]]) is *true*.
28100+
1. Assert: Exactly one element of _referrer_.[[LoadedModules]] is a LoadedModuleRequest Record _record_ such that ModuleRequestsEqual(_record_, _request_) is *true*, since LoadRequestedModules has completed successfully on _referrer_ prior to invoking this abstract operation.
28101+
1. Let _record_ be the LoadedModuleRequest Record in _referrer_.[[LoadedModules]] such that ModuleRequestsEqual(_record_, _request_) is *true*.
2804428102
1. Return _record_.[[Module]].
2804528103
</emu-alg>
2804628104
</emu-clause>
@@ -28076,8 +28134,7 @@ <h1>
2807628134
<p>If this operation is called multiple times with two (_referrer_, _moduleRequest_) pairs such that:</p>
2807728135
<ul>
2807828136
<li>the first _referrer_ is the same as the second _referrer_;</li>
28079-
<li>the first _moduleRequest_.[[Specifier]] is the same as the second _moduleRequest_.[[Specifier]];</li>
28080-
<li>ImportAttributesEqual(the first _moduleRequest_.[[Attributes]], the second _moduleRequest_.[[Attributes]]) is *true*;</li>
28137+
<li>ModuleRequestsEqual(the first _moduleRequest_, the second _moduleRequest_) is *true*;</li>
2808128138
</ul>
2808228139
<p>and it performs FinishLoadingImportedModule(_referrer_, _moduleRequest_, _payload_, _result_) where _result_ is a normal completion, then it must perform FinishLoadingImportedModule(_referrer_, _moduleRequest_, _payload_, _result_) with the same _result_ each time.</p>
2808328140
</li>
@@ -28104,10 +28161,10 @@ <h1>
2810428161
</dl>
2810528162
<emu-alg>
2810628163
1. If _result_ is a normal completion, then
28107-
1. If _referrer_.[[LoadedModules]] contains a Record _record_ such that _record_.[[Specifier]] is _moduleRequest_.[[Specifier]] and ImportAttributesEqual(_record_.[[Attributes]], _moduleRequest_.[[Attributes]]) is *true*, then
28164+
1. If _referrer_.[[LoadedModules]] contains a LoadedModuleRequest Record _record_ such that ModuleRequestsEqual(_record_, _moduleRequest_) is *true*, then
2810828165
1. Assert: _record_.[[Module]] is _result_.[[Value]].
2810928166
1. Else,
28110-
1. Append the Record { [[Specifier]]: _moduleRequest_.[[Specifer]], [[Attributes]]: _moduleRequest_.[[Attributes]], [[Module]]: _result_.[[Value]] } to _referrer_.[[LoadedModules]].
28167+
1. Append the LoadedModuleRequest Record { [[Specifier]]: _moduleRequest_.[[Specifer]], [[Attributes]]: _moduleRequest_.[[Attributes]], [[Module]]: _result_.[[Value]] } to _referrer_.[[LoadedModules]].
2811128168
1. If _payload_ is a GraphLoadingState Record, then
2811228169
1. Perform ContinueModuleLoading(_payload_, _result_).
2811328170
1. Else,
@@ -28116,33 +28173,6 @@ <h1>
2811628173
</emu-alg>
2811728174
</emu-clause>
2811828175

28119-
<emu-clause id="sec-ImportAttributesEqual" type="abstract operation">
28120-
<h1>
28121-
ImportAttributesEqual (
28122-
_left_: a List of ImportAttribute Records,
28123-
_right_: a List of ImportAttribute Records,
28124-
): a Boolean
28125-
</h1>
28126-
<dl class="header">
28127-
<dt>description</dt>
28128-
<dd></dd>
28129-
</dl>
28130-
28131-
<emu-alg>
28132-
1. If the number of elements in _left_ is not the same as the number of elements in _right_, return *false*.
28133-
1. For each ImportAttribute Record _r_ of _left_, do
28134-
1. Let _found_ be *false*.
28135-
1. For each ImportAttribute Record _s_ of _right_, do
28136-
1. If _r_.[[Key]] is _s_.[[Key]], then
28137-
1. If _r_.[[Value]] is _s_.[[Value]], then
28138-
1. Set _found_ to *true*.
28139-
1. Else,
28140-
1. Return *false*.
28141-
1. If _found_ is *false*, return *false*.
28142-
1. Return *true*.
28143-
</emu-alg>
28144-
</emu-clause>
28145-
2814628176
<emu-clause id="sec-AllImportAttributesSupported" type="abstract operation">
2814728177
<h1>
2814828178
AllImportAttributesSupported (

0 commit comments

Comments
 (0)