public class SSAValue
extends java.lang.Object
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.
TypeSafeInstructionFactory,
ParameterAccessor| Modifier and Type | Class and 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.
|
| Modifier and Type | Field and 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 in
|
protected int |
number
The SSA Value itself
|
protected TypeReference |
type
The type of this variable
|
| Constructor and Description |
|---|
SSAValue(int number,
SSAValue copyFrom)
Create a new instance of the same type, validity and name.
|
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,
java.lang.String variableName)
Generates a SSAValue with a NamedKey (or TypeKey if name==null).
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.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.
|
java.lang.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.
|
java.lang.String |
toString() |
protected final int number
protected final TypeReference type
public final SSAValue.VariableKey key
protected final MethodReference mRef
public SSAValue(int number,
TypeReference type,
MethodReference validIn,
SSAValue.VariableKey key)
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.
number - access the value using this numbervalidIn - optionally assign this value to a methodjava.lang.IllegalArgumentException - on negative parameter numberpublic SSAValue(int number,
TypeReference type,
MethodReference validIn,
java.lang.String variableName)
public SSAValue(int number,
TypeReference type,
MethodReference validIn)
public SSAValue(int number,
SSAValue copyFrom)
Of course you still have to assign something to this value.
number - the new number to usecopyFrom - where to get the rest of the attributespublic int getNumber()
As an alternative one can generate Instructions using the TypeSafeInstructionFactory which takes SSAValues as parameters.
public TypeReference getType()
public boolean isAssigned()
public void setAssigned()
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.
java.lang.IllegalStateException - if the variable was already assigned topublic MethodReference getValidIn()
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.
public java.lang.String getVariableName()
public java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object