From 346aafe708bee456c0c8f21184cf38ba6bbd15af Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Sat, 23 Jan 2021 22:54:21 -0500 Subject: [PATCH 1/5] Editorial: Use Declarative Env Rec's HasBinding method ... in other Declarative Env Rec methods. --- spec.html | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/spec.html b/spec.html index 652ddce78b..8cdbd987ed 100644 --- a/spec.html +++ b/spec.html @@ -10235,7 +10235,7 @@

It creates a new mutable binding for the name _N_ that is uninitialized. A binding must not already exist in this Environment Record for _N_. If _D_ is *true*, the new binding is marked as being subject to deletion.
- 1. Assert: _envRec_ does not already have a binding for _N_. + 1. Assert: _envRec_.HasBinding(_N_) is *false*. 1. Create a mutable binding in _envRec_ for _N_ and record that it is uninitialized. If _D_ is *true*, record that the newly created binding may be deleted by a subsequent DeleteBinding call. 1. Return ~unused~. @@ -10256,7 +10256,7 @@

It creates a new immutable binding for the name _N_ that is uninitialized. A binding must not already exist in this Environment Record for _N_. If _S_ is *true*, the new binding is marked as a strict binding.
- 1. Assert: _envRec_ does not already have a binding for _N_. + 1. Assert: _envRec_.HasBinding(_N_) is *false*. 1. Create an immutable binding in _envRec_ for _N_ and record that it is uninitialized. If _S_ is *true*, record that the newly created binding is a strict binding. 1. Return ~unused~. @@ -10277,7 +10277,8 @@

It is used to set the bound value of the current binding of the identifier whose name is _N_ to the value _V_. An uninitialized binding for _N_ must already exist.
- 1. Assert: _envRec_ must have an uninitialized binding for _N_. + 1. Assert: _envRec_.HasBinding(_N_) is *true*. + 1. Assert: the binding for _N_ in _envRec_ is uninitialized. 1. Set the bound value for _N_ in _envRec_ to _V_. 1. Record that the binding for _N_ in _envRec_ has been initialized. 1. Return ~unused~. @@ -10300,7 +10301,7 @@

It attempts to change the bound value of the current binding of the identifier whose name is _N_ to the value _V_. A binding for _N_ normally already exists, but in rare cases it may not. If the binding is an immutable binding, a *TypeError* is thrown if _S_ is *true*.
- 1. [id="step-setmutablebinding-missing-binding"] If _envRec_ does not have a binding for _N_, then + 1. [id="step-setmutablebinding-missing-binding"] If _envRec_.HasBinding(_N_) is *false*, then 1. If _S_ is *true*, throw a *ReferenceError* exception. 1. Perform ! _envRec_.CreateMutableBinding(_N_, *true*). 1. Perform ! _envRec_.InitializeBinding(_N_, _V_). @@ -10336,7 +10337,7 @@

It returns the value of its bound identifier whose name is _N_. If the binding exists but is uninitialized a *ReferenceError* is thrown, regardless of the value of _S_.
- 1. Assert: _envRec_ has a binding for _N_. + 1. Assert: _envRec_.HasBinding(_N_) is *true*. 1. If the binding for _N_ in _envRec_ is an uninitialized binding, throw a *ReferenceError* exception. 1. Return the value currently bound to _N_ in _envRec_. @@ -10356,7 +10357,7 @@

It can only delete bindings that have been explicitly designated as being subject to deletion.
- 1. Assert: _envRec_ has a binding for _N_. + 1. Assert: _envRec_.HasBinding(_N_) is *true*. 1. If the binding for _N_ in _envRec_ cannot be deleted, return *false*. 1. Remove the binding for _N_ from _envRec_. 1. Return *true*. @@ -11396,7 +11397,7 @@

1. Assert: _S_ is *true*. - 1. Assert: _envRec_ has a binding for _N_. + 1. Assert: _envRec_.HasBinding(_N_) is *true*. 1. If the binding for _N_ is an indirect binding, then 1. Let _M_ and _N2_ be the indirection values provided when this binding for _N_ was created. 1. Let _targetEnv_ be _M_.[[Environment]]. @@ -11459,7 +11460,7 @@

