diff --git a/spec.html b/spec.html index 9823aaa49e..6e5272fb21 100644 --- a/spec.html +++ b/spec.html @@ -10592,14 +10592,6 @@

Function Environment Records

- - - BindThisValue(V) - - - Set the [[ThisValue]] and record that it has been initialized. - - GetThisBinding() @@ -10608,34 +10600,27 @@

Function Environment Records

Return the value of this Environment Record's `this` binding. Throws a *ReferenceError* if the `this` binding has not been initialized. - - - GetSuperBase() - - - Return the object that is the base for `super` property accesses bound in this Environment Record. The value *undefined* indicates that such accesses will produce runtime errors. - -

The behaviour of the additional concrete specification methods for Function Environment Records is defined by the following algorithms:

- +

BindThisValue ( + _envRec_: a Function Environment Record, _V_: an ECMAScript language value, - ): either a normal completion containing an ECMAScript language value or a throw completion + ): either a normal completion containing ~unused~ or a throw completion

-
for
-
a Function Environment Record _envRec_
+
description
+
It sets the _envRec_.[[ThisValue]] and records that it has been initialized.
1. Assert: _envRec_.[[ThisBindingStatus]] is not ~lexical~. 1. If _envRec_.[[ThisBindingStatus]] is ~initialized~, throw a *ReferenceError* exception. 1. Set _envRec_.[[ThisValue]] to _V_. 1. Set _envRec_.[[ThisBindingStatus]] to ~initialized~. - 1. Return _V_. + 1. Return ~unused~.
@@ -10675,11 +10660,15 @@

GetThisBinding ( ): either a normal completion containing an ECMAScript lang - -

GetSuperBase ( ): either a normal completion containing either an Object, *null*, or *undefined*, or a throw completion

+ +

+ GetSuperBase ( + _envRec_: a Function Environment Record, + ): either a normal completion containing either an Object, *null*, or *undefined*, or a throw completion +

-
for
-
a Function Environment Record _envRec_
+
description
+
It returns the object that is the base for `super` property accesses bound in _envRec_. The value *undefined* indicates that such accesses will produce runtime errors.
1. Let _home_ be _envRec_.[[FunctionObject]].[[HomeObject]]. @@ -10694,7 +10683,7 @@

GetSuperBase ( ): either a normal completion containing either an Object, *n

Global Environment Records

A Global Environment Record is used to represent the outer most scope that is shared by all of the ECMAScript |Script| elements that are processed in a common realm. A Global Environment Record provides the bindings for built-in globals (clause ), properties of the global object, and for all top-level declarations (, ) that occur within a |Script|.

A Global Environment Record is logically a single record but it is specified as a composite encapsulating an Object Environment Record and a Declarative Environment Record. The Object Environment Record has as its base object the global object of the associated Realm Record. This global object is the value returned by the Global Environment Record's GetThisBinding concrete method. The Object Environment Record component of a Global Environment Record contains the bindings for all built-in globals (clause ) and all bindings introduced by a |FunctionDeclaration|, |GeneratorDeclaration|, |AsyncFunctionDeclaration|, |AsyncGeneratorDeclaration|, or |VariableStatement| contained in global code. The bindings for all other ECMAScript declarations in global code are contained in the Declarative Environment Record component of the Global Environment Record.

-

Properties may be created directly on a global object. Hence, the Object Environment Record component of a Global Environment Record may contain both bindings created explicitly by |FunctionDeclaration|, |GeneratorDeclaration|, |AsyncFunctionDeclaration|, |AsyncGeneratorDeclaration|, or |VariableDeclaration| declarations and bindings created implicitly as properties of the global object. In order to identify which bindings were explicitly created using declarations, a Global Environment Record maintains a list of the names bound using its CreateGlobalVarBinding and CreateGlobalFunctionBinding concrete methods.

+

Properties may be created directly on a global object. Hence, the Object Environment Record component of a Global Environment Record may contain both bindings created explicitly by |FunctionDeclaration|, |GeneratorDeclaration|, |AsyncFunctionDeclaration|, |AsyncGeneratorDeclaration|, or |VariableDeclaration| declarations and bindings created implicitly as properties of the global object. In order to identify which bindings were explicitly created using declarations, a Global Environment Record maintains a list of the names bound using the CreateGlobalVarBinding and CreateGlobalFunctionBinding abstract operations.

