From c8f2f8f9adc6d725fd095a36d3082f8420f2c4e3 Mon Sep 17 00:00:00 2001 From: Michael Ficarra Date: Thu, 6 Jun 2019 19:27:01 -0700 Subject: [PATCH 01/11] change how ReturnIfAbrupt and its shorthands are specified --- spec.html | 84 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 57 insertions(+), 27 deletions(-) diff --git a/spec.html b/spec.html index 2c478f7d8a..150e7f32dd 100644 --- a/spec.html +++ b/spec.html @@ -787,68 +787,97 @@

Throw an Exception

ReturnIfAbrupt

-

Algorithms steps that say or are otherwise equivalent to:

+

An algorithm step that says:

- 1. ReturnIfAbrupt(_argument_). + 1. *[before]* ReturnIfAbrupt(_argument_) *[after]* -

mean the same thing as:

+

is equivalent to the sequence of steps:

1. If _argument_ is an abrupt completion, return _argument_. - 1. Else if _argument_ is a Completion Record, set _argument_ to _argument_.[[Value]]. + 1. Else, if _argument_ is a Completion Record, set _argument_ to _argument_.[[Value]]. + 1. *[before]* _argument_ *[after]* -

Algorithms steps that say or are otherwise equivalent to:

+

where

+ + +

An algorithm step that says:

- 1. ReturnIfAbrupt(AbstractOperation()). + 1. *[before]* ReturnIfAbrupt(AbstractOperation(*[arguments]*)) *[after]* -

mean the same thing as:

+

is equivalent to the sequence of steps:

- 1. Let _hygienicTemp_ be AbstractOperation(). + 1. Let _hygienicTemp_ be AbstractOperation(*[arguments]*). 1. If _hygienicTemp_ is an abrupt completion, return _hygienicTemp_. - 1. Else if _hygienicTemp_ is a Completion Record, set _hygienicTemp_ to _hygienicTemp_.[[Value]]. + 1. Else, if _hygienicTemp_ is a Completion Record, set _hygienicTemp_ to _hygienicTemp_.[[Value]]. + 1. *[before]* _hygienicTemp_ *[after]* -

Where _hygienicTemp_ is ephemeral and visible only in the steps pertaining to ReturnIfAbrupt.

-

Algorithms steps that say or are otherwise equivalent to:

+

where

+ + +

For example, an algorithm step that says:

- 1. Let _result_ be AbstractOperation(ReturnIfAbrupt(_argument_)). + 1. Let _result_ be _someValue_ if ReturnIfAbrupt(_someValue_.OperationName(_firstArgument_, _secondArgument_)) is *true*, and _someOtherValue_ otherwise. -

mean the same thing as:

+

is equivalent to the sequence of steps:

- 1. If _argument_ is an abrupt completion, return _argument_. - 1. If _argument_ is a Completion Record, set _argument_ to _argument_.[[Value]]. - 1. Let _result_ be AbstractOperation(_argument_). + 1. Let _hygienicTemp_ be _someValue_.OperationName(_firstArgument_, _secondArgument_). + 1. If _hygienicTemp_ is an abrupt completion, return _hygienicTemp_. + 1. Else if _hygienicTemp_ is a Completion Record, set _hygienicTemp_ to _hygienicTemp_.[[Value]]. + 1. Let _result_ be _someValue_ if _hygienicTemp_ is *true*, and _someOtherValue_ otherwise. + +

Note that the resulting steps of ReturnIfAbrupt expansion may themselves contain ReturnIfAbrupt. In these cases, expansion can be applied to the resulting steps until the steps no longer contain ReturnIfAbrupt.

+

ReturnIfAbrupt Shorthands

-

Invocations of abstract operations and syntax-directed operations that are prefixed by `?` indicate that ReturnIfAbrupt should be applied to the resulting Completion Record. For example, the step:

+

Invocations of abstract operations may be prefixed by `?` as shorthand for applying the ReturnIfAbrupt expansion.

1. ? OperationName(). -

