summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/astclone/libastclone.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/astclone/libastclone.hxx
add: added projectsHEADmain
Diffstat (limited to 'tiger-compiler/src/astclone/libastclone.hxx')
-rw-r--r--tiger-compiler/src/astclone/libastclone.hxx40
1 files changed, 40 insertions, 0 deletions
diff --git a/tiger-compiler/src/astclone/libastclone.hxx b/tiger-compiler/src/astclone/libastclone.hxx
new file mode 100644
index 0000000..b6fe380
--- /dev/null
+++ b/tiger-compiler/src/astclone/libastclone.hxx
@@ -0,0 +1,40 @@
+#pragma once
+
+#include <ast/exp.hh>
+#include <astclone/cloner.hh>
+#include <astclone/libastclone.hh>
+
+// Define exported clone functions.
+namespace astclone
+{
+ template <typename T> T* clone(const T& tree)
+ {
+ Cloner clone;
+ clone(tree);
+ return dynamic_cast<T*>(clone.result_get());
+ }
+
+ template <typename A> void apply(applicable<A> f, std::unique_ptr<A>& t1)
+ {
+ A* t2 = f(*t1);
+ t1.reset(t2);
+ }
+
+ template <typename A>
+ void apply(applicable_with_bools<A> f,
+ std::unique_ptr<A>& t1,
+ bool cond_1,
+ bool cond_2)
+ {
+ A* t2 = f(*t1, cond_1, cond_2);
+ t1.reset(t2);
+ }
+
+ template <typename A, typename B>
+ void apply(applicable_object<A, B> f, std::unique_ptr<A>& t1, B& t3)
+ {
+ A* t2 = f(*t1, t3);
+ t1.reset(t2);
+ }
+
+} // namespace astclone