From 1cf200548e8d5fa72131e0453d1b788320cf900d Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 22 Jun 2023 15:08:02 -0400 Subject: [PATCH] Update to latest version of ECMA-262 --- spec.emu | 505 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 267 insertions(+), 238 deletions(-) diff --git a/spec.emu b/spec.emu index a407eea..e25282e 100644 --- a/spec.emu +++ b/spec.emu @@ -875,17 +875,14 @@ contributors: Ron Buckton, Ecma International

InitializeReferencedBinding ( - _V_: unknown, - _W_: unknown, + _V_: a Reference Record, + _W_: a Reference Record, _hint_: one of ~normal~, ~sync-dispose~, or ~async-dispose~, ): either a normal completion containing ~unused~ or an abrupt completion

- 1. ReturnIfAbrupt(_V_). - 1. ReturnIfAbrupt(_W_). - 1. Assert: _V_ is a Reference Record. 1. Assert: IsUnresolvableReference(_V_) is *false*. 1. Let _base_ be _V_.[[Base]]. 1. Assert: _base_ is an Environment Record. @@ -975,7 +972,7 @@ contributors: Ron Buckton, Ecma International ~sync-dispose~ or ~async-dispose~. - Indicates whether the resource was added by a `using` declaration or DisposableStack object (~sync-dispose~) or a `await using` declaration or AsyncDisposableStack object (~async-dispose~). + Indicates whether the resource was added by a `using` declaration or DisposableStack object (~sync-dispose~) or by an `await using` declaration or AsyncDisposableStack object (~async-dispose~). @@ -1103,8 +1100,8 @@ contributors: Ron Buckton, Ecma International 1. Set _result_ to _result_.[[Value]]. 1. Let _suppressed_ be _completion_.[[Value]]. 1. Let _error_ be a newly created *SuppressedError* object. - 1. Perform ! CreateNonEnumerableDataPropertyOrThrow(_error_, *"error"*, _result_). - 1. Perform ! CreateNonEnumerableDataPropertyOrThrow(_error_, *"suppressed"*, _suppressed_). + 1. Perform CreateNonEnumerableDataPropertyOrThrow(_error_, *"error"*, _result_). + 1. Perform CreateNonEnumerableDataPropertyOrThrow(_error_, *"suppressed"*, _suppressed_). 1. Set _completion_ to ThrowCompletion(_error_). 1. Else, 1. Set _completion_ to _result_. @@ -1133,11 +1130,11 @@ contributors: Ron Buckton, Ecma International BindingIdentifier : `yield` - 1. Return « *"yield"* ». + 1. Return « *"yield"* ». BindingIdentifier : `await` - 1. Return « *"await"* ». + 1. Return « *"await"* ». LexicalDeclaration : LetOrConst BindingList `;` @@ -1249,7 +1246,7 @@ contributors: Ron Buckton, Ecma International FunctionDeclaration : `function` `(` FormalParameters `)` `{` FunctionBody `}` - 1. Return « *"\*default\*"* ». + 1. Return « *"\*default\*"* ». FormalParameters : [empty] @@ -1278,7 +1275,7 @@ contributors: Ron Buckton, Ecma International GeneratorDeclaration : `function` `*` `(` FormalParameters `)` `{` GeneratorBody `}` - 1. Return « *"\*default\*"* ». + 1. Return « *"\*default\*"* ». AsyncGeneratorDeclaration : `async` `function` `*` BindingIdentifier `(` FormalParameters `)` `{` AsyncGeneratorBody `}` @@ -1286,7 +1283,7 @@ contributors: Ron Buckton, Ecma International AsyncGeneratorDeclaration : `async` `function` `*` `(` FormalParameters `)` `{` AsyncGeneratorBody `}` - 1. Return « *"\*default\*"* ». + 1. Return « *"\*default\*"* ». ClassDeclaration : `class` BindingIdentifier ClassTail @@ -1294,7 +1291,7 @@ contributors: Ron Buckton, Ecma International ClassDeclaration : `class` ClassTail - 1. Return « *"\*default\*"* ». + 1. Return « *"\*default\*"* ». AsyncFunctionDeclaration : `async` `function` BindingIdentifier `(` FormalParameters `)` `{` AsyncFunctionBody `}` @@ -1306,7 +1303,7 @@ contributors: Ron Buckton, Ecma International AsyncFunctionDeclaration : `async` `function` `(` FormalParameters `)` `{` AsyncFunctionBody `}` - 1. Return « *"\*default\*"* ». + 1. Return « *"\*default\*"* ». CoverCallExpressionAndAsyncArrowHead : MemberExpression Arguments @@ -1379,7 +1376,7 @@ contributors: Ron Buckton, Ecma International ExportDeclaration : `export` `default` AssignmentExpression `;` - 1. Return « *"\*default\*"* ». + 1. Return « *"\*default\*"* ».
@@ -1748,8 +1745,8 @@ contributors: Ron Buckton, Ecma International