is equivalent to the following step:

+

is equivalent to

1. ReturnIfAbrupt(OperationName()). -

Similarly, for method application style, the step:

+

wherever it appears. Similarly, prefix `?` may be used to apply the ReturnIfAbrupt expansion to the result of applying a syntax-directed operation.

- 1. ? _someValue_.OperationName(). + 1. Let _result_ be ? SyntaxDirectedOperation of |NonTerminal| with arguments _firstArgument_ and _secondArgument_. -

is equivalent to:

+

is equivalent to the sequence of steps:

- 1. ReturnIfAbrupt(_someValue_.OperationName()). + 1. Let _result_ be SyntaxDirectedOperation of |NonTerminal| with arguments _firstArgument_ and _secondArgument_. + 1. ReturnIfAbrupt(_result_). -

Similarly, prefix `!` is used to indicate that the following invocation of an abstract or syntax-directed operation will never return an abrupt completion and that the resulting Completion Record's [[Value]] field should be used in place of the return value of the operation. For example, the step:

+ +

Invocations of abstract operations may be prefixed by `!` to indicate that the result will never be an abrupt completion and that the resulting Completion Record's [[Value]] field should be used in place of the return value of the operation.

1. Let _val_ be ! OperationName(). -

is equivalent to the following steps:

+

is equivalent to the sequence of steps:

1. Let _val_ be OperationName(). 1. Assert: _val_ is never an abrupt completion. 1. If _val_ is a Completion Record, set _val_ to _val_.[[Value]]. -

Syntax-directed operations for runtime semantics make use of this shorthand by placing `!` or `?` before the invocation of the operation:

+

Similarly, syntax-directed operations may make use of this shorthand by placing `!` before the invocation of the operation:

- 1. Perform ! SyntaxDirectedOperation of |NonTerminal|. + 1. Let _result_ be the result of performing ! SyntaxDirectedOperation for |NonTerminal|. + +

is equivalent to the sequence of steps:

+ + 1. Let _result_ be SyntaxDirectedOperation of |NonTerminal|. + 1. Assert: _result_ is never an abrupt completion. + 1. If _result_ is a Completion Record, set _result_ to _result_.[[Value]].
@@ -7411,7 +7440,8 @@

[[Construct]] ( _argumentsList_, _newTarget_ )

1. If Type(_result_.[[Value]]) is Object, return NormalCompletion(_result_.[[Value]]). 1. If _kind_ is `"base"`, return NormalCompletion(_thisArgument_). 1. If _result_.[[Value]] is not *undefined*, throw a *TypeError* exception. - 1. Else, ReturnIfAbrupt(_result_). + 1. Else, + 1. ReturnIfAbrupt(_result_). 1. Return ? _envRec_.GetThisBinding(). From 4961d80cc8452608c7c555411183ddc2f1fd9b60 Mon Sep 17 00:00:00 2001 From: Michael Ficarra Date: Fri, 7 Jun 2019 11:19:00 -0700 Subject: [PATCH 02/11] move `!` shorthand to implicit completion values section --- spec.html | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/spec.html b/spec.html index 150e7f32dd..21d413ce5e 100644 --- a/spec.html +++ b/spec.html @@ -771,6 +771,27 @@

Implicit Completion Values

1. Return NormalCompletion(*undefined*).

Any reference to a Completion Record value that is in a context that does not explicitly require a complete Completion Record value is equivalent to an explicit reference to the [[Value]] field of the Completion Record value unless the Completion Record is an abrupt completion.

+ +

Invocations of abstract operations may be prefixed by `!` to indicate that the result will never be an abrupt completion and that the resulting Completion Record's [[Value]] field should be used in place of the return value of the operation.

+ + 1. Let _val_ be ! OperationName(). + +

is equivalent to the sequence of steps:

+ + 1. Let _val_ be OperationName(). + 1. Assert: _val_ is never an abrupt completion. + 1. If _val_ is a Completion Record, set _val_ to _val_.[[Value]]. + +

