From 2b463870cef3785614ecebee01e2330b65a234d1 Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Tue, 8 Dec 2020 01:22:55 -0500 Subject: [PATCH] Editorial: Model execution context as a record Resolves issue #1742 --- spec.html | 337 +++++++++++++++++++++++++++++------------------------- 1 file changed, 183 insertions(+), 154 deletions(-) diff --git a/spec.html b/spec.html index 719db1d437e..04ad59b2b6f 100644 --- a/spec.html +++ b/spec.html @@ -3637,7 +3637,7 @@

Await

1. Set _onRejected_.[[AsyncContext]] to _asyncContext_. 1. Perform ! PerformPromiseThen(_promise_, _onFulfilled_, _onRejected_). 1. Remove _asyncContext_ from the execution context stack and restore the execution context that is at the top of the execution context stack as the running execution context. - 1. Set the code evaluation state of _asyncContext_ such that when evaluation is resumed with a Completion _completion_, the following steps of the algorithm that invoked Await will be performed, with _completion_ available. + 1. Set _asyncContext_.[[CodeEvaluationState]] such that when evaluation is resumed with a Completion _completion_, the following steps of the algorithm that invoked Await will be performed, with _completion_ available. 1. Return. 1. NOTE: This returns to the evaluation of the operation that had most previously resumed evaluation of _asyncContext_. @@ -9589,21 +9589,27 @@

SetDefaultGlobalBindings ( _realmRec_ )

Execution Contexts

An execution context is a specification device that is used to track the runtime evaluation of code by an ECMAScript implementation. At any point in time, there is at most one execution context per agent that is actually executing code. This is known as the agent's running execution context. All references to the running execution context in this specification denote the running execution context of the surrounding agent.

The execution context stack is used to track execution contexts. The running execution context is always the top element of this stack. A new execution context is created whenever control is transferred from the executable code associated with the currently running execution context to executable code that is not associated with that execution context. The newly created execution context is pushed onto the stack and becomes the running execution context.

-

An execution context contains whatever implementation specific state is necessary to track the execution progress of its associated code. Each execution context has at least the state components listed in .

- +

Each execution context is represented as an ExecutionContext Record, with at least the fields listed in .

+ + + + + +
- Component + Field Name + + Value Type - Purpose + Meaning
- code evaluation state + [[CodeEvaluationState]] + + implementation-specific Any state needed to perform, suspend, and resume evaluation of the code associated with this execution context. @@ -9611,15 +9617,21 @@

Execution Contexts

- Function + [[Function]] + + a function object | *null* - If this execution context is evaluating the code of a function object, then the value of this component is that function object. If the context is evaluating the code of a |Script| or |Module|, the value is *null*. + If this execution context is evaluating the code of a function object, then the value of this field is that function object. If the context is evaluating the code of a |Script| or |Module|, the value is *null*.
- Realm + [[Realm]] + + a Realm Record The Realm Record from which associated code accesses ECMAScript resources. @@ -9627,7 +9639,10 @@

Execution Contexts

- ScriptOrModule + [[ScriptOrModule]] + + a Module Record | a Script Record | *null* The Module Record or Script Record from which associated code originates. If there is no originating script or module, as is the case for the original execution context created in InitializeHostDefinedRealm, the value is *null*. @@ -9637,22 +9652,28 @@

Execution Contexts

Evaluation of code by the running execution context may be suspended at various points defined within this specification. Once the running execution context has been suspended a different execution context may become the running execution context and commence evaluating its code. At some later time a suspended execution context may again become the running execution context and continue evaluating its code at the point where it had previously been suspended. Transition of the running execution context status among execution contexts usually occurs in stack-like last-in/first-out manner. However, some ECMAScript features require non-LIFO transitions of the running execution context.

-

The value of the Realm component of the running execution context is also called the current Realm Record. The value of the Function component of the running execution context is also called the active function object.

-

Execution contexts for ECMAScript code have the additional state components listed in .

- +

The value of the [[Realm]] field of the running execution context is also called the current Realm Record. The value of the [[Function]] field of the running execution context is also called the active function object.

+

ExecutionContext Records for ECMAScript code have the additional fields listed in .

+ + + +
- Component + Field Name + + Value Type - Purpose + Meaning
- LexicalEnvironment + [[LexicalEnvironment]] + + an Environment Record Identifies the Environment Record used to resolve identifier references made by code within this execution context. @@ -9660,7 +9681,10 @@

Execution Contexts

- VariableEnvironment + [[VariableEnvironment]] + + an Environment Record Identifies the Environment Record that holds bindings created by |VariableStatement|s within this execution context. @@ -9669,22 +9693,27 @@

Execution Contexts

-

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 .

- +

ExecutionContext Records representing the evaluation of generator objects have the additional fields listed in .

+ + +
- Component + Field Name - Purpose + Value Type + + Meaning
- Generator + [[Generator]] + + an Object The generator object that this execution context is evaluating. @@ -9693,7 +9722,7 @@

Execution Contexts

-

In most situations only the running execution context (the top of the execution context stack) is directly manipulated by algorithms within this specification. Hence when the terms “LexicalEnvironment”, and “VariableEnvironment” are used without qualification they are in reference to those components of the running execution context.

+

In most situations only the running execution context (the top of the execution context stack) is directly manipulated by algorithms within this specification.

An execution context is purely a specification mechanism and need not correspond to any particular artefact of an ECMAScript implementation. It is impossible for ECMAScript code to directly access or observe an execution context.

@@ -9702,8 +9731,8 @@

GetActiveScriptOrModule ( )

1. If the execution context stack is empty, return *null*. - 1. Let _ec_ be the topmost execution context on the execution context stack whose ScriptOrModule component is not *null*. - 1. If no such execution context exists, return *null*. Otherwise, return _ec_'s ScriptOrModule. + 1. Let _ec_ be the topmost execution context on the execution context stack whose [[ScriptOrModule]] field is not *null*. + 1. If no such execution context exists, return *null*. Otherwise, return _ec_.[[ScriptOrModule]].
@@ -9712,7 +9741,7 @@

ResolveBinding ( _name_ [ , _env_ ] )

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. Set _env_ to the [[LexicalEnvironment]] field of the running execution context. 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_). @@ -9726,7 +9755,7 @@

ResolveBinding ( _name_ [ , _env_ ] )

GetThisEnvironment ( )

The abstract operation GetThisEnvironment takes no arguments. It finds the Environment Record that currently supplies the binding of the keyword `this`. It performs the following steps when called:

- 1. Let _env_ be the running execution context's LexicalEnvironment. + 1. Let _env_ be the [[LexicalEnvironment]] field of the running execution context. 1. [id="step-getthisenvironment-loop"] Repeat, 1. Let _exists_ be _env_.HasThisBinding(). 1. If _exists_ is *true*, return _env_. @@ -9741,7 +9770,7 @@

GetThisEnvironment ( )

ResolveThisBinding ( )

-

The abstract operation ResolveThisBinding takes no arguments. It determines the binding of the keyword `this` using the LexicalEnvironment of the running execution context. It performs the following steps when called:

+

The abstract operation ResolveThisBinding takes no arguments. It determines the binding of the keyword `this` using the [[LexicalEnvironment]] of the running execution context. It performs the following steps when called:

1. Let _envRec_ be GetThisEnvironment(). 1. Return ? _envRec_.GetThisBinding(). @@ -9750,7 +9779,7 @@

ResolveThisBinding ( )

GetNewTarget ( )

-

The abstract operation GetNewTarget takes no arguments. It determines the NewTarget value using the LexicalEnvironment of the running execution context. It performs the following steps when called:

+

The abstract operation GetNewTarget takes no arguments. It determines the NewTarget value using the [[LexicalEnvironment]] of the running execution context. It performs the following steps when called:

