/** ** \file callgraph/fundec-graph.hh ** \brief Declare and define fundec graph. */ #pragma once #include #include #include #include namespace callgraph { /*--------------. | FundecGraph. | `--------------*/ class FundecGraph : public misc::directed_graph { public: /// Add a vertex to the graph, and attach a function definition to it. void fundec_add(ast::FunctionDec* f); /// Create an edge between two vertices, identified by the /// FunctionDec attached to each of them. void fundec_link(ast::FunctionDec* fu, ast::FunctionDec* fv); /// Retrieve the vertex handle corresponding to a FunctionDec. vertex_descriptor hfundec_get(ast::FunctionDec* f) const; // Search if FunctionDec 'searched' is 'start' or one of its parent. ast::FunctionDec* hfundec_deep_get(ast::FunctionDec* start, ast::FunctionDec* searched) const; protected: /// Print the label of vertex of a graph. std::ostream& vertex_print(vertex_descriptor v, std::ostream& ostr) const override; using hfundecs_type = std::map; hfundecs_type hfundecs; }; using CallGraph = FundecGraph; using ParentGraph = FundecGraph; /*------------. | Iterators. | `------------*/ /// Iterator on the vertices of a FundecGraph. using fundecgraph_vertex_iter_type = boost::graph_traits::vertex_iterator; /// Iterator on the edges of a FundecGraph. using fundecgraph_edge_iter_type = boost::graph_traits::edge_iterator; /// Iterator on the neighborhood of a vertex of a FundecGraph. using fundecgraph_neighb_iter_type = boost::graph_traits::adjacency_iterator; /// \name Aliases. /// \{ /// Iterator on the vertices of a CallGraph. using callgraph_vertex_iter_type = fundecgraph_vertex_iter_type; /// Iterator on the neighborhood of a vertex of a CallGraph. using callgraph_neighb_iter_type = fundecgraph_neighb_iter_type; /// Iterator on the neighborhood of a vertex of a ParentGraph. using parentgraph_neighb_iter_type = fundecgraph_neighb_iter_type; /// \} } // namespace callgraph #include