Package com.ibm.wala.util.ssa
Class SSAValue
- java.lang.Object
-
- com.ibm.wala.util.ssa.SSAValue
-
- Direct Known Subclasses:
ParameterAccessor.Parameter
public class SSAValue extends Object
A number representating an SSA-Value and its type. WALA does not use this on a regular basis but it may come in handy for creating SyntheticMethods. Use ParameterAccessor to get the parameters of a function as SSAValues.- Since:
- 2013-10-20
- See Also:
TypeSafeInstructionFactory
,com.ibm.wala.util.ParameterAccessor
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SSAValue.NamedKey
Identify variables by a string and type.static class
SSAValue.TypeKey
A key that matches variables by their type - does not compare to NamedKey.static class
SSAValue.UniqueKey
A key that cannot be recreated.static interface
SSAValue.VariableKey
All variables with the same name in the source code.static class
SSAValue.WeaklyNamedKey
This NamedKey also equals to TypeKeys.
-
Field Summary
Fields Modifier and Type Field Description SSAValue.VariableKey
key
All variables with the same name in the source code share a key.protected MethodReference
mRef
Method the variable is valid inprotected int
number
The SSA Value itselfprotected TypeReference
type
The type of this variable
-
Constructor Summary
Constructors Constructor Description SSAValue(int number, TypeReference type, MethodReference validIn)
Generates a SSAValue with a UniqueKey.SSAValue(int number, TypeReference type, MethodReference validIn, SSAValue.VariableKey key)
Makes a SSAValue with number and type valid in the specified Method.SSAValue(int number, TypeReference type, MethodReference validIn, String variableName)
Generates a SSAValue with a NamedKey (or TypeKey if name==null).SSAValue(int number, SSAValue copyFrom)
Create a new instance of the same type, validity and name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
int
getNumber()
The SSA-Value to use with SSAInstructions.TypeReference
getType()
The type this SSA-Value represents.MethodReference
getValidIn()
Return the MethodReference this Variable was set valid in.String
getVariableName()
Return the optional variable name.int
hashCode()
boolean
isAssigned()
If setAssigned() was called on this variable.void
setAssigned()
Mark this variable as assigned.String
toString()
-
-
-
Field Detail
-
number
protected final int number
The SSA Value itself
-
type
protected final TypeReference type
The type of this variable
-
key
public final SSAValue.VariableKey key
All variables with the same name in the source code share a key.
-
mRef
protected final MethodReference mRef
Method the variable is valid in
-
-
Constructor Detail
-
SSAValue
public SSAValue(int number, TypeReference type, MethodReference validIn, SSAValue.VariableKey key)
Makes a SSAValue with number and type valid in the specified Method. The number is the one to use with SSAInstructions. The MethodReference (validIn) is an optional value. However the TypeSafeInstructionFactory relies on it to verify its ReturnInstruction so setting it does not hurt. The variableName is optional and not really used yet. It might be handy for debugging.- Parameters:
number
- access the value using this numbervalidIn
- optionally assign this value to a methodvariableName
- optional name of the variable- Throws:
IllegalArgumentException
- on negative parameter number
-
SSAValue
public SSAValue(int number, TypeReference type, MethodReference validIn, String variableName)
Generates a SSAValue with a NamedKey (or TypeKey if name==null).
-
SSAValue
public SSAValue(int number, TypeReference type, MethodReference validIn)
Generates a SSAValue with a UniqueKey.
-
SSAValue
public SSAValue(int number, SSAValue copyFrom)
Create a new instance of the same type, validity and name. Of course you still have to assign something to this value.- Parameters:
number
- the new number to usecopyFrom
- where to get the rest of the attributes
-
-
Method Detail
-
getNumber
public int getNumber()
The SSA-Value to use with SSAInstructions. As an alternative one can generate Instructions using the TypeSafeInstructionFactory which takes SSAValues as parameters.
-
getType
public TypeReference getType()
The type this SSA-Value represents.
-
isAssigned
public boolean isAssigned()
If setAssigned() was called on this variable.
-
setAssigned
public void setAssigned()
Mark this variable as assigned. Sets the value returned by isAssigned() to true. As a safety measure one can only call this method once on a SSAValue, the second time raises an exception. The TypeSafeInstructionFactory calls this method when writing to an SSAValue. It does however not check the setting when reading from an SSAValue. This does obviously not prevent from generating a new SSAValue with the same number and double-assign anyhow.- Throws:
IllegalStateException
- if the variable was already assigned to
-
getValidIn
public MethodReference getValidIn()
Return the MethodReference this Variable was set valid in. The value returned by this method is the one set in the constructor. As this parameter is optional to it this function may return null if it was not set.- Returns:
- the argument validIn to the constructor
-
getVariableName
public String getVariableName()
Return the optional variable name.- Returns:
- the argument variableName to the constructor
-
-