/** ** \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