It creates a new initialized immutable indirect binding for the name _N_. A binding must not already exist in this Environment Record for _N_. _N2_ is the name of a binding that exists in _M_'s Module Environment Record. Accesses to the value of the new binding will indirectly access the bound value of the target binding.
- 1. Assert: _envRec_ does not already have a binding for _N_. + 1. Assert: _envRec_.HasBinding(_N_) is *false*. 1. Assert: When _M_.[[Environment]] is instantiated, it will have a direct binding for _N2_. 1. Create an immutable indirect binding in _envRec_ for _N_ that references _M_ and _N2_ as its target binding and record that the binding is initialized. 1. Return ~unused~. From 4af342bc0876dab7ab703b36d2b680543d15f00e Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Sat, 23 Jan 2021 23:52:38 -0500 Subject: [PATCH 2/5] Editorial: Treat a binding as an 'alias-able' thing ... that has a distinct existence from its env rec. --- spec.html | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/spec.html b/spec.html index 8cdbd987ed..cf59c644d4 100644 --- a/spec.html +++ b/spec.html @@ -10236,7 +10236,8 @@

1. Assert: _envRec_.HasBinding(_N_) is *false*. - 1. Create a mutable binding in _envRec_ for _N_ and record that it is uninitialized. If _D_ is *true*, record that the newly created binding may be deleted by a subsequent DeleteBinding call. + 1. Let _binding_ be a mutable binding for _N_ and record that it is uninitialized. If _D_ is *true*, record that the newly created binding may be deleted by a subsequent DeleteBinding call. + 1. Add _binding_ to _envRec_. 1. Return ~unused~. @@ -10257,7 +10258,8 @@

1. Assert: _envRec_.HasBinding(_N_) is *false*. - 1. Create an immutable binding in _envRec_ for _N_ and record that it is uninitialized. If _S_ is *true*, record that the newly created binding is a strict binding. + 1. Let _binding_ be an immutable binding for _N_ and record that it is uninitialized. If _S_ is *true*, record that the newly created binding is a strict binding. + 1. Add _binding_ to _envRec_. 1. Return ~unused~. @@ -10278,9 +10280,10 @@

1. Assert: _envRec_.HasBinding(_N_) is *true*. - 1. Assert: the binding for _N_ in _envRec_ is uninitialized. - 1. Set the bound value for _N_ in _envRec_ to _V_. - 1. Record that the binding for _N_ in _envRec_ has been initialized. + 1. Let _binding_ be the binding for _N_ in _envRec_. + 1. Assert: _binding_ is uninitialized. + 1. Set the bound value of _binding_ to _V_. + 1. Record that _binding_ has been initialized. 1. Return ~unused~. @@ -10306,10 +10309,11 @@

1. Perform ! _envRec_.CreateMutableBinding(_N_, *true*). 1. Perform ! _envRec_.InitializeBinding(_N_, _V_). 1. Return ~unused~. - 1. If the binding for _N_ in _envRec_ is a strict binding, set _S_ to *true*. - 1. If the binding for _N_ in _envRec_ has not yet been initialized, then + 1. Let _binding_ be the binding for _N_ in _envRec_. + 1. If _binding_ is a strict binding, set _S_ to *true*. + 1. If _binding_ has not yet been initialized, then 1. Throw a *ReferenceError* exception. - 1. Else if the binding for _N_ in _envRec_ is a mutable binding, then + 1. Else if _binding_ is a mutable binding, then 1. Change its bound value to _V_. 1. Else, 1. Assert: This is an attempt to change the value of an immutable binding. @@ -10338,8 +10342,9 @@

1. Assert: _envRec_.HasBinding(_N_) is *true*. - 1. If the binding for _N_ in _envRec_ is an uninitialized binding, throw a *ReferenceError* exception. - 1. Return the value currently bound to _N_ in _envRec_. + 1. Let _binding_ be the binding for _N_ in _envRec_. + 1. If _binding_ is an uninitialized binding, throw a *ReferenceError* exception. + 1. Return the value currently bound in _binding_. @@ -10358,8 +10363,9 @@

