diff --git a/spec.html b/spec.html index be875d4c364..15202b75de4 100644 --- a/spec.html +++ b/spec.html @@ -10070,14 +10070,53 @@

Declarative Environment Records

[[Bindings]] - 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.

@@ -10094,7 +10133,7 @@

It determines if the argument identifier is one of the identifiers bound by the record.
- 1. If _envRec_.[[Bindings]] contains a binding for the name that is the value of _N_, return *true*. + 1. If _envRec_.[[Bindings]] contains a DeclarativeBinding whose [[BoundName]] field is equal to the value of _N_, return *true*. 1. Return *false*. @@ -10115,7 +10154,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 NormalCompletion(~empty~). @@ -10137,7 +10176,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 NormalCompletion(~empty~). @@ -10159,10 +10198,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 NormalCompletion(~empty~). @@ -10188,10 +10227,12 @@

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_.[[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_. + 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~, throw a *ReferenceError* exception. + 1. Else if _binding_.[[IsMutable]] is *true*, change its bound value to _V_. 1. Else, 1. Assert: This is an attempt to change the value of an immutable binding. 1. If _S_ is *true*, throw a *TypeError* exception. @@ -10219,9 +10260,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]]. @@ -10240,8 +10282,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*. @@ -11250,6 +11293,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:

@@ -11269,14 +11337,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.

@@ -11334,7 +11404,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 NormalCompletion(~empty~). @@ -47418,8 +47488,9 @@

Changes to BlockDeclarationInstantiation

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

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