From 21eb2a61acc99dbc8e4a69eb384293a6906b40b8 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Wed, 25 Jan 2023 15:19:53 -0500 Subject: [PATCH 1/4] Editorial: Replace the assignment operator table with code point slicing --- spec.html | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/spec.html b/spec.html index 9085b64748..19e76ded5e 100644 --- a/spec.html +++ b/spec.html @@ -20236,25 +20236,9 @@

Runtime Semantics: Evaluation

1. Let _rref_ be ? Evaluation of |AssignmentExpression|. 1. Let _rval_ be ? GetValue(_rref_). 1. Let _assignmentOpText_ be the source text matched by |AssignmentOperator|. - 1. Let _opText_ be the sequence of Unicode code points associated with _assignmentOpText_ in the following table: -
- - - - - - - - - - - - - - - -
_assignmentOpText_ _opText_
`**=` `**`
`*=` `*`
`/=` `/`
`%=` `%`
`+=` `+`
`-=` `-`
`<<=` `<<`
`>>=` `>>`
`>>>=` `>>>`
`&=` `&`
`^=` `^`
`|=` `|`
-
+ 1. Let _len_ be the number of code points in _assignmentOpText_. + 1. Assert: _len_ ≥ 2 and the last code point in _assignmentOpText_ is `=`. + 1. Let _opText_ be the sequence of the first _len_ - 1 code points of _assignmentOpText_. 1. Let _r_ be ? ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). 1. [id="step-assignmentexpression-evaluation-compound-putvalue"] Perform ? PutValue(_lref_, _r_). 1. Return _r_. From f3f9e2bf1352c7d25968755fadef501068dfc23f Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Wed, 25 Jan 2023 15:21:05 -0500 Subject: [PATCH 2/4] Editorial: Replace the ApplyStringOrNumericBinaryOperator table with explicit steps --- spec.html | 71 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/spec.html b/spec.html index 19e76ded5e..783f372c38 100644 --- a/spec.html +++ b/spec.html @@ -20313,39 +20313,44 @@

1. Let _lnum_ be ? ToNumeric(_lval_). 1. Let _rnum_ be ? ToNumeric(_rval_). 1. If Type(_lnum_) is different from Type(_rnum_), throw a *TypeError* exception. - 1. If _lnum_ is a BigInt, then - 1. If _opText_ is `**`, return ? BigInt::exponentiate(_lnum_, _rnum_). - 1. If _opText_ is `/`, return ? BigInt::divide(_lnum_, _rnum_). - 1. If _opText_ is `%`, return ? BigInt::remainder(_lnum_, _rnum_). - 1. If _opText_ is `>>>`, return ? BigInt::unsignedRightShift(_lnum_, _rnum_). - 1. Let _operation_ be the abstract operation associated with _opText_ and Type(_lnum_) in the following table: -
- - - - - - - - - - - - - - - - - - - - - - - -
_opText_ Type(_lnum_) _operation_
`**` Number Number::exponentiate
`*` Number Number::multiply
`*` BigInt BigInt::multiply
`/` Number Number::divide
`%` Number Number::remainder
`+` Number Number::add
`+` BigInt BigInt::add
`-` Number Number::subtract
`-` BigInt BigInt::subtract
`<<` Number Number::leftShift
`<<` BigInt BigInt::leftShift
`>>` Number Number::signedRightShift
`>>` BigInt BigInt::signedRightShift
`>>>` Number Number::unsignedRightShift
`&` Number Number::bitwiseAND
`&` BigInt BigInt::bitwiseAND
`^` Number Number::bitwiseXOR
`^` BigInt BigInt::bitwiseXOR
`|` Number Number::bitwiseOR
`|` BigInt BigInt::bitwiseOR
-
- 1. Return _operation_(_lnum_, _rnum_). + 1. NOTE: The following steps can only throw an exception if _lnum_ is a BigInt and _opText_ is `**`, `/`, `%`, or `>>>`. + 1. If _opText_ is `**`, then + 1. If _lnum_ is a Number, return Number::exponentiate(_lnum_, _rnum_). + 1. If _lnum_ is a BigInt, return ? BigInt::exponentiate(_lnum_, _rnum_). + 1. If _opText_ is `*`, then + 1. If _lnum_ is a Number, return Number::multiply(_lnum_, _rnum_). + 1. If _lnum_ is a BigInt, return BigInt::multiply(_lnum_, _rnum_). + 1. If _opText_ is `/`, then + 1. If _lnum_ is a Number, return Number::divide(_lnum_, _rnum_). + 1. If _lnum_ is a BigInt, return ? BigInt::divide(_lnum_, _rnum_). + 1. If _opText_ is `%`, then + 1. If _lnum_ is a Number, return Number::remainder(_lnum_, _rnum_). + 1. If _lnum_ is a BigInt, return ? BigInt::remainder(_lnum_, _rnum_). + 1. If _opText_ is `+`, then + 1. If _lnum_ is a Number, return Number::add(_lnum_, _rnum_). + 1. If _lnum_ is a BigInt, return BigInt::add(_lnum_, _rnum_). + 1. If _opText_ is `-`, then + 1. If _lnum_ is a Number, return Number::subtract(_lnum_, _rnum_). + 1. If _lnum_ is a BigInt, return BigInt::subtract(_lnum_, _rnum_). + 1. If _opText_ is `<<`, then + 1. If _lnum_ is a Number, return Number::leftShift(_lnum_, _rnum_). + 1. If _lnum_ is a BigInt, return BigInt::leftShift(_lnum_, _rnum_). + 1. If _opText_ is `>>`, then + 1. If _lnum_ is a Number, return Number::signedRightShift(_lnum_, _rnum_). + 1. If _lnum_ is a BigInt, return BigInt::signedRightShift(_lnum_, _rnum_). + 1. If _opText_ is `>>>`, then + 1. If _lnum_ is a Number, return Number::unsignedRightShift(_lnum_, _rnum_). + 1. If _lnum_ is a BigInt, return ? BigInt::unsignedRightShift(_lnum_, _rnum_). + 1. If _opText_ is `&`, then + 1. If _lnum_ is a Number, return Number::bitwiseAND(_lnum_, _rnum_). + 1. If _lnum_ is a BigInt, return BigInt::bitwiseAND(_lnum_, _rnum_). + 1. If _opText_ is `^`, then + 1. If _lnum_ is a Number, return Number::bitwiseXOR(_lnum_, _rnum_). + 1. If _lnum_ is a BigInt, return BigInt::bitwiseXOR(_lnum_, _rnum_). + 1. If _opText_ is `|`, then + 1. If _lnum_ is a Number, return Number::bitwiseOR(_lnum_, _rnum_). + 1. If _lnum_ is a BigInt, return BigInt::bitwiseOR(_lnum_, _rnum_). + 1. Assert: This step is not reached.