1. Assert: _envRec_.HasBinding(_N_) is *true*. - 1. If the binding for _N_ in _envRec_ cannot be deleted, return *false*. - 1. Remove the binding for _N_ from _envRec_. + 1. Let _binding_ be the binding for _N_ in _envRec_. + 1. If _binding_ cannot be deleted, return *false*. + 1. Remove _binding_ from _envRec_. 1. Return *true*. @@ -11398,13 +11404,14 @@

1. Assert: _S_ is *true*. 1. Assert: _envRec_.HasBinding(_N_) is *true*. - 1. If the binding for _N_ is an indirect binding, then + 1. Let _binding_ be the binding for _N_ in _envRec_. + 1. If _binding_ is an indirect binding, then 1. Let _M_ and _N2_ be the indirection values provided when this binding for _N_ was created. 1. Let _targetEnv_ be _M_.[[Environment]]. 1. If _targetEnv_ is ~empty~, throw a *ReferenceError* exception. 1. Return ? _targetEnv_.GetBindingValue(_N2_, *true*). - 1. If the binding for _N_ in _envRec_ is an uninitialized binding, throw a *ReferenceError* exception. - 1. Return the value currently bound to _N_ in _envRec_. + 1. If _binding_ is an uninitialized binding, throw a *ReferenceError* exception. + 1. Return the value currently bound in _binding_.

_S_ will always be *true* because a |Module| is always strict mode code.

@@ -11462,7 +11469,8 @@

1. Assert: _envRec_.HasBinding(_N_) is *false*. 1. Assert: When _M_.[[Environment]] is instantiated, it will have a direct binding for _N2_. - 1. Create an immutable indirect binding in _envRec_ for _N_ that references _M_ and _N2_ as its target binding and record that the binding is initialized. + 1. Let _binding_ be an immutable indirect binding for _N_ that references _M_ and _N2_ as its target binding and record that the binding is initialized. + 1. Add _binding_ to _envRec_. 1. Return ~unused~. @@ -51767,7 +51775,8 @@

Changes to BlockDeclarationInstantiation

During BlockDeclarationInstantiation the following steps are performed in place of step :

1. Perform the following steps: - 1. If the binding for _fn_ in _env_ is an uninitialized binding, then + 1. Let _binding_ be the binding for _fn_ in _env_. + 1. If _binding_ is an uninitialized binding, then 1. Perform ! _env_.InitializeBinding(_fn_, _fo_). 1. Else, 1. Assert: _d_ is a |FunctionDeclaration|. From 5cb072558af921aa765e1b0a6ca1df21969e00ff Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Sat, 23 Jan 2021 23:59:22 -0500 Subject: [PATCH 3/5] Editorial: Declarative Env Rec has field [[Bindings]] ... that is a List of bindings (without being specific yet about what a binding is). --- spec.html | 58 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 14 deletions(-) diff --git a/spec.html b/spec.html index cf59c644d4..2ef78ab46e 100644 --- a/spec.html +++ b/spec.html @@ -10199,6 +10199,33 @@

The Environment Record Type Hierarchy

Declarative Environment Records

Each Declarative Environment Record is associated with an ECMAScript program scope containing variable, constant, let, class, module, import, and/or function declarations. A Declarative Environment Record binds the set of identifiers defined by the declarations contained within its scope.

+

Declarative Environment Records have the additional fields listed in .

+ + + + + + + + + + + + +
+ Field Name + + Value + + Meaning +
+ [[Bindings]] + + a List of bindings + + Satisfies the invariant that no two bindings in [[Bindings]] are bindings for the same name. +
+

The behaviour of the concrete specification methods for Declarative Environment Records is defined by the following algorithms.

@@ -10215,7 +10242,7 @@

It determines if the argument identifier is one of the identifiers bound by the record.
- 1. If _envRec_ has a binding for _N_, return *true*. + 1. If _envRec_.[[Bindings]] contains a binding for _N_, return *true*. 1. Return *false*. @@ -10237,7 +10264,7 @@

