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/inlining/libinlining.cc | 54 ++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 tiger-compiler/src/inlining/libinlining.cc (limited to 'tiger-compiler/src/inlining/libinlining.cc') diff --git a/tiger-compiler/src/inlining/libinlining.cc b/tiger-compiler/src/inlining/libinlining.cc new file mode 100644 index 0000000..3f6e6b9 --- /dev/null +++ b/tiger-compiler/src/inlining/libinlining.cc @@ -0,0 +1,54 @@ +/** + ** \file inlining/libinlining.cc + ** \brief Functions exported by the inlining module. + */ + +#include + +#include +#include +#include +#include +#include + +namespace inlining +{ + /*-----------. + | Inlining. | + `-----------*/ + + template A* inline_expand(const A& tree) + { + // Inline. + Inliner inline_expand(tree); + inline_expand(tree); + A* inlined = dynamic_cast(inline_expand.result_get()); + assertion(inlined); + std::unique_ptr inlined_ptr(inlined); + // Recompute the bindings and the types. + desugar::bind_and_types_check(*inlined_ptr); + return inlined_ptr.release(); + } + + template ast::ChunkList* inline_expand(const ast::ChunkList&); + + /*-------------------. + | Function pruning. | + `-------------------*/ + + template A* prune(const A& tree) + { + // Prune unused functions. + Pruner prune; + prune(tree); + A* pruned = dynamic_cast(prune.result_get()); + assertion(pruned); + std::unique_ptr pruned_ptr(pruned); + // Recompute the bindings and the types. + desugar::bind_and_types_check(*pruned_ptr); + return pruned_ptr.release(); + } + + template ast::ChunkList* prune(const ast::ChunkList&); + +} // namespace inlining -- cgit v1.2.3