Class TypeResolver

java.lang.Object
de.fraunhofer.aisec.cpg.passes.Pass
de.fraunhofer.aisec.cpg.passes.TypeResolver
All Implemented Interfaces:
java.util.function.Consumer<TranslationResult>

public class TypeResolver
extends Pass
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected java.util.Set<Type> firstOrderTypes  
    protected java.util.Map<Type,​java.util.List<Type>> typeState  

    Fields inherited from class de.fraunhofer.aisec.cpg.passes.Pass

    lang, log
  • Constructor Summary

    Constructors
    Constructor Description
    TypeResolver()  
  • Method Summary

    Modifier and Type Method Description
    void accept​(TranslationResult translationResult)
    Pass on the TypeSystem: Sets RecordDeclaration Relationship from ObjectType to RecordDeclaration
    protected void addType​(Type type)
    Responsible for storing new types into typeState
    void cleanup()  
    protected void ensureUniqueSecondaryTypeEdge​(de.fraunhofer.aisec.cpg.graph.Node node)
    ensures that the if a nodes contains secondary type edges, those types are also merged and no duplicate is left
    protected java.util.Set<Type> ensureUniqueSubTypes​(java.util.Set<Type> subTypes)  
    protected void ensureUniqueType​(de.fraunhofer.aisec.cpg.graph.Node node)  
    void handle​(de.fraunhofer.aisec.cpg.graph.Node node)
    Creates the recordDeclaration relationship between ObjectTypes and RecordDeclaration (from the Type to the Class)
    Type obtainType​(Type type)
    Ensures that two different Types that are created at different Points are still the same object in order to only store one node into the database
    protected void processSecondOrderTypes​(Type type)
    Reduce the SecondOrderTypes to store only the unique SecondOrderTypes
    protected void removeDuplicatesInFields​(Type t)
    Visits all FirstOrderTypes and replace all the fields like returnVal or parameters for FunctionPointertype or Generics for ObjectType
    protected void removeDuplicateTypes()  
    protected void updateType​(de.fraunhofer.aisec.cpg.graph.Node node, java.util.Collection<Type> types)  

    Methods inherited from class de.fraunhofer.aisec.cpg.passes.Pass

    getLang, setLang, supportsLanguageFrontend

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.util.function.Consumer

    andThen
  • Field Details

    • firstOrderTypes

      protected final java.util.Set<Type> firstOrderTypes
    • typeState

      protected final java.util.Map<Type,​java.util.List<Type>> typeState
  • Constructor Details

    • TypeResolver

      public TypeResolver()
  • Method Details

    • processSecondOrderTypes

      protected void processSecondOrderTypes​(Type type)
      Reduce the SecondOrderTypes to store only the unique SecondOrderTypes
      Parameters:
      type - SecondOrderType that is to be eliminated if an equal is already in typeState or is added if not
    • obtainType

      public Type obtainType​(Type type)
      Ensures that two different Types that are created at different Points are still the same object in order to only store one node into the database
      Parameters:
      type - newly created Type
      Returns:
      If the same type was already stored in the typeState Map the stored one is returned. In the other case the parameter type is stored into the map and the parameter type is returned
    • addType

      protected void addType​(Type type)
      Responsible for storing new types into typeState
      Parameters:
      type - new type
    • removeDuplicateTypes

      protected void removeDuplicateTypes()
    • removeDuplicatesInFields

      protected void removeDuplicatesInFields​(Type t)
      Visits all FirstOrderTypes and replace all the fields like returnVal or parameters for FunctionPointertype or Generics for ObjectType
      Parameters:
      t - FirstOrderType
    • accept

      public void accept​(TranslationResult translationResult)
      Pass on the TypeSystem: Sets RecordDeclaration Relationship from ObjectType to RecordDeclaration
      Parameters:
      translationResult -
    • ensureUniqueSubTypes

      protected java.util.Set<Type> ensureUniqueSubTypes​(java.util.Set<Type> subTypes)
    • ensureUniqueType

      protected void ensureUniqueType​(de.fraunhofer.aisec.cpg.graph.Node node)
    • ensureUniqueSecondaryTypeEdge

      protected void ensureUniqueSecondaryTypeEdge​(de.fraunhofer.aisec.cpg.graph.Node node)
      ensures that the if a nodes contains secondary type edges, those types are also merged and no duplicate is left
      Parameters:
      node - implementing HasType.SecondaryTypeEdge
    • updateType

      protected void updateType​(de.fraunhofer.aisec.cpg.graph.Node node, java.util.Collection<Type> types)
    • handle

      public void handle​(de.fraunhofer.aisec.cpg.graph.Node node)
      Creates the recordDeclaration relationship between ObjectTypes and RecordDeclaration (from the Type to the Class)
      Parameters:
      node -
    • cleanup

      public void cleanup()
      Specified by:
      cleanup in class Pass