Package org.codehaus.groovy.classgen.asm

# Class BinaryIntExpressionHelper

java.lang.Object
org.codehaus.groovy.classgen.asm.BinaryExpressionWriter
org.codehaus.groovy.classgen.asm.BinaryIntExpressionHelper

Direct Known Subclasses:
  `BinaryBooleanExpressionHelper`

public class BinaryIntExpressionHelper extends BinaryExpressionWriter
Emits optimized bytecode for integer binary operations.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `BinaryIntExpressionHelper(WriterController wc)`
  Creates an integer-specialized binary expression helper.
  `BinaryIntExpressionHelper(WriterController wc, MethodCaller arraySet, MethodCaller arrayGet)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `doubleTwoOperands(org.objectweb.asm.MethodVisitor mv)`
  Duplicates the two operands already on the operand stack.
  `protected int`
  `getBitwiseOperationBytecode(int type)`
  Returns the bitwise opcode for the supplied token.
  `protected int`
  `getCompareCode()`
  `protected ClassNode`
  `getDevisionOpResultType()`
  `protected ClassNode`
  `getNormalOpResultType()`
  `protected int`
  `getShiftOperationBytecode(int type)`
  Returns the shift opcode for the supplied token.
  `protected int`
  `getStandardOperationBytecode(int type)`
  Returns the arithmetic opcode for the supplied token.
  `protected void`
  `removeTwoOperands(org.objectweb.asm.MethodVisitor mv)`
  Removes the two operands already on the operand stack.
  `protected boolean`
  `supportsDivision()`
  `protected void`
  `writeMinusMinus(org.objectweb.asm.MethodVisitor mv)`
  Emits a prefix/postfix decrement.
  `protected void`
  `writePlusPlus(org.objectweb.asm.MethodVisitor mv)`
  Emits a prefix/postfix increment.
  `protected boolean`
  `writeSpaceship(int type, boolean simulate)`
  writes the spaceship operator, type should be COMPARE_TO
  `protected boolean`
  `writeStdCompare(int type, boolean simulate)`
  writes a std compare.

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

  `arrayGet, arraySet, getArrayGetCaller, getArrayGetResultType, getArraySetCaller, getController, setArraySetAndGet, write, writeBitwiseOp, writeDivision, writePostOrPrefixMethod, writeShiftOp, writeStdOperators`

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

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

- ## Constructor Details

  - ### BinaryIntExpressionHelper

    public BinaryIntExpressionHelper(WriterController wc)
    Creates an integer-specialized binary expression helper.
    Parameters:
      `wc` - the active writer controller

  - ### BinaryIntExpressionHelper

    public BinaryIntExpressionHelper(WriterController wc, MethodCaller arraySet, MethodCaller arrayGet)
    Since:
      2.5.0

- ## Method Details

  - ### writeStdCompare

    protected boolean writeStdCompare(int type, boolean simulate)
    writes a std compare. This involves the tokens IF_ICMPEQ, IF_ICMPNE, IF_ICMPEQ, IF_ICMPNE, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE and IF_ICMPLT
    Overrides:
      `writeStdCompare` in class `BinaryExpressionWriter`
    Parameters:
      `type` - the token type
    Returns:
      true if a successful std compare write

  - ### writeSpaceship

    protected boolean writeSpaceship(int type, boolean simulate)
    writes the spaceship operator, type should be COMPARE_TO
    Overrides:
      `writeSpaceship` in class `BinaryExpressionWriter`
    Parameters:
      `type` - the token type
      `simulate` - whether to probe support without emitting bytecode
    Returns:
      true if a successful spaceship operator write

  - ### doubleTwoOperands

    protected void doubleTwoOperands(org.objectweb.asm.MethodVisitor mv)
    Duplicates the two operands already on the operand stack.
    Specified by:
      `doubleTwoOperands` in class `BinaryExpressionWriter`
    Parameters:
      `mv` - the current method visitor

  - ### getBitwiseOperationBytecode

    protected int getBitwiseOperationBytecode(int type)
    Returns the bitwise opcode for the supplied token.
    Specified by:
      `getBitwiseOperationBytecode` in class `BinaryExpressionWriter`
    Parameters:
      `type` - the normalized token index
    Returns:
      the ASM opcode

  - ### getCompareCode

    protected int getCompareCode()
    Specified by:
      `getCompareCode` in class `BinaryExpressionWriter`
    Returns:
      the ASM compare opcode used by this primitive type

  - ### getNormalOpResultType

    protected ClassNode getNormalOpResultType()
    Specified by:
      `getNormalOpResultType` in class `BinaryExpressionWriter`
    Returns:
      the result type for normal arithmetic operations

  - ### getShiftOperationBytecode

    protected int getShiftOperationBytecode(int type)
    Returns the shift opcode for the supplied token.
    Specified by:
      `getShiftOperationBytecode` in class `BinaryExpressionWriter`
    Parameters:
      `type` - the normalized token index
    Returns:
      the ASM opcode

  - ### getStandardOperationBytecode

    protected int getStandardOperationBytecode(int type)
    Returns the arithmetic opcode for the supplied token.
    Specified by:
      `getStandardOperationBytecode` in class `BinaryExpressionWriter`
    Parameters:
      `type` - the normalized token index
    Returns:
      the ASM opcode

  - ### removeTwoOperands

    protected void removeTwoOperands(org.objectweb.asm.MethodVisitor mv)
    Removes the two operands already on the operand stack.
    Specified by:
      `removeTwoOperands` in class `BinaryExpressionWriter`
    Parameters:
      `mv` - the current method visitor

  - ### writeMinusMinus

    protected void writeMinusMinus(org.objectweb.asm.MethodVisitor mv)
    Emits a prefix/postfix decrement.
    Specified by:
      `writeMinusMinus` in class `BinaryExpressionWriter`
    Parameters:
      `mv` - the current method visitor

  - ### writePlusPlus

    protected void writePlusPlus(org.objectweb.asm.MethodVisitor mv)
    Emits a prefix/postfix increment.
    Specified by:
      `writePlusPlus` in class `BinaryExpressionWriter`
    Parameters:
      `mv` - the current method visitor

  - ### getDevisionOpResultType

    protected ClassNode getDevisionOpResultType()
    Specified by:
      `getDevisionOpResultType` in class `BinaryExpressionWriter`
    Returns:
      the result type for division operations

  - ### supportsDivision

    protected boolean supportsDivision()
    Overrides:
      `supportsDivision` in class `BinaryExpressionWriter`
    Returns:
      whether this primitive helper supports division bytecode directly