summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/callgraph/fundec-graph.hxx
diff options
context:
space:
mode:
authorMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:07:58 +0200
committerMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:07:58 +0200
commit967be9e750221ab2ab783f95df79bb26d290a45e (patch)
tree6802900a5e975f9f68b169f0f503f040056d6952 /tiger-compiler/src/callgraph/fundec-graph.hxx
add: added projectsHEADmain
Diffstat (limited to 'tiger-compiler/src/callgraph/fundec-graph.hxx')
-rw-r--r--tiger-compiler/src/callgraph/fundec-graph.hxx56
1 files changed, 56 insertions, 0 deletions
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 <callgraph/fundec-graph.hh>
+
+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