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 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)
    • 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