Class SSACheckCastInstruction

java.lang.Object
com.ibm.wala.ssa.SSAInstruction
com.ibm.wala.ssa.SSACheckCastInstruction

public abstract class SSACheckCastInstruction extends SSAInstruction
A checkcast (dynamic type test) instruction. This instruction produces a new value number (like an assignment) if the check succeeds.

Note that this instruction generalizes the meaning of checkcast in Java since it supports multiple types for which to check. The meaning is that the case succeeds if the object is of any of the desired types.

  • Constructor Details

    • SSACheckCastInstruction

      protected SSACheckCastInstruction(int iindex, int result, int val, TypeReference[] types, boolean isPEI)
      Parameters:
      result - A new value number def'fed by this instruction when the type check succeeds.
      val - The value being checked by this instruction
      types - The types which this instruction checks
  • Method Details

    • copyForSSA

      public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses)
      Description copied from class: SSAInstruction
      This method is meant to be used during SSA conversion for an IR that is not in SSA form. It creates a new SSAInstruction of the same type as the receiver, with a combination of the receiver's uses and defs and those from the method parameters.

      In particular, if the 'defs' parameter is null, then the new instruction has the same defs as the receiver. If 'defs' is not null, it must be an array with a size equal to the number of defs that the receiver instruction has. In this case, the new instruction has defs taken from the array. The uses of the new instruction work in the same way with the 'uses' parameter.

      Note that this only applies to CAst-based IR translation, since Java bytecode-based IR generation uses a different SSA construction mechanism.

      TODO: move this into the SSAInstructionFactory

      Specified by:
      copyForSSA in class SSAInstruction
    • toString

      public String toString(SymbolTable symbolTable)
      Specified by:
      toString in class SSAInstruction
    • visit

      public void visit(SSAInstruction.IVisitor v)
      Description copied from class: SSAInstruction
      Apply an IVisitor to this instruction. We invoke the appropriate IVisitor method according to the type of this instruction.
      Specified by:
      visit in class SSAInstruction
    • hasDef

      public boolean hasDef()
      Description copied from class: SSAInstruction
      Does this instruction define a normal value, as distinct from a set of exceptions possibly thrown by it (e.g. for invoke instructions).
      Overrides:
      hasDef in class SSAInstruction
      Returns:
      true if the instruction does define a proper value.
    • getDef

      public int getDef()
      Overrides:
      getDef in class SSAInstruction
      Returns:
      A new value number def'fed by this instruction when the type check succeeds.
    • getDef

      public int getDef(int i)
      Description copied from class: SSAInstruction
      Return the ith def
      Overrides:
      getDef in class SSAInstruction
      Parameters:
      i - number of the def, starting at 0.
    • getNumberOfDefs

      public int getNumberOfDefs()
      Overrides:
      getNumberOfDefs in class SSAInstruction
      See Also:
    • getNumberOfUses

      public int getNumberOfUses()
      Overrides:
      getNumberOfUses in class SSAInstruction
    • getUse

      public int getUse(int j)
      Overrides:
      getUse in class SSAInstruction
      Returns:
      value number representing the jth use in this instruction. -1 means TOP (i.e., the value doesn't matter)
    • getDeclaredResultType

      @Deprecated public TypeReference getDeclaredResultType()
      Deprecated.
      the system now supports multiple types, so this accessor will not work for all languages.
    • getDeclaredResultTypes

      public TypeReference[] getDeclaredResultTypes()
    • getResult

      public int getResult()
    • getVal

      public int getVal()
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in class SSAInstruction
    • isPEI

      public boolean isPEI()
      Overrides:
      isPEI in class SSAInstruction
      Returns:
      true iff this instruction may throw an exception.
    • isFallThrough

      public boolean isFallThrough()
      Specified by:
      isFallThrough in class SSAInstruction
      Returns:
      true iff this instruction may fall through to the next
    • toString

      public String toString()
      Overrides:
      toString in class SSAInstruction