1. Assert: _envRec_.HasBinding(_N_) is *false*. 1. Let _binding_ be a mutable binding for _N_ and record that it is uninitialized. If _D_ is *true*, record that the newly created binding may be deleted by a subsequent DeleteBinding call. - 1. Add _binding_ to _envRec_. + 1. Append _binding_ to _envRec_.[[Bindings]]. 1. Return ~unused~. @@ -10259,7 +10286,7 @@

1. Assert: _envRec_.HasBinding(_N_) is *false*. 1. Let _binding_ be an immutable binding for _N_ and record that it is uninitialized. If _S_ is *true*, record that the newly created binding is a strict binding. - 1. Add _binding_ to _envRec_. + 1. Append _binding_ to _envRec_.[[Bindings]]. 1. Return ~unused~. @@ -10280,7 +10307,7 @@

1. Assert: _envRec_.HasBinding(_N_) is *true*. - 1. Let _binding_ be the binding for _N_ in _envRec_. + 1. Let _binding_ be the binding for _N_ in _envRec_.[[Bindings]]. 1. Assert: _binding_ is uninitialized. 1. Set the bound value of _binding_ to _V_. 1. Record that _binding_ has been initialized. @@ -10309,7 +10336,7 @@

1. Perform ! _envRec_.CreateMutableBinding(_N_, *true*). 1. Perform ! _envRec_.InitializeBinding(_N_, _V_). 1. Return ~unused~. - 1. Let _binding_ be the binding for _N_ in _envRec_. + 1. Let _binding_ be the binding for _N_ in _envRec_.[[Bindings]]. 1. If _binding_ is a strict binding, set _S_ to *true*. 1. If _binding_ has not yet been initialized, then 1. Throw a *ReferenceError* exception. @@ -10342,7 +10369,7 @@

1. Assert: _envRec_.HasBinding(_N_) is *true*. - 1. Let _binding_ be the binding for _N_ in _envRec_. + 1. Let _binding_ be the binding for _N_ in _envRec_.[[Bindings]]. 1. If _binding_ is an uninitialized binding, throw a *ReferenceError* exception. 1. Return the value currently bound in _binding_. @@ -10363,9 +10390,9 @@

1. Assert: _envRec_.HasBinding(_N_) is *true*. - 1. Let _binding_ be the binding for _N_ in _envRec_. + 1. Let _binding_ be the binding for _N_ in _envRec_.[[Bindings]]. 1. If _binding_ cannot be deleted, return *false*. - 1. Remove _binding_ from _envRec_. + 1. Remove _binding_ from _envRec_.[[Bindings]]. 1. Return *true*. @@ -11404,7 +11431,7 @@

1. Assert: _S_ is *true*. 1. Assert: _envRec_.HasBinding(_N_) is *true*. - 1. Let _binding_ be the binding for _N_ in _envRec_. + 1. Let _binding_ be the binding for _N_ in _envRec_.[[Bindings]]. 1. If _binding_ is an indirect binding, then 1. Let _M_ and _N2_ be the indirection values provided when this binding for _N_ was created. 1. Let _targetEnv_ be _M_.[[Environment]]. @@ -11470,7 +11497,7 @@

1. Assert: _envRec_.HasBinding(_N_) is *false*. 1. Assert: When _M_.[[Environment]] is instantiated, it will have a direct binding for _N2_. 1. Let _binding_ be an immutable indirect binding for _N_ that references _M_ and _N2_ as its target binding and record that the binding is initialized. - 1. Add _binding_ to _envRec_. + 1. Append _binding_ to _envRec_.[[Bindings]]. 1. Return ~unused~. @@ -11512,7 +11539,8 @@

- 1. Let _env_ be a new Declarative Environment Record containing no bindings. + 1. Let _env_ be a new Declarative Environment Record. + 1. Set _env_.[[Bindings]] to « ». 1. Set _env_.[[OuterEnv]] to _E_. 1. Return _env_. @@ -11547,7 +11575,8 @@

- 1. Let _env_ be a new Function Environment Record containing no bindings. + 1. Let _env_ be a new Function Environment Record. + 1. Set _env_.[[Bindings]] to « ». 1. Set _env_.[[FunctionObject]] to _F_. 1. If _F_.[[ThisMode]] is ~lexical~, set _env_.[[ThisBindingStatus]] to ~lexical~. 1. Else, set _env_.[[ThisBindingStatus]] to ~uninitialized~. @@ -11588,7 +11617,8 @@

