From 967be9e750221ab2ab783f95df79bb26d290a45e Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Mon, 15 Sep 2025 01:07:58 +0200 Subject: add: added projects --- tiger-compiler/src/callgraph/fundec-graph.hxx | 56 +++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 tiger-compiler/src/callgraph/fundec-graph.hxx (limited to 'tiger-compiler/src/callgraph/fundec-graph.hxx') diff --git a/tiger-compiler/src/callgraph/fundec-graph.hxx b/tiger-compiler/src/callgraph/fundec-graph.hxx new file mode 100644 index 0000000..d5d863e --- /dev/null +++ b/tiger-compiler/src/callgraph/fundec-graph.hxx @@ -0,0 +1,56 @@ +/** + ** \file callgraph/fundec-graph.hxx + ** \brief Inline methods for callgraph/fundec-graph.hh. + */ + +#pragma once + +#include + +namespace callgraph +{ + inline void FundecGraph::fundec_add(ast::FunctionDec* f) + { + hfundecs[f] = this->vertex_add(f); + } + + inline void FundecGraph::fundec_link(ast::FunctionDec* fu, + ast::FunctionDec* fv) + { + vertex_descriptor u = hfundecs[fu]; + vertex_descriptor v = hfundecs[fv]; + boost::add_edge(u, v, *this); + } + + inline FundecGraph::vertex_descriptor + FundecGraph::hfundec_get(ast::FunctionDec* f) const + { + hfundecs_type::const_iterator i = hfundecs.find(f); + assertion(i != hfundecs.end()); + return i->second; + } + + inline ast::FunctionDec* + FundecGraph::hfundec_deep_get(ast::FunctionDec* start, + ast::FunctionDec* searched) const + { + if (start == searched) + return searched; + + hfundecs_type::const_iterator i = hfundecs.find(start); + parentgraph_neighb_iter_type parent = + boost::adjacent_vertices(i->second, *this).first; + + if ((*this)[*parent] == start) + return nullptr; + + return hfundec_deep_get((*this)[*parent], searched); + } + + inline std::ostream& FundecGraph::vertex_print(vertex_descriptor v, + std::ostream& ostr) const + { + return ostr << (*this)[v]->name_get(); + } + +} // namespace callgraph -- cgit v1.2.3