Class SSAValue

java.lang.Object
com.ibm.wala.core.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
Author:
Tobias Blaschke <code@tobiasblaschke.de>
See Also:
  • Field Details

    • 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 Details

    • 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 number
      validIn - optionally assign this value to a method
      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 use
      copyFrom - 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

      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
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object