Similarly, syntax-directed operations may make use of this shorthand by placing `!` before the invocation of the operation:

+ + 1. Let _result_ be the result of performing ! SyntaxDirectedOperation for |NonTerminal|. + +

is equivalent to the sequence of steps:

+ + 1. Let _result_ be SyntaxDirectedOperation of |NonTerminal|. + 1. Assert: _result_ is never an abrupt completion. + 1. If _result_ is a Completion Record, set _result_ to _result_.[[Value]]. + @@ -858,27 +879,6 @@

ReturnIfAbrupt Shorthands

1. Let _result_ be SyntaxDirectedOperation of |NonTerminal| with arguments _firstArgument_ and _secondArgument_. 1. ReturnIfAbrupt(_result_). - -

Invocations of abstract operations may be prefixed by `!` to indicate that the result will never be an abrupt completion and that the resulting Completion Record's [[Value]] field should be used in place of the return value of the operation.

- - 1. Let _val_ be ! OperationName(). - -

is equivalent to the sequence of steps:

- - 1. Let _val_ be OperationName(). - 1. Assert: _val_ is never an abrupt completion. - 1. If _val_ is a Completion Record, set _val_ to _val_.[[Value]]. - -

Similarly, syntax-directed operations may make use of this shorthand by placing `!` before the invocation of the operation:

- - 1. Let _result_ be the result of performing ! SyntaxDirectedOperation for |NonTerminal|. - -

is equivalent to the sequence of steps:

- - 1. Let _result_ be SyntaxDirectedOperation of |NonTerminal|. - 1. Assert: _result_ is never an abrupt completion. - 1. If _result_ is a Completion Record, set _result_ to _result_.[[Value]]. -
From 2bc60be09dfe07f59031bbd39c19ea977a9dee10 Mon Sep 17 00:00:00 2001 From: Michael Ficarra Date: Mon, 17 Jun 2019 17:35:49 -0700 Subject: [PATCH 03/11] alignment with #1571 --- spec.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec.html b/spec.html index 21d413ce5e..3876d29ac4 100644 --- a/spec.html +++ b/spec.html @@ -784,7 +784,7 @@

Implicit Completion Values

Similarly, syntax-directed operations may make use of this shorthand by placing `!` before the invocation of the operation:

- 1. Let _result_ be the result of performing ! SyntaxDirectedOperation for |NonTerminal|. + 1. Let _result_ be ! SyntaxDirectedOperation of |NonTerminal|.

is equivalent to the sequence of steps:

@@ -872,11 +872,11 @@

ReturnIfAbrupt Shorthands

wherever it appears. Similarly, prefix `?` may be used to apply the ReturnIfAbrupt expansion to the result of applying a syntax-directed operation.

- 1. Let _result_ be ? SyntaxDirectedOperation of |NonTerminal| with arguments _firstArgument_ and _secondArgument_. + 1. Let _result_ be ? SyntaxDirectedOperation of |NonTerminal|.

is equivalent to the sequence of steps:

- 1. Let _result_ be SyntaxDirectedOperation of |NonTerminal| with arguments _firstArgument_ and _secondArgument_. + 1. Let _result_ be SyntaxDirectedOperation of |NonTerminal|. 1. ReturnIfAbrupt(_result_).
From 4be238d57280df3b9e90a3498071d6d171f1d895 Mon Sep 17 00:00:00 2001 From: Michael Ficarra Date: Mon, 29 Jul 2019 16:51:37 -0700 Subject: [PATCH 04/11] remove commas --- spec.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec.html b/spec.html index 3876d29ac4..0bb32dbb92 100644 --- a/spec.html +++ b/spec.html @@ -815,7 +815,7 @@

ReturnIfAbrupt

is equivalent to the sequence of steps:

1. If _argument_ is an abrupt completion, return _argument_. - 1. Else, if _argument_ is a Completion Record, set _argument_ to _argument_.[[Value]]. + 1. Else if _argument_ is a Completion Record, set _argument_ to _argument_.[[Value]]. 1. *[before]* _argument_ *[after]*

