Package: org.codehaus.groovy.classgen.asm

## [Java] Class BinaryExpressionMultiTypeDispatcher

- org.codehaus.groovy.classgen.asm.BinaryExpressionMultiTypeDispatcher

-     public class BinaryExpressionMultiTypeDispatcher
      extends BinaryExpressionHelper

  This class is for internal use only! This class will dispatch to the right type adapters according to the kind of binary expression that is provided.

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `protected BinaryExpressionWriter[]` | `binExpWriter` | Per-type helpers used to emit primitive binary operations.
    `static Map<ClassNode, Integer>` | `typeMap` | Maps primitive operand types to helper indexes.
    `static String[]` | `typeMapKeyNames` | Human-readable names for the indexes used by typeMap.

  - Inherited fields
    Fields inherited from class | Fields
    --- | ---
    `class BinaryExpressionHelper` | `controller`

  - ### Constructor Summary

    Constructors
    Constructor and description
    `BinaryExpressionMultiTypeDispatcher(WriterController wc)` Creates a dispatcher that routes primitive binary expressions to type-specific helpers.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `protected void` | `assignToArray(Expression orig, 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
    `` | `protected boolean` | `doPrimitiveCompare(ClassNode leftType, ClassNode rightType, BinaryExpression binExp)` Attempts primitive comparison bytecode generation for the supplied operands.
    `` | `protected boolean` | `doPrimtiveCompare(ClassNode leftType, ClassNode rightType, BinaryExpression binExp)` Delegates to doPrimitiveCompare(ClassNode, ClassNode, BinaryExpression).
    `` | `protected void` | `evaluateBinaryExpression(String message, BinaryExpression binExp)` * 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 binExp)` * Evaluates an operator-assignment expression such as `+=`. * * Parameters: `method` - the operator method name * `expression` - the assignment expression
    `` | `protected void` | `evaluateCompareExpression(MethodCaller compareMethod, BinaryExpression binExp)` * 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 binExp)` * 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.
    `` | `protected int` | `getOperandType(ClassNode type)` Returns the helper index for the supplied operand type.
    `` | `protected BinaryExpressionWriter[]` | `initializeDelegateHelpers()` Creates the helper table used for primitive binary-expression 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

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class BinaryExpressionHelper` | `assignToArray, eval, evaluateArrayAssignmentWithOperator, evaluateBinaryExpression, evaluateBinaryExpressionWithAssignment, evaluateCompareExpression, evaluateCompoundAssign, evaluateElvisEqual, evaluateEqual, evaluatePostfixMethod, evaluatePrefixMethod, evaluateTernary, getController, getIsCaseMethod, writePostOrPrefixMethod`

- - ### Field Detail

    - #### protected BinaryExpressionWriter[] binExpWriter

      Per-type helpers used to emit primitive binary operations.

    - #### public static final Map<ClassNode, Integer> typeMap

      Maps primitive operand types to helper indexes.

    - #### public static final String[] typeMapKeyNames

      Human-readable names for the indexes used by typeMap.

  - ### Constructor Detail

    - #### public BinaryExpressionMultiTypeDispatcher(WriterController wc)

      Creates a dispatcher that routes primitive binary expressions to type-specific helpers.

      Parameters:
        `wc` - the active writer controller

  - ### Method Detail

    - #### protected void assignToArray(Expression orig, 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

    - #### protected boolean doPrimitiveCompare(ClassNode leftType, ClassNode rightType, BinaryExpression binExp)

      Attempts primitive comparison bytecode generation for the supplied operands.

      Parameters:
        `leftType` - the left operand type
        `rightType` - the right operand type
        `binExp` - the comparison expression
      Returns:
        `true` if a primitive-specialized implementation handled the comparison

    - #### @Deprecated
      protected boolean doPrimtiveCompare(ClassNode leftType, ClassNode rightType, BinaryExpression binExp)

      Delegates to doPrimitiveCompare(ClassNode, ClassNode, BinaryExpression).

      deprecated:
        Use doPrimitiveCompare(ClassNode, ClassNode, BinaryExpression) instead

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

      * 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 binExp)

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

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

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

      * 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 binExp)

      * 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.

    - #### protected int getOperandType(ClassNode type)

      Returns the helper index for the supplied operand type.

      Parameters:
        `type` - the operand type
      Returns:
        the helper index, or `0` when no primitive specialization applies

    - #### protected BinaryExpressionWriter[] initializeDelegateHelpers()

      Creates the helper table used for primitive binary-expression dispatch.

      Returns:
        the helper table indexed by typeMap

    - #### 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