- 1. Let _env_ be a new Module Environment Record containing no bindings. + 1. Let _env_ be a new Module Environment Record. + 1. Set _env_.[[Bindings]] to « ». 1. Set _env_.[[OuterEnv]] to _E_. 1. Return _env_. @@ -51775,7 +51805,7 @@

Changes to BlockDeclarationInstantiation

During BlockDeclarationInstantiation the following steps are performed in place of step :

1. Perform the following steps: - 1. Let _binding_ be the binding for _fn_ in _env_. + 1. Let _binding_ be the binding for _fn_ in _env_.[[Bindings]]. 1. If _binding_ is an uninitialized binding, then 1. Perform ! _env_.InitializeBinding(_fn_, _fo_). 1. Else, From 126c62c60b9e94e3a93217bddccab05f84c1149e Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Sun, 24 Jan 2021 00:30:29 -0500 Subject: [PATCH 4/5] Editorial: Model a declarative binding as a Record --- spec.html | 123 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 97 insertions(+), 26 deletions(-) diff --git a/spec.html b/spec.html index 2ef78ab46e..62de4ab6d9 100644 --- a/spec.html +++ b/spec.html @@ -10218,14 +10218,53 @@

Declarative Environment Records

[[Bindings]] - a List of bindings + a List of DeclarativeBindings - Satisfies the invariant that no two bindings in [[Bindings]] are bindings for the same name. + Satisfies the invariant that no two records in [[Bindings]] have the same [[BoundName]]. + +

A DeclarativeBinding is either a SimpleDeclarativeBinding or an ImportDeclarativeBinding. SimpleDeclarativeBindings can appear in any Declarative Environment Record, but ImportDeclarativeBindings can only appear in a Module Environment Record.

+ +

A SimpleDeclarativeBinding has the following fields:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Field NameValueMeaning
[[BoundName]]a Stringthe name being bound.
[[BoundValue]]an ECMAScript language value or ~uninitialized~the value that the name is bound to.
[[IsMutable]]a Booleanif *true*, indicates that the binding is mutable.
[[IsDeletable]]a Booleanif *true*, indicates that the binding may be deleted by a subsequent DeleteBinding call.
[[IsStrict]]a Booleanif *true*, indicates that the binding is a strict binding.
+
+

The behaviour of the concrete specification methods for Declarative Environment Records is defined by the following algorithms.

@@ -10242,7 +10281,7 @@

It determines if the argument identifier is one of the identifiers bound by the record.
- 1. If _envRec_.[[Bindings]] contains a binding for _N_, return *true*. + 1. If _envRec_.[[Bindings]] contains a DeclarativeBinding whose [[BoundName]] field equals _N_, return *true*. 1. Return *false*. @@ -10263,7 +10302,7 @@

1. Assert: _envRec_.HasBinding(_N_) is *false*. - 1. Let _binding_ be a mutable binding for _N_ and record that it is uninitialized. If _D_ is *true*, record that the newly created binding may be deleted by a subsequent DeleteBinding call. + 1. Let _binding_ be SimpleDeclarativeBinding { [[BoundName]]: _N_, [[BoundValue]]: ~uninitialized~, [[IsMutable]]: *true*, [[IsDeletable]]: _D_, [[IsStrict]]: *false* }. 1. Append _binding_ to _envRec_.[[Bindings]]. 1. Return ~unused~. @@ -10285,7 +10324,7 @@

1. Assert: _envRec_.HasBinding(_N_) is *false*. - 1. Let _binding_ be an immutable binding for _N_ and record that it is uninitialized. If _S_ is *true*, record that the newly created binding is a strict binding. + 1. Let _binding_ be SimpleDeclarativeBinding { [[BoundName]]: _N_, [[BoundValue]]: ~uninitialized~, [[IsMutable]]: *false*, [[IsDeletable]]: *false*, [[IsStrict]]: _S_ }. 1. Append _binding_ to _envRec_.[[Bindings]]. 1. Return ~unused~. @@ -10307,10 +10346,10 @@

