Package com.tonic.analysis.instruction
Class ConditionalBranchInstruction
- java.lang.Object
-
- com.tonic.analysis.instruction.Instruction
-
- com.tonic.analysis.instruction.ConditionalBranchInstruction
-
public class ConditionalBranchInstruction extends Instruction
Represents the conditional branch instructions.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classConditionalBranchInstruction.BranchTypeThe conditional branch kinds, each pairing a JVM opcode with its mnemonic.
-
Constructor Summary
Constructors Constructor Description ConditionalBranchInstruction(int opcode, int offset, short branchOffset)Constructs a ConditionalBranchInstruction.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(AbstractBytecodeVisitor visitor)Accepts a visitor for bytecode analysis.intgetBranchOffset()Returns the branch offset.intgetLocalChange()Returns the change in local variables caused by this instruction.intgetStackChange()Returns the change in stack size caused by this instruction.ConditionalBranchInstruction.BranchTypegetType()Returns the type of branch operation.StringtoString()Returns a string representation of the instruction.voidwrite(DataOutputStream dos)Writes the conditional branch opcode and its operands to the DataOutputStream.-
Methods inherited from class com.tonic.analysis.instruction.Instruction
getLength, getOffset, getOpcode, setOffset
-
-
-
-
Constructor Detail
-
ConditionalBranchInstruction
public ConditionalBranchInstruction(int opcode, int offset, short branchOffset)Constructs a ConditionalBranchInstruction.- Parameters:
opcode- The opcode of the instruction.offset- The bytecode offset of the instruction.branchOffset- The branch target offset relative to current instruction.- Throws:
IllegalArgumentException- if the opcode is not a conditional branch opcode
-
-
Method Detail
-
accept
public void accept(AbstractBytecodeVisitor visitor)
Description copied from class:InstructionAccepts a visitor for bytecode analysis.- Specified by:
acceptin classInstruction- Parameters:
visitor- The visitor to accept.
-
write
public void write(DataOutputStream dos) throws IOException
Writes the conditional branch opcode and its operands to the DataOutputStream.- Specified by:
writein classInstruction- Parameters:
dos- The DataOutputStream to write to.- Throws:
IOException- If an I/O error occurs.
-
getStackChange
public int getStackChange()
Returns the change in stack size caused by this instruction.- Specified by:
getStackChangein classInstruction- Returns:
- The stack size change based on the branch type.
-
getLocalChange
public int getLocalChange()
Returns the change in local variables caused by this instruction.- Specified by:
getLocalChangein classInstruction- Returns:
- The local variables size change (none).
-
getType
public ConditionalBranchInstruction.BranchType getType()
Returns the type of branch operation.- Returns:
- The BranchType enum value.
-
getBranchOffset
public int getBranchOffset()
Returns the branch offset.- Returns:
- The branch target offset.
-
toString
public String toString()
Returns a string representation of the instruction.- Overrides:
toStringin classInstruction- Returns:
- The mnemonic and branch target of the instruction.
-
-