summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/callgraph/call-graph-visitor.hh
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/call-graph-visitor.hh
add: added projectsHEADmain
Diffstat (limited to 'tiger-compiler/src/callgraph/call-graph-visitor.hh')
-rw-r--r--tiger-compiler/src/callgraph/call-graph-visitor.hh38
1 files changed, 38 insertions, 0 deletions
diff --git a/tiger-compiler/src/callgraph/call-graph-visitor.hh b/tiger-compiler/src/callgraph/call-graph-visitor.hh
new file mode 100644
index 0000000..97d79b4
--- /dev/null
+++ b/tiger-compiler/src/callgraph/call-graph-visitor.hh
@@ -0,0 +1,38 @@
+/**
+ ** \file callgraph/call-graph-visitor.hh
+ ** \brief Definition of callgraph::CallGraphVisitor.
+ **/
+#pragma once
+
+#include <ast/default-visitor.hh>
+#include <ast/non-assert-visitor.hh>
+#include <ast/non-object-visitor.hh>
+#include <callgraph/fundec-graph.hh>
+
+namespace callgraph
+{
+ /// Computes the CallGraph.
+ class CallGraphVisitor
+ : protected ast::DefaultConstVisitor
+ , protected ast::NonObjectConstVisitor
+ , protected ast::NonAssertConstVisitor
+ {
+ public:
+ using super_type = ast::DefaultConstVisitor;
+ using super_type::operator();
+ const CallGraph* create(const ast::Ast& tree);
+ CallGraph* create(ast::Ast& tree);
+
+ protected:
+ void operator()(const ast::CallExp& e) override;
+ void operator()(const ast::FunctionChunk& e) override;
+ void operator()(const ast::FunctionDec& e) override;
+
+ protected:
+ /// Current function.
+ ast::FunctionDec* caller = nullptr;
+ /// Call graph.
+ CallGraph* callgraph_ = nullptr;
+ };
+
+} // namespace callgraph