No hint is provided in the calls to ToPrimitive in steps and . All standard objects except Dates handle the absence of a hint as if ~number~ were given; Dates handle the absence of a hint as if ~string~ were given. Exotic objects may handle the absence of a hint in some other manner.

From 0fad627aee3d2e908651a13b2fa4eae8ca3342a8 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Wed, 25 Jan 2023 15:23:40 -0500 Subject: [PATCH 3/4] Editorial: Group the ApplyStringOrNumericBinaryOperator by type rather than operator Comprehension and visual comparison are easier when everything fits on one screen --- spec.html | 62 +++++++++++++++++++++++-------------------------------- 1 file changed, 26 insertions(+), 36 deletions(-) diff --git a/spec.html b/spec.html index 783f372c38..c1358823bc 100644 --- a/spec.html +++ b/spec.html @@ -20314,42 +20314,32 @@

1. Let _rnum_ be ? ToNumeric(_rval_). 1. If Type(_lnum_) is different from Type(_rnum_), throw a *TypeError* exception. 1. NOTE: The following steps can only throw an exception if _lnum_ is a BigInt and _opText_ is `**`, `/`, `%`, or `>>>`. - 1. If _opText_ is `**`, then - 1. If _lnum_ is a Number, return Number::exponentiate(_lnum_, _rnum_). - 1. If _lnum_ is a BigInt, return ? BigInt::exponentiate(_lnum_, _rnum_). - 1. If _opText_ is `*`, then - 1. If _lnum_ is a Number, return Number::multiply(_lnum_, _rnum_). - 1. If _lnum_ is a BigInt, return BigInt::multiply(_lnum_, _rnum_). - 1. If _opText_ is `/`, then - 1. If _lnum_ is a Number, return Number::divide(_lnum_, _rnum_). - 1. If _lnum_ is a BigInt, return ? BigInt::divide(_lnum_, _rnum_). - 1. If _opText_ is `%`, then - 1. If _lnum_ is a Number, return Number::remainder(_lnum_, _rnum_). - 1. If _lnum_ is a BigInt, return ? BigInt::remainder(_lnum_, _rnum_). - 1. If _opText_ is `+`, then - 1. If _lnum_ is a Number, return Number::add(_lnum_, _rnum_). - 1. If _lnum_ is a BigInt, return BigInt::add(_lnum_, _rnum_). - 1. If _opText_ is `-`, then - 1. If _lnum_ is a Number, return Number::subtract(_lnum_, _rnum_). - 1. If _lnum_ is a BigInt, return BigInt::subtract(_lnum_, _rnum_). - 1. If _opText_ is `<<`, then - 1. If _lnum_ is a Number, return Number::leftShift(_lnum_, _rnum_). - 1. If _lnum_ is a BigInt, return BigInt::leftShift(_lnum_, _rnum_). - 1. If _opText_ is `>>`, then - 1. If _lnum_ is a Number, return Number::signedRightShift(_lnum_, _rnum_). - 1. If _lnum_ is a BigInt, return BigInt::signedRightShift(_lnum_, _rnum_). - 1. If _opText_ is `>>>`, then - 1. If _lnum_ is a Number, return Number::unsignedRightShift(_lnum_, _rnum_). - 1. If _lnum_ is a BigInt, return ? BigInt::unsignedRightShift(_lnum_, _rnum_). - 1. If _opText_ is `&`, then - 1. If _lnum_ is a Number, return Number::bitwiseAND(_lnum_, _rnum_). - 1. If _lnum_ is a BigInt, return BigInt::bitwiseAND(_lnum_, _rnum_). - 1. If _opText_ is `^`, then - 1. If _lnum_ is a Number, return Number::bitwiseXOR(_lnum_, _rnum_). - 1. If _lnum_ is a BigInt, return BigInt::bitwiseXOR(_lnum_, _rnum_). - 1. If _opText_ is `|`, then - 1. If _lnum_ is a Number, return Number::bitwiseOR(_lnum_, _rnum_). - 1. If _lnum_ is a BigInt, return BigInt::bitwiseOR(_lnum_, _rnum_). + 1. If _lnum_ is a Number, then + 1. If _opText_ is `**`, return Number::exponentiate(_lnum_, _rnum_). + 1. If _opText_ is `*`, return Number::multiply(_lnum_, _rnum_). + 1. If _opText_ is `/`, return Number::divide(_lnum_, _rnum_). + 1. If _opText_ is `%`, return Number::remainder(_lnum_, _rnum_). + 1. If _opText_ is `+`, return Number::add(_lnum_, _rnum_). + 1. If _opText_ is `-`, return Number::subtract(_lnum_, _rnum_). + 1. If _opText_ is `<<`, return Number::leftShift(_lnum_, _rnum_). + 1. If _opText_ is `>>`, return Number::signedRightShift(_lnum_, _rnum_). + 1. If _opText_ is `>>>`, return Number::unsignedRightShift(_lnum_, _rnum_). + 1. If _opText_ is `&`, return Number::bitwiseAND(_lnum_, _rnum_). + 1. If _opText_ is `^`, return Number::bitwiseXOR(_lnum_, _rnum_). + 1. If _opText_ is `|`, return Number::bitwiseOR(_lnum_, _rnum_). + 1. If _lnum_ is a BigInt, then + 1. If _opText_ is `**`, return ? BigInt::exponentiate(_lnum_, _rnum_). + 1. If _opText_ is `*`, return BigInt::multiply(_lnum_, _rnum_). + 1. If _opText_ is `/`, return ? BigInt::divide(_lnum_, _rnum_). + 1. If _opText_ is `%`, return ? BigInt::remainder(_lnum_, _rnum_). + 1. If _opText_ is `+`, return BigInt::add(_lnum_, _rnum_). + 1. If _opText_ is `-`, return BigInt::subtract(_lnum_, _rnum_). + 1. If _opText_ is `<<`, return BigInt::leftShift(_lnum_, _rnum_). + 1. If _opText_ is `>>`, return BigInt::signedRightShift(_lnum_, _rnum_). + 1. If _opText_ is `>>>`, return ? BigInt::unsignedRightShift(_lnum_, _rnum_). + 1. If _opText_ is `&`, return BigInt::bitwiseAND(_lnum_, _rnum_). + 1. If _opText_ is `^`, return BigInt::bitwiseXOR(_lnum_, _rnum_). + 1. If _opText_ is `|`, return BigInt::bitwiseOR(_lnum_, _rnum_). 1. Assert: This step is not reached. From e1d6d58048df847e8194fcebac53aef7a1057d4c Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Thu, 26 Jan 2023 23:21:50 -0500 Subject: [PATCH 4/4] Editorial: Accept suggestion --- spec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.html b/spec.html index c1358823bc..4d59179b2a 100644 --- a/spec.html +++ b/spec.html @@ -20313,7 +20313,7 @@

1. Let _lnum_ be ? ToNumeric(_lval_). 1. Let _rnum_ be ? ToNumeric(_rval_). 1. If Type(_lnum_) is different from Type(_rnum_), throw a *TypeError* exception. - 1. NOTE: The following steps can only throw an exception if _lnum_ is a BigInt and _opText_ is `**`, `/`, `%`, or `>>>`. + 1. NOTE: The following steps can only throw an exception if _lnum_ is a BigInt and _opText_ is one of `**`, `/`, `%`, or `>>>`. 1. If _lnum_ is a Number, then 1. If _opText_ is `**`, return Number::exponentiate(_lnum_, _rnum_). 1. If _opText_ is `*`, return Number::multiply(_lnum_, _rnum_).