Package org.codehaus.groovy.classgen.asm

# Class BinaryExpressionMultiTypeDispatcher

java.lang.Object
org.codehaus.groovy.classgen.asm.BinaryExpressionHelper
org.codehaus.groovy.classgen.asm.BinaryExpressionMultiTypeDispatcher

Direct Known Subclasses:
  `StaticTypesBinaryExpressionMultiTypeDispatcher`

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
  Modifier and Type
  Field
  Description
  `protected BinaryExpressionWriter[]`
  `binExpWriter`
  Per-type helpers used to emit primitive binary operations.
  `static final Map<ClassNode,Integer>`
  `typeMap`
  Maps primitive operand types to helper indexes.
  `static final String[]`
  `typeMapKeyNames`
  Human-readable names for the indexes used by `typeMap`.

  ### Fields inherited from class org.codehaus.groovy.classgen.asm.BinaryExpressionHelper

  `controller`

- ## Constructor Summary

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

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `assignToArray(Expression orig, Expression receiver, Expression index, Expression rhsValueLoader, boolean safe)`
  Emits an array-style assignment using the dynamic `putAt` protocol.
  `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)`
  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.
  `protected void`
  `evaluateBinaryExpressionWithAssignment(String method, BinaryExpression binExp)`
  Evaluates an operator-assignment expression such as `+=`.
  `protected void`
  `evaluateCompareExpression(MethodCaller compareMethod, BinaryExpression binExp)`
  Evaluates a comparison expression, using primitive helpers when possible.
  `protected void`
  `evaluateCompoundAssign(String assignName, String baseName, BinaryExpression binExp)`
  GEP-15: dynamic-mode compound-assign codegen.
  `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.

  ### Methods inherited from class org.codehaus.groovy.classgen.asm.BinaryExpressionHelper

  `eval, evaluateArrayAssignmentWithOperator, evaluateElvisEqual, evaluateEqual, evaluatePostfixMethod, evaluatePrefixMethod, evaluateTernary, getController, getIsCaseMethod, writeIsCase`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### binExpWriter

    protected BinaryExpressionWriter[] binExpWriter
    Per-type helpers used to emit primitive binary operations.

  - ### typeMap

    public static final Map<ClassNode,Integer> typeMap
    Maps primitive operand types to helper indexes.

  - ### typeMapKeyNames

    public static final String[] typeMapKeyNames
    Human-readable names for the indexes used by `typeMap`.

- ## Constructor Details

  - ### BinaryExpressionMultiTypeDispatcher

    public BinaryExpressionMultiTypeDispatcher(WriterController wc)
    Creates a dispatcher that routes primitive binary expressions to type-specific helpers.
    Parameters:
      `wc` - the active writer controller

- ## Method Details

  - ### initializeDelegateHelpers

    protected BinaryExpressionWriter[] initializeDelegateHelpers()
    Creates the helper table used for primitive binary-expression dispatch.
    Returns:
      the helper table indexed by `typeMap`

  - ### getOperandType

    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

  - ### doPrimtiveCompare

    @Deprecated protected boolean doPrimtiveCompare(ClassNode leftType, ClassNode rightType, BinaryExpression binExp)
    Deprecated.
    Use `doPrimitiveCompare(ClassNode, ClassNode, BinaryExpression)` instead
    Delegates to `doPrimitiveCompare(ClassNode, ClassNode, BinaryExpression)`.

  - ### doPrimitiveCompare

    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

  - ### evaluateCompareExpression

    protected void evaluateCompareExpression(MethodCaller compareMethod, BinaryExpression binExp)
    Evaluates a comparison expression, using primitive helpers when possible.
    Overrides:
      `evaluateCompareExpression` in class `BinaryExpressionHelper`
    Parameters:
      `compareMethod` - the dynamic comparison helper
      `binExp` - the comparison expression

  - ### evaluateBinaryExpression

    protected void evaluateBinaryExpression(String message, BinaryExpression binExp)
    Evaluates a dynamic binary operator by invoking the named helper method.
    Overrides:
      `evaluateBinaryExpression` in class `BinaryExpressionHelper`
    Parameters:
      `message` - the operator method name
      `binExp` - the expression to compile

  - ### evaluateBinaryExpressionWithAssignment

    protected void evaluateBinaryExpressionWithAssignment(String method, BinaryExpression binExp)
    Evaluates an operator-assignment expression such as `+=`.
    Overrides:
      `evaluateBinaryExpressionWithAssignment` in class `BinaryExpressionHelper`
    Parameters:
      `method` - the operator method name
      `binExp` - the assignment expression

  - ### evaluateCompoundAssign

    protected void evaluateCompoundAssign(String assignName, String baseName, BinaryExpression binExp)
    GEP-15: dynamic-mode compound-assign codegen. Routes through `ScriptBytecodeAdapter.compoundAssign(Object, Object, String, String)` 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.
    Overrides:
      `evaluateCompoundAssign` in class `BinaryExpressionHelper`

  - ### assignToArray

    protected void assignToArray(Expression orig, Expression receiver, Expression index, Expression rhsValueLoader, boolean safe)
    Emits an array-style assignment using the dynamic `putAt` protocol.
    Overrides:
      `assignToArray` in class `BinaryExpressionHelper`
    Parameters:
      `orig` - 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

  - ### writePostOrPrefixMethod

    protected void writePostOrPrefixMethod(int op, String method, Expression expression, Expression orig)
    Emits the method call used to implement a prefix or postfix operation.
    Overrides:
      `writePostOrPrefixMethod` in class `BinaryExpressionHelper`
    Parameters:
      `op` - the token type
      `method` - the helper method name
      `expression` - the receiver expression
      `orig` - the original prefix/postfix expression