where

@@ -833,7 +833,7 @@

ReturnIfAbrupt

1. Let _hygienicTemp_ be AbstractOperation(*[arguments]*). 1. If _hygienicTemp_ is an abrupt completion, return _hygienicTemp_. - 1. Else, if _hygienicTemp_ is a Completion Record, set _hygienicTemp_ to _hygienicTemp_.[[Value]]. + 1. Else if _hygienicTemp_ is a Completion Record, set _hygienicTemp_ to _hygienicTemp_.[[Value]]. 1. *[before]* _hygienicTemp_ *[after]*

where

From facbb1226637d37eb41ee4128f875ba69c71a562 Mon Sep 17 00:00:00 2001 From: Michael Ficarra Date: Mon, 29 Jul 2019 16:52:58 -0700 Subject: [PATCH 05/11] for example --- spec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.html b/spec.html index 0bb32dbb92..7750ac1fd3 100644 --- a/spec.html +++ b/spec.html @@ -870,7 +870,7 @@

ReturnIfAbrupt Shorthands

1. ReturnIfAbrupt(OperationName()). -

wherever it appears. Similarly, prefix `?` may be used to apply the ReturnIfAbrupt expansion to the result of applying a syntax-directed operation.

+

wherever it appears. Similarly, prefix `?` may be used to apply the ReturnIfAbrupt expansion to the result of applying a syntax-directed operation. For example,

1. Let _result_ be ? SyntaxDirectedOperation of |NonTerminal|. From c92bade37cac9f460390c5ac29dccbbe2a58e4f4 Mon Sep 17 00:00:00 2001 From: Michael Ficarra Date: Mon, 29 Jul 2019 16:59:50 -0700 Subject: [PATCH 06/11] move ! shorthand back; rename section --- spec.html | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/spec.html b/spec.html index 7750ac1fd3..2380c25a1c 100644 --- a/spec.html +++ b/spec.html @@ -771,27 +771,6 @@

Implicit Completion Values

1. Return NormalCompletion(*undefined*).

Any reference to a Completion Record value that is in a context that does not explicitly require a complete Completion Record value is equivalent to an explicit reference to the [[Value]] field of the Completion Record value unless the Completion Record is an abrupt completion.

- -

Invocations of abstract operations may be prefixed by `!` to indicate that the result will never be an abrupt completion and that the resulting Completion Record's [[Value]] field should be used in place of the return value of the operation.

- - 1. Let _val_ be ! OperationName(). - -

is equivalent to the sequence of steps:

- - 1. Let _val_ be OperationName(). - 1. Assert: _val_ is never an abrupt completion. - 1. If _val_ is a Completion Record, set _val_ to _val_.[[Value]]. - -

Similarly, syntax-directed operations may make use of this shorthand by placing `!` before the invocation of the operation:

- - 1. Let _result_ be ! SyntaxDirectedOperation of |NonTerminal|. - -

is equivalent to the sequence of steps:

- - 1. Let _result_ be SyntaxDirectedOperation of |NonTerminal|. - 1. Assert: _result_ is never an abrupt completion. - 1. If _result_ is a Completion Record, set _result_ to _result_.[[Value]]. - @@ -861,7 +840,8 @@

ReturnIfAbrupt

-

ReturnIfAbrupt Shorthands

+

Shorthands Relating to Completion Records

+

Invocations of abstract operations may be prefixed by `?` as shorthand for applying the ReturnIfAbrupt expansion.

1. ? OperationName(). @@ -879,6 +859,27 @@

ReturnIfAbrupt Shorthands

1. Let _result_ be SyntaxDirectedOperation of |NonTerminal|. 1. ReturnIfAbrupt(_result_).
+ +

Invocations of abstract operations may be prefixed by `!` to indicate that the result will never be an abrupt completion and that the resulting Completion Record's [[Value]] field should be used in place of the return value of the operation.

