summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/bind/renamer.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/bind/renamer.hh
add: added projectsHEADmain
Diffstat (limited to 'tiger-compiler/src/bind/renamer.hh')
-rw-r--r--tiger-compiler/src/bind/renamer.hh62
1 files changed, 62 insertions, 0 deletions
diff --git a/tiger-compiler/src/bind/renamer.hh b/tiger-compiler/src/bind/renamer.hh
new file mode 100644
index 0000000..f4a1e82
--- /dev/null
+++ b/tiger-compiler/src/bind/renamer.hh
@@ -0,0 +1,62 @@
+/**
+ ** \file bind/renamer.hh
+ ** \brief Implementation of bind::Renamer.
+ */
+
+#pragma once
+
+#include <map>
+#include <ast/default-visitor.hh>
+#include <ast/non-assert-visitor.hh>
+#include <ast/non-object-visitor.hh>
+
+namespace bind
+{
+ /// Perform identifier renaming within an AST (in place),
+ /// without support for objects.
+ class Renamer
+ : public ast::DefaultVisitor
+ , public ast::NonObjectVisitor
+ , public ast::NonAssertVisitor
+ {
+ public:
+ using super_type = ast::DefaultVisitor;
+
+ // Import overloaded virtual functions.
+ using super_type::operator();
+
+ // FIXME DONE: Some code was deleted here.
+
+ // Visit methods.
+ /// \brief Process a declaration body or a usage site.
+ ///
+ /// \a def is the definition site of \e (must be equal to
+ /// \a e if it is a Dec node).
+ template <class E, class Def> void visit(E& e, const Def* def);
+
+ /// \name Visiting definition sites.
+ /// \{
+ // FIXME DONE: Some code was deleted here.
+ void operator()(ast::VarDec& e) override;
+ void operator()(ast::TypeDec& e) override;
+ void operator()(ast::FunctionDec& e) override;
+ /// \}
+
+ /// \name Visiting usage sites.
+ /// \{
+ // FIXME DONE: Some code was deleted here.
+ void operator()(ast::SimpleVar& e) override;
+ void operator()(ast::NameTy& e) override;
+ void operator()(ast::CallExp& e) override;
+ /// \}
+
+ private:
+ // FIXME DONE: Some code was deleted here.
+ std::map<const ast::Dec*, misc::symbol> renames_;
+
+ void new_name_(const ast::Dec*);
+ };
+
+} // namespace bind
+
+#include <bind/renamer.hxx>