From a73afb535bb664c900888bc49a5b2cc855a5e9c2 Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Sat, 23 Jan 2021 23:59:22 -0500 Subject: [PATCH] Editorial: declarative Env Rec has field [[Bindings]] ... that is a List of bindings (without being specific yet about what a binding is). --- spec.html | 60 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 14 deletions(-) diff --git a/spec.html b/spec.html index 83f1c896974..14ab3e1d086 100644 --- a/spec.html +++ b/spec.html @@ -9756,6 +9756,35 @@

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.

+

Object Environment Records have the additional state field listed in .

+ + + + + + + + + + + + + + +
+ Field Name + + Value + + Meaning +
+ [[Bindings]] + + 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.

@@ -9772,7 +9801,7 @@

It determines if the argument identifier is one of the identifiers bound by the record.
- 1. If _envRec_ has a binding for the name that is the value of _N_, return *true*. + 1. If _envRec_.[[Bindings]] contains a binding for the name that is the value of _N_, return *true*. 1. Return *false*. @@ -9794,7 +9823,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 NormalCompletion(~empty~). @@ -9816,7 +9845,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 NormalCompletion(~empty~). @@ -9837,7 +9866,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. @@ -9866,7 +9895,7 @@

1. Perform _envRec_.CreateMutableBinding(_N_, *true*). 1. Perform _envRec_.InitializeBinding(_N_, _V_). 1. Return NormalCompletion(~empty~). - 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, throw a *ReferenceError* exception. 1. Else if _binding_ is a mutable binding, change its bound value to _V_. @@ -9897,7 +9926,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_. @@ -9918,9 +9947,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*. @@ -10959,7 +10988,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]]. @@ -11026,7 +11055,7 @@

1. Assert: _M_ is a Module Record. 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 NormalCompletion(~empty~). @@ -11068,7 +11097,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_. @@ -11105,7 +11135,8 @@

1. Assert: _F_ is an ECMAScript function. 1. Assert: Type(_newTarget_) is Undefined or Object. - 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~. @@ -11146,7 +11177,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_. @@ -47009,7 +47041,7 @@

Changes to BlockDeclarationInstantiation

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

- 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,