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.hh | 42 ++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 tiger-compiler/src/astclone/libastclone.hh (limited to 'tiger-compiler/src/astclone/libastclone.hh') diff --git a/tiger-compiler/src/astclone/libastclone.hh b/tiger-compiler/src/astclone/libastclone.hh new file mode 100644 index 0000000..d62fea9 --- /dev/null +++ b/tiger-compiler/src/astclone/libastclone.hh @@ -0,0 +1,42 @@ +/** + ** \file astclone/libastclone.hh + ** \brief Declare functions and variables exported by the Astclone module. + */ + +#pragma once + +#include + +#include + +/// Cloning an ast::Ast. +namespace astclone +{ + /** \brief Make a deep copy of an AST. + ** \param tree abstract syntax tree's root. + ** \return the cloned AST. */ + template T* clone(const T& tree); + + template using applicable = auto(const A&) -> A*; + + template + using applicable_with_bools = auto(const A&, bool, bool) -> A*; + + template + using applicable_object = auto(const A&, const B&) -> A*; + + /// Have the pure function \a f side effect on \a t. + template void apply(applicable f, std::unique_ptr& t1); + + template + void apply(applicable_with_bools f, + std::unique_ptr& t1, + bool cond_1, + bool cond_2); + + template + void apply(applicable_object f, std::unique_ptr& t1, const B& t3); + +} // namespace astclone + +#include -- cgit v1.2.3