Class SymbolTable

java.lang.Object
com.ibm.wala.ssa.SymbolTable
All Implemented Interfaces:
Cloneable

public class SymbolTable extends Object implements Cloneable
A symbol table which associates information with each variable (value number) in an SSA IR.

By convention, symbol numbers start at 1 ... the "this" parameter will be symbol number 1 in a virtual method.

This class is used heavily during SSA construction by SSABuilder.

  • Constructor Details Link icon

    • SymbolTable Link icon

      public SymbolTable(int numberOfParameters)
      Parameters:
      numberOfParameters - in the IR .. should be ir.getNumberOfParameters()
  • Method Details Link icon

    • newSymbol Link icon

      public int newSymbol()
      Method newSymbol.
      Returns:
      int
    • setConstantValue Link icon

      public void setConstantValue(int vn, ConstantValue val)
    • setDefaultValue Link icon

      public void setDefaultValue(int vn, Object defaultValue)
      Set the default value for a value number. The notion of a default value is for use by languages that do not require variables to be defined before they are used. In this situation, SSA conversion can fail since it depends on the assumption that values are always defined when used. The default value is the constant to be used in cases when a given value is used without having been defined. Currently, this is used only by CAst front ends for languages with this "feature".
    • getDefaultValue Link icon

      public int getDefaultValue(int vn)
    • getNullConstant Link icon

      public int getNullConstant()
    • getConstant Link icon

      public int getConstant(boolean b)
    • getConstant Link icon

      public int getConstant(int i)
    • getConstant Link icon

      public int getConstant(long l)
    • getConstant Link icon

      public int getConstant(float f)
    • getConstant Link icon

      public int getConstant(double d)
    • getOtherConstant Link icon

      public int getOtherConstant(Object v)
    • getConstant Link icon

      public int getConstant(String s)
    • getParameter Link icon

      public int getParameter(int i) throws IllegalArgumentException
      Return the value number of the ith parameter

      By convention, for a non-static method, the 0th parameter is 'this'

      Throws:
      IllegalArgumentException
    • ensureSymbol Link icon

      public void ensureSymbol(int i)
      ensure that the symbol table has allocated space for the particular value number
      Parameters:
      i - a value number
    • getValueString Link icon

      public String getValueString(int valueNumber)
    • isConstant Link icon

      public boolean isConstant(int v)
    • isZero Link icon

      public boolean isZero(int v)
    • isOne Link icon

      public boolean isOne(int v)
    • isTrue Link icon

      public boolean isTrue(int v)
    • isZeroOrFalse Link icon

      public boolean isZeroOrFalse(int v)
    • isOneOrTrue Link icon

      public boolean isOneOrTrue(int v)
    • isFalse Link icon

      public boolean isFalse(int v)
    • isBooleanOrZeroOneConstant Link icon

      public boolean isBooleanOrZeroOneConstant(int v)
    • isBooleanConstant Link icon

      public boolean isBooleanConstant(int v)
    • isIntegerConstant Link icon

      public boolean isIntegerConstant(int v)
    • isLongConstant Link icon

      public boolean isLongConstant(int v)
    • isFloatConstant Link icon

      public boolean isFloatConstant(int v)
    • isDoubleConstant Link icon

      public boolean isDoubleConstant(int v)
    • isNumberConstant Link icon

      public boolean isNumberConstant(int v)
    • isStringConstant Link icon

      public boolean isStringConstant(int v)
    • isNullConstant Link icon

      public boolean isNullConstant(int v)
    • newPhi Link icon

      public int newPhi(int[] rhs) throws IllegalArgumentException
      Throws:
      IllegalArgumentException - if rhs is null
    • getPhiValue Link icon

      public PhiValue getPhiValue(int valueNumber)
      Return the PhiValue that is associated with a given value number
    • getMaxValueNumber Link icon

      public int getMaxValueNumber()
    • getParameterValueNumbers Link icon

      public int[] getParameterValueNumbers()
    • getNumberOfParameters Link icon

      public int getNumberOfParameters()
    • getStringValue Link icon

      public String getStringValue(int v) throws IllegalArgumentException
      Throws:
      IllegalArgumentException
    • getFloatValue Link icon

      public float getFloatValue(int v) throws IllegalArgumentException
      Throws:
      IllegalArgumentException
    • getDoubleValue Link icon

      public double getDoubleValue(int v) throws IllegalArgumentException
      Throws:
      IllegalArgumentException
    • getIntValue Link icon

      public int getIntValue(int v) throws IllegalArgumentException
      Throws:
      IllegalArgumentException
    • getLongValue Link icon

      public long getLongValue(int v) throws IllegalArgumentException
      Throws:
      IllegalArgumentException
    • getConstantValue Link icon

      public Object getConstantValue(int v) throws IllegalArgumentException
      Throws:
      IllegalArgumentException
    • getValue Link icon

      public Value getValue(int valueNumber)
      Returns:
      the Value object for given value number or null if we have no special information about the value
    • isParameter Link icon

      public boolean isParameter(int valueNumber)
      Returns:
      true iff this valueNumber is a parameter
    • copy Link icon

      public SymbolTable copy()