Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editorial: Replace the operator tables with explicit steps #3002

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 26 additions & 47 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -20236,25 +20236,9 @@ <h1>Runtime Semantics: Evaluation</h1>
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:
<figure>
<!-- emu-format ignore -->
<table class="lightweight-table">
<tr><th> _assignmentOpText_ </th><th> _opText_ </th></tr>
<tr><td> `**=` </td><td> `**` </td></tr>
<tr><td> `*=` </td><td> `*` </td></tr>
<tr><td> `/=` </td><td> `/` </td></tr>
<tr><td> `%=` </td><td> `%` </td></tr>
<tr><td> `+=` </td><td> `+` </td></tr>
<tr><td> `-=` </td><td> `-` </td></tr>
<tr><td> `&lt;&lt;=` </td><td> `&lt;&lt;` </td></tr>
<tr><td> `&gt;&gt;=` </td><td> `&gt;&gt;` </td></tr>
<tr><td> `&gt;&gt;&gt;=` </td><td> `&gt;&gt;&gt;` </td></tr>
<tr><td> `&amp;=` </td><td> `&amp;` </td></tr>
<tr><td> `^=` </td><td> `^` </td></tr>
<tr><td> `|=` </td><td> `|` </td></tr>
</table>
</figure>
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_.
Expand Down Expand Up @@ -20329,39 +20313,34 @@ <h1>
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 one of `**`, `/`, `%`, or `>>>`.
gibson042 marked this conversation as resolved.
Show resolved Hide resolved
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 `&amp;`, 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. Let _operation_ be the abstract operation associated with _opText_ and Type(_lnum_) in the following table:
<figure>
<!-- emu-format ignore -->
<table class="lightweight-table">
<tr><th> _opText_ </th><th> Type(_lnum_) </th><th> _operation_ </th></tr>
<tr><td> `**` </td><td> Number </td><td> Number::exponentiate </td></tr>
<tr><td> `*` </td><td> Number </td><td> Number::multiply </td></tr>
<tr><td> `*` </td><td> BigInt </td><td> BigInt::multiply </td></tr>
<tr><td> `/` </td><td> Number </td><td> Number::divide </td></tr>
<tr><td> `%` </td><td> Number </td><td> Number::remainder </td></tr>
<tr><td> `+` </td><td> Number </td><td> Number::add </td></tr>
<tr><td> `+` </td><td> BigInt </td><td> BigInt::add </td></tr>
<tr><td> `-` </td><td> Number </td><td> Number::subtract </td></tr>
<tr><td> `-` </td><td> BigInt </td><td> BigInt::subtract </td></tr>
<tr><td> `&lt;&lt;` </td><td> Number </td><td> Number::leftShift </td></tr>
<tr><td> `&lt;&lt;` </td><td> BigInt </td><td> BigInt::leftShift </td></tr>
<tr><td> `&gt;&gt;` </td><td> Number </td><td> Number::signedRightShift </td></tr>
<tr><td> `&gt;&gt;` </td><td> BigInt </td><td> BigInt::signedRightShift </td></tr>
<tr><td> `&gt;&gt;&gt;` </td><td> Number </td><td> Number::unsignedRightShift </td></tr>
<tr><td> `&amp;` </td><td> Number </td><td> Number::bitwiseAND </td></tr>
<tr><td> `&amp;` </td><td> BigInt </td><td> BigInt::bitwiseAND </td></tr>
<tr><td> `^` </td><td> Number </td><td> Number::bitwiseXOR </td></tr>
<tr><td> `^` </td><td> BigInt </td><td> BigInt::bitwiseXOR </td></tr>
<tr><td> `|` </td><td> Number </td><td> Number::bitwiseOR </td></tr>
<tr><td> `|` </td><td> BigInt </td><td> BigInt::bitwiseOR </td></tr>
</table>
</figure>
1. Return _operation_(_lnum_, _rnum_).
1. If _opText_ is `&amp;`, 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.
</emu-alg>
<emu-note>
<p>No hint is provided in the calls to ToPrimitive in steps <emu-xref href="#step-binary-op-toprimitive-lval"></emu-xref> and <emu-xref href="#step-binary-op-toprimitive-rval"></emu-xref>. 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.</p>
Expand Down