Skip to content

Commit

Permalink
Editorial: Factor out EvaluateStringOrNumericBinaryExpression (#1961)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdyck authored and ljharb committed May 1, 2020
1 parent 0ef6871 commit 8300e6d
Showing 1 changed file with 22 additions and 50 deletions.
72 changes: 22 additions & 50 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -14547,11 +14547,7 @@ <h1>Runtime Semantics: Evaluation</h1>
ExponentiationExpression : UpdateExpression `**` ExponentiationExpression
</emu-grammar>
<emu-alg>
1. Let _left_ be the result of evaluating |UpdateExpression|.
1. Let _leftValue_ be ? GetValue(_left_).
1. Let _right_ be the result of evaluating |ExponentiationExpression|.
1. Let _rightValue_ be ? GetValue(_right_).
1. Return ? ApplyStringOrNumericBinaryOperator(_leftValue_, `**`, _rightValue_).
1. Return ? EvaluateStringOrNumericBinaryExpression(|UpdateExpression|, `**`, |ExponentiationExpression|).
</emu-alg>
</emu-clause>
</emu-clause>
Expand Down Expand Up @@ -14590,12 +14586,8 @@ <h1>Static Semantics: AssignmentTargetType</h1>
<h1>Runtime Semantics: Evaluation</h1>
<emu-grammar>MultiplicativeExpression : MultiplicativeExpression MultiplicativeOperator ExponentiationExpression</emu-grammar>
<emu-alg>
1. Let _left_ be the result of evaluating |MultiplicativeExpression|.
1. Let _leftValue_ be ? GetValue(_left_).
1. Let _right_ be the result of evaluating |ExponentiationExpression|.
1. Let _rightValue_ be ? GetValue(_right_).
1. Let _opText_ be the source text matched by |MultiplicativeOperator|.
1. Return ? ApplyStringOrNumericBinaryOperator(_leftValue_, _opText_, _rightValue_).
1. Return ? EvaluateStringOrNumericBinaryExpression(|MultiplicativeExpression|, _opText_, |ExponentiationExpression|).
</emu-alg>
</emu-clause>
</emu-clause>
Expand Down Expand Up @@ -14646,11 +14638,7 @@ <h1>The Addition Operator ( `+` )</h1>
<h1>Runtime Semantics: Evaluation</h1>
<emu-grammar>AdditiveExpression : AdditiveExpression `+` MultiplicativeExpression</emu-grammar>
<emu-alg>
1. Let _lref_ be the result of evaluating |AdditiveExpression|.
1. Let _lval_ be ? GetValue(_lref_).
1. Let _rref_ be the result of evaluating |MultiplicativeExpression|.
1. Let _rval_ be ? GetValue(_rref_).
1. Return ? ApplyStringOrNumericBinaryOperator(_lval_, `+`, _rval_).
1. Return ? EvaluateStringOrNumericBinaryExpression(|AdditiveExpression|, `+`, |MultiplicativeExpression|).
</emu-alg>
</emu-clause>
</emu-clause>
Expand All @@ -14662,11 +14650,7 @@ <h1>The Subtraction Operator ( `-` )</h1>
<h1>Runtime Semantics: Evaluation</h1>
<emu-grammar>AdditiveExpression : AdditiveExpression `-` MultiplicativeExpression</emu-grammar>
<emu-alg>
1. Let _lref_ be the result of evaluating |AdditiveExpression|.
1. Let _lval_ be ? GetValue(_lref_).
1. Let _rref_ be the result of evaluating |MultiplicativeExpression|.
1. Let _rval_ be ? GetValue(_rref_).
1. Return ? ApplyStringOrNumericBinaryOperator(_lval_, `-`, _rval_).
1. Return ? EvaluateStringOrNumericBinaryExpression(|AdditiveExpression|, `-`, |MultiplicativeExpression|).
</emu-alg>
</emu-clause>
</emu-clause>
Expand Down Expand Up @@ -14721,11 +14705,7 @@ <h1>The Left Shift Operator ( `&lt;&lt;` )</h1>
<h1>Runtime Semantics: Evaluation</h1>
<emu-grammar>ShiftExpression : ShiftExpression `&lt;&lt;` AdditiveExpression</emu-grammar>
<emu-alg>
1. Let _lref_ be the result of evaluating |ShiftExpression|.
1. Let _lval_ be ? GetValue(_lref_).
1. Let _rref_ be the result of evaluating |AdditiveExpression|.
1. Let _rval_ be ? GetValue(_rref_).
1. Return ? ApplyStringOrNumericBinaryOperator(_lval_, `&lt;&lt;`, _rval_).
1. Return ? EvaluateStringOrNumericBinaryExpression(|ShiftExpression|, `&lt;&lt;`, |AdditiveExpression|).
</emu-alg>
</emu-clause>
</emu-clause>
Expand All @@ -14740,11 +14720,7 @@ <h1>The Signed Right Shift Operator ( `&gt;&gt;` )</h1>
<h1>Runtime Semantics: Evaluation</h1>
<emu-grammar>ShiftExpression : ShiftExpression `&gt;&gt;` AdditiveExpression</emu-grammar>
<emu-alg>
1. Let _lref_ be the result of evaluating |ShiftExpression|.
1. Let _lval_ be ? GetValue(_lref_).
1. Let _rref_ be the result of evaluating |AdditiveExpression|.
1. Let _rval_ be ? GetValue(_rref_).
1. Return ? ApplyStringOrNumericBinaryOperator(_lval_, `&gt;&gt;`, _rval_).
1. Return ? EvaluateStringOrNumericBinaryExpression(|ShiftExpression|, `&gt;&gt;`, |AdditiveExpression|).
</emu-alg>
</emu-clause>
</emu-clause>
Expand All @@ -14759,11 +14735,7 @@ <h1>The Unsigned Right Shift Operator ( `&gt;&gt;&gt;` )</h1>
<h1>Runtime Semantics: Evaluation</h1>
<emu-grammar>ShiftExpression : ShiftExpression `&gt;&gt;&gt;` AdditiveExpression</emu-grammar>
<emu-alg>
1. Let _lref_ be the result of evaluating |ShiftExpression|.
1. Let _lval_ be ? GetValue(_lref_).
1. Let _rref_ be the result of evaluating |AdditiveExpression|.
1. Let _rval_ be ? GetValue(_rref_).
1. Return ? ApplyStringOrNumericBinaryOperator(_lval_, `&gt;&gt;&gt;`, _rval_).
1. Return ? EvaluateStringOrNumericBinaryExpression(|ShiftExpression|, `&gt;&gt;&gt;`, |AdditiveExpression|).
</emu-alg>
</emu-clause>
</emu-clause>
Expand Down Expand Up @@ -15077,27 +15049,15 @@ <h1>Static Semantics: AssignmentTargetType</h1>
<h1>Runtime Semantics: Evaluation</h1>
<emu-grammar>BitwiseANDExpression : BitwiseANDExpression `&amp;` EqualityExpression</emu-grammar>
<emu-alg>
1. Let _lref_ be the result of evaluating |BitwiseANDExpression|.
1. Let _lval_ be ? GetValue(_lref_).
1. Let _rref_ be the result of evaluating |EqualityExpression|.
1. Let _rval_ be ? GetValue(_rref_).
1. Return ? ApplyStringOrNumericBinaryOperator(_lval_, `&amp;`, _rval_).
1. Return ? EvaluateStringOrNumericBinaryExpression(|BitwiseANDExpression|, `&amp;`, |EqualityExpression|).
</emu-alg>
<emu-grammar>BitwiseXORExpression : BitwiseXORExpression `^` BitwiseANDExpression</emu-grammar>
<emu-alg>
1. Let _lref_ be the result of evaluating |BitwiseXORExpression|.
1. Let _lval_ be ? GetValue(_lref_).
1. Let _rref_ be the result of evaluating |BitwiseANDExpression|.
1. Let _rval_ be ? GetValue(_rref_).
1. Return ? ApplyStringOrNumericBinaryOperator(_lval_, `^`, _rval_).
1. Return ? EvaluateStringOrNumericBinaryExpression(|BitwiseXORExpression|, `^`, |BitwiseANDExpression|).
</emu-alg>
<emu-grammar>BitwiseORExpression : BitwiseORExpression `|` BitwiseXORExpression</emu-grammar>
<emu-alg>
1. Let _lref_ be the result of evaluating |BitwiseORExpression|.
1. Let _lval_ be ? GetValue(_lref_).
1. Let _rref_ be the result of evaluating |BitwiseXORExpression|.
1. Let _rval_ be ? GetValue(_rref_).
1. Return ? ApplyStringOrNumericBinaryOperator(_lval_, `|`, _rval_).
1. Return ? EvaluateStringOrNumericBinaryExpression(|BitwiseORExpression|, `|`, |BitwiseXORExpression|).
</emu-alg>
</emu-clause>
</emu-clause>
Expand Down Expand Up @@ -15421,6 +15381,18 @@ <h1>Runtime Semantics: ApplyStringOrNumericBinaryOperator ( _lval_, _opText_, _r
</emu-note>
</emu-clause>

<emu-clause id="sec-evaluatestringornumericbinaryexpression" aoid="EvaluateStringOrNumericBinaryExpression">
<h1>Runtime Semantics: EvaluateStringOrNumericBinaryExpression ( _leftOperand_, _opText_, _rightOperand_ )</h1>
<p>The abstract operation EvaluateStringOrNumericBinaryExpression takes arguments _leftOperand_ (a Parse Node), _opText_ (a sequence of Unicode code points), and _rightOperand_ (a Parse Node). It performs the following steps when called:</p>
<emu-alg>
1. Let _lref_ be the result of evaluating _leftOperand_.
1. Let _lval_ be ? GetValue(_lref_).
1. Let _rref_ be the result of evaluating _rightOperand_.
1. Let _rval_ be ? GetValue(_rref_).
1. Return ? ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_).
</emu-alg>
</emu-clause>

<emu-clause id="sec-destructuring-assignment">
<h1>Destructuring Assignment</h1>
<h2>Supplemental Syntax</h2>
Expand Down

0 comments on commit 8300e6d

Please sign in to comment.