mutable
A Database System for Research and Fast Prototyping
Loading...
Searching...
No Matches
InterpreterOperator.cpp
Go to the documentation of this file.
2
3
4using namespace m;
5using namespace m::interpreter;
6
7
8void m::register_interpreter_operators(PhysicalOptimizer &phys_opt)
9{
10#define REGISTER(CLASS) phys_opt.register_operator<interpreter::CLASS>();
12#undef REGISTER
13}
14
15#define ACCEPT(CLASS) \
16 void CLASS::accept(MatchBaseVisitor &v) { v(*this); } \
17 void CLASS::accept(ConstMatchBaseVisitor &v) const { v(*this); }
19#undef ACCEPT
20
21namespace {
22
23template<bool C, bool PreOrder>
24struct recursive_matchbase_visitor : TheRecursiveMatchBaseVisitorBase<C>
25{
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 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 }
44#undef DECLARE
45};
46
47}
48
49template<bool C>
51{
52 recursive_matchbase_visitor<C, /* PreOrder= */ true>{*this}(M);
53}
54
55template<bool C>
57{
58 recursive_matchbase_visitor<C, /* PreOrder= */ false>{*this}(M);
59}
60
61// explicit template instantiations
#define ACCEPT(CLASS)
#define REGISTER(CLASS)
#define M_INTERPRETER_MATCH_LIST(X)
#define M_OPERATOR_LIST(X)
Definition: Operator.hpp:560
#define DECLARE(CLASS)
‍mutable namespace
Definition: Backend.hpp:10
The physical optimizer interface.
typename super::template Const< T > Const
typename super::template Const< T > Const
A generic base class for implementing recursive interpreter::MatchBase visitors.