Class SSAValue
- Direct Known Subclasses:
ParameterAccessor.Parameter
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
- Author:
- Tobias Blaschke <code@tobiasblaschke.de>
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Identify variables by a string and type.static class
A key that matches variables by their type - does not compare to NamedKey.static class
A key that cannot be recreated.static interface
All variables with the same name in the source code.static class
This NamedKey also equals to TypeKeys. -
Field Summary
Modifier and TypeFieldDescriptionfinal SSAValue.VariableKey
All variables with the same name in the source code share a key.protected final MethodReference
Method the variable is valid inprotected final int
The SSA Value itselfprotected final TypeReference
The type of this variable -
Constructor Summary
ConstructorDescriptionCreate 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, String variableName) Generates a SSAValue with a NamedKey (or TypeKey if name==null). -
Method Summary
Modifier and TypeMethodDescriptionboolean
int
The SSA-Value to use with SSAInstructions.getType()
The type this SSA-Value represents.Return the MethodReference this Variable was set valid in.Return the optional variable name.int
hashCode()
boolean
If setAssigned() was called on this variable.void
Mark this variable as assigned.toString()
-
Field Details
-
number
protected final int numberThe SSA Value itself -
type
The type of this variable -
key
All variables with the same name in the source code share a key. -
mRef
Method the variable is valid in
-
-
Constructor Details
-
SSAValue
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 method- Throws:
IllegalArgumentException
- on negative parameter number
-
SSAValue
Generates a SSAValue with a NamedKey (or TypeKey if name==null). -
SSAValue
Generates a SSAValue with a UniqueKey. -
SSAValue
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 Details
-
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
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
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
Return the optional variable name.- Returns:
- the argument variableName to the constructor
-
toString
-
equals
-
hashCode
-