Package: org.codehaus.groovy.classgen.asm

## [Java] Class BinaryExpressionHelper

- org.codehaus.groovy.classgen.asm.BinaryExpressionHelper

-     public class BinaryExpressionHelper
      extends Object

  Emits bytecode for dynamic binary expressions.

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `protected WriterController` | `controller` | Coordinates the active bytecode-generation state.

  - ### Constructor Summary

    Constructors
    Constructor and description
    `BinaryExpressionHelper(WriterController wc)` Creates a binary expression helper for the supplied controller.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `protected void` | `assignToArray(Expression parent, Expression receiver, Expression index, Expression rhsValueLoader, boolean safe)` Emits an array-style assignment using the dynamic `putAt` protocol.
    `` | `public void` | `eval(BinaryExpression expression)` Evaluates the supplied binary expression.
    `` | `protected void` | `evaluateArrayAssignmentWithOperator(String method, BinaryExpression expression, BinaryExpression leftBinExpr)` Evaluates a compound assignment whose left-hand side is a subscript expression.
    `` | `protected void` | `evaluateBinaryExpression(String message, BinaryExpression expression)` Evaluates a dynamic binary operator by invoking the named helper method.
    `` | `protected void` | `evaluateBinaryExpressionWithAssignment(String method, BinaryExpression expression)` Evaluates an operator-assignment expression such as `+=`.
    `` | `protected void` | `evaluateCompareExpression(MethodCaller compareMethod, BinaryExpression expression)` Evaluates a comparison expression, using primitive helpers when possible.
    `` | `protected void` | `evaluateCompoundAssign(String assignName, String baseName, BinaryExpression expression)` GEP-15: dynamic-mode compound-assign codegen.
    `` | `public void` | `evaluateElvisEqual(BinaryExpression expression)` Rewrites and evaluates the Elvis-assignment form.
    `` | `public void` | `evaluateEqual(BinaryExpression expression, boolean defineVariable)` Evaluates an assignment expression.
    `` | `public void` | `evaluatePostfixMethod(PostfixExpression expression)` Evaluates a postfix increment or decrement expression.
    `` | `public void` | `evaluatePrefixMethod(PrefixExpression expression)` Evaluates a prefix increment or decrement expression.
    `` | `public void` | `evaluateTernary(TernaryExpression expression)` Evaluates a ternary or Elvis expression.
    `` | `public WriterController` | `getController()` Returns: the active writer controller
    `` | `public MethodCaller` | `getIsCaseMethod()` Returns: the helper used for `isCase` dispatch
    `` | `protected void` | `writePostOrPrefixMethod(int op, String method, Expression expression, Expression orig)` Emits the method call used to implement a prefix or postfix operation.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### protected final WriterController controller

      Coordinates the active bytecode-generation state.

  - ### Constructor Detail

    - #### public BinaryExpressionHelper(WriterController wc)

      Creates a binary expression helper for the supplied controller.

      Parameters:
        `wc` - the active writer controller

  - ### Method Detail

    - #### protected void assignToArray(Expression parent, Expression receiver, Expression index, Expression rhsValueLoader, boolean safe)

      Emits an array-style assignment using the dynamic `putAt` protocol.

      Parameters:
        `parent` - the original assignment expression
        `receiver` - the array or indexable receiver
        `index` - the subscript expression
        `rhsValueLoader` - an expression that reloads the right-hand value
        `safe` - whether the receiver access is null-safe

    - #### public void eval(BinaryExpression expression)

      Evaluates the supplied binary expression.

      Parameters:
        `expression` - the expression to compile

    - #### protected void evaluateArrayAssignmentWithOperator(String method, BinaryExpression expression, BinaryExpression leftBinExpr)

      Evaluates a compound assignment whose left-hand side is a subscript expression.

      Parameters:
        `method` - the operator method name
        `expression` - the compound assignment expression
        `leftBinExpr` - the indexed left-hand side

    - #### protected void evaluateBinaryExpression(String message, BinaryExpression expression)

      Evaluates a dynamic binary operator by invoking the named helper method.

      Parameters:
        `message` - the operator method name
        `expression` - the expression to compile

    - #### protected void evaluateBinaryExpressionWithAssignment(String method, BinaryExpression expression)

      Evaluates an operator-assignment expression such as `+=`.

      Parameters:
        `method` - the operator method name
        `expression` - the assignment expression

    - #### protected void evaluateCompareExpression(MethodCaller compareMethod, BinaryExpression expression)

      Evaluates a comparison expression, using primitive helpers when possible.

      Parameters:
        `compareMethod` - the dynamic comparison helper
        `expression` - the comparison expression

    - #### protected void evaluateCompoundAssign(String assignName, String baseName, BinaryExpression expression)

      GEP-15: dynamic-mode compound-assign codegen. Routes through ScriptBytecodeAdapter.compoundAssign which dispatches to `assignName` when the receiver responds to it, and falls back to `baseName` otherwise. The caller stores the helper's return value into the LHS — for the in-place branch this is a no-op store of the receiver back to itself; for the fallback branch it is the usual "x = x.op(y)" assignment.

    - #### public void evaluateElvisEqual(BinaryExpression expression)

      Rewrites and evaluates the Elvis-assignment form.

      Parameters:
        `expression` - the Elvis-assignment expression

    - #### public void evaluateEqual(BinaryExpression expression, boolean defineVariable)

      Evaluates an assignment expression.

      Parameters:
        `expression` - the assignment expression
        `defineVariable` - whether the left-hand side declares a new variable

    - #### public void evaluatePostfixMethod(PostfixExpression expression)

      Evaluates a postfix increment or decrement expression.

      Parameters:
        `expression` - the postfix expression

    - #### public void evaluatePrefixMethod(PrefixExpression expression)

      Evaluates a prefix increment or decrement expression.

      Parameters:
        `expression` - the prefix expression

    - #### public void evaluateTernary(TernaryExpression expression)

      Evaluates a ternary or Elvis expression.

      Parameters:
        `expression` - the expression to compile

    - #### public WriterController getController()

      Returns:
        the active writer controller

    - #### public MethodCaller getIsCaseMethod()

      Returns:
        the helper used for `isCase` dispatch

    - #### protected void writePostOrPrefixMethod(int op, String method, Expression expression, Expression orig)

      Emits the method call used to implement a prefix or postfix operation.

      Parameters:
        `op` - the token type
        `method` - the helper method name
        `expression` - the receiver expression
        `orig` - the original prefix/postfix expression