1. Assert: _envRec_.HasBinding(_N_) is *true*. - 1. Let _binding_ be the binding for _N_ in _envRec_.[[Bindings]]. - 1. Assert: _binding_ is uninitialized. - 1. Set the bound value of _binding_ to _V_. - 1. Record that _binding_ has been initialized. + 1. Let _binding_ be the DeclarativeBinding in _envRec_.[[Bindings]] whose [[BoundName]] field equals _N_. + 1. Assert: _binding_ is a SimpleDeclarativeBinding. + 1. Assert: _binding_.[[BoundValue]] is ~uninitialized~. + 1. Set _binding_.[[BoundValue]] to _V_. 1. Return ~unused~. @@ -10336,11 +10375,13 @@

1. Perform ! _envRec_.CreateMutableBinding(_N_, *true*). 1. Perform ! _envRec_.InitializeBinding(_N_, _V_). 1. Return ~unused~. - 1. Let _binding_ be the binding for _N_ in _envRec_.[[Bindings]]. - 1. If _binding_ is a strict binding, set _S_ to *true*. - 1. If _binding_ has not yet been initialized, then + 1. Let _binding_ be the DeclarativeBinding in _envRec_.[[Bindings]] whose [[BoundName]] field equals _N_. + 1. If _binding_ is an ImportDeclarativeBinding, throw a *TypeError* exception. + 1. Assert: _binding_ is a SimpleDeclarativeBinding. + 1. If _binding_.[[IsStrict]] is *true*, set _S_ to *true*. + 1. If _binding_.[[BoundValue]] is ~uninitialized~, then 1. Throw a *ReferenceError* exception. - 1. Else if _binding_ is a mutable binding, then + 1. Else if _binding_.[[IsMutable]] is *true*, then 1. Change its bound value to _V_. 1. Else, 1. Assert: This is an attempt to change the value of an immutable binding. @@ -10369,9 +10410,10 @@

1. Assert: _envRec_.HasBinding(_N_) is *true*. - 1. Let _binding_ be the binding for _N_ in _envRec_.[[Bindings]]. - 1. If _binding_ is an uninitialized binding, throw a *ReferenceError* exception. - 1. Return the value currently bound in _binding_. + 1. Let _binding_ be the DeclarativeBinding in _envRec_.[[Bindings]] whose [[BoundName]] field equals _N_. + 1. Assert: _binding_ is a SimpleDeclarativeBinding. + 1. If _binding_.[[BoundValue]] is ~uninitialized~, throw a *ReferenceError* exception. + 1. Return _binding_.[[BoundValue]]. @@ -10390,8 +10432,9 @@

1. Assert: _envRec_.HasBinding(_N_) is *true*. - 1. Let _binding_ be the binding for _N_ in _envRec_.[[Bindings]]. - 1. If _binding_ cannot be deleted, return *false*. + 1. Let _binding_ be the DeclarativeBinding in _envRec_.[[Bindings]] whose [[BoundName]] field equals _N_. + 1. Assert: _binding_ is a SimpleDeclarativeBinding. + 1. If _binding_.[[IsDeletable]] is *false*, return *false*. 1. Remove _binding_ from _envRec_.[[Bindings]]. 1. Return *true*. @@ -11412,6 +11455,31 @@

Module Environment Records

+

The [[Bindings]] of a Module Environment Record can include both SimpleDeclarativeBindings and ImportDeclarativeBindings. An ImportDeclarativeBinding has the following fields:

+ + + + + + + + + + + + + + + + + + + + + + +
Field NameValueMeaning
[[BoundName]]a Stringthe name being bound.
[[TargetModuleRec]]a Module Recordthe imported module that provides the binding.
[[TargetName]]a Stringthe name of a binding that exists in the target module.
+

The behaviour of the additional concrete specification methods for Module Environment Records are defined by the following algorithms:

@@ -11431,14 +11499,16 @@

