Class PointerType

java.lang.Object
de.fraunhofer.aisec.cpg.graph.Node
de.fraunhofer.aisec.cpg.graph.types.Type
de.fraunhofer.aisec.cpg.graph.types.PointerType
All Implemented Interfaces:
Persistable, SecondOrderType, IVisitable<de.fraunhofer.aisec.cpg.graph.Node>

public class PointerType
extends Type
implements SecondOrderType
PointerTypes represent all references to other Types. For C/CPP this includes pointers, as well as arrays, since technically arrays are pointers. For JAVA the only use case are arrays as there is no such pointer concept.
  • Constructor Details

  • Method Details

    • reference

      public PointerType reference​(PointerType.PointerOrigin origin)
      Specified by:
      reference in class Type
      Parameters:
      origin - Reason for the reference (array of pointer)
      Returns:
      referencing a PointerType results in another PointerType wrapping the first PointerType, e.g. int**
    • dereference

      public Type dereference()
      Specified by:
      dereference in class Type
      Returns:
      dereferencing a PointerType yields the type the pointer was pointing towards
    • refreshNames

      public void refreshNames()
      Overrides:
      refreshNames in class Type
    • duplicate

      public Type duplicate()
      Specified by:
      duplicate in class Type
      Returns:
      Creates an exact copy of the current type (chain)
    • isArray

      public boolean isArray()
    • isSimilar

      public boolean isSimilar​(Type t)
      Description copied from class: Type
      Required for possibleSubTypes to check if the new Type should be considered a subtype or not
      Overrides:
      isSimilar in class Type
      Parameters:
      t - other type the similarity is checked with
      Returns:
      True if the parameter t is equal to the current type (this)
    • getPointerOrigin

      public PointerType.PointerOrigin getPointerOrigin()
    • getElementType

      public Type getElementType()
      Specified by:
      getElementType in interface SecondOrderType
    • getReferenceDepth

      public int getReferenceDepth()
      Overrides:
      getReferenceDepth in class Type
      Returns:
      number of steps that are required in order to traverse the type chain until the root is reached
    • setElementType

      public void setElementType​(Type elementType)
      Specified by:
      setElementType in interface SecondOrderType
    • equals

      public boolean equals​(java.lang.Object o)
      Overrides:
      equals in class Type
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Type