Global Environment Records have the additional fields listed in and the additional methods listed in .

@@ -10777,62 +10766,6 @@

Global Environment Records

Return the value of this Environment Record's `this` binding. - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- HasVarDeclaration (N) - - Determines if the argument identifier has a binding in this Environment Record that was created using a |VariableDeclaration|, |FunctionDeclaration|, |GeneratorDeclaration|, |AsyncFunctionDeclaration|, or |AsyncGeneratorDeclaration|. -
- HasLexicalDeclaration (N) - - Determines if the argument identifier has a binding in this Environment Record that was created using a lexical declaration such as a |LexicalDeclaration| or a |ClassDeclaration|. -
- HasRestrictedGlobalProperty (N) - - Determines if the argument is the name of a global object property that may not be shadowed by a global lexical binding. -
- CanDeclareGlobalVar (N) - - Determines if a corresponding CreateGlobalVarBinding call would succeed if called for the same argument _N_. -
- CanDeclareGlobalFunction (N) - - Determines if a corresponding CreateGlobalFunctionBinding call would succeed if called for the same argument _N_. -
- CreateGlobalVarBinding(N, D) - - Used to create and initialize to *undefined* a global `var` binding in the [[ObjectRecord]] component of a Global Environment Record. The binding will be a mutable binding. The corresponding global object property will have attribute values appropriate for a `var`. The String value _N_ is the bound name. If _D_ is *true*, the binding may be deleted. Logically equivalent to CreateMutableBinding followed by a SetMutableBinding but it allows var declarations to receive special treatment. -
- CreateGlobalFunctionBinding(N, V, D) - - Create and initialize a global `function` binding in the [[ObjectRecord]] component of a Global Environment Record. The binding will be a mutable binding. The corresponding global object property will have attribute values appropriate for a `function`. The String value _N_ is the bound name. _V_ is the initialization value. If the Boolean argument _D_ is *true*, the binding may be deleted. Logically equivalent to CreateMutableBinding followed by a SetMutableBinding but it allows function declarations to receive special treatment. -

The behaviour of the concrete specification methods for Global Environment Records is defined by the following algorithms.

@@ -11050,18 +10983,16 @@

GetThisBinding ( ): a normal completion containing an Object

- +

HasVarDeclaration ( + _envRec_: a Global Environment Record, _N_: a String, ): a Boolean

-
for
-
a Global Environment Record _envRec_
-
description
-
It determines if the argument identifier has a binding in this record that was created using a |VariableStatement| or a |FunctionDeclaration|.
+
It determines if the argument identifier has a binding in _envRec_ that was created using a |VariableDeclaration|, |FunctionDeclaration|, |GeneratorDeclaration|, |AsyncFunctionDeclaration|, or |AsyncGeneratorDeclaration|.
1. Let _varDeclaredNames_ be _envRec_.[[VarNames]]. @@ -11070,18 +11001,16 @@

- +

HasLexicalDeclaration ( + _envRec_: a Global Environment Record, _N_: a String, ): a Boolean

-
for
-
a Global Environment Record _envRec_
-
description
-
It determines if the argument identifier has a binding in this record that was created using a lexical declaration such as a |LexicalDeclaration| or a |ClassDeclaration|.
+
It determines if the argument identifier has a binding in _envRec_ that was created using a lexical declaration such as a |LexicalDeclaration| or a |ClassDeclaration|.
1. Let _DclRec_ be _envRec_.[[DeclarativeRecord]]. @@ -11089,16 +11018,14 @@

- +

HasRestrictedGlobalProperty ( + _envRec_: a Global Environment Record, _N_: a String, ): either a normal completion containing a Boolean or a throw completion

-
for
-
a Global Environment Record _envRec_
-
description
It determines if the argument identifier is the name of a property of the global object that must not be shadowed by a global lexical binding.
@@ -11115,16 +11042,14 @@

- +

CanDeclareGlobalVar ( + _envRec_: a Global Environment Record, _N_: a String, ): either a normal completion containing a Boolean or a throw completion

