Package jminusminus
Class CLInstruction
java.lang.Object
jminusminus.CLInstruction
- Direct Known Subclasses:
CLArithmeticInstruction,CLArrayInstruction,CLBitInstruction,CLComparisonInstruction,CLConversionInstruction,CLFieldInstruction,CLFlowControlInstruction,CLLoadStoreInstruction,CLMethodInstruction,CLMiscInstruction,CLObjectInstruction,CLStackInstruction
Representation of a JVM instruction. It stores the opcode and mnenomic of an instruction, its
operand count (DYNAMIC if the instruction has variable number operands), pc (location counter),
stack units (words produced - words consumed from the operand stack), and local variable index
(IRRELEVANT if the instruction does not operate on local variables).
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final CLInsInfo[]For each JVM instruction, this array stores its opcode, mnemonic, number of operands (DYNAMIC for instructions with variable attribute count), local variable index (IRRELEVANT where not applicable), stack units, and instruction category.protected intIndex of the local variable that this instruction refers to; applies only to instructions that operate on local variables.protected StringMnemonic for this instruction.protected intOpcode for this instruction.protected intNumber of operands for this instruction; determined statically for all instructions except TABLESWITCH and LOOKUPSWITCH.protected intLocation counter; index of this instruction within the code array of a method.protected intStack units; words produced - words consumed from the operand stack by this instruction. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected intbyteAt(int i, int byteNum) Returns the byte from i at position byteNum.static booleanisValid(int opcode) Returns true if the opcode is valid, and false otherwise.intReturns the local variable index for this instruction.mnemonic()Returns the mnemonic for this instruction.intopcode()Returns the opcode for this instruction.intReturns the number of operands for this instruction.intpc()Returns the pc for this instruction.intReturns the stack units for this instruction.toBytes()Returns the bytecode for this instruction.
-
Field Details
-
opcode
protected int opcodeOpcode for this instruction. -
mnemonic
Mnemonic for this instruction. -
operandCount
protected int operandCountNumber of operands for this instruction; determined statically for all instructions except TABLESWITCH and LOOKUPSWITCH. -
pc
protected int pcLocation counter; index of this instruction within the code array of a method. -
stackUnits
protected int stackUnitsStack units; words produced - words consumed from the operand stack by this instruction. -
localVariableIndex
protected int localVariableIndexIndex of the local variable that this instruction refers to; applies only to instructions that operate on local variables. -
instructionInfo
For each JVM instruction, this array stores its opcode, mnemonic, number of operands (DYNAMIC for instructions with variable attribute count), local variable index (IRRELEVANT where not applicable), stack units, and instruction category. For example, for IMUL, these parameters are IMUL, "imul", 0, IRRELEVANT, -1, ARITHMETIC1.
-
-
Constructor Details
-
CLInstruction
CLInstruction()
-
-
Method Details
-
isValid
public static boolean isValid(int opcode) Returns true if the opcode is valid, and false otherwise.- Parameters:
opcode- instruction opcode.- Returns:
- true if the opcode is valid, and false otherwise.
-
opcode
public int opcode()Returns the opcode for this instruction.- Returns:
- the opcode for this instruction.
-
mnemonic
Returns the mnemonic for this instruction.- Returns:
- the mnemonic for this instruction.
-
operandCount
public int operandCount()Returns the number of operands for this instruction.- Returns:
- the number of operands for this instruction.
-
pc
public int pc()Returns the pc for this instruction.- Returns:
- the pc for this instruction.
-
stackUnits
public int stackUnits()Returns the stack units for this instruction.- Returns:
- the stack units for this instruction.
-
localVariableIndex
public int localVariableIndex()Returns the local variable index for this instruction.- Returns:
- the local variable index for this instruction.
-
toBytes
Returns the bytecode for this instruction.- Returns:
- the bytecode for this instruction.
-
byteAt
protected int byteAt(int i, int byteNum) Returns the byte from i at position byteNum.- Parameters:
i- number whose individual byte is required.byteNum- the byte to return (1: lower - 4: higher).- Returns:
- the byte at the specified position.
-