Package: org.codehaus.groovy.classgen.asm

## [Java] Class BinaryExpressionWriter

- org.codehaus.groovy.classgen.asm.BinaryExpressionWriter

-     public abstract class BinaryExpressionWriter
      extends Object

  Base class for writing primitive typed operations

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `protected static int[]` | `stdCompareCodes` | Jump opcodes used for primitive comparison results.

  - ### Constructor Summary

    Constructors
    Constructor and description
    `BinaryExpressionWriter(WriterController controller, MethodCaller arraySet, MethodCaller arrayGet)` Creates a primitive-operation writer.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public boolean` | `arrayGet(int operation, boolean simulate)` Attempts to write an array-read operation.
    `` | `public boolean` | `arraySet(boolean simulate)` Writes an array-store operation.
    `` | `protected abstract void` | `doubleTwoOperands(org.objectweb.asm.MethodVisitor mv)` Duplicates the two operands already on the operand stack.
    `` | `protected MethodCaller` | `getArrayGetCaller()` Returns: the helper used for primitive array loads
    `` | `protected ClassNode` | `getArrayGetResultType()` Returns: the result type produced by getArrayGetCaller()
    `` | `protected MethodCaller` | `getArraySetCaller()` Returns: the helper used for primitive array stores
    `` | `protected abstract int` | `getBitwiseOperationBytecode(int type)` Returns the bitwise opcode for the supplied token.
    `` | `protected abstract int` | `getCompareCode()` Returns: the ASM compare opcode used by this primitive type
    `` | `public WriterController` | `getController()` return writer controller
    `` | `protected abstract ClassNode` | `getDevisionOpResultType()` Returns: the result type for division operations
    `` | `protected abstract ClassNode` | `getNormalOpResultType()` Returns: the result type for normal arithmetic operations
    `` | `protected abstract int` | `getShiftOperationBytecode(int type)` Returns the shift opcode for the supplied token.
    `` | `protected abstract int` | `getStandardOperationBytecode(int type)` Returns the arithmetic opcode for the supplied token.
    `` | `protected abstract void` | `removeTwoOperands(org.objectweb.asm.MethodVisitor mv)` Removes the two operands already on the operand stack.
    `` | `public void` | `setArraySetAndGet(MethodCaller arraySet, MethodCaller arrayGet)` Replaces the helpers used for primitive array access.
    `` | `protected boolean` | `supportsDivision()` Returns: whether this primitive helper supports division bytecode directly
    `` | `public boolean` | `write(int operation, boolean simulate)` Attempts to write the supplied binary operation.
    `` | `protected boolean` | `writeBitwiseOp(int type, boolean simulate)` writes some the bitwise operations. type is one of BITWISE_OR, BITWISE_AND, BITWISE_XOR
    `` | `protected boolean` | `writeDivision(boolean simulate)` Writes a division operation for the current primitive type.
    `` | `protected abstract void` | `writeMinusMinus(org.objectweb.asm.MethodVisitor mv)` Emits a prefix/postfix decrement.
    `` | `protected abstract void` | `writePlusPlus(org.objectweb.asm.MethodVisitor mv)` Emits a prefix/postfix increment.
    `` | `public boolean` | `writePostOrPrefixMethod(int operation, boolean simulate)` Attempts to write a postfix or prefix increment/decrement operation.
    `` | `protected boolean` | `writeShiftOp(int type, boolean simulate)` Write shifting operations.
    `` | `protected boolean` | `writeSpaceship(int type, boolean simulate)` Writes a spaceship comparison for the current primitive type.
    `` | `protected boolean` | `writeStdCompare(int type, boolean simulate)` writes some int standard operations for compares
    `` | `protected boolean` | `writeStdOperators(int type, boolean simulate)` Writes a standard arithmetic operator for the current primitive type.

  - ### Inherited Methods Summary

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

- - ### Field Detail

    - #### protected static final int[] stdCompareCodes

      Jump opcodes used for primitive comparison results.

  - ### Constructor Detail

    - #### public BinaryExpressionWriter(WriterController controller, MethodCaller arraySet, MethodCaller arrayGet)

      Creates a primitive-operation writer.

      Parameters:
        `controller` - the active writer controller
        `arraySet` - the helper used for array stores
        `arrayGet` - the helper used for array loads

  - ### Method Detail

    - #### public boolean arrayGet(int operation, boolean simulate)

      Attempts to write an array-read operation.

      Parameters:
        `operation` - the token type
        `simulate` - whether to probe support without emitting bytecode
      Returns:
        `true` if the operation is an array read

    - #### public boolean arraySet(boolean simulate)

      Writes an array-store operation.

      Parameters:
        `simulate` - whether to probe support without emitting bytecode
      Returns:
        always `true`

    - #### protected abstract void doubleTwoOperands(org.objectweb.asm.MethodVisitor mv)

      Duplicates the two operands already on the operand stack.

      Parameters:
        `mv` - the current method visitor

    - #### protected MethodCaller getArrayGetCaller()

      Returns:
        the helper used for primitive array loads

    - #### protected ClassNode getArrayGetResultType()

      Returns:
        the result type produced by getArrayGetCaller()

    - #### protected MethodCaller getArraySetCaller()

      Returns:
        the helper used for primitive array stores

    - #### protected abstract int getBitwiseOperationBytecode(int type)

      Returns the bitwise opcode for the supplied token.

      Parameters:
        `type` - the normalized token index
      Returns:
        the ASM opcode

    - #### protected abstract int getCompareCode()

      Returns:
        the ASM compare opcode used by this primitive type

    - #### public WriterController getController()

      return writer controller

      Since:
        2.5.0

    - #### protected abstract ClassNode getDevisionOpResultType()

      Returns:
        the result type for division operations

    - #### protected abstract ClassNode getNormalOpResultType()

      Returns:
        the result type for normal arithmetic operations

    - #### protected abstract int getShiftOperationBytecode(int type)

      Returns the shift opcode for the supplied token.

      Parameters:
        `type` - the normalized token index
      Returns:
        the ASM opcode

    - #### protected abstract int getStandardOperationBytecode(int type)

      Returns the arithmetic opcode for the supplied token.

      Parameters:
        `type` - the normalized token index
      Returns:
        the ASM opcode

    - #### protected abstract void removeTwoOperands(org.objectweb.asm.MethodVisitor mv)

      Removes the two operands already on the operand stack.

      Parameters:
        `mv` - the current method visitor

    - #### public void setArraySetAndGet(MethodCaller arraySet, MethodCaller arrayGet)

      Replaces the helpers used for primitive array access.

      Parameters:
        `arraySet` - the array-store helper
        `arrayGet` - the array-load helper

    - #### protected boolean supportsDivision()

      Returns:
        whether this primitive helper supports division bytecode directly

    - #### public boolean write(int operation, boolean simulate)

      Attempts to write the supplied binary operation.

      Parameters:
        `operation` - the token type
        `simulate` - whether to probe support without emitting bytecode
      Returns:
        `true` if the operation is supported

    - #### protected boolean writeBitwiseOp(int type, boolean simulate)

      writes some the bitwise operations. type is one of BITWISE_OR, BITWISE_AND, BITWISE_XOR

      Parameters:
        `type` - the token type
      Returns:
        true if a successful bitwise operation write

    - #### protected boolean writeDivision(boolean simulate)

      Writes a division operation for the current primitive type.

      Parameters:
        `simulate` - whether to probe support without emitting bytecode
      Returns:
        `true` if division is supported

    - #### protected abstract void writeMinusMinus(org.objectweb.asm.MethodVisitor mv)

      Emits a prefix/postfix decrement.

      Parameters:
        `mv` - the current method visitor

    - #### protected abstract void writePlusPlus(org.objectweb.asm.MethodVisitor mv)

      Emits a prefix/postfix increment.

      Parameters:
        `mv` - the current method visitor

    - #### public boolean writePostOrPrefixMethod(int operation, boolean simulate)

      Attempts to write a postfix or prefix increment/decrement operation.

      Parameters:
        `operation` - the token type
        `simulate` - whether to probe support without emitting bytecode
      Returns:
        `true` if the operation is supported

    - #### protected boolean writeShiftOp(int type, boolean simulate)

      Write shifting operations. Type is one of LEFT_SHIFT, RIGHT_SHIFT, or RIGHT_SHIFT_UNSIGNED

      Parameters:
        `type` - the token type
      Returns:
        true on a successful shift operation write

    - #### protected boolean writeSpaceship(int type, boolean simulate)

      Writes a spaceship comparison for the current primitive type.

      Parameters:
        `type` - the token type
        `simulate` - whether to probe support without emitting bytecode
      Returns:
        `true` if the operation is supported

    - #### protected boolean writeStdCompare(int type, boolean simulate)

      writes some int standard operations for compares

      Parameters:
        `type` - the token type
      Returns:
        true if a successful std operator write

    - #### protected boolean writeStdOperators(int type, boolean simulate)

      Writes a standard arithmetic operator for the current primitive type.

      Parameters:
        `type` - the token type
        `simulate` - whether to probe support without emitting bytecode
      Returns:
        `true` if the operation is supported