Skip to content

Commit

Permalink
Editorial: declarative Env Rec has field [[Bindings]]
Browse files Browse the repository at this point in the history
... that is a List of bindings
(without being specific yet about what a binding is).
  • Loading branch information
jmdyck committed May 13, 2021
1 parent c15b56d commit 88924ea
Showing 1 changed file with 46 additions and 14 deletions.
60 changes: 46 additions & 14 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -8724,13 +8724,42 @@ <h1>The Environment Record Type Hierarchy</h1>
<emu-clause id="sec-declarative-environment-records">
<h1>Declarative Environment Records</h1>
<p>Each <dfn>declarative Environment Record</dfn> 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.</p>
<p>Object Environment Records have the additional state field listed in <emu-xref href="#table-additional-fields-of-declarative-environment-records"></emu-xref>.</p>
<emu-table id="table-additional-fields-of-declarative-environment-records" caption="Additional Fields of Declarative Environment Records">
<table>
<tbody>
<tr>
<th>
Field Name
</th>
<th>
Value
</th>
<th>
Meaning
</th>
</tr>
<tr>
<td>
[[Bindings]]
</td>
<td>
List of bindings
</td>
<td>
Satisfies the invariant that no two bindings in [[Bindings]] are bindings for the same name.
</td>
</tr>
</tbody>
</table>
</emu-table>
<p>The behaviour of the concrete specification methods for declarative Environment Records is defined by the following algorithms.</p>

<emu-clause id="sec-declarative-environment-records-hasbinding-n">
<h1>HasBinding ( _N_ )</h1>
<p>The HasBinding concrete method of a declarative Environment Record _envRec_ takes argument _N_ (a String). It determines if the argument identifier is one of the identifiers bound by the record. It performs the following steps when called:</p>
<emu-alg>
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*.
</emu-alg>
</emu-clause>
Expand All @@ -8741,7 +8770,7 @@ <h1>CreateMutableBinding ( _N_, _D_ )</h1>
<emu-alg>
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~).
</emu-alg>
</emu-clause>
Expand All @@ -8752,7 +8781,7 @@ <h1>CreateImmutableBinding ( _N_, _S_ )</h1>
<emu-alg>
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~).
</emu-alg>
</emu-clause>
Expand All @@ -8762,7 +8791,7 @@ <h1>InitializeBinding ( _N_, _V_ )</h1>
<p>The InitializeBinding concrete method of a declarative Environment Record _envRec_ takes arguments _N_ (a String) and _V_ (an ECMAScript language value). It is used to set the bound value of the current binding of the identifier whose name is the value of the argument _N_ to the value of argument _V_. An uninitialized binding for _N_ must already exist. It performs the following steps when called:</p>
<emu-alg>
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. <emu-not-ref>Record</emu-not-ref> that _binding_ has been initialized.
Expand All @@ -8779,7 +8808,7 @@ <h1>SetMutableBinding ( _N_, _V_, _S_ )</h1>
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_.
Expand All @@ -8799,7 +8828,7 @@ <h1>GetBindingValue ( _N_, _S_ )</h1>
<p>The GetBindingValue concrete method of a declarative Environment Record _envRec_ takes arguments _N_ (a String) and _S_ (a Boolean). It returns the value of its bound identifier whose name is the value of the argument _N_. If the binding exists but is uninitialized a *ReferenceError* is thrown, regardless of the value of _S_. It performs the following steps when called:</p>
<emu-alg>
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_.
</emu-alg>
Expand All @@ -8810,9 +8839,9 @@ <h1>DeleteBinding ( _N_ )</h1>
<p>The DeleteBinding concrete method of a declarative Environment Record _envRec_ takes argument _N_ (a String). It can only delete bindings that have been explicitly designated as being subject to deletion. It performs the following steps when called:</p>
<emu-alg>
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*.
</emu-alg>
</emu-clause>
Expand Down Expand Up @@ -9577,7 +9606,7 @@ <h1>GetBindingValue ( _N_, _S_ )</h1>
<emu-alg>
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]].
Expand Down Expand Up @@ -9626,7 +9655,7 @@ <h1>CreateImportBinding ( _N_, _M_, _N2_ )</h1>
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~).
</emu-alg>
</emu-clause>
Expand Down Expand Up @@ -9656,7 +9685,8 @@ <h1>GetIdentifierReference ( _env_, _name_, _strict_ )</h1>
<h1>NewDeclarativeEnvironment ( _E_ )</h1>
<p>The abstract operation NewDeclarativeEnvironment takes argument _E_ (an Environment Record or *null*). It performs the following steps when called:</p>
<emu-alg>
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 &laquo; &raquo;.
1. Set _env_.[[OuterEnv]] to _E_.
1. Return _env_.
</emu-alg>
Expand All @@ -9680,7 +9710,8 @@ <h1>NewFunctionEnvironment ( _F_, _newTarget_ )</h1>
<emu-alg>
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 &laquo; &raquo;.
1. Set _env_.[[FunctionObject]] to _F_.
1. If _F_.[[ThisMode]] is ~lexical~, set _env_.[[ThisBindingStatus]] to ~lexical~.
1. Else, set _env_.[[ThisBindingStatus]] to ~uninitialized~.
Expand Down Expand Up @@ -9710,7 +9741,8 @@ <h1>NewGlobalEnvironment ( _G_, _thisValue_ )</h1>
<h1>NewModuleEnvironment ( _E_ )</h1>
<p>The abstract operation NewModuleEnvironment takes argument _E_ (an Environment Record). It performs the following steps when called:</p>
<emu-alg>
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 &laquo; &raquo;.
1. Set _env_.[[OuterEnv]] to _E_.
1. Return _env_.
</emu-alg>
Expand Down Expand Up @@ -42876,7 +42908,7 @@ <h1>Changes to BlockDeclarationInstantiation</h1>
</emu-alg>
<p>During BlockDeclarationInstantiation the following steps are performed in place of step <emu-xref href="#step-blockdeclarationinstantiation-initializebinding"></emu-xref>:</p>
<emu-alg replaces-step="step-blockdeclarationinstantiation-initializebinding">
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,
Expand Down

0 comments on commit 88924ea

Please sign in to comment.