+ + 1. Let _val_ be ! OperationName(). + +

is equivalent to the sequence of steps:

+ + 1. Let _val_ be OperationName(). + 1. Assert: _val_ is never an abrupt completion. + 1. If _val_ is a Completion Record, set _val_ to _val_.[[Value]]. + +

Similarly, syntax-directed operations may make use of this shorthand by placing `!` before the invocation of the operation:

+ + 1. Let _result_ be ! SyntaxDirectedOperation of |NonTerminal|. + +

is equivalent to the sequence of steps:

+ + 1. Let _result_ be SyntaxDirectedOperation of |NonTerminal|. + 1. Assert: _result_ is never an abrupt completion. + 1. If _result_ is a Completion Record, set _result_ to _result_.[[Value]]. +
From e17ee93f2d7281b236192ae3aaac8727bb4f5a86 Mon Sep 17 00:00:00 2001 From: Michael Ficarra Date: Mon, 29 Jul 2019 17:14:23 -0700 Subject: [PATCH 07/11] variable -> alias --- spec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.html b/spec.html index 2380c25a1c..d88e2a276b 100644 --- a/spec.html +++ b/spec.html @@ -801,7 +801,7 @@

ReturnIfAbrupt

  • *[before]*, if present, is any algorithm text that does not contain ReturnIfAbrupt.
  • *[after]*, if present, is any algorithm text. -
  • _argument_ is any variable. +
  • _argument_ is any alias.

An algorithm step that says:

From f371c802c8843bab8abbc665eef0a86f52d558b6 Mon Sep 17 00:00:00 2001 From: Michael Ficarra Date: Tue, 30 Jul 2019 12:18:41 -0700 Subject: [PATCH 08/11] single-step macro expansion for ? example --- spec.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec.html b/spec.html index d88e2a276b..2e885480f7 100644 --- a/spec.html +++ b/spec.html @@ -856,8 +856,7 @@

Shorthands Relating to Completion Records

is equivalent to the sequence of steps:

- 1. Let _result_ be SyntaxDirectedOperation of |NonTerminal|. - 1. ReturnIfAbrupt(_result_). + 1. Let _result_ be ReturnIfAbrupt(SyntaxDirectedOperation of |NonTerminal|).

Invocations of abstract operations may be prefixed by `!` to indicate that the result will never be an abrupt completion and that the resulting Completion Record's [[Value]] field should be used in place of the return value of the operation.

From c06aefa1a01315e053152d2f3d79e60a9dc03b7d Mon Sep 17 00:00:00 2001 From: Michael Ficarra Date: Tue, 30 Jul 2019 15:19:06 -0700 Subject: [PATCH 09/11] simplify example --- spec.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec.html b/spec.html index 2e885480f7..2edda6638e 100644 --- a/spec.html +++ b/spec.html @@ -826,14 +826,14 @@

ReturnIfAbrupt

For example, an algorithm step that says:

- 1. Let _result_ be _someValue_ if ReturnIfAbrupt(_someValue_.OperationName(_firstArgument_, _secondArgument_)) is *true*, and _someOtherValue_ otherwise. + 1. Set _someAlias_ to _someValue_ if ReturnIfAbrupt(_someValue_.OperationName(_firstArgument_, _secondArgument_)) is *true*.

is equivalent to the sequence of steps:

1. Let _hygienicTemp_ be _someValue_.OperationName(_firstArgument_, _secondArgument_). 1. If _hygienicTemp_ is an abrupt completion, return _hygienicTemp_. 1. Else if _hygienicTemp_ is a Completion Record, set _hygienicTemp_ to _hygienicTemp_.[[Value]]. - 1. Let _result_ be _someValue_ if _hygienicTemp_ is *true*, and _someOtherValue_ otherwise. + 1. Set _someAlias_ to _someValue_ if _hygienicTemp_ is *true*.

Note that the resulting steps of ReturnIfAbrupt expansion may themselves contain ReturnIfAbrupt. In these cases, expansion can be applied to the resulting steps until the steps no longer contain ReturnIfAbrupt.

