From cd75ff845cc9400fda59d99cad683b4fc2a40150 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Wed, 28 Jun 2023 17:53:26 -0700 Subject: [PATCH] spec feedback from @bakkot --- spec.emu | 148 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 140 insertions(+), 8 deletions(-) diff --git a/spec.emu b/spec.emu index dc38c81..5855539 100644 --- a/spec.emu +++ b/spec.emu @@ -51,7 +51,7 @@ contributors: Luca Casonato, Guy Bedford, Nicolò Ribaudo

EvaluateImportCall ( - _specifierExpression_: a ParseNode, + _specifierExpression_: a Parse Node, _phase_: ~source~ or ~evaluation~ ): either a normal completion containing a Promise or a throw completion @@ -60,7 +60,7 @@ contributors: Luca Casonato, Guy Bedford, Nicolò Ribaudo 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 evaluating _specifierExpression_. 1. Let _specifier_ be ? GetValue(_specifierRef_). 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). 1. Let _specifierString_ be Completion(ToString(_specifier_)). @@ -133,7 +133,7 @@ contributors: Luca Casonato, Guy Bedford, Nicolò Ribaudo

ModuleRequest Records

-

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

+

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

@@ -376,7 +376,7 @@ contributors: Luca Casonato, Guy Bedford, Nicolò Ribaudo GetModuleSource() @@ -840,6 +840,140 @@ contributors: Luca Casonato, Guy Bedford, Nicolò Ribaudo +

An ImportEntry Record is a Record that digests information about a single declarative import. Each ImportEntry Record has the fields defined in :

+ +
-

It returns either a normal completion completion for the ModuleSource Object corresponding to this source Module Record's source phase (), or a throw completion.

+

It returns either a normal completion completion for the Module Source Object corresponding to this source Module Record's source phase (), or a throw completion.

When called multiple times on the same Module Record, if GetModuleSource() returns a normal completion it must always return a normal completion containing the same object. The returned object should be an instance of a subclass of %AbstractModuleSource%, and it must have an internal slot [[ModuleSourceClassName]].
+ + + + + + + + + + + + + + + + + + + + +
+ Field Name + + Value Type + + Meaning +
+ [[ModuleRequest]] + + a String + + String value of the |ModuleSpecifier| of the |ImportDeclaration|. +
+ [[ImportName]] + + a String or ~namespace-object~, ~namespace-object~ or ~source~ + + The name under which the desired binding is exported by the module identified by [[ModuleRequest]]. The value ~namespace-object~ indicates that the import request is for the target module's namespace object. The value ~source~ represents an import of the import phase representation at that phase name. +
+ [[LocalName]] + + a String + + The name that is used to locally access the imported value from within the importing module. +
+
+ +

gives examples of ImportEntry records fields used to represent the syntactic import forms:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Import Statement Form + + [[ModuleRequest]] + + [[ImportName]] + + [[LocalName]] +
+ `import v from "mod";` + + *"mod"* + + *"default"* + + *"v"* +
+ `import * as ns from "mod";` + + *"mod"* + + ~namespace-object~ + + *"ns"* +
+ `import {x} from "mod";` + + *"mod"* + + *"x"* + + *"x"* +
+ `import {x as v} from "mod";` + + *"mod"* + + *"x"* + + *"v"* +
+ `import "mod";` + + An ImportEntry Record is not created. +
+
+

@@ -883,7 +1017,7 @@ contributors: Luca Casonato, Guy Bedford, Nicolò Ribaudo

The actual process performed is host-defined, but typically consists of performing whatever I/O operations are necessary to load the appropriate Module Record. Multiple different (_referrer_, _specifier__moduleRequest_.[[Specifier]]) pairs may map to the same Module Record instance. The actual mapping semantics is host-defined but typically a normalization process is applied to _specifier_ as part of the mapping process. A typical normalization process would include actions such as expansion of relative and abbreviated path specifiers.

-

Implementations may provide unobservable module loading optimizations, such as speculative preloading of modules that are likely to be requested next. When doing so, they should consider whether the module is being imported for its ~source~ phase, which won't cause calls to the HostLoadImportedModule hook for its transitive dependencies, or for its ~evaluation~ phase.

+

Implementations may provide unobservable module loading optimizations, such as speculative preloading of modules that are likely to be requested next. When doing so, they should consider whether the module is being imported for its ~source~ phase, which won't cause calls to the HostLoadImportedModule hook for its transitive dependencies, or for its ~evaluation~ phase, which will.

@@ -1026,7 +1160,6 @@ contributors: Luca Casonato, Guy Bedford, Nicolò Ribaudo 1. Throw a *TypeError* exception. -

The *"length"* property of this function is *+0*𝔽.

@@ -1054,7 +1187,6 @@ contributors: Luca Casonato, Guy Bedford, Nicolò Ribaudo
  • is %AbstractModuleSource.prototype%.
  • is an ordinary object.
  • does not have a global name or appear as a property of the global object.
  • -
  • does not have a [[ModuleSourceClassName]] slot that is specific to _AbstractModuleSource_ and _AbstractModuleSource_ subclass instance objects.
  • has the following properties:
  • @@ -1064,7 +1196,7 @@ contributors: Luca Casonato, Guy Bedford, Nicolò Ribaudo -

    get %AbstractModuleSource%.prototype [ @@toStringTag ]

    +

    get %AbstractModuleSource%.prototype [ @@toStringTag ] ( )

    %AbstractModuleSource%.prototype `[@@toStringTag]` is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps when called:

    1. Let _O_ be the *this* value.