Branch data Line data Source code
1 : : #include "backend/InterpreterOperator.hpp" 2 : : 3 : : 4 : : using namespace m; 5 : : using namespace m::interpreter; 6 : : 7 : : 8 : 81 : void m::register_interpreter_operators(PhysicalOptimizer &phys_opt) 9 : : { 10 : : #define REGISTER(CLASS) phys_opt.register_operator<interpreter::CLASS>(); 11 : 81 : M_OPERATOR_LIST(REGISTER) 12 : : #undef REGISTER 13 : 81 : } 14 : : 15 : : #define ACCEPT(CLASS) \ 16 : : void CLASS::accept(MatchBaseVisitor &v) { v(*this); } \ 17 : : void CLASS::accept(ConstMatchBaseVisitor &v) const { v(*this); } 18 : 0 : M_INTERPRETER_MATCH_LIST(ACCEPT) 19 : : #undef ACCEPT 20 : : 21 : : namespace { 22 : : 23 : : template<bool C, bool PreOrder> 24 : : struct recursive_matchbase_visitor : TheRecursiveMatchBaseVisitorBase<C> 25 : : { 26 : : using super = TheRecursiveMatchBaseVisitorBase<C>; 27 : : template<typename T> using Const = typename super::template Const<T>; 28 : : using callback_t = std::conditional_t<C, ConstMatchBaseVisitor, MatchBaseVisitor>; 29 : : 30 : : private: 31 : : callback_t &callback_; 32 : : 33 : : public: 34 : 0 : recursive_matchbase_visitor(callback_t &callback) : callback_(callback) { } 35 : : 36 : : using super::operator(); 37 : : #define DECLARE(CLASS) \ 38 : : void operator()(Const<CLASS> &M) override { \ 39 : : if constexpr (PreOrder) try { callback_(M); } catch (visit_skip_subtree) { return; } \ 40 : : super::operator()(M); \ 41 : : if constexpr (not PreOrder) callback_(M); \ 42 : : } 43 [ # # # # : 0 : M_INTERPRETER_MATCH_LIST(DECLARE) # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # ] 44 : : #undef DECLARE 45 : : }; 46 : : 47 : : } 48 : : 49 : : template<bool C> 50 : 0 : void ThePreOrderMatchBaseVisitor<C>::operator()(Const<MatchBase> &M) 51 : : { 52 [ # # ]: 0 : recursive_matchbase_visitor<C, /* PreOrder= */ true>{*this}(M); 53 : 0 : } 54 : : 55 : : template<bool C> 56 : 0 : void ThePostOrderMatchBaseVisitor<C>::operator()(Const<MatchBase> &M) 57 : : { 58 [ # # ]: 0 : recursive_matchbase_visitor<C, /* PreOrder= */ false>{*this}(M); 59 : 0 : } 60 : : 61 : : // explicit template instantiations 62 : : template struct m::interpreter::ThePreOrderMatchBaseVisitor<true>; 63 : : template struct m::interpreter::ThePostOrderMatchBaseVisitor<true>;