From 8a121c37c9e9d19e18f125b2cff88651e6beb9af Mon Sep 17 00:00:00 2001 From: Michael Ficarra Date: Tue, 30 Jul 2019 16:04:38 -0700 Subject: [PATCH 10/11] reduce ReturnIfAbrupt to a single macro expansion --- spec.html | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/spec.html b/spec.html index 2edda6638e..33059b86e4 100644 --- a/spec.html +++ b/spec.html @@ -789,28 +789,11 @@

Throw an Exception

ReturnIfAbrupt

An algorithm step that says:

- 1. *[before]* ReturnIfAbrupt(_argument_) *[after]* + 1. *[before]* ReturnIfAbrupt(*[argument]*) *[after]*

is equivalent to the sequence of steps:

- 1. If _argument_ is an abrupt completion, return _argument_. - 1. Else if _argument_ is a Completion Record, set _argument_ to _argument_.[[Value]]. - 1. *[before]* _argument_ *[after]* - -

where

-
    -
  • *[before]*, if present, is any algorithm text that does not contain ReturnIfAbrupt. -
  • *[after]*, if present, is any algorithm text. -
  • _argument_ is any alias. -
- -

An algorithm step that says:

- - 1. *[before]* ReturnIfAbrupt(AbstractOperation(*[arguments]*)) *[after]* - -

is equivalent to the sequence of steps:

- - 1. Let _hygienicTemp_ be AbstractOperation(*[arguments]*). + 1. Let _hygienicTemp_ be *[argument]*. 1. If _hygienicTemp_ is an abrupt completion, return _hygienicTemp_. 1. Else if _hygienicTemp_ is a Completion Record, set _hygienicTemp_ to _hygienicTemp_.[[Value]]. 1. *[before]* _hygienicTemp_ *[after]* @@ -819,9 +802,8 @@

ReturnIfAbrupt

  • *[before]*, if present, is any algorithm text that does not contain ReturnIfAbrupt.
  • *[after]*, if present, is any algorithm text. -
  • *[arguments]*, if present, is any algorithm text that provides an argument list to AbstractOperation. -
  • AbstractOperation is any abstract operation reference, regardless of the notation used to refer to it. -
  • _hygienicTemp_ is ephemeral and visible only in the steps pertaining to ReturnIfAbrupt. +
  • *[argument]* is an alias, an application of an abstract operation, an application of a syntax-directed operation, or a use of ReturnIfAbrupt. +
  • _hygienicTemp_ is ephemeral and visible only in the steps pertaining to this ReturnIfAbrupt expansion.

For example, an algorithm step that says:

From ea5d20db0396bf27079fb33537e01dd75ee41ad7 Mon Sep 17 00:00:00 2001 From: Michael Ficarra Date: Tue, 30 Jul 2019 16:05:37 -0700 Subject: [PATCH 11/11] add --- spec.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec.html b/spec.html index 33059b86e4..45cbb3a5fb 100644 --- a/spec.html +++ b/spec.html @@ -800,10 +800,10 @@

ReturnIfAbrupt

where

    -
  • *[before]*, if present, is any algorithm text that does not contain ReturnIfAbrupt. -
  • *[after]*, if present, is any algorithm text. -
  • *[argument]* is an alias, an application of an abstract operation, an application of a syntax-directed operation, or a use of ReturnIfAbrupt. -
  • _hygienicTemp_ is ephemeral and visible only in the steps pertaining to this ReturnIfAbrupt expansion. +
  • *[before]*, if present, is any algorithm text that does not contain ReturnIfAbrupt.
  • +
  • *[after]*, if present, is any algorithm text.
  • +
  • *[argument]* is an alias, an application of an abstract operation, an application of a syntax-directed operation, or a use of ReturnIfAbrupt.
  • +
  • _hygienicTemp_ is ephemeral and visible only in the steps pertaining to this ReturnIfAbrupt expansion.

For example, an algorithm step that says: