diff --git a/index.bs b/index.bs index 5aba1f92..5d9ad982 100644 --- a/index.bs +++ b/index.bs @@ -34,6 +34,7 @@ spec: url; type: interface; text: URL spec: dom; type: interface; text: Document spec: ecma-262; type: dfn; for: /; text: internal method spec: ecma-262; type: dfn; for: /; text: internal slot +spec: ecma-262; type: dfn; for: /; text:realm
@@ -125,6 +126,10 @@ urlPrefix: https://tc39.github.io/ecma262/; spec: ECMA-262
         text: CreateSetIterator; url: sec-createsetiterator
         text: DefinePropertyOrThrow; url: sec-definepropertyorthrow
         text: DetachArrayBuffer; url: sec-detacharraybuffer
+        for: Environment Record; url: table-15
+            text: SetMutableBinding
+            text: CreateMutableBinding
+            text: InitializeBinding
         text: Get; url: sec-get-o-p
         text: GetFunctionRealm; url: sec-getfunctionrealm
         text: GetIterator; url: sec-getiterator
@@ -138,6 +143,7 @@ urlPrefix: https://tc39.github.io/ecma262/; spec: ECMA-262
         text: IsSharedArrayBuffer; url: sec-issharedarraybuffer
         text: IteratorStep; url: sec-iteratorstep
         text: IteratorValue; url: sec-iteratorvalue
+        text: NewModuleEnvironment; url: sec-newmoduleenvironment
         text: NormalCompletion; url: sec-normalcompletion
         text: ObjectCreate; url: sec-objectcreate
         text: OrdinaryDefineOwnProperty; url: sec-ordinarydefineownproperty
@@ -181,15 +187,27 @@ urlPrefix: https://tc39.github.io/ecma262/; spec: ECMA-262
         text: constructor; url: constructor
         text: conventions; for: ECMAScript; url: sec-algorithm-conventions
         text: current Realm; url: current-realm
+        text: ECMAScript code execution context; url: sec-execution-contexts
+        for: ECMAScript code execution context; url: table-23
+            text: LexicalEnvironment
+            text: VariableEnvironment
         text: element; for: ECMAScript String; url: sec-ecmascript-language-types-string-type
         text: enumerable; url: sec-property-attributes
+        text: EnvironmentRecord; for: Lexical Environment; url: sec-lexical-environments
         text: equally close values; url: sec-ecmascript-language-types-number-type
         text: error objects; for: ECMAScript; url: sec-error-objects
+        for: Execution context; url: table-22
+            text: Function
+            text: Realm
+            text: ScriptOrModule
+        text: execution context stack; url: execution-context-stack
         text: function object; url: function-object
         text: immutable prototype exotic object; url: sec-immutable-prototype-exotic-objects
         url: sec-object-internal-methods-and-internal-slots
             text: internal method
             text: internal slot
+        text: Module Record; url: sec-abstract-module-records
+        text: Module Record Fields; url: table-36
         text: Number type; url: sec-ecmascript-language-types-number-type
         text: Object; for: ECMAScript; url: sec-object-type
         for: ordinary object; url: sec-ordinary-object-internal-methods-and-internal-slots
@@ -197,13 +215,20 @@ urlPrefix: https://tc39.github.io/ecma262/; spec: ECMA-262
             text: internal slot
         text: own property; url: sec-own-property
         text: Property Descriptor; url: sec-property-descriptor-specification-type
+        text: Source Text Module Record; url: sourctextmodule-record
         text: realm; url: realm
+        text: ResolvedBinding Record; url: resolvedbinding-record
+        text: running execution context; url: running-execution-context
 
 {
     "GEOMETRY": {
         "aliasOf": "GEOMETRY-1"
+    },
+    "JSSTDLIB": {
+        "href": "https://github.com/tc39/proposal-javascript-standard-library/",
+        "title": "Standard Library Proposal"
     }
 }
 
@@ -13244,6 +13269,165 @@ the exact steps to take if an exception was thrown, or by explicitly +

Synthetic module records

+ +A Synthetic Module Record is used to represent information about a module that is +defined by specifications. +The set of exported names is static, and determined at creation time (as an argument to +[$CreateSyntheticModule$]), while the set of exported values can be changed over time using +[$SetSyntheticModuleExport$]. +It has no imports or dependencies. + +Note: A [=Synthetic Module Record=] could be used for defining a variety of module types: for +example, built-in modules, or JSON modules, or CSS modules. + +Note: [=Synthetic Module Records=] are being developed in concert with the authors of the +JavaScript Standard Library proposal, and might eventually move to the ECMAScript +specification. [[JSSTDLIB]] [[ECMA-262]]. + +In addition to the [=Module Record Fields=], Synthetic Module Records have the additional fields +listed below. +Each of these fields is initially set in [$CreateSyntheticModule$]. + + + + + + + + +
Additional Fields of Synthetic Module Records
Field Name + Value Type + Meaning +
\[[ExportNames]] + List of String + A List of all names that are exported. +
\[[EvaluationSteps]] + An abstract operation + An abstract operation that will be performed upon evaluation of the module, taking the + [=Synthetic Module Record=] as its sole argument. + These will usually set up the exported values, by using [$SetSyntheticModuleExport$]. + They must not modify \[[ExportNames]]. + They may return an abrupt completion. +
+ +

