From 13fc82f76fc274fc6c16d5cb57a1d7fa0d048657 Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Sun, 15 Sep 2019 20:14:44 -0400 Subject: [PATCH 1/7] Editorial: Replace "outer environment reference" with [[OuterEnv]] (#1697) (currently attached to Lexical Environment, but that will change) --- spec.html | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/spec.html b/spec.html index 6a6c7e4a90..db0d8edb7b 100644 --- a/spec.html +++ b/spec.html @@ -6190,10 +6190,10 @@

Executable Code and Execution Contexts

Lexical Environments

-

A Lexical Environment is a specification type used to define the association of |Identifier|s to specific variables and functions based upon the lexical nesting structure of ECMAScript code. A Lexical Environment consists of an Environment Record and a possibly null reference to an outer Lexical Environment. Usually a Lexical Environment is associated with some specific syntactic structure of ECMAScript code such as a |FunctionDeclaration|, a |BlockStatement|, or a |Catch| clause of a |TryStatement| and a new Lexical Environment is created each time such code is evaluated.

+

A Lexical Environment is a specification type used to define the association of |Identifier|s to specific variables and functions based upon the lexical nesting structure of ECMAScript code. A Lexical Environment consists of an Environment Record and a possibly null reference to an outer Lexical Environment ([[OuterEnv]] field). Usually a Lexical Environment is associated with some specific syntactic structure of ECMAScript code such as a |FunctionDeclaration|, a |BlockStatement|, or a |Catch| clause of a |TryStatement| and a new Lexical Environment is created each time such code is evaluated.

An Environment Record records the identifier bindings that are created within the scope of its associated Lexical Environment. It is referred to as the Lexical Environment's EnvironmentRecord.

-

The outer environment reference is used to model the logical nesting of Lexical Environment values. The outer reference of a (inner) Lexical Environment is a reference to the Lexical Environment that logically surrounds the inner Lexical Environment. An outer Lexical Environment may, of course, have its own outer Lexical Environment. A Lexical Environment may serve as the outer environment for multiple inner Lexical Environments. For example, if a |FunctionDeclaration| contains two nested |FunctionDeclaration|s then the Lexical Environments of each of the nested functions will have as their outer Lexical Environment the Lexical Environment of the current evaluation of the surrounding function.

-

A global environment is a Lexical Environment which does not have an outer environment. The global environment's outer environment reference is *null*. A global environment's EnvironmentRecord may be prepopulated with identifier bindings and includes an associated global object whose properties provide some of the global environment's identifier bindings. As ECMAScript code is executed, additional properties may be added to the global object and the initial properties may be modified.

+

The [[OuterEnv]] field is used to model the logical nesting of Lexical Environment values. The outer reference of a (inner) Lexical Environment is a reference to the Lexical Environment that logically surrounds the inner Lexical Environment. An outer Lexical Environment may, of course, have its own outer Lexical Environment. A Lexical Environment may serve as the outer environment for multiple inner Lexical Environments. For example, if a |FunctionDeclaration| contains two nested |FunctionDeclaration|s then the Lexical Environments of each of the nested functions will have as their outer Lexical Environment the Lexical Environment of the current evaluation of the surrounding function.

+

A global environment is a Lexical Environment which does not have an outer environment. The global environment's [[OuterEnv]] is *null*. A global environment's EnvironmentRecord may be prepopulated with identifier bindings and includes an associated global object whose properties provide some of the global environment's identifier bindings. As ECMAScript code is executed, additional properties may be added to the global object and the initial properties may be modified.

A module environment is a Lexical Environment that contains the bindings for the top level declarations of a |Module|. It also contains the bindings that are explicitly imported by the |Module|. The outer environment of a module environment is a global environment.

A function environment is a Lexical Environment that corresponds to the invocation of an ECMAScript function object. A function environment may establish a new `this` binding. A function environment also captures the state necessary to support `super` method invocations.

Lexical Environments and Environment Record values are purely specification mechanisms and need not correspond to any specific artefact of an ECMAScript implementation. It is impossible for an ECMAScript program to directly access or manipulate such values.

@@ -7197,7 +7197,7 @@

GetIdentifierReference ( _lex_, _name_, _strict_ )

1. If _exists_ is *true*, then 1. Return a value of type Reference whose base value component is _envRec_, whose referenced name component is _name_, and whose strict reference flag is _strict_. 1. Else, - 1. Let _outer_ be the value of _lex_'s outer environment reference. + 1. Let _outer_ be _lex_.[[OuterEnv]]. 1. Return ? GetIdentifierReference(_outer_, _name_, _strict_).
@@ -7209,7 +7209,7 @@

NewDeclarativeEnvironment ( _E_ )

1. Let _env_ be a new Lexical Environment. 1. Let _envRec_ be a new declarative Environment Record containing no bindings. 1. Set _env_'s EnvironmentRecord to _envRec_. - 1. Set the outer lexical environment reference of _env_ to _E_. + 1. Set _env_.[[OuterEnv]] to _E_. 1. Return _env_. @@ -7221,7 +7221,7 @@

NewObjectEnvironment ( _O_, _E_ )

1. Let _env_ be a new Lexical Environment. 1. Let _envRec_ be a new object Environment Record containing _O_ as the binding object. 1. Set _env_'s EnvironmentRecord to _envRec_. - 1. Set the outer lexical environment reference of _env_ to _E_. + 1. Set _env_.[[OuterEnv]] to _E_. 1. Return _env_. @@ -7241,7 +7241,7 @@

NewFunctionEnvironment ( _F_, _newTarget_ )

1. Set _envRec_.[[HomeObject]] to _home_. 1. Set _envRec_.[[NewTarget]] to _newTarget_. 1. Set _env_'s EnvironmentRecord to _envRec_. - 1. Set the outer lexical environment reference of _env_ to _F_.[[Environment]]. + 1. Set _env_.[[OuterEnv]] to _F_.[[Environment]]. 1. Return _env_. @@ -7259,7 +7259,7 @@

NewGlobalEnvironment ( _G_, _thisValue_ )

1. Set _globalRec_.[[DeclarativeRecord]] to _dclRec_. 1. Set _globalRec_.[[VarNames]] to a new empty List. 1. Set _env_'s EnvironmentRecord to _globalRec_. - 1. Set the outer lexical environment reference of _env_ to *null*. + 1. Set _env_.[[OuterEnv]] to *null*. 1. Return _env_. @@ -7271,7 +7271,7 @@

NewModuleEnvironment ( _E_ )

1. Let _env_ be a new Lexical Environment. 1. Let _envRec_ be a new module Environment Record containing no bindings. 1. Set _env_'s EnvironmentRecord to _envRec_. - 1. Set the outer lexical environment reference of _env_ to _E_. + 1. Set _env_.[[OuterEnv]] to _E_. 1. Return _env_. @@ -7557,7 +7557,7 @@

GetThisEnvironment ( )

1. Let _envRec_ be _lex_'s EnvironmentRecord. 1. Let _exists_ be _envRec_.HasThisBinding(). 1. If _exists_ is *true*, return _envRec_. - 1. Let _outer_ be the value of _lex_'s outer environment reference. + 1. Let _outer_ be _lex_.[[OuterEnv]]. 1. Assert: _outer_ is not *null*. 1. Set _lex_ to _outer_. @@ -17604,7 +17604,7 @@

Runtime Semantics: CreatePerIterationEnvironment ( _perIterationBindings_ )< 1. If _perIterationBindings_ has any elements, then 1. Let _lastIterationEnv_ be the running execution context's LexicalEnvironment. 1. Let _lastIterationEnvRec_ be _lastIterationEnv_'s EnvironmentRecord. - 1. Let _outer_ be _lastIterationEnv_'s outer environment reference. + 1. Let _outer_ be _lastIterationEnv_.[[OuterEnv]]. 1. Assert: _outer_ is not *null*. 1. Let _thisIterationEnv_ be NewDeclarativeEnvironment(_outer_). 1. Let _thisIterationEnvRec_ be _thisIterationEnv_'s EnvironmentRecord. @@ -24953,7 +24953,7 @@

Runtime Semantics: EvalDeclarationInstantiation ( _body_, _varEnv_, _lexEnv_ 1. Throw a *SyntaxError* exception. 1. NOTE: Annex defines alternate semantics for the above step. 1. NOTE: A direct eval will not hoist var declaration over a like-named lexical declaration. - 1. Set _thisLex_ to _thisLex_'s outer environment reference. + 1. Set _thisLex_ to _thisLex_.[[OuterEnv]]. 1. Let _functionsToInitialize_ be a new empty List. 1. Let _declaredFunctionNames_ be a new empty List. 1. For each _d_ in _varDeclarations_, in reverse list order, do @@ -42985,7 +42985,7 @@

Changes to EvalDeclarationInstantiation

1. If _thisEnvRec_ is not an object Environment Record, then 1. If _thisEnvRec_.HasBinding(_F_) is *true*, then 1. Let _bindingExists_ be *true*. - 1. Set _thisLex_ to _thisLex_'s outer environment reference. + 1. Set _thisLex_ to _thisLex_.[[OuterEnv]]. 1. If _bindingExists_ is *false* and _varEnvRec_ is a global Environment Record, then 1. If _varEnvRec_.HasLexicalDeclaration(_F_) is *false*, then 1. Let _fnDefinable_ be ? _varEnvRec_.CanDeclareGlobalVar(_F_). From 88cc6abf01ed2edf0355a6a6b53f09fa12113695 Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Mon, 16 Sep 2019 10:08:07 -0400 Subject: [PATCH 2/7] Editorial: Merge Lexical Environment into Environment Record in algorithms (#1697) Mostly this amounts to erasing the distinction between _LE_ and "_LE_'s EnvironmentRecord". For the merged thing, I always used the metavariable/alias that had formerly been used for the Lexical Environment, even though this sometimes resulted in more diff lines. --- spec.html | 341 +++++++++++++++++++++++------------------------------- 1 file changed, 147 insertions(+), 194 deletions(-) diff --git a/spec.html b/spec.html index db0d8edb7b..0beb5119e5 100644 --- a/spec.html +++ b/spec.html @@ -7131,8 +7131,7 @@

GetBindingValue ( _N_, _S_ )

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 *undefined*, throw a *ReferenceError* exception. - 1. Let _targetER_ be _targetEnv_'s EnvironmentRecord. - 1. Return ? _targetER_.GetBindingValue(_N2_, *true*). + 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_. @@ -7192,10 +7191,9 @@

GetIdentifierReference ( _lex_, _name_, _strict_ )

1. If _lex_ is the value *null*, then 1. Return a value of type Reference whose base value component is *undefined*, whose referenced name component is _name_, and whose strict reference flag is _strict_. - 1. Let _envRec_ be _lex_'s EnvironmentRecord. - 1. Let _exists_ be ? _envRec_.HasBinding(_name_). + 1. Let _exists_ be ? _lex_.HasBinding(_name_). 1. If _exists_ is *true*, then - 1. Return a value of type Reference whose base value component is _envRec_, whose referenced name component is _name_, and whose strict reference flag is _strict_. + 1. Return a value of type Reference whose base value component is _lex_, whose referenced name component is _name_, and whose strict reference flag is _strict_. 1. Else, 1. Let _outer_ be _lex_.[[OuterEnv]]. 1. Return ? GetIdentifierReference(_outer_, _name_, _strict_). @@ -7206,9 +7204,7 @@

GetIdentifierReference ( _lex_, _name_, _strict_ )

NewDeclarativeEnvironment ( _E_ )

The abstract operation NewDeclarativeEnvironment takes argument _E_ (a Lexical Environment). It performs the following steps when called:

- 1. Let _env_ be a new Lexical Environment. - 1. Let _envRec_ be a new declarative Environment Record containing no bindings. - 1. Set _env_'s EnvironmentRecord to _envRec_. + 1. Let _env_ be a new declarative Environment Record containing no bindings. 1. Set _env_.[[OuterEnv]] to _E_. 1. Return _env_. @@ -7218,9 +7214,7 @@

NewDeclarativeEnvironment ( _E_ )

NewObjectEnvironment ( _O_, _E_ )

The abstract operation NewObjectEnvironment takes arguments _O_ (an Object) and _E_ (a Lexical Environment). It performs the following steps when called:

- 1. Let _env_ be a new Lexical Environment. - 1. Let _envRec_ be a new object Environment Record containing _O_ as the binding object. - 1. Set _env_'s EnvironmentRecord to _envRec_. + 1. Let _env_ be a new object Environment Record containing _O_ as the binding object. 1. Set _env_.[[OuterEnv]] to _E_. 1. Return _env_. @@ -7232,15 +7226,13 @@

NewFunctionEnvironment ( _F_, _newTarget_ )

1. Assert: _F_ is an ECMAScript function. 1. Assert: Type(_newTarget_) is Undefined or Object. - 1. Let _env_ be a new Lexical Environment. - 1. Let _envRec_ be a new function Environment Record containing no bindings. - 1. Set _envRec_.[[FunctionObject]] to _F_. - 1. If _F_.[[ThisMode]] is ~lexical~, set _envRec_.[[ThisBindingStatus]] to ~lexical~. - 1. Else, set _envRec_.[[ThisBindingStatus]] to ~uninitialized~. + 1. Let _env_ be a new function Environment Record containing no bindings. + 1. Set _env_.[[FunctionObject]] to _F_. + 1. If _F_.[[ThisMode]] is ~lexical~, set _env_.[[ThisBindingStatus]] to ~lexical~. + 1. Else, set _env_.[[ThisBindingStatus]] to ~uninitialized~. 1. Let _home_ be _F_.[[HomeObject]]. - 1. Set _envRec_.[[HomeObject]] to _home_. - 1. Set _envRec_.[[NewTarget]] to _newTarget_. - 1. Set _env_'s EnvironmentRecord to _envRec_. + 1. Set _env_.[[HomeObject]] to _home_. + 1. Set _env_.[[NewTarget]] to _newTarget_. 1. Set _env_.[[OuterEnv]] to _F_.[[Environment]]. 1. Return _env_. @@ -7250,15 +7242,13 @@

NewFunctionEnvironment ( _F_, _newTarget_ )

NewGlobalEnvironment ( _G_, _thisValue_ )

The abstract operation NewGlobalEnvironment takes arguments _G_ and _thisValue_. It performs the following steps when called:

- 1. Let _env_ be a new Lexical Environment. 1. Let _objRec_ be a new object Environment Record containing _G_ as the binding object. 1. Let _dclRec_ be a new declarative Environment Record containing no bindings. - 1. Let _globalRec_ be a new global Environment Record. - 1. Set _globalRec_.[[ObjectRecord]] to _objRec_. - 1. Set _globalRec_.[[GlobalThisValue]] to _thisValue_. - 1. Set _globalRec_.[[DeclarativeRecord]] to _dclRec_. - 1. Set _globalRec_.[[VarNames]] to a new empty List. - 1. Set _env_'s EnvironmentRecord to _globalRec_. + 1. Let _env_ be a new global Environment Record. + 1. Set _env_.[[ObjectRecord]] to _objRec_. + 1. Set _env_.[[GlobalThisValue]] to _thisValue_. + 1. Set _env_.[[DeclarativeRecord]] to _dclRec_. + 1. Set _env_.[[VarNames]] to a new empty List. 1. Set _env_.[[OuterEnv]] to *null*. 1. Return _env_. @@ -7268,9 +7258,7 @@

NewGlobalEnvironment ( _G_, _thisValue_ )

NewModuleEnvironment ( _E_ )

The abstract operation NewModuleEnvironment takes argument _E_ (a Lexical Environment). It performs the following steps when called:

- 1. Let _env_ be a new Lexical Environment. - 1. Let _envRec_ be a new module Environment Record containing no bindings. - 1. Set _env_'s EnvironmentRecord to _envRec_. + 1. Let _env_ be a new module Environment Record containing no bindings. 1. Set _env_.[[OuterEnv]] to _E_. 1. Return _env_. @@ -7554,9 +7542,8 @@

GetThisEnvironment ( )

1. Let _lex_ be the running execution context's LexicalEnvironment. 1. Repeat, - 1. Let _envRec_ be _lex_'s EnvironmentRecord. - 1. Let _exists_ be _envRec_.HasThisBinding(). - 1. If _exists_ is *true*, return _envRec_. + 1. Let _exists_ be _lex_.HasThisBinding(). + 1. If _exists_ is *true*, return _lex_. 1. Let _outer_ be _lex_.[[OuterEnv]]. 1. Assert: _outer_ is not *null*. 1. Set _lex_ to _outer_. @@ -8407,16 +8394,14 @@

OrdinaryCallBindThis ( _F_, _calleeContext_, _thisArgument_ )

1. Else, 1. If _thisArgument_ is *undefined* or *null*, then 1. Let _globalEnv_ be _calleeRealm_.[[GlobalEnv]]. - 1. Let _globalEnvRec_ be _globalEnv_'s EnvironmentRecord. - 1. Assert: _globalEnvRec_ is a global Environment Record. - 1. Let _thisValue_ be _globalEnvRec_.[[GlobalThisValue]]. + 1. Assert: _globalEnv_ is a global Environment Record. + 1. Let _thisValue_ be _globalEnv_.[[GlobalThisValue]]. 1. Else, 1. Let _thisValue_ be ! ToObject(_thisArgument_). 1. NOTE: ToObject produces wrapper objects using _calleeRealm_. - 1. Let _envRec_ be _localEnv_'s EnvironmentRecord. - 1. Assert: _envRec_ is a function Environment Record. - 1. Assert: The next step never returns an abrupt completion because _envRec_.[[ThisBindingStatus]] is not ~initialized~. - 1. Return _envRec_.BindThisValue(_thisValue_). + 1. Assert: _localEnv_ is a function Environment Record. + 1. Assert: The next step never returns an abrupt completion because _localEnv_.[[ThisBindingStatus]] is not ~initialized~. + 1. Return _localEnv_.BindThisValue(_thisValue_).
@@ -8443,7 +8428,6 @@

[[Construct]] ( _argumentsList_, _newTarget_ )

1. Assert: _calleeContext_ is now the running execution context. 1. If _kind_ is ~base~, perform OrdinaryCallBindThis(_F_, _calleeContext_, _thisArgument_). 1. Let _constructorEnv_ be the LexicalEnvironment of _calleeContext_. - 1. Let _envRec_ be _constructorEnv_'s EnvironmentRecord. 1. Let _result_ be OrdinaryCallEvaluateBody(_F_, _argumentsList_). 1. Remove _calleeContext_ from the execution context stack and restore _callerContext_ as the running execution context. 1. If _result_.[[Type]] is ~return~, then @@ -8451,7 +8435,7 @@

[[Construct]] ( _argumentsList_, _newTarget_ )

1. If _kind_ is ~base~, return NormalCompletion(_thisArgument_). 1. If _result_.[[Value]] is not *undefined*, throw a *TypeError* exception. 1. Else, ReturnIfAbrupt(_result_). - 1. Return ? _envRec_.GetThisBinding(). + 1. Return ? _constructorEnv_.GetThisBinding().
@@ -8616,32 +8600,30 @@

FunctionDeclarationInstantiation ( _func_, _argumentsList_ )

1. If _strict_ is *true* or if _hasParameterExpressions_ is *false*, then 1. NOTE: Only a single lexical environment is needed for the parameters and top-level vars. 1. Let _env_ be the LexicalEnvironment of _calleeContext_. - 1. Let _envRec_ be _env_'s EnvironmentRecord. 1. Else, 1. NOTE: A separate Environment Record is needed to ensure that bindings created by direct eval calls in the formal parameter list are outside the environment where parameters are declared. 1. Let _calleeEnv_ be the LexicalEnvironment of _calleeContext_. 1. Let _env_ be NewDeclarativeEnvironment(_calleeEnv_). - 1. Let _envRec_ be _env_'s EnvironmentRecord. 1. Assert: The VariableEnvironment of _calleeContext_ is _calleeEnv_. 1. Set the LexicalEnvironment of _calleeContext_ to _env_. 1. For each String _paramName_ in _parameterNames_, do - 1. Let _alreadyDeclared_ be _envRec_.HasBinding(_paramName_). + 1. Let _alreadyDeclared_ be _env_.HasBinding(_paramName_). 1. NOTE: Early errors ensure that duplicate parameter names can only occur in non-strict functions that do not have parameter default values or rest parameters. 1. If _alreadyDeclared_ is *false*, then - 1. Perform ! _envRec_.CreateMutableBinding(_paramName_, *false*). + 1. Perform ! _env_.CreateMutableBinding(_paramName_, *false*). 1. If _hasDuplicates_ is *true*, then - 1. Perform ! _envRec_.InitializeBinding(_paramName_, *undefined*). + 1. Perform ! _env_.InitializeBinding(_paramName_, *undefined*). 1. If _argumentsObjectNeeded_ is *true*, then 1. If _strict_ is *true* or if _simpleParameterList_ is *false*, then 1. Let _ao_ be CreateUnmappedArgumentsObject(_argumentsList_). 1. Else, 1. NOTE: A mapped argument object is only provided for non-strict functions that don't have a rest parameter, any parameter default value initializers, or any destructured parameters. - 1. Let _ao_ be CreateMappedArgumentsObject(_func_, _formals_, _argumentsList_, _envRec_). + 1. Let _ao_ be CreateMappedArgumentsObject(_func_, _formals_, _argumentsList_, _env_). 1. If _strict_ is *true*, then - 1. Perform ! _envRec_.CreateImmutableBinding(*"arguments"*, *false*). + 1. Perform ! _env_.CreateImmutableBinding(*"arguments"*, *false*). 1. Else, - 1. Perform ! _envRec_.CreateMutableBinding(*"arguments"*, *false*). - 1. Call _envRec_.InitializeBinding(*"arguments"*, _ao_). + 1. Perform ! _env_.CreateMutableBinding(*"arguments"*, *false*). + 1. Call _env_.InitializeBinding(*"arguments"*, _ao_). 1. Let _parameterBindings_ be a new List of _parameterNames_ with *"arguments"* appended. 1. Else, 1. Let _parameterBindings_ be _parameterNames_. @@ -8656,44 +8638,41 @@

FunctionDeclarationInstantiation ( _func_, _argumentsList_ )

1. For each _n_ in _varNames_, do 1. If _n_ is not an element of _instantiatedVarNames_, then 1. Append _n_ to _instantiatedVarNames_. - 1. Perform ! _envRec_.CreateMutableBinding(_n_, *false*). - 1. Call _envRec_.InitializeBinding(_n_, *undefined*). + 1. Perform ! _env_.CreateMutableBinding(_n_, *false*). + 1. Call _env_.InitializeBinding(_n_, *undefined*). 1. Let _varEnv_ be _env_. - 1. Let _varEnvRec_ be _envRec_. 1. Else, 1. NOTE: A separate Environment Record is needed to ensure that closures created by expressions in the formal parameter list do not have visibility of declarations in the function body. 1. Let _varEnv_ be NewDeclarativeEnvironment(_env_). - 1. Let _varEnvRec_ be _varEnv_'s EnvironmentRecord. 1. Set the VariableEnvironment of _calleeContext_ to _varEnv_. 1. Let _instantiatedVarNames_ be a new empty List. 1. For each _n_ in _varNames_, do 1. If _n_ is not an element of _instantiatedVarNames_, then 1. Append _n_ to _instantiatedVarNames_. - 1. Perform ! _varEnvRec_.CreateMutableBinding(_n_, *false*). + 1. Perform ! _varEnv_.CreateMutableBinding(_n_, *false*). 1. If _n_ is not an element of _parameterBindings_ or if _n_ is an element of _functionNames_, let _initialValue_ be *undefined*. 1. Else, - 1. Let _initialValue_ be ! _envRec_.GetBindingValue(_n_, *false*). - 1. Call _varEnvRec_.InitializeBinding(_n_, _initialValue_). + 1. Let _initialValue_ be ! _env_.GetBindingValue(_n_, *false*). + 1. Call _varEnv_.InitializeBinding(_n_, _initialValue_). 1. NOTE: A var with the same name as a formal parameter initially has the same value as the corresponding initialized parameter. 1. NOTE: Annex adds additional steps at this point. 1. If _strict_ is *false*, then 1. Let _lexEnv_ be NewDeclarativeEnvironment(_varEnv_). 1. NOTE: Non-strict functions use a separate lexical Environment Record for top-level lexical declarations so that a direct eval can determine whether any var scoped declarations introduced by the eval code conflict with pre-existing top-level lexically scoped declarations. This is not needed for strict functions because a strict direct eval always places all declarations into a new Environment Record. 1. Else, let _lexEnv_ be _varEnv_. - 1. Let _lexEnvRec_ be _lexEnv_'s EnvironmentRecord. 1. Set the LexicalEnvironment of _calleeContext_ to _lexEnv_. 1. Let _lexDeclarations_ be the LexicallyScopedDeclarations of _code_. 1. For each element _d_ in _lexDeclarations_, do 1. NOTE: A lexically declared name cannot be the same as a function/generator declaration, formal parameter, or a var name. Lexically declared names are only instantiated here but not initialized. 1. For each element _dn_ of the BoundNames of _d_, do 1. If IsConstantDeclaration of _d_ is *true*, then - 1. Perform ! _lexEnvRec_.CreateImmutableBinding(_dn_, *true*). + 1. Perform ! _lexEnv_.CreateImmutableBinding(_dn_, *true*). 1. Else, - 1. Perform ! _lexEnvRec_.CreateMutableBinding(_dn_, *false*). + 1. Perform ! _lexEnv_.CreateMutableBinding(_dn_, *false*). 1. For each Parse Node _f_ in _functionsToInitialize_, do 1. Let _fn_ be the sole element of the BoundNames of _f_. 1. Let _fo_ be InstantiateFunctionObject of _f_ with argument _lexEnv_. - 1. Perform ! _varEnvRec_.SetMutableBinding(_fn_, _fo_, *false*). + 1. Perform ! _varEnv_.SetMutableBinding(_fn_, _fo_, *false*). 1. Return NormalCompletion(~empty~). @@ -9611,8 +9590,7 @@

[[Get]] ( _P_, _Receiver_ )

1. Return ? GetModuleNamespace(_targetModule_). 1. Let _targetEnv_ be _targetModule_.[[Environment]]. 1. If _targetEnv_ is *undefined*, throw a *ReferenceError* exception. - 1. Let _targetEnvRec_ be _targetEnv_'s EnvironmentRecord. - 1. Return ? _targetEnvRec_.GetBindingValue(_binding_.[[BindingName]], *true*). + 1. Return ? _targetEnv_.GetBindingValue(_binding_.[[BindingName]], *true*).

ResolveExport is side-effect free. Each time this operation is called with a specific _exportName_, _resolveSet_ pair as arguments it must return the same result. An implementation might choose to pre-compute or cache the ResolveExport results for the [[Exports]] of each module namespace exotic object.

@@ -12317,8 +12295,7 @@

Runtime Semantics: InitializeBoundName ( _name_, _value_, _environment_ ) 1. Assert: Type(_name_) is String. 1. If _environment_ is not *undefined*, then - 1. Let _env_ be the EnvironmentRecord component of _environment_. - 1. Perform _env_.InitializeBinding(_name_, _value_). + 1. Perform _environment_.InitializeBinding(_name_, _value_). 1. Return NormalCompletion(*undefined*). 1. Else, 1. Let _lhs_ be ResolveBinding(_name_). @@ -16312,19 +16289,18 @@

Runtime Semantics: BlockDeclarationInstantiation ( _code_, _env_ )

#sec-web-compat-blockdeclarationinstantiation accordingly. --> - 1. Let _envRec_ be _env_'s EnvironmentRecord. - 1. Assert: _envRec_ is a declarative Environment Record. + 1. Assert: _env_ is a declarative Environment Record. 1. Let _declarations_ be the LexicallyScopedDeclarations of _code_. 1. For each element _d_ in _declarations_, do 1. For each element _dn_ of the BoundNames of _d_, do 1. If IsConstantDeclaration of _d_ is *true*, then - 1. Perform ! _envRec_.CreateImmutableBinding(_dn_, *true*). + 1. Perform ! _env_.CreateImmutableBinding(_dn_, *true*). 1. Else, - 1. Perform ! _envRec_.CreateMutableBinding(_dn_, *false*). + 1. Perform ! _env_.CreateMutableBinding(_dn_, *false*). 1. If _d_ is a |FunctionDeclaration|, a |GeneratorDeclaration|, an |AsyncFunctionDeclaration|, or an |AsyncGeneratorDeclaration|, then 1. Let _fn_ be the sole element of the BoundNames of _d_. 1. Let _fo_ be InstantiateFunctionObject of _d_ with argument _env_. - 1. Perform _envRec_.InitializeBinding(_fn_, _fo_). + 1. Perform _env_.InitializeBinding(_fn_, _fo_). @@ -17556,14 +17532,13 @@

Runtime Semantics: LabelledEvaluation

1. Let _oldEnv_ be the running execution context's LexicalEnvironment. 1. Let _loopEnv_ be NewDeclarativeEnvironment(_oldEnv_). - 1. Let _loopEnvRec_ be _loopEnv_'s EnvironmentRecord. 1. Let _isConst_ be IsConstantDeclaration of |LexicalDeclaration|. 1. Let _boundNames_ be the BoundNames of |LexicalDeclaration|. 1. For each element _dn_ of _boundNames_, do 1. If _isConst_ is *true*, then - 1. Perform ! _loopEnvRec_.CreateImmutableBinding(_dn_, *true*). + 1. Perform ! _loopEnv_.CreateImmutableBinding(_dn_, *true*). 1. Else, - 1. Perform ! _loopEnvRec_.CreateMutableBinding(_dn_, *false*). + 1. Perform ! _loopEnv_.CreateMutableBinding(_dn_, *false*). 1. Set the running execution context's LexicalEnvironment to _loopEnv_. 1. Let _forDcl_ be the result of evaluating |LexicalDeclaration|. 1. If _forDcl_ is an abrupt completion, then @@ -17603,15 +17578,13 @@

Runtime Semantics: CreatePerIterationEnvironment ( _perIterationBindings_ )< 1. If _perIterationBindings_ has any elements, then 1. Let _lastIterationEnv_ be the running execution context's LexicalEnvironment. - 1. Let _lastIterationEnvRec_ be _lastIterationEnv_'s EnvironmentRecord. 1. Let _outer_ be _lastIterationEnv_.[[OuterEnv]]. 1. Assert: _outer_ is not *null*. 1. Let _thisIterationEnv_ be NewDeclarativeEnvironment(_outer_). - 1. Let _thisIterationEnvRec_ be _thisIterationEnv_'s EnvironmentRecord. 1. For each element _bn_ of _perIterationBindings_, do - 1. Perform ! _thisIterationEnvRec_.CreateMutableBinding(_bn_, *false*). - 1. Let _lastValue_ be ? _lastIterationEnvRec_.GetBindingValue(_bn_, *true*). - 1. Perform _thisIterationEnvRec_.InitializeBinding(_bn_, _lastValue_). + 1. Perform ! _thisIterationEnv_.CreateMutableBinding(_bn_, *false*). + 1. Let _lastValue_ be ? _lastIterationEnv_.GetBindingValue(_bn_, *true*). + 1. Perform _thisIterationEnv_.InitializeBinding(_bn_, _lastValue_). 1. Set the running execution context's LexicalEnvironment to _thisIterationEnv_. 1. Return *undefined*. @@ -17844,13 +17817,12 @@

Runtime Semantics: BindingInstantiation

With parameter _environment_.

ForDeclaration : LetOrConst ForBinding - 1. Let _envRec_ be _environment_'s EnvironmentRecord. - 1. Assert: _envRec_ is a declarative Environment Record. + 1. Assert: _environment_ is a declarative Environment Record. 1. For each element _name_ of the BoundNames of |ForBinding|, do 1. If IsConstantDeclaration of |LetOrConst| is *true*, then - 1. Perform ! _envRec_.CreateImmutableBinding(_name_, *true*). + 1. Perform ! _environment_.CreateImmutableBinding(_name_, *true*). 1. Else, - 1. Perform ! _envRec_.CreateMutableBinding(_name_, *false*). + 1. Perform ! _environment_.CreateMutableBinding(_name_, *false*). @@ -17922,9 +17894,8 @@

Runtime Semantics: ForIn/OfHeadEvaluation ( _uninitializedBoundNames_, _expr 1. If _uninitializedBoundNames_ is not an empty List, then 1. Assert: _uninitializedBoundNames_ has no duplicate entries. 1. Let _newEnv_ be NewDeclarativeEnvironment(_oldEnv_). - 1. Let _newEnvRec_ be _newEnv_'s EnvironmentRecord. 1. For each string _name_ in _uninitializedBoundNames_, do - 1. Perform ! _newEnvRec_.CreateMutableBinding(_name_, *false*). + 1. Perform ! _newEnv_.CreateMutableBinding(_name_, *false*). 1. Set the running execution context's LexicalEnvironment to _newEnv_. 1. Let _exprRef_ be the result of evaluating _expr_. 1. Set the running execution context's LexicalEnvironment to _oldEnv_. @@ -18390,7 +18361,7 @@

Runtime Semantics: Evaluation

1. Let _obj_ be ? ToObject(? GetValue(_val_)). 1. Let _oldEnv_ be the running execution context's LexicalEnvironment. 1. Let _newEnv_ be NewObjectEnvironment(_obj_, _oldEnv_). - 1. Set the _withEnvironment_ flag of _newEnv_'s EnvironmentRecord to *true*. + 1. Set the _withEnvironment_ flag of _newEnv_ to *true*. 1. Set the running execution context's LexicalEnvironment to _newEnv_. 1. Let _C_ be the result of evaluating |Statement|. 1. Set the running execution context's LexicalEnvironment to _oldEnv_. @@ -19263,9 +19234,8 @@

Runtime Semantics: CatchClauseEvaluation

1. Let _oldEnv_ be the running execution context's LexicalEnvironment. 1. Let _catchEnv_ be NewDeclarativeEnvironment(_oldEnv_). - 1. Let _catchEnvRec_ be _catchEnv_'s EnvironmentRecord. 1. For each element _argName_ of the BoundNames of |CatchParameter|, do - 1. Perform ! _catchEnvRec_.CreateMutableBinding(_argName_, *false*). + 1. Perform ! _catchEnv_.CreateMutableBinding(_argName_, *false*). 1. Set the running execution context's LexicalEnvironment to _catchEnv_. 1. Let _status_ be BindingInitialization of |CatchParameter| with arguments _thrownValue_ and _catchEnv_. 1. If _status_ is an abrupt completion, then @@ -19842,14 +19812,13 @@

Runtime Semantics: Evaluation

1. Let _scope_ be the running execution context's LexicalEnvironment. 1. Let _funcEnv_ be NewDeclarativeEnvironment(_scope_). - 1. Let _envRec_ be _funcEnv_'s EnvironmentRecord. 1. Let _name_ be StringValue of |BindingIdentifier|. - 1. Perform _envRec_.CreateImmutableBinding(_name_, *false*). + 1. Perform _funcEnv_.CreateImmutableBinding(_name_, *false*). 1. Let _closure_ be OrdinaryFunctionCreate(%Function.prototype%, |FormalParameters|, |FunctionBody|, ~non-lexical-this~, _funcEnv_). 1. Perform SetFunctionName(_closure_, _name_). 1. Perform MakeConstructor(_closure_). 1. Set _closure_.[[SourceText]] to the source text matched by |FunctionExpression|. - 1. Perform _envRec_.InitializeBinding(_name_, _closure_). + 1. Perform _funcEnv_.InitializeBinding(_name_, _closure_). 1. Return _closure_. @@ -20588,14 +20557,13 @@

Runtime Semantics: Evaluation

1. Let _scope_ be the running execution context's LexicalEnvironment. 1. Let _funcEnv_ be NewDeclarativeEnvironment(_scope_). - 1. Let _envRec_ be _funcEnv_'s EnvironmentRecord. 1. Let _name_ be StringValue of |BindingIdentifier|. - 1. Perform _envRec_.CreateImmutableBinding(_name_, *false*). + 1. Perform _funcEnv_.CreateImmutableBinding(_name_, *false*). 1. Let _closure_ be OrdinaryFunctionCreate(%Generator%, |FormalParameters|, |GeneratorBody|, ~non-lexical-this~, _funcEnv_). 1. Perform SetFunctionName(_closure_, _name_). 1. Let _prototype_ be OrdinaryObjectCreate(%Generator.prototype%). 1. Perform DefinePropertyOrThrow(_closure_, *"prototype"*, PropertyDescriptor { [[Value]]: _prototype_, [[Writable]]: *true*, [[Enumerable]]: *false*, [[Configurable]]: *false* }). - 1. Perform _envRec_.InitializeBinding(_name_, _closure_). + 1. Perform _funcEnv_.InitializeBinding(_name_, _closure_). 1. Set _closure_.[[SourceText]] to the source text matched by |GeneratorExpression|. 1. Return _closure_. @@ -20926,14 +20894,13 @@

Runtime Semantics: Evaluation

1. Let _scope_ be the running execution context's LexicalEnvironment. 1. Let _funcEnv_ be ! NewDeclarativeEnvironment(_scope_). - 1. Let _envRec_ be _funcEnv_'s EnvironmentRecord. 1. Let _name_ be StringValue of |BindingIdentifier|. - 1. Perform ! _envRec_.CreateImmutableBinding(_name_, *false*). + 1. Perform ! _funcEnv_.CreateImmutableBinding(_name_, *false*). 1. Let _closure_ be ! OrdinaryFunctionCreate(%AsyncGenerator%, |FormalParameters|, |AsyncGeneratorBody|, ~non-lexical-this~, _funcEnv_). 1. Perform ! SetFunctionName(_closure_, _name_). 1. Let _prototype_ be ! OrdinaryObjectCreate(%AsyncGenerator.prototype%). 1. Perform ! DefinePropertyOrThrow(_closure_, *"prototype"*, PropertyDescriptor { [[Value]]: _prototype_, [[Writable]]: *true*, [[Enumerable]]: *false*, [[Configurable]]: *false* }). - 1. Perform ! _envRec_.InitializeBinding(_name_, _closure_). + 1. Perform ! _funcEnv_.InitializeBinding(_name_, _closure_). 1. Set _closure_.[[SourceText]] to the source text matched by |AsyncGeneratorExpression|. 1. Return _closure_. @@ -21200,9 +21167,8 @@

Runtime Semantics: ClassDefinitionEvaluation

1. Let _lex_ be the LexicalEnvironment of the running execution context. 1. Let _classScope_ be NewDeclarativeEnvironment(_lex_). - 1. Let _classScopeEnvRec_ be _classScope_'s EnvironmentRecord. 1. If _classBinding_ is not *undefined*, then - 1. Perform _classScopeEnvRec_.CreateImmutableBinding(_classBinding_, *true*). + 1. Perform _classScope_.CreateImmutableBinding(_classBinding_, *true*). 1. If |ClassHeritage_opt| is not present, then 1. Let _protoParent_ be %Object.prototype%. 1. Let _constructorParent_ be %Function.prototype%. @@ -21251,7 +21217,7 @@

Runtime Semantics: ClassDefinitionEvaluation

1. Return Completion(_status_). 1. Set the running execution context's LexicalEnvironment to _lex_. 1. If _classBinding_ is not *undefined*, then - 1. Perform _classScopeEnvRec_.InitializeBinding(_classBinding_, _F_). + 1. Perform _classScope_.InitializeBinding(_classBinding_, _F_). 1. Return _F_.
@@ -21598,12 +21564,11 @@

Runtime Semantics: Evaluation

1. Let _scope_ be the LexicalEnvironment of the running execution context. 1. Let _funcEnv_ be ! NewDeclarativeEnvironment(_scope_). - 1. Let _envRec_ be _funcEnv_'s EnvironmentRecord. 1. Let _name_ be StringValue of |BindingIdentifier|. - 1. Perform ! _envRec_.CreateImmutableBinding(_name_, *false*). + 1. Perform ! _funcEnv_.CreateImmutableBinding(_name_, *false*). 1. Let _closure_ be ! OrdinaryFunctionCreate(%AsyncFunction.prototype%, |FormalParameters|, |AsyncFunctionBody|, ~non-lexical-this~, _funcEnv_). 1. Perform ! SetFunctionName(_closure_, _name_). - 1. Perform ! _envRec_.InitializeBinding(_name_, _closure_). + 1. Perform ! _funcEnv_.InitializeBinding(_name_, _closure_). 1. Set _closure_.[[SourceText]] to the source text matched by |AsyncFunctionExpression|. 1. Return _closure_. @@ -22466,17 +22431,16 @@

Runtime Semantics: GlobalDeclarationInstantiation ( _script_, _env_ )

#sec-web-compat-globaldeclarationinstantiation accordingly. --> - 1. Let _envRec_ be _env_'s EnvironmentRecord. - 1. Assert: _envRec_ is a global Environment Record. + 1. Assert: _env_ is a global Environment Record. 1. Let _lexNames_ be the LexicallyDeclaredNames of _script_. 1. Let _varNames_ be the VarDeclaredNames of _script_. 1. For each _name_ in _lexNames_, do - 1. If _envRec_.HasVarDeclaration(_name_) is *true*, throw a *SyntaxError* exception. - 1. If _envRec_.HasLexicalDeclaration(_name_) is *true*, throw a *SyntaxError* exception. - 1. Let _hasRestrictedGlobal_ be ? _envRec_.HasRestrictedGlobalProperty(_name_). + 1. If _env_.HasVarDeclaration(_name_) is *true*, throw a *SyntaxError* exception. + 1. If _env_.HasLexicalDeclaration(_name_) is *true*, throw a *SyntaxError* exception. + 1. Let _hasRestrictedGlobal_ be ? _env_.HasRestrictedGlobalProperty(_name_). 1. If _hasRestrictedGlobal_ is *true*, throw a *SyntaxError* exception. 1. For each _name_ in _varNames_, do - 1. If _envRec_.HasLexicalDeclaration(_name_) is *true*, throw a *SyntaxError* exception. + 1. If _env_.HasLexicalDeclaration(_name_) is *true*, throw a *SyntaxError* exception. 1. Let _varDeclarations_ be the VarScopedDeclarations of _script_. 1. Let _functionsToInitialize_ be a new empty List. 1. Let _declaredFunctionNames_ be a new empty List. @@ -22486,7 +22450,7 @@

Runtime Semantics: GlobalDeclarationInstantiation ( _script_, _env_ )

1. NOTE: If there are multiple function declarations for the same name, the last declaration is used. 1. Let _fn_ be the sole element of the BoundNames of _d_. 1. If _fn_ is not an element of _declaredFunctionNames_, then - 1. Let _fnDefinable_ be ? _envRec_.CanDeclareGlobalFunction(_fn_). + 1. Let _fnDefinable_ be ? _env_.CanDeclareGlobalFunction(_fn_). 1. If _fnDefinable_ is *false*, throw a *TypeError* exception. 1. Append _fn_ to _declaredFunctionNames_. 1. Insert _d_ as the first element of _functionsToInitialize_. @@ -22495,7 +22459,7 @@

Runtime Semantics: GlobalDeclarationInstantiation ( _script_, _env_ )

1. If _d_ is a |VariableDeclaration|, a |ForBinding|, or a |BindingIdentifier|, then 1. For each String _vn_ in the BoundNames of _d_, do 1. If _vn_ is not an element of _declaredFunctionNames_, then - 1. Let _vnDefinable_ be ? _envRec_.CanDeclareGlobalVar(_vn_). + 1. Let _vnDefinable_ be ? _env_.CanDeclareGlobalVar(_vn_). 1. If _vnDefinable_ is *false*, throw a *TypeError* exception. 1. If _vn_ is not an element of _declaredVarNames_, then 1. Append _vn_ to _declaredVarNames_. @@ -22506,15 +22470,15 @@

Runtime Semantics: GlobalDeclarationInstantiation ( _script_, _env_ )

1. NOTE: Lexically declared names are only instantiated here but not initialized. 1. For each element _dn_ of the BoundNames of _d_, do 1. If IsConstantDeclaration of _d_ is *true*, then - 1. Perform ? _envRec_.CreateImmutableBinding(_dn_, *true*). + 1. Perform ? _env_.CreateImmutableBinding(_dn_, *true*). 1. Else, - 1. Perform ? _envRec_.CreateMutableBinding(_dn_, *false*). + 1. Perform ? _env_.CreateMutableBinding(_dn_, *false*). 1. For each Parse Node _f_ in _functionsToInitialize_, do 1. Let _fn_ be the sole element of the BoundNames of _f_. 1. Let _fo_ be InstantiateFunctionObject of _f_ with argument _env_. - 1. Perform ? _envRec_.CreateGlobalFunctionBinding(_fn_, _fo_, *false*). + 1. Perform ? _env_.CreateGlobalFunctionBinding(_fn_, _fo_, *false*). 1. For each String _vn_ in _declaredVarNames_, in list order, do - 1. Perform ? _envRec_.CreateGlobalVarBinding(_vn_, *false*). + 1. Perform ? _env_.CreateGlobalVarBinding(_vn_, *false*). 1. Return NormalCompletion(~empty~).
@@ -23912,23 +23876,22 @@

InitializeEnvironment ( ) Concrete Method

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 EnvironmentRecord. 1. For each ImportEntry Record _in_ in _module_.[[ImportEntries]], do 1. Let _importedModule_ be ! HostResolveImportedModule(_module_, _in_.[[ModuleRequest]]). 1. NOTE: The above call cannot fail because imported module requests are a subset of _module_.[[RequestedModules]], and these have been resolved earlier in this algorithm. 1. If _in_.[[ImportName]] is *"\*"*, then 1. Let _namespace_ be ? GetModuleNamespace(_importedModule_). - 1. Perform ! _envRec_.CreateImmutableBinding(_in_.[[LocalName]], *true*). - 1. Call _envRec_.InitializeBinding(_in_.[[LocalName]], _namespace_). + 1. Perform ! _env_.CreateImmutableBinding(_in_.[[LocalName]], *true*). + 1. Call _env_.InitializeBinding(_in_.[[LocalName]], _namespace_). 1. Else, 1. Let _resolution_ be ? _importedModule_.ResolveExport(_in_.[[ImportName]]). 1. If _resolution_ is *null* or *"ambiguous"*, throw a *SyntaxError* exception. 1. If _resolution_.[[BindingName]] is *"\*namespace\*"*, then 1. Let _namespace_ be ? GetModuleNamespace(_resolution_.[[Module]]). - 1. Perform ! _envRec_.CreateImmutableBinding(_in_.[[LocalName]], *true*). - 1. Call _envRec_.InitializeBinding(_in_.[[LocalName]], _namespace_). + 1. Perform ! _env_.CreateImmutableBinding(_in_.[[LocalName]], *true*). + 1. Call _env_.InitializeBinding(_in_.[[LocalName]], _namespace_). 1. Else, - 1. Call _envRec_.CreateImportBinding(_in_.[[LocalName]], _resolution_.[[Module]], _resolution_.[[BindingName]]). + 1. Call _env_.CreateImportBinding(_in_.[[LocalName]], _resolution_.[[Module]], _resolution_.[[BindingName]]). 1. Let _moduleContext_ be a new ECMAScript code execution context. 1. Set the Function of _moduleContext_ to *null*. 1. Assert: _module_.[[Realm]] is not *undefined*. @@ -23944,19 +23907,19 @@

InitializeEnvironment ( ) Concrete Method

1. For each element _d_ in _varDeclarations_, do 1. For each element _dn_ of the BoundNames of _d_, do 1. If _dn_ is not an element of _declaredVarNames_, then - 1. Perform ! _envRec_.CreateMutableBinding(_dn_, *false*). - 1. Call _envRec_.InitializeBinding(_dn_, *undefined*). + 1. Perform ! _env_.CreateMutableBinding(_dn_, *false*). + 1. Call _env_.InitializeBinding(_dn_, *undefined*). 1. Append _dn_ to _declaredVarNames_. 1. Let _lexDeclarations_ be the LexicallyScopedDeclarations of _code_. 1. For each element _d_ in _lexDeclarations_, do 1. For each element _dn_ of the BoundNames of _d_, do 1. If IsConstantDeclaration of _d_ is *true*, then - 1. Perform ! _envRec_.CreateImmutableBinding(_dn_, *true*). + 1. Perform ! _env_.CreateImmutableBinding(_dn_, *true*). 1. Else, - 1. Perform ! _envRec_.CreateMutableBinding(_dn_, *false*). + 1. Perform ! _env_.CreateMutableBinding(_dn_, *false*). 1. If _d_ is a |FunctionDeclaration|, a |GeneratorDeclaration|, an |AsyncFunctionDeclaration|, or an |AsyncGeneratorDeclaration|, then 1. Let _fo_ be InstantiateFunctionObject of _d_ with argument _env_. - 1. Call _envRec_.InitializeBinding(_dn_, _fo_). + 1. Call _env_.InitializeBinding(_dn_, _fo_). 1. Remove _moduleContext_ from the execution context stack. 1. Return NormalCompletion(~empty~).
@@ -24824,7 +24787,7 @@

Value Properties of the Global Object

globalThis

-

The initial value of the *"globalThis"* property of the global object in a Realm Record _realm_ is _realm_.[[GlobalEnv]]'s EnvironmentRecord's [[GlobalThisValue]].

+

The initial value of the *"globalThis"* property of the global object in a Realm Record _realm_ is _realm_.[[GlobalEnv]].[[GlobalThisValue]].

This property has the attributes { [[Writable]]: *true*, [[Enumerable]]: *false*, [[Configurable]]: *true* }.

@@ -24935,21 +24898,18 @@

Runtime Semantics: EvalDeclarationInstantiation ( _body_, _varEnv_, _lexEnv_ 1. Let _varNames_ be the VarDeclaredNames of _body_. 1. Let _varDeclarations_ be the VarScopedDeclarations of _body_. - 1. Let _lexEnvRec_ be _lexEnv_'s EnvironmentRecord. - 1. Let _varEnvRec_ be _varEnv_'s EnvironmentRecord. 1. If _strict_ is *false*, then - 1. If _varEnvRec_ is a global Environment Record, then + 1. If _varEnv_ is a global Environment Record, then 1. For each _name_ in _varNames_, do - 1. If _varEnvRec_.HasLexicalDeclaration(_name_) is *true*, throw a *SyntaxError* exception. + 1. If _varEnv_.HasLexicalDeclaration(_name_) is *true*, throw a *SyntaxError* exception. 1. NOTE: `eval` will not create a global var declaration that would be shadowed by a global lexical declaration. 1. Let _thisLex_ be _lexEnv_. 1. Assert: The following loop will terminate. 1. Repeat, while _thisLex_ is not the same as _varEnv_, - 1. Let _thisEnvRec_ be _thisLex_'s EnvironmentRecord. - 1. If _thisEnvRec_ is not an object Environment Record, then + 1. If _thisLex_ is not an object Environment Record, then 1. NOTE: The environment of with statements cannot contain any lexical declaration so it doesn't need to be checked for var/let hoisting conflicts. 1. For each _name_ in _varNames_, do - 1. If _thisEnvRec_.HasBinding(_name_) is *true*, then + 1. If _thisLex_.HasBinding(_name_) is *true*, then 1. Throw a *SyntaxError* exception. 1. NOTE: Annex defines alternate semantics for the above step. 1. NOTE: A direct eval will not hoist var declaration over a like-named lexical declaration. @@ -24962,8 +24922,8 @@

Runtime Semantics: EvalDeclarationInstantiation ( _body_, _varEnv_, _lexEnv_ 1. NOTE: If there are multiple function declarations for the same name, the last declaration is used. 1. Let _fn_ be the sole element of the BoundNames of _d_. 1. If _fn_ is not an element of _declaredFunctionNames_, then - 1. If _varEnvRec_ is a global Environment Record, then - 1. Let _fnDefinable_ be ? _varEnvRec_.CanDeclareGlobalFunction(_fn_). + 1. If _varEnv_ is a global Environment Record, then + 1. Let _fnDefinable_ be ? _varEnv_.CanDeclareGlobalFunction(_fn_). 1. If _fnDefinable_ is *false*, throw a *TypeError* exception. 1. Append _fn_ to _declaredFunctionNames_. 1. Insert _d_ as the first element of _functionsToInitialize_. @@ -24973,42 +24933,42 @@

Runtime Semantics: EvalDeclarationInstantiation ( _body_, _varEnv_, _lexEnv_ 1. If _d_ is a |VariableDeclaration|, a |ForBinding|, or a |BindingIdentifier|, then 1. For each String _vn_ in the BoundNames of _d_, do 1. If _vn_ is not an element of _declaredFunctionNames_, then - 1. If _varEnvRec_ is a global Environment Record, then - 1. Let _vnDefinable_ be ? _varEnvRec_.CanDeclareGlobalVar(_vn_). + 1. If _varEnv_ is a global Environment Record, then + 1. Let _vnDefinable_ be ? _varEnv_.CanDeclareGlobalVar(_vn_). 1. If _vnDefinable_ is *false*, throw a *TypeError* exception. 1. If _vn_ is not an element of _declaredVarNames_, then 1. Append _vn_ to _declaredVarNames_. - 1. NOTE: No abnormal terminations occur after this algorithm step unless _varEnvRec_ is a global Environment Record and the global object is a Proxy exotic object. + 1. NOTE: No abnormal terminations occur after this algorithm step unless _varEnv_ is a global Environment Record and the global object is a Proxy exotic object. 1. Let _lexDeclarations_ be the LexicallyScopedDeclarations of _body_. 1. For each element _d_ in _lexDeclarations_, do 1. NOTE: Lexically declared names are only instantiated here but not initialized. 1. For each element _dn_ of the BoundNames of _d_, do 1. If IsConstantDeclaration of _d_ is *true*, then - 1. Perform ? _lexEnvRec_.CreateImmutableBinding(_dn_, *true*). + 1. Perform ? _lexEnv_.CreateImmutableBinding(_dn_, *true*). 1. Else, - 1. Perform ? _lexEnvRec_.CreateMutableBinding(_dn_, *false*). + 1. Perform ? _lexEnv_.CreateMutableBinding(_dn_, *false*). 1. For each Parse Node _f_ in _functionsToInitialize_, do 1. Let _fn_ be the sole element of the BoundNames of _f_. 1. Let _fo_ be InstantiateFunctionObject of _f_ with argument _lexEnv_. - 1. If _varEnvRec_ is a global Environment Record, then - 1. Perform ? _varEnvRec_.CreateGlobalFunctionBinding(_fn_, _fo_, *true*). + 1. If _varEnv_ is a global Environment Record, then + 1. Perform ? _varEnv_.CreateGlobalFunctionBinding(_fn_, _fo_, *true*). 1. Else, - 1. Let _bindingExists_ be _varEnvRec_.HasBinding(_fn_). + 1. Let _bindingExists_ be _varEnv_.HasBinding(_fn_). 1. If _bindingExists_ is *false*, then - 1. Let _status_ be ! _varEnvRec_.CreateMutableBinding(_fn_, *true*). - 1. Assert: _status_ is not an abrupt completion because of validation preceding step 12. - 1. Perform ! _varEnvRec_.InitializeBinding(_fn_, _fo_). + 1. Let _status_ be ! _varEnv_.CreateMutableBinding(_fn_, *true*). + 1. Assert: _status_ is not an abrupt completion because of validation preceding step 10. + 1. Perform ! _varEnv_.InitializeBinding(_fn_, _fo_). 1. Else, - 1. Perform ! _varEnvRec_.SetMutableBinding(_fn_, _fo_, *false*). + 1. Perform ! _varEnv_.SetMutableBinding(_fn_, _fo_, *false*). 1. For each String _vn_ in _declaredVarNames_, in list order, do - 1. If _varEnvRec_ is a global Environment Record, then - 1. Perform ? _varEnvRec_.CreateGlobalVarBinding(_vn_, *true*). + 1. If _varEnv_ is a global Environment Record, then + 1. Perform ? _varEnv_.CreateGlobalVarBinding(_vn_, *true*). 1. Else, - 1. Let _bindingExists_ be _varEnvRec_.HasBinding(_vn_). + 1. Let _bindingExists_ be _varEnv_.HasBinding(_vn_). 1. If _bindingExists_ is *false*, then - 1. Let _status_ be ! _varEnvRec_.CreateMutableBinding(_vn_, *true*). - 1. Assert: _status_ is not an abrupt completion because of validation preceding step 12. - 1. Perform ! _varEnvRec_.InitializeBinding(_vn_, *undefined*). + 1. Let _status_ be ! _varEnv_.CreateMutableBinding(_vn_, *true*). + 1. Assert: _status_ is not an abrupt completion because of validation preceding step 10. + 1. Perform ! _varEnv_.InitializeBinding(_vn_, *undefined*). 1. Return NormalCompletion(~empty~). @@ -42924,22 +42884,20 @@

Changes to FunctionDeclarationInstantiation

1. If replacing the |FunctionDeclaration| _f_ with a |VariableStatement| that has _F_ as a |BindingIdentifier| would not produce any Early Errors for _func_ and _F_ is not an element of _parameterNames_, then 1. NOTE: A var binding for _F_ is only instantiated here if it is neither a VarDeclaredName, the name of a formal parameter, or another |FunctionDeclaration|. 1. If _initializedBindings_ does not contain _F_ and _F_ is not *"arguments"*, then - 1. Perform ! _varEnvRec_.CreateMutableBinding(_F_, *false*). - 1. Perform _varEnvRec_.InitializeBinding(_F_, *undefined*). + 1. Perform ! _varEnv_.CreateMutableBinding(_F_, *false*). + 1. Perform _varEnv_.InitializeBinding(_F_, *undefined*). 1. Append _F_ to _instantiatedVarNames_. 1. When the |FunctionDeclaration| _f_ is evaluated, perform the following steps in place of the |FunctionDeclaration| Evaluation algorithm provided in : 1. Let _fenv_ be the running execution context's VariableEnvironment. - 1. Let _fenvRec_ be _fenv_'s EnvironmentRecord. 1. Let _benv_ be the running execution context's LexicalEnvironment. - 1. Let _benvRec_ be _benv_'s EnvironmentRecord. - 1. Let _fobj_ be ! _benvRec_.GetBindingValue(_F_, *false*). - 1. Perform ! _fenvRec_.SetMutableBinding(_F_, _fobj_, *false*). + 1. Let _fobj_ be ! _benv_.GetBindingValue(_F_, *false*). + 1. Perform ! _fenv_.SetMutableBinding(_F_, _fobj_, *false*). 1. Return NormalCompletion(~empty~).

Changes to GlobalDeclarationInstantiation

-

During GlobalDeclarationInstantiation the following steps are performed in place of step 14:

+

During GlobalDeclarationInstantiation the following steps are performed in place of step 13:

1. Let _strict_ be IsStrict of _script_. 1. If _strict_ is *false*, then @@ -42949,26 +42907,24 @@

Changes to GlobalDeclarationInstantiation

1. For each |FunctionDeclaration| _f_ that is directly contained in the |StatementList| of a |Block|, |CaseClause|, or |DefaultClause| Contained within _script_, do 1. Let _F_ be StringValue of the |BindingIdentifier| of _f_. 1. If replacing the |FunctionDeclaration| _f_ with a |VariableStatement| that has _F_ as a |BindingIdentifier| would not produce any Early Errors for _script_, then - 1. If _envRec_.HasLexicalDeclaration(_F_) is *false*, then - 1. Let _fnDefinable_ be ? _envRec_.CanDeclareGlobalVar(_F_). + 1. If _env_.HasLexicalDeclaration(_F_) is *false*, then + 1. Let _fnDefinable_ be ? _env_.CanDeclareGlobalVar(_F_). 1. If _fnDefinable_ is *true*, then 1. NOTE: A var binding for _F_ is only instantiated here if it is neither a VarDeclaredName nor the name of another |FunctionDeclaration|. 1. If _declaredFunctionOrVarNames_ does not contain _F_, then - 1. Perform ? _envRec_.CreateGlobalVarBinding(_F_, *false*). + 1. Perform ? _env_.CreateGlobalVarBinding(_F_, *false*). 1. Append _F_ to _declaredFunctionOrVarNames_. 1. When the |FunctionDeclaration| _f_ is evaluated, perform the following steps in place of the |FunctionDeclaration| Evaluation algorithm provided in : 1. Let _genv_ be the running execution context's VariableEnvironment. - 1. Let _genvRec_ be _genv_'s EnvironmentRecord. 1. Let _benv_ be the running execution context's LexicalEnvironment. - 1. Let _benvRec_ be _benv_'s EnvironmentRecord. - 1. Let _fobj_ be ! _benvRec_.GetBindingValue(_F_, *false*). - 1. Perform ? _genvRec_.SetMutableBinding(_F_, _fobj_, *false*). + 1. Let _fobj_ be ! _benv_.GetBindingValue(_F_, *false*). + 1. Perform ? _genv_.SetMutableBinding(_F_, _fobj_, *false*). 1. Return NormalCompletion(~empty~).

Changes to EvalDeclarationInstantiation

-

During EvalDeclarationInstantiation the following steps are performed in place of step 9:

+

During EvalDeclarationInstantiation the following steps are performed in place of step 7:

1. If _strict_ is *false*, then 1. Let _declaredFunctionOrVarNames_ be a new empty List. @@ -42981,35 +42937,32 @@

Changes to EvalDeclarationInstantiation

1. Let _thisLex_ be _lexEnv_. 1. Assert: The following loop will terminate. 1. Repeat, while _thisLex_ is not the same as _varEnv_, - 1. Let _thisEnvRec_ be _thisLex_'s EnvironmentRecord. - 1. If _thisEnvRec_ is not an object Environment Record, then - 1. If _thisEnvRec_.HasBinding(_F_) is *true*, then + 1. If _thisLex_ is not an object Environment Record, then + 1. If _thisLex_.HasBinding(_F_) is *true*, then 1. Let _bindingExists_ be *true*. 1. Set _thisLex_ to _thisLex_.[[OuterEnv]]. - 1. If _bindingExists_ is *false* and _varEnvRec_ is a global Environment Record, then - 1. If _varEnvRec_.HasLexicalDeclaration(_F_) is *false*, then - 1. Let _fnDefinable_ be ? _varEnvRec_.CanDeclareGlobalVar(_F_). + 1. If _bindingExists_ is *false* and _varEnv_ is a global Environment Record, then + 1. If _varEnv_.HasLexicalDeclaration(_F_) is *false*, then + 1. Let _fnDefinable_ be ? _varEnv_.CanDeclareGlobalVar(_F_). 1. Else, 1. Let _fnDefinable_ be *false*. 1. Else, 1. Let _fnDefinable_ be *true*. 1. If _bindingExists_ is *false* and _fnDefinable_ is *true*, then 1. If _declaredFunctionOrVarNames_ does not contain _F_, then - 1. If _varEnvRec_ is a global Environment Record, then - 1. Perform ? _varEnvRec_.CreateGlobalVarBinding(_F_, *true*). + 1. If _varEnv_ is a global Environment Record, then + 1. Perform ? _varEnv_.CreateGlobalVarBinding(_F_, *true*). 1. Else, - 1. Let _bindingExists_ be _varEnvRec_.HasBinding(_F_). + 1. Let _bindingExists_ be _varEnv_.HasBinding(_F_). 1. If _bindingExists_ is *false*, then - 1. Perform ! _varEnvRec_.CreateMutableBinding(_F_, *true*). - 1. Perform ! _varEnvRec_.InitializeBinding(_F_, *undefined*). + 1. Perform ! _varEnv_.CreateMutableBinding(_F_, *true*). + 1. Perform ! _varEnv_.InitializeBinding(_F_, *undefined*). 1. Append _F_ to _declaredFunctionOrVarNames_. 1. When the |FunctionDeclaration| _f_ is evaluated, perform the following steps in place of the |FunctionDeclaration| Evaluation algorithm provided in : 1. Let _genv_ be the running execution context's VariableEnvironment. - 1. Let _genvRec_ be _genv_'s EnvironmentRecord. 1. Let _benv_ be the running execution context's LexicalEnvironment. - 1. Let _benvRec_ be _benv_'s EnvironmentRecord. - 1. Let _fobj_ be ! _benvRec_.GetBindingValue(_F_, *false*). - 1. Perform ? _genvRec_.SetMutableBinding(_F_, _fobj_, *false*). + 1. Let _fobj_ be ! _benv_.GetBindingValue(_F_, *false*). + 1. Perform ? _genv_.SetMutableBinding(_F_, _fobj_, *false*). 1. Return NormalCompletion(~empty~).
@@ -43035,18 +42988,18 @@

Changes to `switch` Statement Static Semantics: Early Errors

Changes to BlockDeclarationInstantiation

-

During BlockDeclarationInstantiation the following steps are performed in place of step 4.a.ii.1:

+

During BlockDeclarationInstantiation the following steps are performed in place of step 3.a.ii.1:

- 1. If _envRec_.HasBinding(_dn_) is *false*, then - 1. Perform ! _envRec_.CreateMutableBinding(_dn_, *false*). + 1. If _env_.HasBinding(_dn_) is *false*, then + 1. Perform ! _env_.CreateMutableBinding(_dn_, *false*). -

During BlockDeclarationInstantiation the following steps are performed in place of step 4.b.iii:

+

During BlockDeclarationInstantiation the following steps are performed in place of step 3.b.iii:

- 1. If the binding for _fn_ in _envRec_ is an uninitialized binding, then - 1. Perform _envRec_.InitializeBinding(_fn_, _fo_). + 1. If the binding for _fn_ in _env_ is an uninitialized binding, then + 1. Perform _env_.InitializeBinding(_fn_, _fo_). 1. Else, 1. Assert: _d_ is a |FunctionDeclaration|. - 1. Perform _envRec_.SetMutableBinding(_fn_, _fo_, *false*). + 1. Perform _env_.SetMutableBinding(_fn_, _fo_, *false*).
@@ -43083,13 +43036,13 @@

VariableStatements in Catch Blocks

The |Block| of a |Catch| clause may contain `var` declarations that bind a name that is also bound by the |CatchParameter|. At runtime, such bindings are instantiated in the VariableDeclarationEnvironment. They do not shadow the same-named bindings introduced by the |CatchParameter| and hence the |Initializer| for such `var` declarations will assign to the corresponding catch parameter rather than the `var` binding.

This modified behaviour also applies to `var` and `function` declarations introduced by direct eval calls contained within the |Block| of a |Catch| clause. This change is accomplished by modifying the algorithm of as follows:

-

Step 5.d.ii.2.a.i is replaced by:

+

Step 3.d.i.2.a.i is replaced by:

- 1. If _thisEnvRec_ is not the Environment Record for a |Catch| clause, throw a *SyntaxError* exception. + 1. If _thisLex_ is not the Environment Record for a |Catch| clause, throw a *SyntaxError* exception. -

Step 9.d.ii.4.b.i.i is replaced by:

+

Step 7.d.ii.4.a.i.i is replaced by:

- 1. If _thisEnvRec_ is not the Environment Record for a |Catch| clause, let _bindingExists_ be *true*. + 1. If _thisLex_ is not the Environment Record for a |Catch| clause, let _bindingExists_ be *true*. From 6f70907e715e33c9d3d4cc623425d2cb90139ef0 Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Mon, 16 Sep 2019 10:26:02 -0400 Subject: [PATCH 3/7] Editorial: Eliminate remaining mentions of Lexical Environment (#1697) ... mostly by changing "Lexical Environment" to "Environment Record". For lowercase "lexical environment", the treatment varies, because it's used with a few senses: - same as uppercase, - the LexicalEnvironment component of an execution context, and - the general (non-ES-specific) sense. --- spec.html | 78 +++++++++++++++++++++++++++---------------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/spec.html b/spec.html index 0beb5119e5..a7bef1c43f 100644 --- a/spec.html +++ b/spec.html @@ -3927,7 +3927,7 @@

Well-Known Intrinsic Objects

ECMAScript Specification Types

-

A specification type corresponds to meta-values that are used within algorithms to describe the semantics of ECMAScript language constructs and ECMAScript language types. The specification types include Reference, List, Completion, Property Descriptor, Lexical Environment, Environment Record, Abstract Closure, and Data Block. Specification type values are specification artefacts that do not necessarily correspond to any specific entity within an ECMAScript implementation. Specification type values may be used to describe intermediate results of ECMAScript expression evaluation but such values cannot be stored as properties of objects or values of ECMAScript language variables.

+

A specification type corresponds to meta-values that are used within algorithms to describe the semantics of ECMAScript language constructs and ECMAScript language types. The specification types include Reference, List, Completion, Property Descriptor, Environment Record, Abstract Closure, and Data Block. Specification type values are specification artefacts that do not necessarily correspond to any specific entity within an ECMAScript implementation. Specification type values may be used to describe intermediate results of ECMAScript expression evaluation but such values cannot be stored as properties of objects or values of ECMAScript language variables.

The List and Record Specification Types

@@ -4414,8 +4414,8 @@

CompletePropertyDescriptor ( _Desc_ )

-

The Lexical Environment and Environment Record Specification Types

-

The Lexical Environment and Environment Record types are used to explain the behaviour of name resolution in nested functions and blocks. These types and the operations upon them are defined in .

+

The Environment Record Specification Type

+

The Environment Record type is used to explain the behaviour of name resolution in nested functions and blocks. This type and the operations upon it are defined in .

@@ -6189,14 +6189,14 @@

ListIteratorNext Functions

Executable Code and Execution Contexts

-

Lexical Environments

-

A Lexical Environment is a specification type used to define the association of |Identifier|s to specific variables and functions based upon the lexical nesting structure of ECMAScript code. A Lexical Environment consists of an Environment Record and a possibly null reference to an outer Lexical Environment ([[OuterEnv]] field). Usually a Lexical Environment is associated with some specific syntactic structure of ECMAScript code such as a |FunctionDeclaration|, a |BlockStatement|, or a |Catch| clause of a |TryStatement| and a new Lexical Environment is created each time such code is evaluated.

-

An Environment Record records the identifier bindings that are created within the scope of its associated Lexical Environment. It is referred to as the Lexical Environment's EnvironmentRecord.

-

The [[OuterEnv]] field is used to model the logical nesting of Lexical Environment values. The outer reference of a (inner) Lexical Environment is a reference to the Lexical Environment that logically surrounds the inner Lexical Environment. An outer Lexical Environment may, of course, have its own outer Lexical Environment. A Lexical Environment may serve as the outer environment for multiple inner Lexical Environments. For example, if a |FunctionDeclaration| contains two nested |FunctionDeclaration|s then the Lexical Environments of each of the nested functions will have as their outer Lexical Environment the Lexical Environment of the current evaluation of the surrounding function.

-

A global environment is a Lexical Environment which does not have an outer environment. The global environment's [[OuterEnv]] is *null*. A global environment's EnvironmentRecord may be prepopulated with identifier bindings and includes an associated global object whose properties provide some of the global environment's identifier bindings. As ECMAScript code is executed, additional properties may be added to the global object and the initial properties may be modified.

-

A module environment is a Lexical Environment that contains the bindings for the top level declarations of a |Module|. It also contains the bindings that are explicitly imported by the |Module|. The outer environment of a module environment is a global environment.

-

A function environment is a Lexical Environment that corresponds to the invocation of an ECMAScript function object. A function environment may establish a new `this` binding. A function environment also captures the state necessary to support `super` method invocations.

-

Lexical Environments and Environment Record values are purely specification mechanisms and need not correspond to any specific artefact of an ECMAScript implementation. It is impossible for an ECMAScript program to directly access or manipulate such values.

+

Environment Records

+

An Environment Record is a specification type used to define the association of |Identifier|s to specific variables and functions based upon the lexical nesting structure of ECMAScript code. An Environment Record consists of an Environment Record and a possibly null reference to an outer Environment Record ([[OuterEnv]] field). Usually an Environment Record is associated with some specific syntactic structure of ECMAScript code such as a |FunctionDeclaration|, a |BlockStatement|, or a |Catch| clause of a |TryStatement| and a new Environment Record is created each time such code is evaluated.

+

An Environment Record records the identifier bindings that are created within the scope of its associated Environment Record. It is referred to as the Environment Record's EnvironmentRecord.

+

The [[OuterEnv]] field is used to model the logical nesting of Environment Record values. The outer reference of a (inner) Environment Record is a reference to the Environment Record that logically surrounds the inner Environment Record. An outer Environment Record may, of course, have its own outer Environment Record. An Environment Record may serve as the outer environment for multiple inner Environment Records. For example, if a |FunctionDeclaration| contains two nested |FunctionDeclaration|s then the Environment Records of each of the nested functions will have as their outer Environment Record the Environment Record of the current evaluation of the surrounding function.

+

A global environment is an Environment Record which does not have an outer environment. The global environment's [[OuterEnv]] is *null*. A global environment's EnvironmentRecord may be prepopulated with identifier bindings and includes an associated global object whose properties provide some of the global environment's identifier bindings. As ECMAScript code is executed, additional properties may be added to the global object and the initial properties may be modified.

+

A module environment is an Environment Record that contains the bindings for the top level declarations of a |Module|. It also contains the bindings that are explicitly imported by the |Module|. The outer environment of a module environment is a global environment.

+

A function environment is an Environment Record that corresponds to the invocation of an ECMAScript function object. A function environment may establish a new `this` binding. A function environment also captures the state necessary to support `super` method invocations.

+

Environment Records are purely specification mechanisms and need not correspond to any specific artefact of an ECMAScript implementation. It is impossible for an ECMAScript program to directly access or manipulate such values.

Environment Records

@@ -7181,13 +7181,13 @@

CreateImportBinding ( _N_, _M_, _N2_ )

- -

Lexical Environment Operations

-

The following abstract operations are used in this specification to operate upon lexical environments:

+ +

Environment Record Operations

+

The following abstract operations are used in this specification to operate upon Environment Records:

GetIdentifierReference ( _lex_, _name_, _strict_ )

-

The abstract operation GetIdentifierReference takes arguments _lex_ (a Lexical Environment or *null*), _name_ (a String), and _strict_ (a Boolean). It performs the following steps when called:

+

The abstract operation GetIdentifierReference takes arguments _lex_ (an Environment Record or *null*), _name_ (a String), and _strict_ (a Boolean). It performs the following steps when called:

1. If _lex_ is the value *null*, then 1. Return a value of type Reference whose base value component is *undefined*, whose referenced name component is _name_, and whose strict reference flag is _strict_. @@ -7202,7 +7202,7 @@

GetIdentifierReference ( _lex_, _name_, _strict_ )

NewDeclarativeEnvironment ( _E_ )

-

The abstract operation NewDeclarativeEnvironment takes argument _E_ (a Lexical Environment). It performs the following steps when called:

+

The abstract operation NewDeclarativeEnvironment takes argument _E_ (an Environment Record). It performs the following steps when called:

1. Let _env_ be a new declarative Environment Record containing no bindings. 1. Set _env_.[[OuterEnv]] to _E_. @@ -7212,7 +7212,7 @@

NewDeclarativeEnvironment ( _E_ )

NewObjectEnvironment ( _O_, _E_ )

-

The abstract operation NewObjectEnvironment takes arguments _O_ (an Object) and _E_ (a Lexical Environment). It performs the following steps when called:

+

The abstract operation NewObjectEnvironment takes arguments _O_ (an Object) and _E_ (an Environment Record). It performs the following steps when called:

1. Let _env_ be a new object Environment Record containing _O_ as the binding object. 1. Set _env_.[[OuterEnv]] to _E_. @@ -7256,7 +7256,7 @@

NewGlobalEnvironment ( _G_, _thisValue_ )

NewModuleEnvironment ( _E_ )

-

The abstract operation NewModuleEnvironment takes argument _E_ (a Lexical Environment). It performs the following steps when called:

+

The abstract operation NewModuleEnvironment takes argument _E_ (an Environment Record). It performs the following steps when called:

1. Let _env_ be a new module Environment Record containing no bindings. 1. Set _env_.[[OuterEnv]] to _E_. @@ -7311,7 +7311,7 @@

Realms

[[GlobalEnv]] - Lexical Environment + Environment Record The global environment for this realm @@ -7469,7 +7469,7 @@

Execution Contexts

LexicalEnvironment - Identifies the Lexical Environment used to resolve identifier references made by code within this execution context. + Identifies the Environment Record used to resolve identifier references made by code within this execution context. @@ -7477,13 +7477,13 @@

Execution Contexts

VariableEnvironment - Identifies the Lexical Environment whose EnvironmentRecord holds bindings created by |VariableStatement|s within this execution context. + Identifies the Environment Record that holds bindings created by |VariableStatement|s within this execution context. -

The LexicalEnvironment and VariableEnvironment components of an execution context are always Lexical Environments.

+

The LexicalEnvironment and VariableEnvironment components of an execution context are always Environment Records.

Execution contexts representing the evaluation of generator objects have the additional state components listed in .

@@ -7523,11 +7523,11 @@

GetActiveScriptOrModule ( )

ResolveBinding ( _name_ [ , _env_ ] )

-

The abstract operation ResolveBinding takes argument _name_ (a String) and optional argument _env_ (a Lexical Environment). It is used to determine the binding of _name_. _env_ can be used to explicitly provide the Lexical Environment that is to be searched for the binding. It performs the following steps when called:

+

The abstract operation ResolveBinding takes argument _name_ (a String) and optional argument _env_ (an Environment Record). It is used to determine the binding of _name_. _env_ can be used to explicitly provide the Environment Record that is to be searched for the binding. It performs the following steps when called:

1. If _env_ is not present or if _env_ is *undefined*, then 1. Set _env_ to the running execution context's LexicalEnvironment. - 1. Assert: _env_ is a Lexical Environment. + 1. Assert: _env_ is an Environment Record. 1. If the code matching the syntactic production that is being evaluated is contained in strict mode code, let _strict_ be *true*; else let _strict_ be *false*. 1. Return ? GetIdentifierReference(_env_, _name_, _strict_). @@ -8220,10 +8220,10 @@

ECMAScript Function Objects

[[Environment]]
@@ -8441,7 +8441,7 @@

[[Construct]] ( _argumentsList_, _newTarget_ )

OrdinaryFunctionCreate ( _functionPrototype_, _ParameterList_, _Body_, _thisMode_, _Scope_ )

-

The abstract operation OrdinaryFunctionCreate takes arguments _functionPrototype_ (an Object), _ParameterList_ (a Parse Node), _Body_ (a Parse Node), _thisMode_ (either ~lexical-this~ or ~non-lexical-this~), and _Scope_ (a Lexical Environment). It performs the following steps when called:

+

The abstract operation OrdinaryFunctionCreate takes arguments _functionPrototype_ (an Object), _ParameterList_ (a Parse Node), _Body_ (a Parse Node), _thisMode_ (either ~lexical-this~ or ~non-lexical-this~), and _Scope_ (an Environment Record). It performs the following steps when called:

1. Assert: Type(_functionPrototype_) is Object. 1. Let _internalSlotsList_ be the internal slots listed in . @@ -8633,7 +8633,7 @@

FunctionDeclarationInstantiation ( _func_, _argumentsList_ )

1. Else, 1. Perform ? IteratorBindingInitialization for _formals_ with _iteratorRecord_ and _env_ as arguments. 1. If _hasParameterExpressions_ is *false*, then - 1. NOTE: Only a single lexical environment is needed for the parameters and top-level vars. + 1. NOTE: Only a single Environment Record is needed for the parameters and top-level vars. 1. Let _instantiatedVarNames_ be a copy of the List _parameterBindings_. 1. For each _n_ in _varNames_, do 1. If _n_ is not an element of _instantiatedVarNames_, then @@ -8658,7 +8658,7 @@

FunctionDeclarationInstantiation ( _func_, _argumentsList_ )

1. NOTE: Annex adds additional steps at this point. 1. If _strict_ is *false*, then 1. Let _lexEnv_ be NewDeclarativeEnvironment(_varEnv_). - 1. NOTE: Non-strict functions use a separate lexical Environment Record for top-level lexical declarations so that a direct eval can determine whether any var scoped declarations introduced by the eval code conflict with pre-existing top-level lexically scoped declarations. This is not needed for strict functions because a strict direct eval always places all declarations into a new Environment Record. + 1. NOTE: Non-strict functions use a separate Environment Record for top-level lexical declarations so that a direct eval can determine whether any var scoped declarations introduced by the eval code conflict with pre-existing top-level lexically scoped declarations. This is not needed for strict functions because a strict direct eval always places all declarations into a new Environment Record. 1. Else, let _lexEnv_ be _varEnv_. 1. Set the LexicalEnvironment of _calleeContext_ to _lexEnv_. 1. Let _lexDeclarations_ be the LexicallyScopedDeclarations of _code_. @@ -16282,7 +16282,7 @@

Runtime Semantics: BlockDeclarationInstantiation ( _code_, _env_ )

When a |Block| or |CaseBlock| is evaluated a new declarative Environment Record is created and bindings for each block scoped variable, constant, function, or class declared in the block are instantiated in the Environment Record.

-

The abstract operation BlockDeclarationInstantiation takes arguments _code_ (a Parse Node) and _env_ (a Lexical Environment). _code_ is the Parse Node corresponding to the body of the block. _env_ is the Lexical Environment in which bindings are to be created. It performs the following steps when called:

+

The abstract operation BlockDeclarationInstantiation takes arguments _code_ (a Parse Node) and _env_ (an Environment Record). _code_ is the Parse Node corresponding to the body of the block. _env_ is the Environment Record in which bindings are to be created. It performs the following steps when called:

- Lexical Environment + Environment Record - The Lexical Environment that the function was closed over. Used as the outer environment when evaluating the code of the function. + The Environment Record that the function was closed over. Used as the outer environment when evaluating the code of the function.