Package com.tonic.analysis.ssa.ir
Class SimpleInstruction
- java.lang.Object
-
- com.tonic.analysis.ssa.ir.IRInstruction
-
- com.tonic.analysis.ssa.ir.SimpleInstruction
-
public class SimpleInstruction extends IRInstruction
A single-operand instruction identified by itsSimpleOp: arraylength, monitor ops, throw, goto, or catch.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Taccept(IRVisitor<T> visitor)Accepts a visitor for this instruction.IRInstructioncopyWithNewOperands(SSAValue newResult, List<Value> newOperands)Creates a copy of this instruction with new result and operands.static SimpleInstructioncreateArrayLength(SSAValue result, Value array)Creates an arraylength read.static SimpleInstructioncreateCatch(SSAValue result)Creates the pseudo-instruction that captures the caught exception the JVM leaves on the stack at handler entry.static SimpleInstructioncreateGoto(IRBlock target)Creates an unconditional jump.static SimpleInstructioncreateMonitorEnter(Value objectRef)Creates a monitorenter.static SimpleInstructioncreateMonitorExit(Value objectRef)Creates a monitorexit.static SimpleInstructioncreateThrow(Value exception)Creates an athrow.SimpleOpgetOp()ValuegetOperand()List<Value>getOperands()Gets the operands used by this instruction.IRBlockgetTarget()booleanisTerminator()Checks if this instruction terminates a basic block.voidreplaceOperand(Value oldValue, Value newValue)Replaces an operand value with a new value.voidreplaceTarget(IRBlock oldTarget, IRBlock newTarget)Replaces a target block in terminator instructions.voidsetTarget(IRBlock target)StringtoString()-
Methods inherited from class com.tonic.analysis.ssa.ir.IRInstruction
equals, getBlock, getBytecodeOffset, getId, getResult, getResultType, hashCode, hasResult, isPhi, resetIdCounter, setBlock, setBytecodeOffset, setResult
-
-
-
-
Method Detail
-
createArrayLength
public static SimpleInstruction createArrayLength(SSAValue result, Value array)
Creates an arraylength read.- Parameters:
result- the SSA value receiving the lengtharray- the array reference- Returns:
- the instruction
-
createMonitorEnter
public static SimpleInstruction createMonitorEnter(Value objectRef)
Creates a monitorenter.- Parameters:
objectRef- the object whose monitor is entered- Returns:
- the instruction
-
createMonitorExit
public static SimpleInstruction createMonitorExit(Value objectRef)
Creates a monitorexit.- Parameters:
objectRef- the object whose monitor is released- Returns:
- the instruction
-
createThrow
public static SimpleInstruction createThrow(Value exception)
Creates an athrow.- Parameters:
exception- the exception to throw- Returns:
- the instruction
-
createGoto
public static SimpleInstruction createGoto(IRBlock target)
Creates an unconditional jump.- Parameters:
target- the block to jump to- Returns:
- the instruction
-
createCatch
public static SimpleInstruction createCatch(SSAValue result)
Creates the pseudo-instruction that captures the caught exception the JVM leaves on the stack at handler entry.- Parameters:
result- value the caught exception is bound to- Returns:
- the instruction
-
getOp
public SimpleOp getOp()
- Returns:
- the op
-
getOperand
public Value getOperand()
- Returns:
- the operand
-
getTarget
public IRBlock getTarget()
- Returns:
- the target
-
setTarget
public void setTarget(IRBlock target)
- Parameters:
target- the jump target block
-
getOperands
public List<Value> getOperands()
Description copied from class:IRInstructionGets the operands used by this instruction.- Specified by:
getOperandsin classIRInstruction- Returns:
- list of operand values
-
replaceOperand
public void replaceOperand(Value oldValue, Value newValue)
Description copied from class:IRInstructionReplaces an operand value with a new value.- Specified by:
replaceOperandin classIRInstruction- Parameters:
oldValue- the value to replacenewValue- the replacement value
-
accept
public <T> T accept(IRVisitor<T> visitor)
Description copied from class:IRInstructionAccepts a visitor for this instruction.- Specified by:
acceptin classIRInstruction- Type Parameters:
T- the return type- Parameters:
visitor- the visitor to accept- Returns:
- the visitor result
-
isTerminator
public boolean isTerminator()
Description copied from class:IRInstructionChecks if this instruction terminates a basic block.- Overrides:
isTerminatorin classIRInstruction- Returns:
- true if this is a terminator instruction
-
replaceTarget
public void replaceTarget(IRBlock oldTarget, IRBlock newTarget)
Description copied from class:IRInstructionReplaces a target block in terminator instructions.- Overrides:
replaceTargetin classIRInstruction- Parameters:
oldTarget- the block to replacenewTarget- the replacement block
-
copyWithNewOperands
public IRInstruction copyWithNewOperands(SSAValue newResult, List<Value> newOperands)
Description copied from class:IRInstructionCreates a copy of this instruction with new result and operands.- Overrides:
copyWithNewOperandsin classIRInstruction- Parameters:
newResult- the new result value (may be null)newOperands- the new operand values- Returns:
- a copy of this instruction, or null if copying not supported
-
-