summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/inlining/pruner.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/inlining/pruner.hh
add: added projectsHEADmain
Diffstat (limited to 'tiger-compiler/src/inlining/pruner.hh')
-rw-r--r--tiger-compiler/src/inlining/pruner.hh42
1 files changed, 42 insertions, 0 deletions
diff --git a/tiger-compiler/src/inlining/pruner.hh b/tiger-compiler/src/inlining/pruner.hh
new file mode 100644
index 0000000..30a0609
--- /dev/null
+++ b/tiger-compiler/src/inlining/pruner.hh
@@ -0,0 +1,42 @@
+/**
+ ** \file inlining/pruner.hh
+ ** \brief Declaration of inlining::Pruner.
+ */
+
+#pragma once
+
+#include <map>
+
+#include <astclone/cloner.hh>
+#include <misc/set.hh>
+
+namespace inlining
+{
+ /// Prune useless function declarations within an AST.
+ class Pruner : public astclone::Cloner
+ {
+ public:
+ using super_type = astclone::Cloner;
+
+ // Import overloaded virtual functions.
+ using super_type::operator();
+
+ using func_vect = std::vector<ast::FunctionDec*>;
+ using func_count = std::map<misc::symbol, int>;
+
+ /// \name Visit methods.
+ /// \{
+ // FIXME: Some code was deleted here.
+ /// \}
+
+ ast::FunctionChunk* prune(ast::FunctionChunk& e);
+
+ private:
+ // Keep track of current nested functions
+ std::vector<const ast::FunctionDec*> current_functions_;
+
+ // Associate function dec with the number of CallExp calling it
+ func_count called_functions_;
+ };
+
+} // namespace inlining