Class Cfa<CfaNodeT extends CfaNode<CfaEdgeT,​SignatureT>,​CfaEdgeT extends CfaEdge<CfaNodeT>,​SignatureT extends Signature>

  • Direct Known Subclasses:
    JvmCfa

    public abstract class Cfa<CfaNodeT extends CfaNode<CfaEdgeT,​SignatureT>,​CfaEdgeT extends CfaEdge<CfaNodeT>,​SignatureT extends Signature>
    extends java.lang.Object
    A Cfa is a control flow automaton with nodes <CfaNodeT> and edges <CfaEdgeT>. It can be used for different programming languages with functions identified by <SignatureT>.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Map<SignatureT,​java.util.Map<java.lang.Integer,​CfaNodeT>> functionNodes  
    • Constructor Summary

      Constructors 
      Constructor Description
      Cfa()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addFunctionEntryNode​(SignatureT signature, CfaNodeT node)
      Add an entry node to the graph for a specified function (with offset 0).
      void addFunctionNode​(SignatureT signature, CfaNodeT node, int offset)
      Add a node to the graph for a specified function.
      java.util.stream.Stream<CfaNodeT> getAllNodes()
      Returns a stream of all the nodes present in the graph.
      CfaNodeT getFunctionEntryNode​(SignatureT signature)
      Returns the entry node of a specific function (with offset 0), returns null if the function or its entry node are not in the graph.
      java.util.Collection<CfaNodeT> getFunctionEntryNodes()
      Returns a collection of the entry nodes (with offset 0) of all the functions present in the graph, returns an empty collection if the graph is empty.
      CfaNodeT getFunctionNode​(Clazz clazz, Method method, int offset)
      Returns the node of a function at a specific code offset, returns null if the function or the specific node are not in the graph.
      CfaNodeT getFunctionNode​(SignatureT signature, int offset)
      Returns the node of a function at a specific code offset, returns null if the function or the specific node are not in the graph.
      java.util.Collection<CfaNodeT> getFunctionNodes​(SignatureT signature)
      Returns all the nodes of a specific function, returns an empty collection if the function is not in the graph or if it has no nodes.
      boolean isEmpty()
      Returns true if there are no nodes in the CFA, false otherwise.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Cfa

        public Cfa()
    • Method Detail

      • isEmpty

        public boolean isEmpty()
        Returns true if there are no nodes in the CFA, false otherwise.
      • getAllNodes

        public java.util.stream.Stream<CfaNodeT> getAllNodes()
        Returns a stream of all the nodes present in the graph.

        Note: a Stream is provided to avoid creating new collections unnecessarily.

      • getFunctionEntryNodes

        public java.util.Collection<CfaNodeT> getFunctionEntryNodes()
        Returns a collection of the entry nodes (with offset 0) of all the functions present in the graph, returns an empty collection if the graph is empty.
      • getFunctionEntryNode

        public CfaNodeT getFunctionEntryNode​(SignatureT signature)
        Returns the entry node of a specific function (with offset 0), returns null if the function or its entry node are not in the graph.
        Parameters:
        signature - The signature of the function.
      • getFunctionNodes

        public java.util.Collection<CfaNodeT> getFunctionNodes​(SignatureT signature)
        Returns all the nodes of a specific function, returns an empty collection if the function is not in the graph or if it has no nodes.
        Parameters:
        signature - The signature of the function.
      • getFunctionNode

        public CfaNodeT getFunctionNode​(SignatureT signature,
                                        int offset)
        Returns the node of a function at a specific code offset, returns null if the function or the specific node are not in the graph.
        Parameters:
        signature - The signature of the function.
        offset - The offset of the code location represented by the node.
      • getFunctionNode

        public CfaNodeT getFunctionNode​(Clazz clazz,
                                        Method method,
                                        int offset)
        Returns the node of a function at a specific code offset, returns null if the function or the specific node are not in the graph.
        Parameters:
        clazz - The Clazz in which the function is declared.
        method - The Method in which the function is declared.
        offset - The offset of the code location represented by the node.
      • addFunctionEntryNode

        public void addFunctionEntryNode​(SignatureT signature,
                                         CfaNodeT node)
        Add an entry node to the graph for a specified function (with offset 0).
        Parameters:
        signature - The signature of the function,.
        node - The entry node to add.
      • addFunctionNode

        public void addFunctionNode​(SignatureT signature,
                                    CfaNodeT node,
                                    int offset)
        Add a node to the graph for a specified function.
        Parameters:
        signature - The signature of the function.
        node - The node to add.