-
for
-
a Global Environment Record _envRec_
-
description
It determines if a corresponding CreateGlobalVarBinding call would succeed if called for the same argument _N_. Redundant var declarations and var declarations for pre-existing global object properties are allowed.
@@ -11137,16 +11062,14 @@

- +

CanDeclareGlobalFunction ( + _envRec_: a Global Environment Record, _N_: a String, ): either a normal completion containing a Boolean or a throw completion

-
for
-
a Global Environment Record _envRec_
-
description
It determines if a corresponding CreateGlobalFunctionBinding call would succeed if called for the same argument _N_.
@@ -11161,17 +11084,15 @@

- +

CreateGlobalVarBinding ( + _envRec_: a Global Environment Record, _N_: a String, _D_: a Boolean, ): either a normal completion containing ~unused~ or a throw completion

-
for
-
a Global Environment Record _envRec_
-
description
It creates and initializes a mutable binding in the associated Object Environment Record and records the bound name in the associated [[VarNames]] List. If a binding already exists, it is reused and assumed to be initialized.
@@ -11189,18 +11110,16 @@

- +

CreateGlobalFunctionBinding ( + _envRec_: a Global Environment Record, _N_: a String, _V_: an ECMAScript language value, _D_: a Boolean, ): either a normal completion containing ~unused~ or a throw completion

-
for
-
a Global Environment Record _envRec_
-
description
It creates and initializes a mutable binding in the associated Object Environment Record and records the bound name in the associated [[VarNames]] List. If a binding already exists, it is replaced.
@@ -11240,14 +11159,6 @@

Module Environment Records

- - - CreateImportBinding(N, M, N2) - - - Create an immutable indirect binding in a Module Environment Record. The String value _N_ is the text of the bound name. _M_ is a Module Record, and _N2_ is a binding that exists in _M_'s Module Environment Record. - - GetThisBinding() @@ -11323,20 +11234,18 @@

GetThisBinding ( ): a normal completion containing *undefined*

- +

CreateImportBinding ( + _envRec_: a Module Environment Record, _N_: a String, _M_: a Module Record, _N2_: a String, ): ~unused~

-
for
-
a Module Environment Record _envRec_
-
description
-
It creates a new initialized immutable indirect binding for the name _N_. A binding must not already exist in this Environment Record for _N_. _N2_ is the name of a binding that exists in _M_'s Module Environment Record. Accesses to the value of the new binding will indirectly access the bound value of the target binding.
+
It creates a new initialized immutable indirect binding for the name _N_. A binding must not already exist in _envRec_ for _N_. _N2_ is the name of a binding that exists in _M_'s Module Environment Record. Accesses to the value of the new binding will indirectly access the bound value of the target binding.
1. Assert: _envRec_ does not already have a binding for _N_. @@ -13343,7 +13252,7 @@

1. NOTE: ToObject produces wrapper objects using _calleeRealm_. 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. Perform ! _localEnv_.BindThisValue(_thisValue_). + 1. Perform ! BindThisValue(_localEnv_, _thisValue_). 1. Return ~unused~. @@ -19344,7 +19253,7 @@

Runtime Semantics: Evaluation

1. If IsConstructor(_func_) is *false*, throw a *TypeError* exception. 1. Let _result_ be ? Construct(_func_, _argList_, _newTarget_). 1. Let _thisER_ be GetThisEnvironment(). - 1. Perform ? _thisER_.BindThisValue(_result_). + 1. Perform ? BindThisValue(_thisER_, _result_). 1. Let _F_ be _thisER_.[[FunctionObject]]. 1. Assert: _F_ is an ECMAScript function object. 1. Perform ? InitializeInstanceElements(_result_, _F_). @@ -19379,7 +19288,7 @@

1. Let _env_ be GetThisEnvironment(). 1. Assert: _env_.HasSuperBinding() is *true*. - 1. Let _baseValue_ be ? _env_.GetSuperBase(). + 1. Let _baseValue_ be ? GetSuperBase(_env_). 1. Return the Reference Record { [[Base]]: _baseValue_, [[ReferencedName]]: _propertyKey_, [[Strict]]: _strict_, [[ThisValue]]: _actualThis_ }. @@ -25981,12 +25890,12 @@