Runtime Semantics: IteratorBindingInitialization ( - _iteratorRecord_: unknown, - _environment_: unknown, + _iteratorRecord_: an Iterator Record, + _environment_: an Environment Record or *undefined*, ): either a normal completion containing ~unused~ or an abrupt completion

@@ -1802,7 +1799,8 @@ contributors: Ron Buckton, Ecma International 1. Let _next_ be Completion(IteratorStep(_iteratorRecord_)). 1. If _next_ is an abrupt completion, set _iteratorRecord_.[[Done]] to *true*. 1. ReturnIfAbrupt(_next_). - 1. If _next_ is *false*, set _iteratorRecord_.[[Done]] to *true*. + 1. If _next_ is *false*, then + 1. Set _iteratorRecord_.[[Done]] to *true*. 1. Else, 1. Set _v_ to Completion(IteratorValue(_next_)). 1. If _v_ is an abrupt completion, set _iteratorRecord_.[[Done]] to *true*. @@ -1811,7 +1809,7 @@ contributors: Ron Buckton, Ecma International 1. If IsAnonymousFunctionDefinition(|Initializer|) is *true*, then 1. Set _v_ to ? NamedEvaluation of |Initializer| with argument _bindingId_. 1. Else, - 1. Let _defaultValue_ be the result of evaluating |Initializer|. + 1. Let _defaultValue_ be ? Evaluation of |Initializer|. 1. Set _v_ to ? GetValue(_defaultValue_). 1. If _environment_ is *undefined*, return ? PutValue(_lhs_, _v_). 1. Return ? InitializeReferencedBinding(_lhs_, _v_, ~normal~). @@ -1823,13 +1821,14 @@ contributors: Ron Buckton, Ecma International 1. Let _next_ be Completion(IteratorStep(_iteratorRecord_)). 1. If _next_ is an abrupt completion, set _iteratorRecord_.[[Done]] to *true*. 1. ReturnIfAbrupt(_next_). - 1. If _next_ is *false*, set _iteratorRecord_.[[Done]] to *true*. + 1. If _next_ is *false*, then + 1. Set _iteratorRecord_.[[Done]] to *true*. 1. Else, 1. Set _v_ to Completion(IteratorValue(_next_)). 1. If _v_ is an abrupt completion, set _iteratorRecord_.[[Done]] to *true*. 1. ReturnIfAbrupt(_v_). 1. If |Initializer| is present and _v_ is *undefined*, then - 1. Let _defaultValue_ be the result of evaluating |Initializer|. + 1. Let _defaultValue_ be ? Evaluation of |Initializer|. 1. Set _v_ to ? GetValue(_defaultValue_). 1. Return ? BindingInitialization of |BindingPattern| with arguments _v_ and _environment_. @@ -1892,7 +1891,8 @@ contributors: Ron Buckton, Ecma International 1. Let _next_ be Completion(IteratorStep(_iteratorRecord_)). 1. If _next_ is an abrupt completion, set _iteratorRecord_.[[Done]] to *true*. 1. ReturnIfAbrupt(_next_). - 1. If _next_ is *false*, set _iteratorRecord_.[[Done]] to *true*. + 1. If _next_ is *false*, then + 1. Set _iteratorRecord_.[[Done]] to *true*. 1. Else, 1. Set _v_ to Completion(IteratorValue(_next_)). 1. If _v_ is an abrupt completion, set _iteratorRecord_.[[Done]] to *true*. @@ -1913,7 +1913,8 @@ contributors: Ron Buckton, Ecma International 1. Let _next_ be Completion(IteratorStep(_iteratorRecord_)). 1. If _next_ is an abrupt completion, set _iteratorRecord_.[[Done]] to *true*. 1. ReturnIfAbrupt(_next_). - 1. If _next_ is *false*, set _iteratorRecord_.[[Done]] to *true*. + 1. If _next_ is *false*, then + 1. Set _iteratorRecord_.[[Done]] to *true*. 1. Else, 1. Set _v_ to Completion(IteratorValue(_next_)). 1. If _v_ is an abrupt completion, set _iteratorRecord_.[[Done]] to *true*. @@ -2092,7 +2093,7 @@ contributors: Ron Buckton, Ecma International

