From 2521cf53ed99c2b1a112a81abd4b05cb5d3fa5b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Thu, 18 May 2023 14:46:49 +0300 Subject: [PATCH] Updates from review --- spec.html | 128 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 79 insertions(+), 49 deletions(-) diff --git a/spec.html b/spec.html index f4636be525a..825a72a82dc 100644 --- a/spec.html +++ b/spec.html @@ -11538,10 +11538,10 @@

Realms

[[LoadedModules]] - a List of Records with fields [[Specifier]] (a String), [[Attributes]] (a List of ImportAttribute Records) and [[Module]] (a Module Record) + a List of LoadedModuleRequest Records -

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]].

+

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*.

As mentioned in HostLoadImportedModule (), [[LoadedModules]] in Realm Records is only used when running an `import()` expression in a context where there is no active script or module. @@ -19334,18 +19334,18 @@

Runtime Semantics: Evaluation

EvaluateImportCall ( - _specifierExpression_: a ParseNode, - optional _optionsExpression_: a ParseNode, + _specifierExpression_: a Parse Node, + optional _optionsExpression_: a Parse Node, ): either a normal completion containing a Promise or a throw completion

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 _specifierExpression_. 1. Let _specifier_ be ? GetValue(_specifierRef_). 1. If _optionsExpression_ is present, then - 1. Let _optionsRef_ be the result of evaluating _optionsExpression_. + 1. Let _optionsRef_ be ? Evaluation of _optionsExpression_. 1. Let _options_ be ? GetValue(_optionsRef_). 1. Else, 1. Let _options_ be *undefined*. @@ -19354,7 +19354,7 @@

1. IfAbruptRejectPromise(_specifierString_, _promiseCapability_). 1. Let _attributes_ be a new empty List. 1. If _options_ is not *undefined*, then - 1. If Type(_options_) is not Object, then + 1. If _options_ is not an Object, then 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « a newly created *TypeError* object »). 1. Return _promiseCapability_.[[Promise]]. 1. Let _attributesObj_ be Completion(Get(_options_, *"with"*)). @@ -19363,7 +19363,7 @@

1. Let _attributesObj_ be Completion(Get(_options_, *"assert"*)). 1. IfAbruptRejectPromise(_attributesObj_, _promiseCapability_). 1. If _attributesObj_ is not *undefined*, then - 1. If Type(_attributesObj_) is not Object, then + 1. If _attributesObj_ is not an Object, then 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « a newly created *TypeError* object »). 1. Return _promiseCapability_.[[Promise]]. 1. Let _entries_ be Completion(EnumerableOwnProperties(_attributesObj_, ~key+value~)). @@ -19371,7 +19371,7 @@

1. For each element _entry_ of _entries_, do 1. Let _key_ be ! Get(_entry_, *"0"*). 1. Let _value_ be ! Get(_entry_, *"1"*). - 1. If Type(_value_) is not String, then + 1. If _value_ is not a String, then 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « a newly created *TypeError* object »). 1. Return _promiseCapability_.[[Promise]]. 1. Append the ImportAttribute Record { [[Key]]: _key_, [[Value]]: _value_ } to _attributes_. @@ -25712,10 +25712,10 @@

Script Records

[[LoadedModules]] - a List of Records with fields [[Specifier]] (a String), [[Attributes]] (a List of ImportAttribute Records) and [[Module]] (a Module Record) + a List of LoadedModuleRequest Records - 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]]. + 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*. @@ -25957,7 +25957,7 @@

-

ModuleRequest and ImportAttribute Records

+

ModuleRequest Records

A ModuleRequest Record represents the request to import a module with given import attributes. It consists of the following fields:

@@ -25998,6 +25998,34 @@

ModuleRequest and ImportAttribute Records

+

A LoadedModuleRequest Record represents the request to import a module together with the resulting Module Record. It consists of the fields defined in table , alongside with the following additions:

+ + + + + + + + + + + + +
+ Field Name + + Value Type + + Meaning +
+ [[Module]] + + a Module Record + + The loaded module corresponding to this module request +
+
+

An ImportAttribute Record consists of the following fields:

@@ -26036,6 +26064,36 @@

ModuleRequest and ImportAttribute Records

+ + +

+ ModuleRequestsEqual ( + _left_: a ModuleRequest Record or a LoadedModuleRequest Record, + _right_: a ModuleRequest Record or a LoadedModuleRequest Record, + ): a Boolean +

+
+
description
+
+
+ + + 1. If _left_.[[Specifier]] is not _right_.[[Specifier]], return *false*. + 1. Let _leftAttrs_ be _left_.[[Attributes]]. + 1. Let _rightAttrs_ be _right_.[[Attributes]]. + 1. If the number of elements in _leftAttrs_ is not the number of elements in _rightAttrs_, return *false*. + 1. For each ImportAttribute Record _l_ of _leftAttrs_, do + 1. Let _found_ be *false*. + 1. For each ImportAttribute Record _r_ of _rightAttrs_, do + 1. If _l_.[[Key]] is _r_.[[Key]], then + 1. If _l_.[[Value]] is _r_.[[Value]], then + 1. Set _found_ to *true*. + 1. Else, + 1. Return *false*. + 1. If _found_ is *false*, return *false*. + 1. Return *true*. + +
@@ -26055,7 +26113,7 @@

