From 6c12fea2b74e80ca49357b42f72de782d489eb44 Mon Sep 17 00:00:00 2001 From: Mike Pennisi Date: Tue, 24 Jan 2023 18:44:52 -0500 Subject: [PATCH 1/3] Introduce a shorthand for ECMA262 abstract ops --- infra.bs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/infra.bs b/infra.bs index 2237cd5..fa88aa0 100644 --- a/infra.bs +++ b/infra.bs @@ -14,8 +14,10 @@ urlPrefix: https://tc39.github.io/ecma262/#; spec: ECMA-262; type: dfn text: %JSON.parse%; url: sec-json.parse text: %JSON.stringify%; url: sec-json.stringify + text: Completion Record; url: sec-completion-record-specification-type text: List; url: sec-list-and-record-specification-type text: The String Type; url: sec-ecmascript-language-types-string-type + text: abrupt completion; url: sec-completion-record-specification-type text: realm; url: realm type: method; for: Array; text: sort(); url: sec-array.prototype.sort type: abstract-op; @@ -644,6 +646,35 @@ Standard that should be reported and addressed. +

ECMA-262 Abstract Operations

+ +

ECMA-262 uses a specification type named [=Completion Record=] to model exception-based control +flow. Because web specifications have first-class support for exception handling, +special care must be taken when interpreting the results of ECMA-262 abstract operations. +[[!ECMA-262]] + +

This specification defines a shorthand named ? to interpret +ECMA-262 completion records in terms of web specifications' "throw" semantics. Algorithm steps that +say or are otherwise equivalent to: + +

+
    +
  1. Let |result| be ? AbstractOperation(). +

+
+ +

mean the same thing as: + +

+
    +
  1. Let |hygienicTemp| be AbstractOperation(). +

  2. Assert: |hygienicTemp| is a [=Completion Record=]. +

  3. If |hygienicTemp| is an [=abrupt completion=], throw |hygienicTemp|.\[[Value]]. +

  4. Let |result| be |hygienicTemp|.\[[Value]]. +

+
+ +

Primitive data types

Nulls

From 9b862160e5a1b372f4cc06c8a89cb77c3736a5ff Mon Sep 17 00:00:00 2001 From: Mike Pennisi Date: Thu, 16 Feb 2023 19:45:03 -0500 Subject: [PATCH 2/3] fixup! Introduce a shorthand for ECMA262 abstract ops --- infra.bs | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/infra.bs b/infra.bs index fa88aa0..a1559f8 100644 --- a/infra.bs +++ b/infra.bs @@ -18,6 +18,7 @@ urlPrefix: https://tc39.github.io/ecma262/#; spec: ECMA-262; text: List; url: sec-list-and-record-specification-type text: The String Type; url: sec-ecmascript-language-types-string-type text: abrupt completion; url: sec-completion-record-specification-type + text: abstract operation; url: sec-algorithm-conventions-abstract-operations text: realm; url: realm type: method; for: Array; text: sort(); url: sec-array.prototype.sort type: abstract-op; @@ -648,14 +649,20 @@ Standard that should be reported and addressed.

ECMA-262 Abstract Operations

-

ECMA-262 uses a specification type named [=Completion Record=] to model exception-based control -flow. Because web specifications have first-class support for exception handling, -special care must be taken when interpreting the results of ECMA-262 abstract operations. -[[!ECMA-262]] +

ECMA-262 defines some algorithms as [=abstract operations=] which may be invoked from algorithms +in other specifications. Some of these [=abstract operations=] return a type of value named +[=Completion Record=], and ECMA262's calling conventions use this type to model control flow +interruptions such as thrown exceptions. Because web specifications do not observe the same +conventions (e.g. exception handling is built in to the processing +model), preserving the operations' semantics necessarily involves interpreting [=Completion +Records=]. [[!ECMA-262]] + +

This specification defines a shorthand named ? as a +convenience for web specifications wishing to faithfully interpret ECMA-262 [=abstract operations=] +which return [=Completion Records=]. Algorithms which invoke such operations are encouraged to +integrate them them concisely and consistently using this shorthand. -

This specification defines a shorthand named ? to interpret -ECMA-262 completion records in terms of web specifications' "throw" semantics. Algorithm steps that -say or are otherwise equivalent to: +

Algorithm steps that say or are otherwise equivalent to:

    @@ -675,6 +682,11 @@ say or are otherwise equivalent to:
+

This shorthand is intended to be suitable for use with any invocation, but the first +of the two preceding examples does not match all common calling conventions. See tc39/ecma262 issue #1573 +for details. + +

Primitive data types

Nulls

@@ -1758,7 +1770,7 @@ specification. [[!ECMA-262]] given a string |string|:
    -
  1. Return ? [$Call$](%JSON.parse%, undefined, « |string| »). +

  2. Return ? [$Call$](%JSON.parse%, undefined, « |string| »).

To parse JSON bytes to a JavaScript value, @@ -1775,7 +1787,7 @@ given a JavaScript value |value|:

  1. -

    Let |result| be ? [$Call$](%JSON.stringify%, undefined, « |value| »). +

    Let |result| be ? [$Call$](%JSON.stringify%, undefined, « |value| »).

    Since no additional arguments are passed to %JSON.stringify%, the resulting string will have no whitespace inserted. @@ -1812,7 +1824,7 @@ standards, it is often more convenient to convert between JSON and realm-indepen given a string |string|:

      -
    1. Let |jsValue| be ? [$Call$](%JSON.parse%, undefined, « |string| »). +

    2. Let |jsValue| be ? [$Call$](%JSON.parse%, undefined, « |string| »).

    3. Return the result of [=converting a JSON-derived JavaScript value to an Infra value=], given |jsValue|. From da1baac649ad73514d2f9e0d3c0ee74fe92f62fd Mon Sep 17 00:00:00 2001 From: Mike Pennisi Date: Thu, 23 Feb 2023 18:47:23 -0500 Subject: [PATCH 3/3] fixup! Introduce a shorthand for ECMA262 abstract ops --- infra.bs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/infra.bs b/infra.bs index a1559f8..5e1b27b 100644 --- a/infra.bs +++ b/infra.bs @@ -651,16 +651,16 @@ Standard that should be reported and addressed.

      ECMA-262 defines some algorithms as [=abstract operations=] which may be invoked from algorithms in other specifications. Some of these [=abstract operations=] return a type of value named -[=Completion Record=], and ECMA262's calling conventions use this type to model control flow -interruptions such as thrown exceptions. Because web specifications do not observe the same -conventions (e.g. exception handling is built in to the processing -model), preserving the operations' semantics necessarily involves interpreting [=Completion -Records=]. [[!ECMA-262]] +[=Completion Record=] which ECMA262 uses to model control flow interruptions such as thrown +exceptions. Because web specifications do not observe the same conventions (e.g. +exception handling is built in to the processing model), +preserving the operations' semantics necessarily involves handling [=Completion Records=]. +[[!ECMA-262]]

      This specification defines a shorthand named ? as a convenience for web specifications wishing to faithfully interpret ECMA-262 [=abstract operations=] which return [=Completion Records=]. Algorithms which invoke such operations are encouraged to -integrate them them concisely and consistently using this shorthand. +integrate them concisely and consistently using this shorthand.

      Algorithm steps that say or are otherwise equivalent to: