Package org.apache.commons.compress.harmony.unpack200.bytecode.forms

# Class VariableInstructionForm

java.lang.Object
org.apache.commons.compress.harmony.unpack200.bytecode.forms.ByteCodeForm
org.apache.commons.compress.harmony.unpack200.bytecode.forms.VariableInstructionForm

Direct Known Subclasses:
  `SwitchForm`, `WideForm`

public abstract class VariableInstructionForm extends ByteCodeForm
This abstract class implements the common code for instructions which have variable lengths. This is currently the *switch instructions and some wide (_w) instructions.

- ## Field Summary

  ### Fields inherited from class org.apache.commons.compress.harmony.unpack200.bytecode.forms.ByteCodeForm

  `byteCodeArray, byteCodesByName, WIDENED`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `VariableInstructionForm(int opcode, String name)`
  Constructs a new instance with the specified opcode, name, operandType and rewrite.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `setRewrite2Bytes(int operand, int absPosition, int[] rewrite)`
  This method writes operand directly into the rewrite array at index position specified.
  `void`
  `setRewrite4Bytes(int operand, int[] rewrite)`
  Given an int operand, set the rewrite bytes for the next available operand position and the three immediately following it to a highest-byte, mid-high, mid-low, low-byte encoding of the operand.
  `void`
  `setRewrite4Bytes(int operand, int absPosition, int[] rewrite)`
  This method writes operand directly into the rewrite array at index position specified.

  ### Methods inherited from class org.apache.commons.compress.harmony.unpack200.bytecode.forms.ByteCodeForm

  `calculateOperandPosition, firstOperandIndex, fixUpByteCodeTargets, get, getName, getOpcode, getRewrite, getRewriteCopy, hasMultipleByteCodes, hasNoOperand, nestedMustStartClassPool, operandLength, setByteCodeOperands, toString`

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

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

- ## Constructor Details

  - ### VariableInstructionForm

    public VariableInstructionForm(int opcode, String name)
    Constructs a new instance with the specified opcode, name, operandType and rewrite.
    Parameters:
      `opcode` - index corresponding to the opcode's value.
      `name` - String printable name of the opcode.

- ## Method Details

  - ### setRewrite2Bytes

    public void setRewrite2Bytes(int operand, int absPosition, int[] rewrite)
    This method writes operand directly into the rewrite array at index position specified.
    Parameters:
      `operand` - value to write
      `absPosition` - position in array to write. Note that this is absolute position in the array, so one can overwrite the bytecode if one isn't careful.
      `rewrite` - array to write into

  - ### setRewrite4Bytes

    public void setRewrite4Bytes(int operand, int absPosition, int[] rewrite)
    This method writes operand directly into the rewrite array at index position specified.
    Parameters:
      `operand` - value to write
      `absPosition` - position in array to write. Note that this is absolute position in the array, so one can overwrite the bytecode if one isn't careful.
      `rewrite` - array to write into

  - ### setRewrite4Bytes

    public void setRewrite4Bytes(int operand, int[] rewrite)
    Given an int operand, set the rewrite bytes for the next available operand position and the three immediately following it to a highest-byte, mid-high, mid-low, low-byte encoding of the operand. Note that unlike the ByteCode setOperand* operations, this starts with an actual bytecode rewrite array (rather than a ByteCodeForm prototype rewrite array). Also, this method overwrites -1 values in the rewrite array - so if you start with an array that looks like: {100, -1, -1, -1, -1, 200, -1, -1, -1, -1} then calling setRewrite4Bytes(0, rewrite) the first time will convert it to: {100, 0, 0, 0, 0, 200, -1, -1, -1, -1} Calling setRewrite4Bytes(0, rewrite) a second time will convert it to: {100, 0, 0, 0, 0, 200, 0, 0, 0, 0}
    Parameters:
      `operand` - int to set the rewrite bytes to
      `rewrite` - int[] bytes to rewrite