java.lang.Object
de.fraunhofer.aisec.cpg.graph.Node
de.fraunhofer.aisec.cpg.graph.types.Type
All Implemented Interfaces:
Persistable, IVisitable<de.fraunhofer.aisec.cpg.graph.Node>
Direct Known Subclasses:
FunctionPointerType, IncompleteType, ObjectType, ParameterizedType, PointerType, ReferenceType, UnknownType

public abstract class Type
extends de.fraunhofer.aisec.cpg.graph.Node
Abstract Type, describing all possible SubTypes, i.e. all different Subtypes are compliant with this class. Contains information which is included in any Type such as name, storage, qualifier and origin
  • Nested Class Summary

    Nested Classes
    Modifier and Type Class Description
    static class  Type.Origin
    Type Origin describes where the Type information came from
    static class  Type.Qualifier
    Describes possible qualifiers that can be added to the type in order to modify its behavior.
    static class  Type.Storage
    Describes Storage specifier of variables.

    Nested classes/interfaces inherited from class de.fraunhofer.aisec.cpg.graph.Node

    de.fraunhofer.aisec.cpg.graph.Node.Companion
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected Type.Origin origin  
    protected boolean primitive  
    protected Type.Qualifier qualifier  
    protected @NonNull Type.Storage storage
    auto, extern, static, register: consider "auto" as modifier or auto to automatically infer the value.
    protected @NonNull java.util.Set<Type> superTypes  
    static java.lang.String UNKNOWN_TYPE_STRING  

    Fields inherited from class de.fraunhofer.aisec.cpg.graph.Node

    Companion, EMPTY_NAME, TO_STRING_STYLE
  • Constructor Summary

    Constructors
    Constructor Description
    Type()  
    Type​(Type type)  
    Type​(java.lang.String typeName)  
    Type​(java.lang.String typeName, @Nullable Type.Storage storage, Type.Qualifier qualifier)  
  • Method Summary

    Modifier and Type Method Description
    abstract Type dereference()  
    abstract Type duplicate()  
    boolean equals​(java.lang.Object o)  
    Type.Qualifier getQualifier()  
    int getReferenceDepth()  
    Type getRoot()
    Obtain the root Type Element for a Type Chain (follows Pointer and ReferenceTypes until Object- Incomplete- FunctionPtrType is reached
    @NonNull Type.Storage getStorage()  
    @NonNull java.util.Set<Type> getSuperTypes()
    All direct supertypes of this type.
    java.lang.String getTypeName()  
    Type.Origin getTypeOrigin()  
    int hashCode()  
    boolean isFirstOrderType()  
    boolean isPrimitive()  
    boolean isSimilar​(Type t)
    Required for possibleSubTypes to check if the new Type should be considered a subtype or not
    abstract Type reference​(PointerType.PointerOrigin pointer)  
    void refreshNames()  
    void setAdditionalTypeKeywords​(java.lang.String keywords)  
    void setQualifier​(Type.Qualifier qualifier)  
    void setRoot​(Type newRoot)  
    void setStorage​(@NonNull Type.Storage storage)  
    void setTypeOrigin​(Type.Origin origin)  
    java.lang.String toString()  

    Methods inherited from class de.fraunhofer.aisec.cpg.graph.Node

    addAnnotations, addNextDFG, addNextEOG, addPrevDFG, addPrevEOG, addTypedef, clearNextEOG, disconnectFromGraph, getAnnotations, getArgumentIndex, getAstChildren, getCode, getComment, getFile, getId, getLocation, getName, getNextDFG, getNextEOG, getNextEOGEdges, getPrevDFG, getPrevEOG, getPrevEOGEdges, getTypedefs, isImplicit, isInferred, removeNextDFG, removePrevDFG, removePrevEOGEntry, setAnnotations, setArgumentIndex, setCode, setComment, setFile, setId, setImplicit, setInferred, setLocation, setName, setNextDFG, setNextEOG, setNextEOGEdges, setPrevDFG, setPrevEOG, setPrevEOGEdges, setTypedefs

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface de.fraunhofer.aisec.cpg.processing.IVisitable

    accept
  • Field Details

    • UNKNOWN_TYPE_STRING

      public static final java.lang.String UNKNOWN_TYPE_STRING
      See Also:
      Constant Field Values
    • superTypes

      protected @NonNull java.util.Set<Type> superTypes
    • storage

      protected @NonNull Type.Storage storage
      auto, extern, static, register: consider "auto" as modifier or auto to automatically infer the value.
    • primitive

      protected boolean primitive
    • qualifier

      protected Type.Qualifier qualifier
    • origin

      protected Type.Origin origin
  • Constructor Details

    • Type

      public Type()
    • Type

      public Type​(java.lang.String typeName)
    • Type

      public Type​(Type type)
    • Type

      public Type​(java.lang.String typeName, @Nullable Type.Storage storage, Type.Qualifier qualifier)
  • Method Details

    • getSuperTypes

      public @NonNull java.util.Set<Type> getSuperTypes()
      All direct supertypes of this type.
      Returns:
    • getStorage

      public @NonNull Type.Storage getStorage()
    • setStorage

      public void setStorage​(@NonNull Type.Storage storage)
    • getQualifier

      public Type.Qualifier getQualifier()
    • setQualifier

      public void setQualifier​(Type.Qualifier qualifier)
    • getTypeOrigin

      public Type.Origin getTypeOrigin()
    • setTypeOrigin

      public void setTypeOrigin​(Type.Origin origin)
    • isPrimitive

      public boolean isPrimitive()
    • reference

      public abstract Type reference​(PointerType.PointerOrigin pointer)
      Parameters:
      pointer - Reason for the reference (array of pointer)
      Returns:
      Returns a reference to the current Type. E.g. when creating a pointer to an existing ObjectType
    • dereference

      public abstract Type dereference()
      Returns:
      Dereferences the current Type by resolving the reference. E.g. when dereferencing an pointer type we obtain the type the pointer is pointing towards
    • refreshNames

      public void refreshNames()
    • getRoot

      public Type getRoot()
      Obtain the root Type Element for a Type Chain (follows Pointer and ReferenceTypes until Object- Incomplete- FunctionPtrType is reached
      Returns:
      root Type
    • setRoot

      public void setRoot​(Type newRoot)
    • duplicate

      public abstract Type duplicate()
      Returns:
      Creates an exact copy of the current type (chain)
    • getTypeName

      public java.lang.String getTypeName()
    • getReferenceDepth

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

      public void setAdditionalTypeKeywords​(java.lang.String keywords)
    • isFirstOrderType

      public boolean isFirstOrderType()
      Returns:
      True if the Type parameter t is a FirstOrderType (Root of a chain) and not a Pointer or RefrenceType
    • isSimilar

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

      public boolean equals​(java.lang.Object o)
      Overrides:
      equals in class de.fraunhofer.aisec.cpg.graph.Node
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class de.fraunhofer.aisec.cpg.graph.Node
    • toString

      @NotNull public java.lang.String toString()
      Overrides:
      toString in class de.fraunhofer.aisec.cpg.graph.Node