1. Let _envRec_ be GetThisEnvironment(). 1. Assert: _envRec_ has a [[NewTarget]] field. @@ -9793,13 +9822,13 @@

Jobs and Host Operations to Enqueue Jobs

At any particular time, _scriptOrModule_ (a Script Record, a Module Record, or *null*) is the active script or module if all of the following conditions are true:

  • GetActiveScriptOrModule() is _scriptOrModule_.
  • -
  • If _scriptOrModule_ is a Script Record or Module Record, let _ec_ be the topmost execution context on the execution context stack whose ScriptOrModule component is _scriptOrModule_. The Realm component of _ec_ is _scriptOrModule_.[[Realm]].
  • +
  • If _scriptOrModule_ is a Script Record or Module Record, let _ec_ be the topmost execution context on the execution context stack whose [[ScriptOrModule]] field is _scriptOrModule_. The [[Realm]] field of _ec_ is _scriptOrModule_.[[Realm]].

At any particular time, an execution is prepared to evaluate ECMAScript code if all of the following conditions are true:

  • The execution context stack is not empty.
  • -
  • The Realm component of the topmost execution context on the execution context stack is a Realm Record.
  • +
  • The [[Realm]] field of the topmost execution context on the execution context stack is a Realm Record.
@@ -9918,10 +9947,10 @@

InitializeHostDefinedRealm ( )

1. Let _realm_ be CreateRealm(). - 1. Let _newContext_ be a new execution context. - 1. Set the Function of _newContext_ to *null*. - 1. Set the Realm of _newContext_ to _realm_. - 1. Set the ScriptOrModule of _newContext_ to *null*. + 1. Let _newContext_ be a new ExecutionContext Record. + 1. Set _newContext_.[[Function]] to *null*. + 1. Set _newContext_.[[Realm]] to _realm_. + 1. Set _newContext_.[[ScriptOrModule]] to *null*. 1. Push _newContext_ onto the execution context stack; _newContext_ is now the running execution context. 1. If the host requires use of an exotic object to serve as _realm_'s global object, let _global_ be such an object created in a host-defined manner. Otherwise, let _global_ be *undefined*, indicating that an ordinary object should be created as the global object. 1. If the host requires that the `this` binding in _realm_'s global scope return an object other than the global object, let _thisValue_ be such an object created in a host-defined manner. Otherwise, let _thisValue_ be *undefined*, indicating that _realm_'s global `this` binding should be the global object. @@ -10807,14 +10836,14 @@

PrepareForOrdinaryCall ( _F_, _newTarget_ )

1. Assert: Type(_newTarget_) is Undefined or Object. 1. Let _callerContext_ be the running execution context. - 1. Let _calleeContext_ be a new ECMAScript code execution context. - 1. Set the Function of _calleeContext_ to _F_. + 1. Let _calleeContext_ be a new ECMAScript code ExecutionContext Record. + 1. Set _calleeContext_.[[Function]] to _F_. 1. Let _calleeRealm_ be _F_.[[Realm]]. - 1. Set the Realm of _calleeContext_ to _calleeRealm_. - 1. Set the ScriptOrModule of _calleeContext_ to _F_.[[ScriptOrModule]]. + 1. Set _calleeContext_.[[Realm]] to _calleeRealm_. + 1. Set _calleeContext_.[[ScriptOrModule]] to _F_.[[ScriptOrModule]]. 1. Let _localEnv_ be NewFunctionEnvironment(_F_, _newTarget_). - 1. Set the LexicalEnvironment of _calleeContext_ to _localEnv_. - 1. Set the VariableEnvironment of _calleeContext_ to _localEnv_. + 1. Set _calleeContext_.[[LexicalEnvironment]] to _localEnv_. + 1. Set _calleeContext_.[[VariableEnvironment]] to _localEnv_. 1. If _callerContext_ is not already suspended, suspend _callerContext_. 1. Push _calleeContext_ onto the execution context stack; _calleeContext_ is now the running execution context. 1. NOTE: Any exception objects produced after this point are associated with _calleeRealm_. @@ -10829,7 +10858,7 @@

OrdinaryCallBindThis ( _F_, _calleeContext_, _thisArgument_ )

1. Let _thisMode_ be _F_.[[ThisMode]]. 1. If _thisMode_ is ~lexical~, return NormalCompletion(*undefined*). 1. Let _calleeRealm_ be _F_.[[Realm]]. - 1. Let _localEnv_ be the LexicalEnvironment of _calleeContext_. + 1. Let _localEnv_ be _calleeContext_.[[LexicalEnvironment]]. 1. If _thisMode_ is ~strict~, let _thisValue_ be _thisArgument_. 1. Else, 1. If _thisArgument_ is *undefined* or *null*, then @@ -10902,7 +10931,7 @@

[[Construct]] ( _argumentsList_, _newTarget_ )