CreateSyntheticModule

+ +
+The abstract operation CreateSyntheticModule(|exportNames|, |evaluationSteps|, |realm|, |hostDefined|) creates a [=Synthetic Module Record=] based upon +the given exported names and evaluation steps. +It performs the following steps: + + 1. Return [=Synthetic Module Record=] { + \[[Realm]]: |realm|, + \[[Environment]]: undefined, + \[[Namespace]]: undefined, + \[[HostDefined]]: |hostDefined|, + \[[ExportNames]]: |exportNames|, + \[[EvaluationSteps]]: |evaluationSteps| + }. +
+ +Note: we could set up \[[Environment]] either here or in [$Synthetic Module Record/Instantiate$](). +It is done in [$Synthetic Module Record/Instantiate$]() for symmetry with [=Source Text Module Records=], +but there is no observable difference. + +

SetSyntheticModuleExport

+ +
+The abstract operation SetSyntheticModuleExport(|module|, |exportName|, +|exportValue|) can be used to set or change the exported value for a pre-established export of a +Synthetic Module Record. +It performs the following steps: + + 1. Let |envRec| be |module|.\[[Environment]]'s [=Lexical Environment/EnvironmentRecord=]. + 1. Perform |envRec|.[$Environment Record/SetMutableBinding$](|exportName|, |exportValue|, + true). +
+ +

Concrete Methods

+ +The following are the concrete methods for [=Synthetic Module Record=] that implement the +corresponding [=Module Record=] abstract methods. + +
GetExportedNames
+ +
+The GetExportedNames(exportStarSet) concrete method of a [=Synthetic Module Record=] implements the +corresponding [=Module Record=] abstract method. + +It performs the following steps: + + 1. Let |module| be this [=Synthetic Module Record=]. + 1. Return |module|.\[[ExportNames]]. +
+ +
ResolveExport
+ +
+The ResolveExport(|exportName|, resolveSet) concrete method of a [=Synthetic Module Record=] implements the +corresponding [=Module Record=] abstract method. + +It performs the following steps: + + 1. Let |module| be this [=Synthetic Module Record=]. + 1. If |module|.\[[ExportNames]] does not contain |exportName|, return null. + 1. Return [=ResolvedBinding Record=] { \[[Module]]: |module|, \[[BindingName]]: |exportName| }. +
+ +
Instantiate
+ +
+The Instantiate() concrete method of a +[=Synthetic Module Record=] implements the corresponding [=Module Record=] abstract method. + +It performs the following steps: + + 1. Let |module| be this [=Synthetic Module Record=]. + 1. Let |realm| be |module|.\[[Realm]]. + 1. Assert: |realm| is not undefined. + 1. Let |env| be [$NewModuleEnvironment$](|realm|.\[[GlobalEnv]]). + 1. Set |module|.\[[Environment]] to |env|. + 1. Let |envRec| be |env|'s [=Lexical Environment/EnvironmentRecord=]. + 1. For each |exportName| in |module|.\[[ExportNames]], + 1. Perform [=!=] |envRec|.[$Environment Record/CreateMutableBinding$](|exportName|, + false). + 1. Perform [=!=] |envRec|.[$Environment Record/InitializeBinding$](|exportName|, + undefined). + 1. Return undefined. +
+ +
Evaluate
+ +
+The Evaluate() concrete method of a +[=Synthetic Module Record=] implements the corresponding [=Module Record=] abstract method. + +It performs the following steps: + + 1. Let |module| be this [=Synthetic Module Record=]. + 1. Let |moduleCxt| be a new [=ECMAScript code execution context=]. + 1. Set the [=Execution context/Function=] of |moduleCxt| to null. + 1. Assert: |module|.\[[Realm]] is not undefined. + 1. Set the [=Execution context/Realm=] of |moduleCxt| to |module|.\[[Realm]]. + 1. Set the [=Execution context/ScriptOrModule=] of |moduleCxt| to |module|. + 1. Set the [=ECMAScript code execution context/VariableEnvironment=] of |moduleCxt| to + |module|.\[[Environment]]. + 1. Set the [=ECMAScript code execution context/LexicalEnvironment=] of |moduleCxt| to + |module|.\[[Environment]]. + 1. Suspend the currently [=running execution context=]. + 1. Push |moduleCxt| on to the [=execution context stack=]; |moduleCxt| is now the + [=running execution context=]. + 1. Let |completion| be the result of performing |module|.\[[EvaluationSteps]](|module|). + 1. Suspend |moduleCxt| and remove it from the [=execution context stack=]. + 1. Resume the context that is now on the top of the [=execution context stack=] as the + [=running execution context=]. + 1. Return [$Completion$](|completion|). +
+ +

Common definitions

This section specifies some common definitions that all