diff --git a/spec.html b/spec.html index 2c478f7d8a..45cbb3a5fb 100644 --- a/spec.html +++ b/spec.html @@ -787,68 +787,79 @@

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:

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

Algorithms steps that say or are otherwise equivalent to:

- - 1. ReturnIfAbrupt(AbstractOperation()). - -

mean the same thing as:

+

is equivalent to the sequence of steps:

- 1. Let _hygienicTemp_ be AbstractOperation(). + 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]* -

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. Set _someAlias_ to _someValue_ if ReturnIfAbrupt(_someValue_.OperationName(_firstArgument_, _secondArgument_)) is *true*. -

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. 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.

+ -

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:

+

Shorthands Relating to Completion Records

+ +

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. For example,

- 1. ? _someValue_.OperationName(). + 1. Let _result_ be ? SyntaxDirectedOperation of |NonTerminal|. -

is equivalent to:

+

is equivalent to the sequence of steps:

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

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 ! 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]].
@@ -7411,7 +7422,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().