1. Let _calleeContext_ be PrepareForOrdinaryCall(_F_, _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 _constructorEnv_ be _calleeContext_.[[LexicalEnvironment]]. 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 @@ -11077,13 +11106,13 @@

FunctionDeclarationInstantiation ( _func_, _argumentsList_ )

1. Set _argumentsObjectNeeded_ to *false*. 1. If _strict_ is *true* or if _hasParameterExpressions_ is *false*, then 1. NOTE: Only a single Environment Record is needed for the parameters and top-level vars. - 1. Let _env_ be the LexicalEnvironment of _calleeContext_. + 1. Let _env_ be _calleeContext_.[[LexicalEnvironment]]. 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 _calleeEnv_ be _calleeContext_.[[LexicalEnvironment]]. 1. Let _env_ be NewDeclarativeEnvironment(_calleeEnv_). - 1. Assert: The VariableEnvironment of _calleeContext_ is _calleeEnv_. - 1. Set the LexicalEnvironment of _calleeContext_ to _env_. + 1. Assert: _calleeContext_.[[VariableEnvironment]] is _calleeEnv_. + 1. Set _calleeContext_.[[LexicalEnvironment]] to _env_. 1. For each String _paramName_ of _parameterNames_, do 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. @@ -11122,7 +11151,7 @@

FunctionDeclarationInstantiation ( _func_, _argumentsList_ )

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. Set the VariableEnvironment of _calleeContext_ to _varEnv_. + 1. Set _calleeContext_.[[VariableEnvironment]] to _varEnv_. 1. Let _instantiatedVarNames_ be a new empty List. 1. For each element _n_ of _varNames_, do 1. If _n_ is not an element of _instantiatedVarNames_, then @@ -11138,7 +11167,7 @@

FunctionDeclarationInstantiation ( _func_, _argumentsList_ )

1. Let _lexEnv_ be NewDeclarativeEnvironment(_varEnv_). 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. Set _calleeContext_.[[LexicalEnvironment]] to _lexEnv_. 1. Let _lexDeclarations_ be the LexicallyScopedDeclarations of _code_. 1. For each element _d_ of _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. @@ -11179,11 +11208,11 @@

[[Call]] ( _thisArgument_, _argumentsList_ )

1. Let _callerContext_ be the running execution context. 1. If _callerContext_ is not already suspended, suspend _callerContext_. - 1. Let _calleeContext_ be a new execution context. - 1. Set the Function of _calleeContext_ to _F_. + 1. Let _calleeContext_ be a new ExecutionContext Record. + 1. Set _calleeContext_.[[Function]] to _F_. 1. Let _calleeRealm_ be _F_.[[Realm]]. - 1. Set the Realm of _calleeContext_ to _calleeRealm_. - 1. Set the ScriptOrModule of _calleeContext_ to *null*. + 1. Set _calleeContext_.[[Realm]] to _calleeRealm_. + 1. Set _calleeContext_.[[ScriptOrModule]] to *null*. 1. Perform any necessary implementation-defined initialization of _calleeContext_. 1. Push _calleeContext_ onto the execution context stack; _calleeContext_ is now the running execution context. 1. [id="step-call-builtin-function-result"] Let _result_ be the Completion Record that is the result of evaluating _F_ in a manner that conforms to the specification of _F_. _thisArgument_ is the *this* value, _argumentsList_ provides the named parameters, and the NewTarget value is *undefined*. @@ -17682,16 +17711,16 @@

Runtime Semantics: Evaluation

Block : `{` StatementList `}` - 1. Let _oldEnv_ be the running execution context's LexicalEnvironment. + 1. Let _oldEnv_ be the [[LexicalEnvironment]] field of the running execution context. 1. Let _blockEnv_ be NewDeclarativeEnvironment(_oldEnv_). 1. Perform BlockDeclarationInstantiation(|StatementList|, _blockEnv_). - 1. Set the running execution context's LexicalEnvironment to _blockEnv_. + 1. Set the [[LexicalEnvironment]] field of the running execution context to _blockEnv_. 1. Let _blockValue_ be the result of evaluating |StatementList|. - 1. Set the running execution context's LexicalEnvironment to _oldEnv_. + 1. Set the [[LexicalEnvironment]] field of the running execution context to _oldEnv_. 1. Return _blockValue_. -

No matter how control leaves the |Block| the LexicalEnvironment is always restored to its former state.

+

No matter how control leaves the |Block| the [[LexicalEnvironment]] is always restored to its former state.

StatementList : StatementList StatementListItem @@ -17744,7 +17773,7 @@

Declarations and the Variable Statement

Let and Const Declarations

-

`let` and `const` declarations define variables that are scoped to the running execution context's LexicalEnvironment. The variables are created when their containing Environment Record is instantiated but may not be accessed in any way until the variable's |LexicalBinding| is evaluated. A variable defined by a |LexicalBinding| with an |Initializer| is assigned the value of its |Initializer|'s |AssignmentExpression| when the |LexicalBinding| is evaluated, not when the variable is created. If a |LexicalBinding| in a `let` declaration does not have an |Initializer| the variable is assigned the value *undefined* when the |LexicalBinding| is evaluated.

+

`let` and `const` declarations define variables that are scoped to the [[LexicalEnvironment]] field of the running execution context. The variables are created when their containing Environment Record is instantiated but may not be accessed in any way until the variable's |LexicalBinding| is evaluated. A variable defined by a |LexicalBinding| with an |Initializer| is assigned the value of its |Initializer|'s |AssignmentExpression| when the |LexicalBinding| is evaluated, not when the variable is created. If a |LexicalBinding| in a `let` declaration does not have an |Initializer| the variable is assigned the value *undefined* when the |LexicalBinding| is evaluated.

Syntax

@@ -17820,7 +17849,7 @@

Runtime Semantics: Evaluation

1. Let _rhs_ be the result of evaluating |Initializer|. 1. Let _value_ be ? GetValue(_rhs_). - 1. Let _env_ be the running execution context's LexicalEnvironment. + 1. Let _env_ be the [[LexicalEnvironment]] field of the running execution context. 1. Return the result of performing BindingInitialization for |BindingPattern| using _value_ and _env_ as the arguments.
@@ -17829,7 +17858,7 @@

Runtime Semantics: Evaluation

Variable Statement

-

A `var` statement declares variables that are scoped to the running execution context's VariableEnvironment. Var variables are created when their containing Environment Record is instantiated and are initialized to *undefined* when created. Within the scope of any VariableEnvironment a common |BindingIdentifier| may appear in more than one |VariableDeclaration| but those declarations collectively define only one variable. A variable defined by a |VariableDeclaration| with an |Initializer| is assigned the value of its |Initializer|'s |AssignmentExpression| when the |VariableDeclaration| is executed, not when the variable is created.

+

A `var` statement declares variables that are scoped to the [[VariableEnvironment]] field of the running execution context. Var variables are created when their containing Environment Record is instantiated and are initialized to *undefined* when created. Within the scope of any [[VariableEnvironment]] a common |BindingIdentifier| may appear in more than one |VariableDeclaration| but those declarations collectively define only one variable. A variable defined by a |VariableDeclaration| with an |Initializer| is assigned the value of its |Initializer|'s |AssignmentExpression| when the |VariableDeclaration| is executed, not when the variable is created.

Syntax

@@ -17875,7 +17904,7 @@

Runtime Semantics: Evaluation

1. [id="step-vardecllist-evaluation-putvalue"] Return ? PutValue(_lhs_, _value_).
-

If a |VariableDeclaration| is nested within a with statement and the |BindingIdentifier| in the |VariableDeclaration| is the same as a property name of the binding object of the with statement's object Environment Record, then step will assign _value_ to the property instead of assigning to the VariableEnvironment binding of the |Identifier|.

+

If a |VariableDeclaration| is nested within a with statement and the |BindingIdentifier| in the |VariableDeclaration| is the same as a property name of the binding object of the with statement's object Environment Record, then step will assign _value_ to the property instead of assigning to the [[VariableEnvironment]] binding of the |Identifier|.

VariableDeclaration : BindingPattern Initializer @@ -18280,7 +18309,7 @@

Runtime Semantics: ForLoopEvaluation

ForStatement : `for` `(` LexicalDeclaration Expression? `;` Expression? `)` Statement - 1. Let _oldEnv_ be the running execution context's LexicalEnvironment. + 1. Let _oldEnv_ be the [[LexicalEnvironment]] field of the running execution context. 1. Let _loopEnv_ be NewDeclarativeEnvironment(_oldEnv_). 1. Let _isConst_ be IsConstantDeclaration of |LexicalDeclaration|. 1. Let _boundNames_ be the BoundNames of |LexicalDeclaration|. @@ -18289,14 +18318,14 @@

Runtime Semantics: ForLoopEvaluation

1. Perform ! _loopEnv_.CreateImmutableBinding(_dn_, *true*). 1. Else, 1. Perform ! _loopEnv_.CreateMutableBinding(_dn_, *false*). - 1. Set the running execution context's LexicalEnvironment to _loopEnv_. + 1. Set the [[LexicalEnvironment]] field of the running execution context to _loopEnv_. 1. Let _forDcl_ be the result of evaluating |LexicalDeclaration|. 1. If _forDcl_ is an abrupt completion, then - 1. Set the running execution context's LexicalEnvironment to _oldEnv_. + 1. Set the [[LexicalEnvironment]] field of the running execution context to _oldEnv_. 1. Return Completion(_forDcl_). 1. If _isConst_ is *false*, let _perIterationLets_ be _boundNames_; otherwise let _perIterationLets_ be « ». 1. Let _bodyResult_ be ForBodyEvaluation(the first |Expression|, the second |Expression|, |Statement|, _perIterationLets_, _labelSet_). - 1. Set the running execution context's LexicalEnvironment to _oldEnv_. + 1. Set the [[LexicalEnvironment]] field of the running execution context to _oldEnv_. 1. Return Completion(_bodyResult_).
@@ -18327,7 +18356,7 @@

CreatePerIterationEnvironment ( _perIterationBindings_ )

The abstract operation CreatePerIterationEnvironment takes argument _perIterationBindings_. It performs the following steps when called:

1. If _perIterationBindings_ has any elements, then - 1. Let _lastIterationEnv_ be the running execution context's LexicalEnvironment. + 1. Let _lastIterationEnv_ be the [[LexicalEnvironment]] field of the running execution context. 1. Let _outer_ be _lastIterationEnv_.[[OuterEnv]]. 1. Assert: _outer_ is not *null*. 1. Let _thisIterationEnv_ be NewDeclarativeEnvironment(_outer_). @@ -18335,7 +18364,7 @@

CreatePerIterationEnvironment ( _perIterationBindings_ )

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. Set the [[LexicalEnvironment]] field of the running execution context to _thisIterationEnv_. 1. Return *undefined*.
@@ -18561,15 +18590,15 @@

Runtime Semantics: ForInOfLoopEvaluation

ForIn/OfHeadEvaluation ( _uninitializedBoundNames_, _expr_, _iterationKind_ )

The abstract operation ForIn/OfHeadEvaluation takes arguments _uninitializedBoundNames_, _expr_, and _iterationKind_ (either ~enumerate~, ~iterate~, or ~async-iterate~). It performs the following steps when called:

- 1. Let _oldEnv_ be the running execution context's LexicalEnvironment. + 1. Let _oldEnv_ be the [[LexicalEnvironment]] field of the running execution context. 1. If _uninitializedBoundNames_ is not an empty List, then 1. Assert: _uninitializedBoundNames_ has no duplicate entries. 1. Let _newEnv_ be NewDeclarativeEnvironment(_oldEnv_). 1. For each String _name_ of _uninitializedBoundNames_, do 1. Perform ! _newEnv_.CreateMutableBinding(_name_, *false*). - 1. Set the running execution context's LexicalEnvironment to _newEnv_. + 1. Set the [[LexicalEnvironment]] field of the running execution context to _newEnv_. 1. Let _exprRef_ be the result of evaluating _expr_. - 1. Set the running execution context's LexicalEnvironment to _oldEnv_. + 1. Set the [[LexicalEnvironment]] field of the running execution context to _oldEnv_. 1. Let _exprValue_ be ? GetValue(_exprRef_). 1. If _iterationKind_ is ~enumerate~, then 1. If _exprValue_ is *undefined* or *null*, then @@ -18591,7 +18620,7 @@

ForIn/OfBodyEvaluation ( _lhs_, _stmt_, _iteratorRecord_, _iterationKind_, _

The abstract operation ForIn/OfBodyEvaluation takes arguments _lhs_, _stmt_, _iteratorRecord_, _iterationKind_, _lhsKind_ (either ~assignment~, ~varBinding~ or ~lexicalBinding~), and _labelSet_ and optional argument _iteratorKind_ (either ~sync~ or ~async~). It performs the following steps when called:

1. If _iteratorKind_ is not present, set _iteratorKind_ to ~sync~. - 1. Let _oldEnv_ be the running execution context's LexicalEnvironment. + 1. Let _oldEnv_ be the [[LexicalEnvironment]] field of the running execution context. 1. Let _V_ be *undefined*. 1. Let _destructuring_ be IsDestructuring of _lhs_. 1. If _destructuring_ is *true* and if _lhsKind_ is ~assignment~, then @@ -18612,7 +18641,7 @@

ForIn/OfBodyEvaluation ( _lhs_, _stmt_, _iteratorRecord_, _iterationKind_, _ 1. Assert: _lhs_ is a |ForDeclaration|. 1. Let _iterationEnv_ be NewDeclarativeEnvironment(_oldEnv_). 1. Perform ForDeclarationBindingInstantiation for _lhs_ passing _iterationEnv_ as the argument. - 1. Set the running execution context's LexicalEnvironment to _iterationEnv_. + 1. Set the [[LexicalEnvironment]] field of the running execution context to _iterationEnv_. 1. If _destructuring_ is *false*, then 1. Assert: _lhs_ binds a single name. 1. Let _lhsName_ be the sole element of BoundNames of _lhs_. @@ -18635,7 +18664,7 @@

ForIn/OfBodyEvaluation ( _lhs_, _stmt_, _iteratorRecord_, _iterationKind_, _ 1. Assert: _lhs_ is a |ForDeclaration|. 1. Let _status_ be ForDeclarationBindingInitialization of _lhs_ with arguments _nextValue_ and _iterationEnv_. 1. If _status_ is an abrupt completion, then - 1. Set the running execution context's LexicalEnvironment to _oldEnv_. + 1. Set the [[LexicalEnvironment]] field of the running execution context to _oldEnv_. 1. If _iteratorKind_ is ~async~, return ? AsyncIteratorClose(_iteratorRecord_, _status_). 1. If _iterationKind_ is ~enumerate~, then 1. Return _status_. @@ -18643,7 +18672,7 @@

ForIn/OfBodyEvaluation ( _lhs_, _stmt_, _iteratorRecord_, _iterationKind_, _ 1. Assert: _iterationKind_ is ~iterate~. 1. Return ? IteratorClose(_iteratorRecord_, _status_). 1. Let _result_ be the result of evaluating _stmt_. - 1. Set the running execution context's LexicalEnvironment to _oldEnv_. + 1. Set the [[LexicalEnvironment]] field of the running execution context to _oldEnv_. 1. If LoopContinues(_result_, _labelSet_) is *false*, then 1. If _iterationKind_ is ~enumerate~, then 1. Return Completion(UpdateEmpty(_result_, _V_)). @@ -18955,16 +18984,16 @@

Runtime Semantics: Evaluation

1. Let _val_ be the result of evaluating |Expression|. 1. Let _obj_ be ? ToObject(? GetValue(_val_)). - 1. Let _oldEnv_ be the running execution context's LexicalEnvironment. + 1. Let _oldEnv_ be the [[LexicalEnvironment]] field of the running execution context. 1. Let _newEnv_ be NewObjectEnvironment(_obj_, _oldEnv_). 1. Set the _withEnvironment_ flag of _newEnv_ to *true*. - 1. Set the running execution context's LexicalEnvironment to _newEnv_. + 1. Set the [[LexicalEnvironment]] field of the running execution context to _newEnv_. 1. Let _C_ be the result of evaluating |Statement|. - 1. Set the running execution context's LexicalEnvironment to _oldEnv_. + 1. Set the [[LexicalEnvironment]] field of the running execution context to _oldEnv_. 1. Return Completion(UpdateEmpty(_C_, *undefined*)). -

No matter how control leaves the embedded |Statement|, whether normally or by some form of abrupt completion or exception, the LexicalEnvironment is always restored to its former state.

+

No matter how control leaves the embedded |Statement|, whether normally or by some form of abrupt completion or exception, the [[LexicalEnvironment]] is always restored to its former state.

@@ -19086,16 +19115,16 @@

Runtime Semantics: Evaluation

1. Let _exprRef_ be the result of evaluating |Expression|. 1. Let _switchValue_ be ? GetValue(_exprRef_). - 1. Let _oldEnv_ be the running execution context's LexicalEnvironment. + 1. Let _oldEnv_ be the [[LexicalEnvironment]] field of the running execution context. 1. Let _blockEnv_ be NewDeclarativeEnvironment(_oldEnv_). 1. Perform BlockDeclarationInstantiation(|CaseBlock|, _blockEnv_). - 1. Set the running execution context's LexicalEnvironment to _blockEnv_. + 1. Set the [[LexicalEnvironment]] field of the running execution context to _blockEnv_. 1. Let _R_ be CaseBlockEvaluation of |CaseBlock| with argument _switchValue_. - 1. Set the running execution context's LexicalEnvironment to _oldEnv_. + 1. Set the [[LexicalEnvironment]] field of the running execution context to _oldEnv_. 1. Return _R_. -

No matter how control leaves the |SwitchStatement| the LexicalEnvironment is always restored to its former state.

+

No matter how control leaves the |SwitchStatement| the [[LexicalEnvironment]] is always restored to its former state.

CaseClause : `case` Expression `:` @@ -19293,17 +19322,17 @@

Runtime Semantics: CatchClauseEvaluation

With parameter _thrownValue_.

Catch : `catch` `(` CatchParameter `)` Block - 1. Let _oldEnv_ be the running execution context's LexicalEnvironment. + 1. Let _oldEnv_ be the [[LexicalEnvironment]] field of the running execution context. 1. Let _catchEnv_ be NewDeclarativeEnvironment(_oldEnv_). 1. For each element _argName_ of the BoundNames of |CatchParameter|, do 1. Perform ! _catchEnv_.CreateMutableBinding(_argName_, *false*). - 1. Set the running execution context's LexicalEnvironment to _catchEnv_. + 1. Set the [[LexicalEnvironment]] field of the running execution context to _catchEnv_. 1. Let _status_ be BindingInitialization of |CatchParameter| with arguments _thrownValue_ and _catchEnv_. 1. If _status_ is an abrupt completion, then - 1. Set the running execution context's LexicalEnvironment to _oldEnv_. + 1. Set the [[LexicalEnvironment]] field of the running execution context to _oldEnv_. 1. Return Completion(_status_). 1. Let _B_ be the result of evaluating |Block|. - 1. Set the running execution context's LexicalEnvironment to _oldEnv_. + 1. Set the [[LexicalEnvironment]] field of the running execution context to _oldEnv_. 1. Return Completion(_B_). Catch : `catch` Block @@ -19311,7 +19340,7 @@

Runtime Semantics: CatchClauseEvaluation

1. Return the result of evaluating |Block|.
-

No matter how control leaves the |Block| the LexicalEnvironment is always restored to its former state.

+

No matter how control leaves the |Block| the [[LexicalEnvironment]] is always restored to its former state.

@@ -19788,7 +19817,7 @@

Runtime Semantics: InstantiateOrdinaryFunctionExpression

FunctionExpression : `function` `(` FormalParameters `)` `{` FunctionBody `}` 1. If _name_ is not present, set _name_ to *""*. - 1. Let _scope_ be the LexicalEnvironment of the running execution context. + 1. Let _scope_ be the [[LexicalEnvironment]] field of the running execution context. 1. Let _sourceText_ be the source text matched by |FunctionExpression|. 1. Let _closure_ be OrdinaryFunctionCreate(%Function.prototype%, _sourceText_, |FormalParameters|, |FunctionBody|, ~non-lexical-this~, _scope_). 1. Perform SetFunctionName(_closure_, _name_). @@ -19799,7 +19828,7 @@

Runtime Semantics: InstantiateOrdinaryFunctionExpression

1. Assert: _name_ is not present. 1. Set _name_ to StringValue of |BindingIdentifier|. - 1. Let _scope_ be the running execution context's LexicalEnvironment. + 1. Let _scope_ be the [[LexicalEnvironment]] field of the running execution context. 1. Let _funcEnv_ be NewDeclarativeEnvironment(_scope_). 1. Perform _funcEnv_.CreateImmutableBinding(_name_, *false*). 1. Let _sourceText_ be the source text matched by |FunctionExpression|. @@ -19949,7 +19978,7 @@

Runtime Semantics: InstantiateArrowFunctionExpression

ArrowFunction : ArrowParameters `=>` ConciseBody 1. If _name_ is not present, set _name_ to *""*. - 1. Let _scope_ be the LexicalEnvironment of the running execution context. + 1. Let _scope_ be the [[LexicalEnvironment]] field of the running execution context. 1. Let _sourceText_ be the source text matched by |ArrowFunction|. 1. Let _parameters_ be CoveredFormalsList of |ArrowParameters|. 1. [id="step-arrowfunction-evaluation-functioncreate"] Let _closure_ be OrdinaryFunctionCreate(%Function.prototype%, _sourceText_, _parameters_, |ConciseBody|, ~lexical-this~, _scope_). @@ -20078,7 +20107,7 @@

Runtime Semantics: DefineMethod

1. Let _propKey_ be the result of evaluating |PropertyName|. 1. ReturnIfAbrupt(_propKey_). - 1. Let _scope_ be the running execution context's LexicalEnvironment. + 1. Let _scope_ be the [[LexicalEnvironment]] field of the running execution context. 1. If _functionPrototype_ is present, then 1. Let _prototype_ be _functionPrototype_. 1. Else, @@ -20104,7 +20133,7 @@

Runtime Semantics: MethodDefinitionEvaluation

1. Let _propKey_ be the result of evaluating |PropertyName|. 1. ReturnIfAbrupt(_propKey_). - 1. Let _scope_ be the running execution context's LexicalEnvironment. + 1. Let _scope_ be the [[LexicalEnvironment]] field of the running execution context. 1. Let _sourceText_ be the source text matched by |MethodDefinition|. 1. Let _formalParameterList_ be an instance of the production FormalParameters : [empty]. 1. Let _closure_ be OrdinaryFunctionCreate(%Function.prototype%, _sourceText_, _formalParameterList_, |FunctionBody|, ~non-lexical-this~, _scope_). @@ -20117,7 +20146,7 @@

Runtime Semantics: MethodDefinitionEvaluation

1. Let _propKey_ be the result of evaluating |PropertyName|. 1. ReturnIfAbrupt(_propKey_). - 1. Let _scope_ be the running execution context's LexicalEnvironment. + 1. Let _scope_ be the [[LexicalEnvironment]] field of the running execution context. 1. Let _sourceText_ be the source text matched by |MethodDefinition|. 1. Let _closure_ be OrdinaryFunctionCreate(%Function.prototype%, _sourceText_, |PropertySetParameterList|, |FunctionBody|, ~non-lexical-this~, _scope_). 1. Perform MakeMethod(_closure_, _object_). @@ -20129,7 +20158,7 @@

Runtime Semantics: MethodDefinitionEvaluation

1. Let _propKey_ be the result of evaluating |PropertyName|. 1. ReturnIfAbrupt(_propKey_). - 1. Let _scope_ be the running execution context's LexicalEnvironment. + 1. Let _scope_ be the [[LexicalEnvironment]] field of the running execution context. 1. Let _sourceText_ be the source text matched by |GeneratorMethod|. 1. Let _closure_ be OrdinaryFunctionCreate(%GeneratorFunction.prototype%, _sourceText_, |UniqueFormalParameters|, |GeneratorBody|, ~non-lexical-this~, _scope_). 1. Perform MakeMethod(_closure_, _object_). @@ -20145,7 +20174,7 @@

Runtime Semantics: MethodDefinitionEvaluation

1. Let _propKey_ be the result of evaluating |PropertyName|. 1. ReturnIfAbrupt(_propKey_). - 1. Let _scope_ be the running execution context's LexicalEnvironment. + 1. Let _scope_ be the [[LexicalEnvironment]] field of the running execution context. 1. Let _sourceText_ be the source text matched by |AsyncGeneratorMethod|. 1. Let _closure_ be ! OrdinaryFunctionCreate(%AsyncGeneratorFunction.prototype%, _sourceText_, |UniqueFormalParameters|, |AsyncGeneratorBody|, ~non-lexical-this~, _scope_). 1. Perform ! MakeMethod(_closure_, _object_). @@ -20161,7 +20190,7 @@

Runtime Semantics: MethodDefinitionEvaluation

1. Let _propKey_ be the result of evaluating |PropertyName|. 1. ReturnIfAbrupt(_propKey_). - 1. Let _scope_ be the LexicalEnvironment of the running execution context. + 1. Let _scope_ be the [[LexicalEnvironment]] field of the running execution context. 1. Let _sourceText_ be the source text matched by |AsyncMethod|. 1. Let _closure_ be ! OrdinaryFunctionCreate(%AsyncFunction.prototype%, _sourceText_, |UniqueFormalParameters|, |AsyncFunctionBody|, ~non-lexical-this~, _scope_). 1. Perform ! MakeMethod(_closure_, _object_). @@ -20306,7 +20335,7 @@

Runtime Semantics: InstantiateGeneratorFunctionExpression

GeneratorExpression : `function` `*` `(` FormalParameters `)` `{` GeneratorBody `}` 1. If _name_ is not present, set _name_ to *""*. - 1. Let _scope_ be the LexicalEnvironment of the running execution context. + 1. Let _scope_ be the [[LexicalEnvironment]] field of the running execution context. 1. Let _sourceText_ be the source text matched by |GeneratorExpression|. 1. Let _closure_ be OrdinaryFunctionCreate(%GeneratorFunction.prototype%, _sourceText_, |FormalParameters|, |GeneratorBody|, ~non-lexical-this~, _scope_). 1. Perform SetFunctionName(_closure_, _name_). @@ -20318,7 +20347,7 @@

Runtime Semantics: InstantiateGeneratorFunctionExpression

1. Assert: _name_ is not present. 1. Set _name_ to StringValue of |BindingIdentifier|. - 1. Let _scope_ be the running execution context's LexicalEnvironment. + 1. Let _scope_ be the [[LexicalEnvironment]] field of the running execution context. 1. Let _funcEnv_ be NewDeclarativeEnvironment(_scope_). 1. Perform _funcEnv_.CreateImmutableBinding(_name_, *false*). 1. Let _sourceText_ be the source text matched by |GeneratorExpression|. @@ -20518,7 +20547,7 @@

Runtime Semantics: InstantiateAsyncGeneratorFunctionExpression

1. If _name_ is not present, set _name_ to *""*. - 1. Let _scope_ be the LexicalEnvironment of the running execution context. + 1. Let _scope_ be the [[LexicalEnvironment]] field of the running execution context. 1. Let _sourceText_ be the source text matched by |AsyncGeneratorExpression|. 1. Let _closure_ be ! OrdinaryFunctionCreate(%AsyncGeneratorFunction.prototype%, _sourceText_, |FormalParameters|, |AsyncGeneratorBody|, ~non-lexical-this~, _scope_). 1. Perform SetFunctionName(_closure_, _name_). @@ -20532,7 +20561,7 @@

Runtime Semantics: InstantiateAsyncGeneratorFunctionExpression

1. Assert: _name_ is not present. 1. Set _name_ to StringValue of |BindingIdentifier|. - 1. Let _scope_ be the running execution context's LexicalEnvironment. + 1. Let _scope_ be the [[LexicalEnvironment]] field of the running execution context. 1. Let _funcEnv_ be ! NewDeclarativeEnvironment(_scope_). 1. Perform ! _funcEnv_.CreateImmutableBinding(_name_, *false*). 1. Let _sourceText_ be the source text matched by |AsyncGeneratorExpression|. @@ -20723,7 +20752,7 @@

Runtime Semantics: ClassDefinitionEvaluation

With parameters _classBinding_ and _className_.

ClassTail : ClassHeritage? `{` ClassBody? `}` - 1. Let _env_ be the LexicalEnvironment of the running execution context. + 1. Let _env_ be the [[LexicalEnvironment]] field of the running execution context. 1. Let _classScope_ be NewDeclarativeEnvironment(_env_). 1. If _classBinding_ is not *undefined*, then 1. Perform _classScope_.CreateImmutableBinding(_classBinding_, *true*). @@ -20731,9 +20760,9 @@

Runtime Semantics: ClassDefinitionEvaluation

1. Let _protoParent_ be %Object.prototype%. 1. Let _constructorParent_ be %Function.prototype%. 1. Else, - 1. Set the running execution context's LexicalEnvironment to _classScope_. + 1. Set the [[LexicalEnvironment]] field of the running execution context to _classScope_. 1. Let _superclassRef_ be the result of evaluating |ClassHeritage|. - 1. Set the running execution context's LexicalEnvironment to _env_. + 1. Set the [[LexicalEnvironment]] field of the running execution context to _env_. 1. Let _superclass_ be ? GetValue(_superclassRef_). 1. If _superclass_ is *null*, then 1. Let _protoParent_ be *null*. @@ -20755,7 +20784,7 @@

Runtime Semantics: ClassDefinitionEvaluation

constructor() {}
1. Set _constructor_ to ParseText(_constructorText_, |MethodDefinition[~Yield, ~Await]|). 1. Assert: _constructor_ is a Parse Node. - 1. Set the running execution context's LexicalEnvironment to _classScope_. + 1. Set the [[LexicalEnvironment]] field of the running execution context to _classScope_. 1. Let _constructorInfo_ be ! DefineMethod of _constructor_ with arguments _proto_ and _constructorParent_. 1. Let _F_ be _constructorInfo_.[[Closure]]. 1. Perform SetFunctionName(_F_, _className_). @@ -20771,9 +20800,9 @@

Runtime Semantics: ClassDefinitionEvaluation

1. Else, 1. Let _status_ be PropertyDefinitionEvaluation of _m_ with arguments _F_ and *false*. 1. If _status_ is an abrupt completion, then - 1. Set the running execution context's LexicalEnvironment to _env_. + 1. Set the [[LexicalEnvironment]] field of the running execution context to _env_. 1. Return Completion(_status_). - 1. Set the running execution context's LexicalEnvironment to _env_. + 1. Set the [[LexicalEnvironment]] field of the running execution context to _env_. 1. If _classBinding_ is not *undefined*, then 1. Perform _classScope_.InitializeBinding(_classBinding_, _F_). 1. Return _F_. @@ -20787,7 +20816,7 @@

Runtime Semantics: BindingClassDeclarationEvaluation

1. Let _className_ be StringValue of |BindingIdentifier|. 1. Let _value_ be ? ClassDefinitionEvaluation of |ClassTail| with arguments _className_ and _className_. 1. Set _value_.[[SourceText]] to the source text matched by |ClassDeclaration|. - 1. Let _env_ be the running execution context's LexicalEnvironment. + 1. Let _env_ be the [[LexicalEnvironment]] field of the running execution context. 1. Perform ? InitializeBoundName(_className_, _value_, _env_). 1. Return _value_.
@@ -20930,7 +20959,7 @@

Runtime Semantics: InstantiateAsyncFunctionExpression

1. If _name_ is not present, set _name_ to *""*. - 1. Let _scope_ be the LexicalEnvironment of the running execution context. + 1. Let _scope_ be the [[LexicalEnvironment]] field of the running execution context. 1. Let _sourceText_ be the source text matched by |AsyncFunctionExpression|. 1. Let _closure_ be ! OrdinaryFunctionCreate(%AsyncFunction.prototype%, _sourceText_, |FormalParameters|, |AsyncFunctionBody|, ~non-lexical-this~, _scope_). 1. Perform SetFunctionName(_closure_, _name_). @@ -20942,7 +20971,7 @@

Runtime Semantics: InstantiateAsyncFunctionExpression

1. Assert: _name_ is not present. 1. Set _name_ to StringValue of |BindingIdentifier|. - 1. Let _scope_ be the LexicalEnvironment of the running execution context. + 1. Let _scope_ be the [[LexicalEnvironment]] field of the running execution context. 1. Let _funcEnv_ be ! NewDeclarativeEnvironment(_scope_). 1. Perform ! _funcEnv_.CreateImmutableBinding(_name_, *false*). 1. Let _sourceText_ be the source text matched by |AsyncFunctionExpression|. @@ -21103,7 +21132,7 @@

Runtime Semantics: InstantiateAsyncArrowFunctionExpression

1. If _name_ is not present, set _name_ to *""*. - 1. Let _scope_ be the LexicalEnvironment of the running execution context. + 1. Let _scope_ be the [[LexicalEnvironment]] field of the running execution context. 1. Let _sourceText_ be the source text matched by |AsyncArrowFunction|. 1. Let _parameters_ be |AsyncArrowBindingIdentifier|. 1. Let _closure_ be ! OrdinaryFunctionCreate(%AsyncFunction.prototype%, _sourceText_, _parameters_, |AsyncConciseBody|, ~lexical-this~, _scope_). @@ -21115,7 +21144,7 @@

Runtime Semantics: InstantiateAsyncArrowFunctionExpression

1. If _name_ is not present, set _name_ to *""*. - 1. Let _scope_ be the LexicalEnvironment of the running execution context. + 1. Let _scope_ be the [[LexicalEnvironment]] field of the running execution context. 1. Let _sourceText_ be the source text matched by |AsyncArrowFunction|. 1. Let _head_ be CoveredAsyncArrowHead of |CoverCallExpressionAndAsyncArrowHead|. 1. Let _parameters_ be the |ArrowFormalParameters| of _head_. @@ -21648,12 +21677,12 @@

ScriptEvaluation ( _scriptRecord_ )

1. Let _globalEnv_ be _scriptRecord_.[[Realm]].[[GlobalEnv]]. - 1. Let _scriptContext_ be a new ECMAScript code execution context. - 1. Set the Function of _scriptContext_ to *null*. - 1. Set the Realm of _scriptContext_ to _scriptRecord_.[[Realm]]. - 1. Set the ScriptOrModule of _scriptContext_ to _scriptRecord_. - 1. Set the VariableEnvironment of _scriptContext_ to _globalEnv_. - 1. Set the LexicalEnvironment of _scriptContext_ to _globalEnv_. + 1. Let _scriptContext_ be a new ECMAScript code ExecutionContext Record. + 1. Set _scriptContext_.[[Function]] to *null*. + 1. Set _scriptContext_.[[Realm]] to _scriptRecord_.[[Realm]]. + 1. Set _scriptContext_.[[ScriptOrModule]] to _scriptRecord_. + 1. Set _scriptContext_.[[VariableEnvironment]] to _globalEnv_. + 1. Set _scriptContext_.[[LexicalEnvironment]] to _globalEnv_. 1. Suspend the currently running execution context. 1. Push _scriptContext_ onto the execution context stack; _scriptContext_ is now the running execution context. 1. Let _scriptBody_ be _scriptRecord_.[[ECMAScriptCode]]. @@ -22899,13 +22928,13 @@

InitializeEnvironment ( ) Concrete Method

1. Call _env_.InitializeBinding(_in_.[[LocalName]], _namespace_). 1. Else, 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. Let _moduleContext_ be a new ECMAScript code ExecutionContext Record. + 1. Set _moduleContext_.[[Function]] to *null*. 1. Assert: _module_.[[Realm]] is not *undefined*. - 1. Set the Realm of _moduleContext_ to _module_.[[Realm]]. - 1. Set the ScriptOrModule of _moduleContext_ to _module_. - 1. Set the VariableEnvironment of _moduleContext_ to _module_.[[Environment]]. - 1. Set the LexicalEnvironment of _moduleContext_ to _module_.[[Environment]]. + 1. Set _moduleContext_.[[Realm]] to _module_.[[Realm]]. + 1. Set _moduleContext_.[[ScriptOrModule]] to _module_. + 1. Set _moduleContext_.[[VariableEnvironment]] to _module_.[[Environment]]. + 1. Set _moduleContext_.[[LexicalEnvironment]] to _module_.[[Environment]]. 1. Set _module_.[[Context]] to _moduleContext_. 1. Push _moduleContext_ onto the execution context stack; _moduleContext_ is now the running execution context. 1. Let _code_ be _module_.[[ECMAScriptCode]]. @@ -23577,7 +23606,7 @@

Runtime Semantics: Evaluation

1. Let _value_ be ? BindingClassDeclarationEvaluation of |ClassDeclaration|. 1. Let _className_ be the sole element of BoundNames of |ClassDeclaration|. 1. If _className_ is *"\*default\*"*, then - 1. Let _env_ be the running execution context's LexicalEnvironment. + 1. Let _env_ be the [[LexicalEnvironment]] field of the running execution context. 1. Perform ? InitializeBoundName(*"\*default\*"*, _value_, _env_). 1. Return NormalCompletion(~empty~).
@@ -23588,7 +23617,7 @@

Runtime Semantics: Evaluation

1. Else, 1. Let _rhs_ be the result of evaluating |AssignmentExpression|. 1. Let _value_ be ? GetValue(_rhs_). - 1. Let _env_ be the running execution context's LexicalEnvironment. + 1. Let _env_ be the [[LexicalEnvironment]] field of the running execution context. 1. Perform ? InitializeBoundName(*"\*default\*"*, _value_, _env_). 1. Return NormalCompletion(~empty~).
@@ -23724,7 +23753,7 @@

eval ( _x_ )

1. Assert: The execution context stack has at least two elements. 1. Let _callerContext_ be the second to top element of the execution context stack. - 1. Let _callerRealm_ be _callerContext_'s Realm. + 1. Let _callerRealm_ be _callerContext_.[[Realm]]. 1. Return ? PerformEval(_x_, _callerRealm_, *false*, *false*). @@ -23759,19 +23788,19 @@

PerformEval ( _x_, _callerRealm_, _strictCaller_, _direct_ )

1. Let _runningContext_ be the running execution context. 1. NOTE: If _direct_ is *true*, _runningContext_ will be the execution context that performed the direct eval. If _direct_ is *false*, _runningContext_ will be the execution context for the invocation of the `eval` function. 1. If _direct_ is *true*, then - 1. Let _lexEnv_ be NewDeclarativeEnvironment(_runningContext_'s LexicalEnvironment). - 1. Let _varEnv_ be _runningContext_'s VariableEnvironment. + 1. Let _lexEnv_ be NewDeclarativeEnvironment(_runningContext_.[[LexicalEnvironment]]). + 1. Let _varEnv_ be _runningContext_.[[VariableEnvironment]]. 1. Else, 1. Let _lexEnv_ be NewDeclarativeEnvironment(_evalRealm_.[[GlobalEnv]]). 1. Let _varEnv_ be _evalRealm_.[[GlobalEnv]]. 1. If _strictEval_ is *true*, set _varEnv_ to _lexEnv_. 1. If _runningContext_ is not already suspended, suspend _runningContext_. - 1. Let _evalContext_ be a new ECMAScript code execution context. - 1. Set _evalContext_'s Function to *null*. - 1. Set _evalContext_'s Realm to _evalRealm_. - 1. Set _evalContext_'s ScriptOrModule to _runningContext_'s ScriptOrModule. - 1. Set _evalContext_'s VariableEnvironment to _varEnv_. - 1. Set _evalContext_'s LexicalEnvironment to _lexEnv_. + 1. Let _evalContext_ be a new ECMAScript code ExecutionContext Record. + 1. Set _evalContext_.[[Function]] to *null*. + 1. Set _evalContext_.[[Realm]] to _evalRealm_. + 1. Set _evalContext_.[[ScriptOrModule]] to _runningContext_.[[ScriptOrModule]]. + 1. Set _evalContext_.[[VariableEnvironment]] to _varEnv_. + 1. Set _evalContext_.[[LexicalEnvironment]] to _lexEnv_. 1. Push _evalContext_ onto the execution context stack; _evalContext_ is now the running execution context. 1. Let _result_ be EvalDeclarationInstantiation(_body_, _varEnv_, _lexEnv_, _strictEval_). 1. If _result_.[[Type]] is ~normal~, then @@ -23783,7 +23812,7 @@

PerformEval ( _x_, _callerRealm_, _strictCaller_, _direct_ )

1. Return Completion(_result_).
-

The eval code cannot instantiate variable or function bindings in the variable environment of the calling context that invoked the eval if the calling context is evaluating formal parameter initializers or if either the code of the calling context or the eval code is strict mode code. Instead such bindings are instantiated in a new VariableEnvironment that is only accessible to the eval code. Bindings introduced by `let`, `const`, or `class` declarations are always instantiated in a new LexicalEnvironment.

+

The eval code cannot instantiate variable or function bindings in the variable environment of the calling context that invoked the eval if the calling context is evaluating formal parameter initializers or if either the code of the calling context or the eval code is strict mode code. Instead such bindings are instantiated in a new [[VariableEnvironment]] that is only accessible to the eval code. Bindings introduced by `let`, `const`, or `class` declarations are always instantiated in a new [[LexicalEnvironment]].

@@ -25021,7 +25050,7 @@

CreateDynamicFunction ( _constructor_, _newTarget_, _kind_, _args_ )

1. Assert: The execution context stack has at least two elements. 1. Let _callerContext_ be the second to top element of the execution context stack. - 1. Let _callerRealm_ be _callerContext_'s Realm. + 1. Let _callerRealm_ be _callerContext_.[[Realm]]. 1. Let _calleeRealm_ be the current Realm Record. 1. Perform ? HostEnsureCanCompileStrings(_callerRealm_, _calleeRealm_). 1. If _newTarget_ is *undefined*, set _newTarget_ to _constructor_. @@ -38794,8 +38823,8 @@

GeneratorStart ( _generator_, _generatorBody_ )

1. Assert: The value of _generator_.[[GeneratorState]] is *undefined*. 1. Let _genContext_ be the running execution context. - 1. Set the Generator component of _genContext_ to _generator_. - 1. Set the code evaluation state of _genContext_ such that when evaluation is resumed for that execution context the following steps will be performed: + 1. Set _genContext_.[[Generator]] to _generator_. + 1. Set _genContext_.[[CodeEvaluationState]] such that when evaluation is resumed for that execution context the following steps will be performed: 1. If _generatorBody_ is a Parse Node, then 1. Let _result_ be the result of evaluating _generatorBody_. 1. Else, @@ -38879,8 +38908,8 @@

GetGeneratorKind ( )

The abstract operation GetGeneratorKind takes no arguments. It performs the following steps when called:

1. Let _genContext_ be the running execution context. - 1. If _genContext_ does not have a Generator component, return ~non-generator~. - 1. Let _generator_ be the Generator component of _genContext_. + 1. If _genContext_ does not have a [[Generator]] field, return ~non-generator~. + 1. Let _generator_ be _genContext_.[[Generator]]. 1. If _generator_ has an [[AsyncGeneratorState]] internal slot, return ~async~. 1. Else, return ~sync~. @@ -38893,11 +38922,11 @@

GeneratorYield ( _iterNextObj_ )

1. Assert: _iterNextObj_ is an Object that implements the IteratorResult interface. 1. Let _genContext_ be the running execution context. 1. Assert: _genContext_ is the execution context of a generator. - 1. Let _generator_ be the value of the Generator component of _genContext_. + 1. Let _generator_ be _genContext_.[[Generator]]. 1. Assert: GetGeneratorKind() is ~sync~. 1. Set _generator_.[[GeneratorState]] to ~suspendedYield~. 1. Remove _genContext_ from the execution context stack and restore the execution context that is at the top of the execution context stack as the running execution context. - 1. Set the code evaluation state of _genContext_ such that when evaluation is resumed with a Completion _resumptionValue_ the following steps will be performed: + 1. Set _genContext_.[[CodeEvaluationState]] such that when evaluation is resumed with a Completion _resumptionValue_ the following steps will be performed: 1. Return _resumptionValue_. 1. NOTE: This returns to the evaluation of the |YieldExpression| that originally called this abstract operation. 1. Return NormalCompletion(_iterNextObj_). @@ -39055,8 +39084,8 @@

AsyncGeneratorStart ( _generator_, _generatorBody_ )

1. Assert: _generator_ is an AsyncGenerator instance. 1. Assert: _generator_.[[AsyncGeneratorState]] is *undefined*. 1. Let _genContext_ be the running execution context. - 1. Set the Generator component of _genContext_ to _generator_. - 1. Set the code evaluation state of _genContext_ such that when evaluation is resumed for that execution context the following steps will be performed: + 1. Set _genContext_.[[Generator]] to _generator_. + 1. Set _genContext_.[[CodeEvaluationState]] such that when evaluation is resumed for that execution context the following steps will be performed: 1. If _generatorBody_ is a Parse Node, then 1. Let _result_ be the result of evaluating _generatorBody_. 1. Else, @@ -39223,12 +39252,12 @@

AsyncGeneratorYield ( _value_ )

1. Let _genContext_ be the running execution context. 1. Assert: _genContext_ is the execution context of a generator. - 1. Let _generator_ be the value of the Generator component of _genContext_. + 1. Let _generator_ be _genContext_.[[Generator]]. 1. Assert: GetGeneratorKind() is ~async~. 1. Set _value_ to ? Await(_value_). 1. Set _generator_.[[AsyncGeneratorState]] to ~suspendedYield~. 1. Remove _genContext_ from the execution context stack and restore the execution context that is at the top of the execution context stack as the running execution context. - 1. Set the code evaluation state of _genContext_ such that when evaluation is resumed with a Completion _resumptionValue_ the following steps will be performed: + 1. Set _genContext_.[[CodeEvaluationState]] such that when evaluation is resumed with a Completion _resumptionValue_ the following steps will be performed: 1. If _resumptionValue_.[[Type]] is not ~return~, return Completion(_resumptionValue_). 1. Let _awaited_ be Await(_resumptionValue_.[[Value]]). 1. If _awaited_.[[Type]] is ~throw~, return Completion(_awaited_). @@ -39363,7 +39392,7 @@

AsyncFunctionStart ( _promiseCapability_, _asyncFunctionBody_ )

1. Let _runningContext_ be the running execution context. 1. Let _asyncContext_ be a copy of _runningContext_. 1. NOTE: Copying the execution state is required for the step below to resume its execution. It is ill-defined to resume a currently executing context. - 1. Set the code evaluation state of _asyncContext_ such that when evaluation is resumed for that execution context the following steps will be performed: + 1. Set _asyncContext_.[[CodeEvaluationState]] such that when evaluation is resumed for that execution context the following steps will be performed: 1. Let _result_ be the result of evaluating _asyncFunctionBody_. 1. Assert: If we return here, the async function either threw an exception or performed an implicit or explicit return; all awaiting is done. 1. Remove _asyncContext_ from the execution context stack and restore the execution context that is at the top of the execution context stack as the running execution context. @@ -41732,8 +41761,8 @@

Changes to FunctionDeclarationInstantiation

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 _benv_ be the running execution context's LexicalEnvironment. + 1. Let _fenv_ be the [[VariableEnvironment]] field of the running execution context. + 1. Let _benv_ be the [[LexicalEnvironment]] field of the running execution context. 1. Let _fobj_ be ! _benv_.GetBindingValue(_F_, *false*). 1. Perform ! _fenv_.SetMutableBinding(_F_, _fobj_, *false*). 1. Return NormalCompletion(~empty~). @@ -41759,8 +41788,8 @@

Changes to GlobalDeclarationInstantiation

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 _benv_ be the running execution context's LexicalEnvironment. + 1. Let _genv_ be the [[VariableEnvironment]] field of the running execution context. + 1. Let _benv_ be the [[LexicalEnvironment]] field of the running execution context. 1. Let _fobj_ be ! _benv_.GetBindingValue(_F_, *false*). 1. Perform ? _genv_.SetMutableBinding(_F_, _fobj_, *false*). 1. Return NormalCompletion(~empty~). @@ -41803,8 +41832,8 @@

Changes to EvalDeclarationInstantiation

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 _benv_ be the running execution context's LexicalEnvironment. + 1. Let _genv_ be the [[VariableEnvironment]] field of the running execution context. + 1. Let _benv_ be the [[LexicalEnvironment]] field of the running execution context. 1. Let _fobj_ be ! _benv_.GetBindingValue(_F_, *false*). 1. Perform ? _genv_.SetMutableBinding(_F_, _fobj_, *false*). 1. Return NormalCompletion(~empty~).