Static Semantics: ModuleRequests ( ): a List of ModuleRequest Records

1. Let _requests_ be ModuleRequests of |ModuleItemList|. 1. Let _additionalRequests_ be ModuleRequests of |ModuleItem|. 1. For each ModuleRequest Record _mr_ of _additionalRequests_, do - 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 + 1. If _requests_ does not contain a ModuleRequest Record _mr2_ such that ModuleRequestsEqual(_mr_, _mr2_) is *true*, then 1. Append _mr_ to _requests_. 1. Return _requests_. @@ -26307,10 +26365,10 @@

Cyclic Module Records

[[LoadedModules]] - a List of Records with fields [[Specifier]] (a String), [[Attributes]] (a List of ImportAttribute Records) and [[Module]] (a Module Record) + a List of LoadedModuleRequest Records - 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. + 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*. @@ -26529,7 +26587,7 @@

1. Let _requestedModulesCount_ be the number of elements in _module_.[[RequestedModules]]. 1. Set _state_.[[PendingModulesCount]] to _state_.[[PendingModulesCount]] + _requestedModulesCount_. 1. For each ModuleRequest Record _request_ of _module_.[[RequestedModules]], do - 1. If _module_.[[LoadedModules]] contains a Record _record_ such that _record_.[[Specifier]] is _request_.[[Specifier]] and ImportAttributesEqual(_record_.[[Attributes]], _request_.[[Attributes]]) is *true*, then + 1. If _module_.[[LoadedModules]] contains a LoadedModuleRequest Record _record_ such that ModuleRequestsEqual(_record_, _request_) is *true*, then 1. Perform InnerModuleLoading(_state_, _record_.[[Module]]). 1. Else, 1. Perform HostLoadImportedModule(_module_, _request_, _state_.[[HostDefined]], _state_). @@ -28039,8 +28097,8 @@

- 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. - 1. Let _record_ be the Record in _referrer_.[[LoadedModules]] such that _record_.[[Specifier]] is _request_.[[Specifier]] and ImportAttributesEqual(_record_.[[Attributes]], _request_.[[Attributes]]) is *true*. + 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. + 1. Let _record_ be the LoadedModuleRequest Record in _referrer_.[[LoadedModules]] such that ModuleRequestsEqual(_record_, _request_) is *true*. 1. Return _record_.[[Module]]. @@ -28076,8 +28134,7 @@

If this operation is called multiple times with two (_referrer_, _moduleRequest_) pairs such that:

  • the first _referrer_ is the same as the second _referrer_;
  • -
  • the first _moduleRequest_.[[Specifier]] is the same as the second _moduleRequest_.[[Specifier]];
  • -
  • ImportAttributesEqual(the first _moduleRequest_.[[Attributes]], the second _moduleRequest_.[[Attributes]]) is *true*;
  • +
  • ModuleRequestsEqual(the first _moduleRequest_, the second _moduleRequest_) is *true*;

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.

@@ -28104,10 +28161,10 @@

1. If _result_ is a normal completion, then - 1. If _referrer_.[[LoadedModules]] contains a Record _record_ such that _record_.[[Specifier]] is _moduleRequest_.[[Specifier]] and ImportAttributesEqual(_record_.[[Attributes]], _moduleRequest_.[[Attributes]]) is *true*, then + 1. If _referrer_.[[LoadedModules]] contains a LoadedModuleRequest Record _record_ such that ModuleRequestsEqual(_record_, _moduleRequest_) is *true*, then 1. Assert: _record_.[[Module]] is _result_.[[Value]]. 1. Else, - 1. Append the Record { [[Specifier]]: _moduleRequest_.[[Specifer]], [[Attributes]]: _moduleRequest_.[[Attributes]], [[Module]]: _result_.[[Value]] } to _referrer_.[[LoadedModules]]. + 1. Append the LoadedModuleRequest Record { [[Specifier]]: _moduleRequest_.[[Specifer]], [[Attributes]]: _moduleRequest_.[[Attributes]], [[Module]]: _result_.[[Value]] } to _referrer_.[[LoadedModules]]. 1. If _payload_ is a GraphLoadingState Record, then 1. Perform ContinueModuleLoading(_payload_, _result_). 1. Else, @@ -28116,33 +28173,6 @@

- -

- ImportAttributesEqual ( - _left_: a List of ImportAttribute Records, - _right_: a List of ImportAttribute Records, - ): a Boolean -

-
-
description
-
-
- - - 1. If the number of elements in _left_ is not the same as the number of elements in _right_, return *false*. - 1. For each ImportAttribute Record _r_ of _left_, do - 1. Let _found_ be *false*. - 1. For each ImportAttribute Record _s_ of _right_, do - 1. If _r_.[[Key]] is _s_.[[Key]], then - 1. If _r_.[[Value]] is _s_.[[Value]], then - 1. Set _found_ to *true*. - 1. Else, - 1. Return *false*. - 1. If _found_ is *false*, return *false*. - 1. Return *true*. - -
-

AllImportAttributesSupported (