Package jminusminus
Class CLFlowControlInstruction
java.lang.Object
jminusminus.CLInstruction
jminusminus.CLFlowControlInstruction
Representation for FLOW_CONTROL1, FLOW_CONTROL2, FLOW_CONTROL3 and FLOW_CONTROL4 instructions.
-
Field Summary
Fields inherited from class jminusminus.CLInstruction
instructionInfo, localVariableIndex, mnemonic, opcode, operandCount, pc, stackUnits
-
Constructor Summary
ConstructorDescriptionCLFlowControlInstruction
(int pc, int index, boolean isWidened) Constructs a CLFlowControlInstruction object for RET instruction.CLFlowControlInstruction
(int opcode, int pc, String jumpToLabel) Constructs a CLFlowControlInstruction object for FLOW_CONTROL1 instructions.CLFlowControlInstruction
(int opcode, int pc, String defaultLabel, int low, int high, ArrayList<String> labels) Constructs a CLFlowControlInstruction object for TABLESWITCH instruction.CLFlowControlInstruction
(int opcode, int pc, String defaultLabel, int numPairs, TreeMap<Integer, String> matchLabelPairs) Constructs a CLFlowControlInstruction object for LOOKUPSWITCH instruction. -
Method Summary
Modifier and TypeMethodDescriptionint
Returns the pc of instruction to jump to.boolean
resolveLabels
(Hashtable<String, Integer> labelToPC) Resolves the jump labels to the corresponding offset values using the given label to pc mapping.toBytes()
Returns the bytecode for this instruction.Methods inherited from class jminusminus.CLInstruction
byteAt, isValid, localVariableIndex, mnemonic, opcode, operandCount, pc, stackUnits
-
Constructor Details
-
CLFlowControlInstruction
Constructs a CLFlowControlInstruction object for FLOW_CONTROL1 instructions.- Parameters:
opcode
- the opcode for this instruction.pc
- index of this instruction within the code array of a method.jumpToLabel
- the label to jump to.
-
CLFlowControlInstruction
public CLFlowControlInstruction(int pc, int index, boolean isWidened) Constructs a CLFlowControlInstruction object for RET instruction.- Parameters:
pc
- index of this instruction within the code array of a method.index
- index of the local variable containing the return address.isWidened
- whether this instruction is preceeded by the WIDE (widening) instruction.
-
CLFlowControlInstruction
public CLFlowControlInstruction(int opcode, int pc, String defaultLabel, int low, int high, ArrayList<String> labels) Constructs a CLFlowControlInstruction object for TABLESWITCH instruction.- Parameters:
opcode
- the opcode for this instruction.pc
- index of this instruction within the code array of a method.defaultLabel
- jump label for default value.low
- smallest value of index.high
- highest value of index.labels
- list of jump labels for each index value from low to high, end values included.
-
CLFlowControlInstruction
public CLFlowControlInstruction(int opcode, int pc, String defaultLabel, int numPairs, TreeMap<Integer, String> matchLabelPairs) Constructs a CLFlowControlInstruction object for LOOKUPSWITCH instruction.- Parameters:
opcode
- the opcode for this instruction.pc
- index of this instruction within the code array of a method.defaultLabel
- jump label for default value.numPairs
- number of pairs in the match table.matchLabelPairs
- key match table.
-
-
Method Details
-
resolveLabels
Resolves the jump labels to the corresponding offset values using the given label to pc mapping. If unable to resolve a label, the offset is set such that the next instruction will be executed.- Parameters:
labelToPC
- label to pc mapping.- Returns:
- true if all labels were resolved successfully, and false otherwise.
-
jumpToOffset
public int jumpToOffset()Returns the pc of instruction to jump to.- Returns:
- pc to jump to.
-
toBytes
Returns the bytecode for this instruction.- Specified by:
toBytes
in classCLInstruction
- Returns:
- the bytecode for this instruction.
-