1. Assert: _S_ is *true*. 1. Assert: _envRec_.HasBinding(_N_) is *true*. - 1. Let _binding_ be the binding for _N_ in _envRec_.[[Bindings]]. - 1. If _binding_ is an indirect binding, then - 1. Let _M_ and _N2_ be the indirection values provided when this binding for _N_ was created. + 1. Let _binding_ be the DeclarativeBinding in _envRec_.[[Bindings]] whose [[BoundName]] field equals _N_. + 1. If _binding_ is an ImportDeclarativeBinding, then + 1. Let _M_ be _binding_.[[TargetModuleRec]]. + 1. Let _N2_ be _binding_.[[TargetName]]. 1. Let _targetEnv_ be _M_.[[Environment]]. 1. If _targetEnv_ is ~empty~, throw a *ReferenceError* exception. 1. Return ? _targetEnv_.GetBindingValue(_N2_, *true*). - 1. If _binding_ is an uninitialized binding, throw a *ReferenceError* exception. - 1. Return the value currently bound in _binding_. + 1. Assert: _binding_ is a SimpleDeclarativeBinding. + 1. If _binding_.[[BoundValue]] is ~uninitialized~, throw a *ReferenceError* exception. + 1. Return _binding_.[[BoundValue]].

_S_ will always be *true* because a |Module| is always strict mode code.

@@ -11496,7 +11566,7 @@

1. Assert: _envRec_.HasBinding(_N_) is *false*. 1. Assert: When _M_.[[Environment]] is instantiated, it will have a direct binding for _N2_. - 1. Let _binding_ be an immutable indirect binding for _N_ that references _M_ and _N2_ as its target binding and record that the binding is initialized. + 1. Let _binding_ be ImportDeclarativeBinding { [[BoundName]]: _N_, [[TargetModuleRec]]: _M_, [[TargetName]]: _N2_ }. 1. Append _binding_ to _envRec_.[[Bindings]]. 1. Return ~unused~. @@ -51805,8 +51875,9 @@

Changes to BlockDeclarationInstantiation

During BlockDeclarationInstantiation the following steps are performed in place of step :

1. Perform the following steps: - 1. Let _binding_ be the binding for _fn_ in _env_.[[Bindings]]. - 1. If _binding_ is an uninitialized binding, then + 1. Let _binding_ be the DeclarativeBinding in _env_.[[Bindings]] whose [[BoundName]] field equals _fn_. + 1. Assert: _binding_ is a SimpleDeclarativeBinding. + 1. If _binding_.[[BoundValue]] is ~uninitialized~, then 1. Perform ! _env_.InitializeBinding(_fn_, _fo_). 1. Else, 1. Assert: _d_ is a |FunctionDeclaration|. From ade059f1282d4050c4025203238eaa64cf0dac5d Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Sat, 2 Sep 2023 23:02:35 -0400 Subject: [PATCH 5/5] fixup: add 'variants' attributes; change "equals" to "is" --- spec.html | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/spec.html b/spec.html index 62de4ab6d9..2211e5550b 100644 --- a/spec.html +++ b/spec.html @@ -10227,9 +10227,9 @@

Declarative Environment Records

-

A DeclarativeBinding is either a SimpleDeclarativeBinding or an ImportDeclarativeBinding. SimpleDeclarativeBindings can appear in any Declarative Environment Record, but ImportDeclarativeBindings can only appear in a Module Environment Record.

+

A DeclarativeBinding is either a SimpleDeclarativeBinding or an ImportDeclarativeBinding. SimpleDeclarativeBindings can appear in any Declarative Environment Record, but ImportDeclarativeBindings can only appear in a Module Environment Record.

-

A SimpleDeclarativeBinding has the following fields:

+

A SimpleDeclarativeBinding has the following fields:

@@ -10281,7 +10281,7 @@

It determines if the argument identifier is one of the identifiers bound by the record.
- 1. If _envRec_.[[Bindings]] contains a DeclarativeBinding whose [[BoundName]] field equals _N_, return *true*. + 1. If _envRec_.[[Bindings]] contains a DeclarativeBinding whose [[BoundName]] field is _N_, return *true*. 1. Return *false*. @@ -10346,7 +10346,7 @@