Executable Code and Execution Contexts

Environment Records

-

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. 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|. Each time such code is evaluated, a new Environment Record is created to record the identifier bindings that are created by that code.

+

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. 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|. Each time such code is evaluated, a new Environment Record is created to record the identifier bindings that are created by that code.

Every Environment Record has an [[OuterEnv]] field, which is either *null* or a reference to an outer Environment Record. This is used to model the logical nesting of Environment Record values. The outer reference of an (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.

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.

@@ -2101,7 +2102,6 @@ contributors: Ron Buckton, Ecma International

The Environment Record abstract class includes the abstract specification methods defined in . These abstract methods have distinct concrete algorithms for each of the concrete subclasses.

- -
Method @@ -2190,15 +2190,14 @@ contributors: Ron Buckton, Ecma International If this Environment Record is associated with a `with` statement, return the with object. Otherwise, return *undefined*.

Declarative Environment Records

-

Each declarative Environment Record is associated with an ECMAScript program scope containing variable, constant, let, class, module, import, and/or function declarations. A declarative Environment Record binds the set of identifiers defined by the declarations contained within its scope.

-

Every Declarative Environment Record also has a [[DisposeCapability]] field, which contains a DisposeCapability Record. This field holds a stack of resources tracked by the `using` declarations and `await using` declarations that must be disposed when the Evaluation step that constructed the Environment Record has completed.

-

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

+

Each Declarative Environment Record is associated with an ECMAScript program scope containing variable, constant, let, class, module, import, and/or function declarations. A Declarative Environment Record binds the set of identifiers defined by the declarations contained within its scope.

+

Every Declarative Environment Record also has a [[DisposeCapability]] field, which contains a DisposeCapability Record. This field holds a stack of resources tracked by `using` declarations and `await using` declarations that must be disposed when the Evaluation step that constructed the Environment Record has completed.

+

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

@@ -2210,10 +2209,10 @@ contributors: Ron Buckton, Ecma International

for
-
a declarative Environment Record _envRec_
+
a Declarative Environment Record _envRec_
description
-
It is used to set the bound value of the current binding of the identifier whose name is the value of the argument _N_ to the value of argument _V_. An uninitialized binding for _N_ must already exist.
+
It is used to set the bound value of the current binding of the identifier whose name is _N_ to the value _V_. An uninitialized binding for _N_ must already exist.
1. Assert: _envRec_ must have an uninitialized binding for _N_. @@ -2316,15 +2315,15 @@ contributors: Ron Buckton, Ecma International

FunctionDeclarationInstantiation ( _func_: a function object, - _argumentsList_: unknown, - ) + _argumentsList_: a List of ECMAScript language values, + ): either a normal completion containing ~unused~ or an abrupt completion

description
_func_ is the function object for which the execution context is being established.
-

When an execution context is established for evaluating an ECMAScript function a new function Environment Record is created and bindings for each formal parameter are instantiated in that Environment Record. Each declaration in the function body is also instantiated. If the function's formal parameters do not include any default value initializers then the body declarations are instantiated in the same Environment Record as the parameters. If default value parameter initializers exist, a second Environment Record is created for the body declarations. Formal parameters and functions are initialized as part of FunctionDeclarationInstantiation. All other bindings are initialized during evaluation of the function body.

+

When an execution context is established for evaluating an ECMAScript function a new Function Environment Record is created and bindings for each formal parameter are instantiated in that Environment Record. Each declaration in the function body is also instantiated. If the function's formal parameters do not include any default value initializers then the body declarations are instantiated in the same Environment Record as the parameters. If default value parameter initializers exist, a second Environment Record is created for the body declarations. Formal parameters and functions are initialized as part of FunctionDeclarationInstantiation. All other bindings are initialized during evaluation of the function body.

It performs the following steps when called: