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
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 ByteCodeForm
byteCodeArray, byteCodesByName, WIDENED -
Constructor Summary
ConstructorsConstructorDescriptionVariableInstructionForm(int opcode, String name) Constructs a new instance with the specified opcode, name, operandType and rewrite. -
Method Summary
Modifier and TypeMethodDescriptionvoidsetRewrite2Bytes(int operand, int absPosition, int[] rewrite) This method writes operand directly into the rewrite array at index position specified.voidsetRewrite4Bytes(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.voidsetRewrite4Bytes(int operand, int absPosition, int[] rewrite) This method writes operand directly into the rewrite array at index position specified.Methods inherited from class ByteCodeForm
calculateOperandPosition, firstOperandIndex, fixUpByteCodeTargets, get, getName, getOpcode, getRewrite, getRewriteCopy, hasMultipleByteCodes, hasNoOperand, nestedMustStartClassPool, operandLength, setByteCodeOperands, toString
-
Constructor Details
-
VariableInstructionForm
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
This method writes operand directly into the rewrite array at index position specified.- Parameters:
operand- value to writeabsPosition- 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
This method writes operand directly into the rewrite array at index position specified.- Parameters:
operand- value to writeabsPosition- 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
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 torewrite- int[] bytes to rewrite
-