1. Let _lexNames_ be the LexicallyDeclaredNames of _script_. 1. Let _varNames_ be the VarDeclaredNames of _script_. 1. For each element _name_ of _lexNames_, do - 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 HasVarDeclaration(_env_, _name_) is *true*, throw a *SyntaxError* exception. + 1. If HasLexicalDeclaration(_env_, _name_) is *true*, throw a *SyntaxError* exception. + 1. Let _hasRestrictedGlobal_ be ? HasRestrictedGlobalProperty(_env_, _name_). 1. If _hasRestrictedGlobal_ is *true*, throw a *SyntaxError* exception. 1. For each element _name_ of _varNames_, do - 1. If _env_.HasLexicalDeclaration(_name_) is *true*, throw a *SyntaxError* exception. + 1. If HasLexicalDeclaration(_env_, _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. @@ -25996,7 +25905,7 @@

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 _declaredFunctionNames_ does not contain _fn_, then - 1. Let _fnDefinable_ be ? _env_.CanDeclareGlobalFunction(_fn_). + 1. Let _fnDefinable_ be ? CanDeclareGlobalFunction(_env_, _fn_). 1. If _fnDefinable_ is *false*, throw a *TypeError* exception. 1. Append _fn_ to _declaredFunctionNames_. 1. Insert _d_ as the first element of _functionsToInitialize_. @@ -26005,7 +25914,7 @@

1. If _d_ is either a |VariableDeclaration|, a |ForBinding|, or a |BindingIdentifier|, then 1. For each String _vn_ of the BoundNames of _d_, do 1. If _declaredFunctionNames_ does not contain _vn_, then - 1. Let _vnDefinable_ be ? _env_.CanDeclareGlobalVar(_vn_). + 1. Let _vnDefinable_ be ? CanDeclareGlobalVar(_env_, _vn_). 1. If _vnDefinable_ is *false*, throw a *TypeError* exception. 1. If _declaredVarNames_ does not contain _vn_, then 1. Append _vn_ to _declaredVarNames_. @@ -26023,9 +25932,9 @@

1. For each Parse Node _f_ of _functionsToInitialize_, do 1. Let _fn_ be the sole element of the BoundNames of _f_. 1. Let _fo_ be InstantiateFunctionObject of _f_ with arguments _env_ and _privateEnv_. - 1. Perform ? _env_.CreateGlobalFunctionBinding(_fn_, _fo_, *false*). + 1. Perform ? CreateGlobalFunctionBinding(_env_, _fn_, _fo_, *false*). 1. For each String _vn_ of _declaredVarNames_, do - 1. Perform ? _env_.CreateGlobalVarBinding(_vn_, *false*). + 1. Perform ? CreateGlobalVarBinding(_env_, _vn_, *false*). 1. Return ~unused~. @@ -28131,7 +28040,7 @@

InitializeEnvironment ( ): either a normal completion containing ~unused~ or 1. Perform ! _env_.CreateImmutableBinding(_in_.[[LocalName]], *true*). 1. Perform ! _env_.InitializeBinding(_in_.[[LocalName]], _namespace_). 1. Else, - 1. Perform _env_.CreateImportBinding(_in_.[[LocalName]], _resolution_.[[Module]], _resolution_.[[BindingName]]). + 1. Perform CreateImportBinding(_env_, _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*. @@ -29132,7 +29041,7 @@

1. If _strict_ is *false*, then 1. If _varEnv_ is a Global Environment Record, then 1. For each element _name_ of _varNames_, do - 1. If _varEnv_.HasLexicalDeclaration(_name_) is *true*, throw a *SyntaxError* exception. + 1. If HasLexicalDeclaration(_varEnv_, _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 _thisEnv_ be _lexEnv_. 1. Assert: The following loop will terminate. @@ -29161,7 +29070,7 @@

1. Let _fn_ be the sole element of the BoundNames of _d_. 1. If _declaredFunctionNames_ does not contain _fn_, then 1. If _varEnv_ is a Global Environment Record, then - 1. Let _fnDefinable_ be ? _varEnv_.CanDeclareGlobalFunction(_fn_). + 1. Let _fnDefinable_ be ? CanDeclareGlobalFunction(_varEnv_, _fn_). 1. If _fnDefinable_ is *false*, throw a *TypeError* exception. 1. Append _fn_ to _declaredFunctionNames_. 1. Insert _d_ as the first element of _functionsToInitialize_. @@ -29171,7 +29080,7 @@

1. For each String _vn_ of the BoundNames of _d_, do 1. If _declaredFunctionNames_ does not contain _vn_, then 1. If _varEnv_ is a Global Environment Record, then - 1. Let _vnDefinable_ be ? _varEnv_.CanDeclareGlobalVar(_vn_). + 1. Let _vnDefinable_ be ? CanDeclareGlobalVar(_varEnv_, _vn_). 1. If _vnDefinable_ is *false*, throw a *TypeError* exception. 1. If _declaredVarNames_ does not contain _vn_, then 1. Append _vn_ to _declaredVarNames_. @@ -29189,7 +29098,7 @@

1. Let _fn_ be the sole element of the BoundNames of _f_. 1. Let _fo_ be InstantiateFunctionObject of _f_ with arguments _lexEnv_ and _privateEnv_. 1. If _varEnv_ is a Global Environment Record, then - 1. Perform ? _varEnv_.CreateGlobalFunctionBinding(_fn_, _fo_, *true*). + 1. Perform ? CreateGlobalFunctionBinding(_varEnv_, _fn_, _fo_, *true*). 1. Else, 1. Let _bindingExists_ be ! _varEnv_.HasBinding(_fn_). 1. If _bindingExists_ is *false*, then @@ -29200,7 +29109,7 @@

1. Perform ! _varEnv_.SetMutableBinding(_fn_, _fo_, *false*). 1. For each String _vn_ of _declaredVarNames_, do 1. If _varEnv_ is a Global Environment Record, then - 1. Perform ? _varEnv_.CreateGlobalVarBinding(_vn_, *true*). + 1. Perform ? CreateGlobalVarBinding(_varEnv_, _vn_, *true*). 1. Else, 1. Let _bindingExists_ be ! _varEnv_.HasBinding(_vn_). 1. If _bindingExists_ is *false*, then @@ -51061,12 +50970,12 @@

Changes to GlobalDeclarationInstantiation

1. For each |FunctionDeclaration| _f_ that is directly contained in the |StatementList| of any |Block|, |CaseClause|, or |DefaultClause| _x_ such that _script_ Contains _x_ is *true*, do 1. Let _F_ be the 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 _env_.HasLexicalDeclaration(_F_) is *false*, then - 1. Let _fnDefinable_ be ? _env_.CanDeclareGlobalVar(_F_). + 1. If HasLexicalDeclaration(_env_, _F_) is *false*, then + 1. Let _fnDefinable_ be ? CanDeclareGlobalVar(_env_, _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 ? _env_.CreateGlobalVarBinding(_F_, *false*). + 1. Perform ? CreateGlobalVarBinding(_env_, _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. @@ -51095,8 +51004,8 @@

Changes to EvalDeclarationInstantiation

1. [id="step-evaldeclarationinstantiation-web-compat-bindingexists"] Let _bindingExists_ be *true*. 1. Set _thisEnv_ to _thisEnv_.[[OuterEnv]]. 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. If HasLexicalDeclaration(_varEnv_, _F_) is *false*, then + 1. Let _fnDefinable_ be ? CanDeclareGlobalVar(_varEnv_, _F_). 1. Else, 1. Let _fnDefinable_ be *false*. 1. Else, @@ -51104,7 +51013,7 @@

Changes to EvalDeclarationInstantiation

1. If _bindingExists_ is *false* and _fnDefinable_ is *true*, then 1. If _declaredFunctionOrVarNames_ does not contain _F_, then 1. If _varEnv_ is a Global Environment Record, then - 1. Perform ? _varEnv_.CreateGlobalVarBinding(_F_, *true*). + 1. Perform ? CreateGlobalVarBinding(_varEnv_, _F_, *true*). 1. Else, 1. Let _bindingExists_ be ! _varEnv_.HasBinding(_F_). 1. If _bindingExists_ is *false*, then