Skip to content

Commit

Permalink
Editorial: ApplyStringOrNumericBinaryOperator: refactor into two ex…
Browse files Browse the repository at this point in the history
…plicit tables (tc39#3420)
  • Loading branch information
ljharb committed Sep 6, 2024
1 parent afecb99 commit 38e5690
Showing 1 changed file with 44 additions and 29 deletions.
73 changes: 44 additions & 29 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -20688,35 +20688,50 @@ <h1>
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:
<figure>
<!-- emu-format ignore -->
<table class="lightweight-table">
<thead>
<tr><th> _opText_ </th><th> Type(_lNum_) </th><th> _operation_ </th></tr>
</thead>
<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. Let _operation_ be the abstract operation associated with _opText_ in the following table:
<figure>
<!-- emu-format ignore -->
<table class="lightweight-table">
<thead>
<tr><th> _opText_ </th><th> _operation_ </th></tr>
</thead>
<tbody>
<tr><td> `*` </td><td> BigInt::multiply </td></tr>
<tr><td> `+` </td><td> BigInt::add </td></tr>
<tr><td> `-` </td><td> BigInt::subtract </td></tr>
<tr><td> `&lt;&lt;` </td><td> BigInt::leftShift </td></tr>
<tr><td> `&gt;&gt;` </td><td> BigInt::signedRightShift </td></tr>
<tr><td> `&amp;` </td><td> BigInt::bitwiseAND </td></tr>
<tr><td> `^` </td><td> BigInt::bitwiseXOR </td></tr>
<tr><td> `|` </td><td> BigInt::bitwiseOR </td></tr>
</tbody>
</table>
</figure>
1. Else,
1. Assert: _lNum_ is a Number.
1. Let _operation_ be the abstract operation associated with _opText_ in the following table:
<figure>
<!-- emu-format ignore -->
<table class="lightweight-table">
<thead>
<tr><th> _opText_ </th><th> _operation_ </th></tr>
</thead>
<tbody>
<tr><td> `**` </td><td> Number::exponentiate </td></tr>
<tr><td> `*` </td><td> Number::multiply </td></tr>
<tr><td> `/` </td><td> Number::divide </td></tr>
<tr><td> `%` </td><td> Number::remainder </td></tr>
<tr><td> `+` </td><td> Number::add </td></tr>
<tr><td> `-` </td><td> Number::subtract </td></tr>
<tr><td> `&lt;&lt;` </td><td> Number::leftShift </td></tr>
<tr><td> `&gt;&gt;` </td><td> Number::signedRightShift </td></tr>
<tr><td> `&gt;&gt;&gt;` </td><td> Number::unsignedRightShift </td></tr>
<tr><td> `&amp;` </td><td> Number::bitwiseAND </td></tr>
<tr><td> `^` </td><td> Number::bitwiseXOR </td></tr>
<tr><td> `|` </td><td> Number::bitwiseOR </td></tr>
</tbody>
</table>
</figure>
1. Return _operation_(_lNum_, _rNum_).
</emu-alg>
<emu-note>
Expand Down

0 comments on commit 38e5690

Please sign in to comment.