Package com.ibm.wala.ssa
Class SSAInstruction
- java.lang.Object
-
- com.ibm.wala.ssa.SSAInstruction
-
- Direct Known Subclasses:
AstAssertInstruction
,AstEchoInstruction
,AstIsDefinedInstruction
,AstLexicalAccess
,ReflectiveMemberAccess
,SSAAbstractBinaryInstruction
,SSAAbstractInvokeInstruction
,SSAAbstractThrowInstruction
,SSAAbstractUnaryInstruction
,SSAAddressOfInstruction
,SSAArrayLengthInstruction
,SSAArrayReferenceInstruction
,SSACheckCastInstruction
,SSAComparisonInstruction
,SSAConditionalBranchInstruction
,SSAConversionInstruction
,SSAFieldAccessInstruction
,SSAGetCaughtExceptionInstruction
,SSAGotoInstruction
,SSAInstanceofInstruction
,SSALoadMetadataInstruction
,SSAMonitorInstruction
,SSANewInstruction
,SSAPhiInstruction
,SSAReturnInstruction
,SSAStoreIndirectInstruction
,SSASwitchInstruction
public abstract class SSAInstruction extends Object
An instruction in SSA form.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
SSAInstruction.IVisitor
This interface is used by Instruction.visit to dispatch based on the instruction type.static class
SSAInstruction.Visitor
A base visitor implementation that does nothing.
-
Constructor Summary
Constructors Modifier Constructor Description protected
SSAInstruction(int iindex)
prevent instantiation by the outside
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract SSAInstruction
copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses)
This method is meant to be used during SSA conversion for an IR that is not in SSA form.boolean
equals(Object obj)
We assume these instructions are canonical and managed by a governing IR object.int
getDef()
int
getDef(int i)
Return the ith defCollection<TypeReference>
getExceptionTypes()
This method should never return null.int
getNumberOfDefs()
int
getNumberOfUses()
int
getUse(int j)
protected String
getValueString(SymbolTable symbolTable, int valueNumber)
boolean
hasDef()
Does this instruction define a normal value, as distinct from a set of exceptions possibly thrown by it (e.g.abstract int
hashCode()
abstract boolean
isFallThrough()
boolean
isPEI()
String
toString()
abstract String
toString(SymbolTable symbolTable)
abstract void
visit(SSAInstruction.IVisitor v)
Apply an IVisitor to this instruction.
-
-
-
Field Detail
-
NO_INDEX
public static final int NO_INDEX
- See Also:
- Constant Field Values
-
iindex
public final int iindex
-
-
Method Detail
-
copyForSSA
public abstract SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses)
This method is meant to be used during SSA conversion for an IR that is not in SSA form. It creates a new SSAInstruction of the same type as the receiver, with a combination of the receiver's uses and defs and those from the method parameters. In particular, if the 'defs' parameter is null, then the new instruction has the same defs as the receiver. If 'defs' is not null, it must be an array with a size equal to the number of defs that the receiver instruction has. In this case, the new instruction has defs taken from the array. The uses of the new instruction work in the same way with the 'uses' parameter. Note that this only applies to CAst-based IR translation, since Java bytecode-based IR generation uses a different SSA construction mechanism. TODO: move this into the SSAInstructionFactory
-
toString
public abstract String toString(SymbolTable symbolTable)
-
getValueString
protected String getValueString(SymbolTable symbolTable, int valueNumber)
-
visit
public abstract void visit(SSAInstruction.IVisitor v)
Apply an IVisitor to this instruction. We invoke the appropriate IVisitor method according to the type of this instruction.
-
hasDef
public boolean hasDef()
Does this instruction define a normal value, as distinct from a set of exceptions possibly thrown by it (e.g. for invoke instructions).- Returns:
- true if the instruction does define a proper value.
-
getDef
public int getDef()
-
getDef
public int getDef(int i)
Return the ith def- Parameters:
i
- number of the def, starting at 0.
-
getNumberOfDefs
public int getNumberOfDefs()
-
getNumberOfUses
public int getNumberOfUses()
-
getUse
public int getUse(int j) throws UnsupportedOperationException
- Returns:
- value number representing the jth use in this instruction. -1 means TOP (i.e., the value doesn't matter)
- Throws:
UnsupportedOperationException
-
isPEI
public boolean isPEI()
- Returns:
- true iff this instruction may throw an exception.
-
getExceptionTypes
public Collection<TypeReference> getExceptionTypes()
This method should never return null.- Returns:
- the set of exception types that an instruction might throw ... disregarding athrows and invokes.
-
isFallThrough
public abstract boolean isFallThrough()
- Returns:
- true iff this instruction may fall through to the next
-
equals
public final boolean equals(Object obj)
We assume these instructions are canonical and managed by a governing IR object. Be careful. Depending on the caching policy (seeSSACache
), the governing IR may be deleted to reclaim memory and recomputed as needed. When an IR is recomputed, it also creates fresh SSAInstruction objects that will not equal old ones. Thus, do not compare for identity SSAInstructions obtained from distinct calls that retrieve cached values (e.g. distinct CGNode.getIR() calls). See the github issue for details.- Overrides:
equals
in classObject
- See Also:
Object.equals(java.lang.Object)
-
-