1. Assert: _envRec_.HasBinding(_N_) is *true*. - 1. Let _binding_ be the DeclarativeBinding in _envRec_.[[Bindings]] whose [[BoundName]] field equals _N_. + 1. Let _binding_ be the DeclarativeBinding in _envRec_.[[Bindings]] whose [[BoundName]] field is _N_. 1. Assert: _binding_ is a SimpleDeclarativeBinding. 1. Assert: _binding_.[[BoundValue]] is ~uninitialized~. 1. Set _binding_.[[BoundValue]] to _V_. @@ -10375,7 +10375,7 @@

1. Perform ! _envRec_.CreateMutableBinding(_N_, *true*). 1. Perform ! _envRec_.InitializeBinding(_N_, _V_). 1. Return ~unused~. - 1. Let _binding_ be the DeclarativeBinding in _envRec_.[[Bindings]] whose [[BoundName]] field equals _N_. + 1. Let _binding_ be the DeclarativeBinding in _envRec_.[[Bindings]] whose [[BoundName]] field is _N_. 1. If _binding_ is an ImportDeclarativeBinding, throw a *TypeError* exception. 1. Assert: _binding_ is a SimpleDeclarativeBinding. 1. If _binding_.[[IsStrict]] is *true*, set _S_ to *true*. @@ -10410,7 +10410,7 @@

1. Assert: _envRec_.HasBinding(_N_) is *true*. - 1. Let _binding_ be the DeclarativeBinding in _envRec_.[[Bindings]] whose [[BoundName]] field equals _N_. + 1. Let _binding_ be the DeclarativeBinding in _envRec_.[[Bindings]] whose [[BoundName]] field is _N_. 1. Assert: _binding_ is a SimpleDeclarativeBinding. 1. If _binding_.[[BoundValue]] is ~uninitialized~, throw a *ReferenceError* exception. 1. Return _binding_.[[BoundValue]]. @@ -10432,7 +10432,7 @@

1. Assert: _envRec_.HasBinding(_N_) is *true*. - 1. Let _binding_ be the DeclarativeBinding in _envRec_.[[Bindings]] whose [[BoundName]] field equals _N_. + 1. Let _binding_ be the DeclarativeBinding in _envRec_.[[Bindings]] whose [[BoundName]] field is _N_. 1. Assert: _binding_ is a SimpleDeclarativeBinding. 1. If _binding_.[[IsDeletable]] is *false*, return *false*. 1. Remove _binding_ from _envRec_.[[Bindings]]. @@ -11455,7 +11455,7 @@

Module Environment Records

-

The [[Bindings]] of a Module Environment Record can include both SimpleDeclarativeBindings and ImportDeclarativeBindings. An ImportDeclarativeBinding has the following fields:

+

The [[Bindings]] of a Module Environment Record can include both SimpleDeclarativeBindings and ImportDeclarativeBindings. An ImportDeclarativeBinding has the following fields:

@@ -11499,7 +11499,7 @@

1. Assert: _S_ is *true*. 1. Assert: _envRec_.HasBinding(_N_) is *true*. - 1. Let _binding_ be the DeclarativeBinding in _envRec_.[[Bindings]] whose [[BoundName]] field equals _N_. + 1. Let _binding_ be the DeclarativeBinding in _envRec_.[[Bindings]] whose [[BoundName]] field is _N_. 1. If _binding_ is an ImportDeclarativeBinding, then 1. Let _M_ be _binding_.[[TargetModuleRec]]. 1. Let _N2_ be _binding_.[[TargetName]]. @@ -51875,7 +51875,7 @@

Changes to BlockDeclarationInstantiation

During BlockDeclarationInstantiation the following steps are performed in place of step :

1. Perform the following steps: - 1. Let _binding_ be the DeclarativeBinding in _env_.[[Bindings]] whose [[BoundName]] field equals _fn_. + 1. Let _binding_ be the DeclarativeBinding in _env_.[[Bindings]] whose [[BoundName]] field is _fn_. 1. Assert: _binding_ is a SimpleDeclarativeBinding. 1. If _binding_.[[BoundValue]] is ~uninitialized~, then 1. Perform ! _env_.InitializeBinding(_fn_, _fo_).