From 967be9e750221ab2ab783f95df79bb26d290a45e Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Mon, 15 Sep 2025 01:07:58 +0200 Subject: add: added projects --- tiger-compiler/src/astclone/libastclone.hxx | 40 +++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tiger-compiler/src/astclone/libastclone.hxx (limited to 'tiger-compiler/src/astclone/libastclone.hxx') 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 +#include +#include + +// Define exported clone functions. +namespace astclone +{ + template T* clone(const T& tree) + { + Cloner clone; + clone(tree); + return dynamic_cast(clone.result_get()); + } + + template void apply(applicable f, std::unique_ptr& t1) + { + A* t2 = f(*t1); + t1.reset(t2); + } + + template + void apply(applicable_with_bools f, + std::unique_ptr& t1, + bool cond_1, + bool cond_2) + { + A* t2 = f(*t1, cond_1, cond_2); + t1.reset(t2); + } + + template + void apply(applicable_object f, std::unique_ptr& t1, B& t3) + { + A* t2 = f(*t1, t3); + t1.reset(t2); + } + +} // namespace astclone -- cgit v1.2.3