42 #define DECL_OP_UNA(fname, key_prefix, A0, R, ...) \
44 auto func = make_ref<TOpUnary<A0, R>>(); \
46 func->function = [](A0 a) -> R __VA_ARGS__; \
47 func->name = #fname; \
49 std::stringstream source_builder; \
50 source_builder << "(" \
51 << func->get_type_arg_0()->get_cpp() \
52 << " a)" #__VA_ARGS__; \
54 func->source = source_builder.str(); \
56 std::stringstream key_builder; \
57 key_builder << #key_prefix << "_" \
58 << func->get_type_arg_0()->get_code() \
59 << func->get_type_res()->get_code(); \
60 func->key = key_builder.str(); \
62 fname = func.as<OpUnary>(); \
65 #define DECL_OP_UNA_S(name, key_prefix, T, ...) \
66 DECL_OP_UNA(name, key_prefix, T, T, __VA_ARGS__)
68 #define DECL_OP_BIN(fname, key_prefix, A0, A1, R, ...) \
70 auto func = make_ref<TOpBinary<A0, A1, R>>(); \
72 func->function = [](A0 a, A1 b) -> R __VA_ARGS__; \
73 func->name = #fname; \
75 std::stringstream source_builder; \
76 source_builder << "(" \
77 << func->get_type_arg_0()->get_cpp() \
79 << func->get_type_arg_1()->get_cpp() \
80 << " b)" #__VA_ARGS__; \
82 func->source = source_builder.str(); \
84 std::stringstream key_builder; \
85 key_builder << #key_prefix << "_" \
86 << func->get_type_arg_0()->get_code() \
87 << func->get_type_arg_1()->get_code() \
88 << func->get_type_res()->get_code(); \
89 func->key = key_builder.str(); \
91 fname = func.as<OpBinary>(); \
94 #define DECL_OP_BIN_S(name, key_prefix, T, ...) \
95 DECL_OP_BIN(name, key_prefix, T, T, T, __VA_ARGS__)
97 #define DECL_OP_SELECT(fname, key_prefix, A0, ...) \
99 auto func = make_ref<TOpSelect<A0>>(); \
101 func->function = [](A0 a) -> bool __VA_ARGS__; \
102 func->name = #fname; \
104 std::stringstream source_builder; \
105 source_builder << "(" \
106 << func->get_type_arg_0()->get_cpp() \
107 << " a)" #__VA_ARGS__; \
109 func->source = source_builder.str(); \
111 std::stringstream key_builder; \
112 key_builder << #key_prefix << "_" \
113 << func->get_type_arg_0()->get_code(); \
114 func->key = key_builder.str(); \
116 fname = func.as<OpSelect>(); \
124 template<
typename A0,
typename R>
130 const std::string&
get_label()
const override;
133 std::string
get_key()
override;
137 std::function<R(A0)>
function;
144 template<
typename A0,
typename R>
146 label = std::move(new_label);
148 template<
typename A0,
typename R>
152 template<
typename A0,
typename R>
156 template<
typename A0,
typename R>
160 template<
typename A0,
typename R>
164 template<
typename A0,
typename R>
166 return get_ttype<A0>().template as<Type>();
168 template<
typename A0,
typename R>
170 return get_ttype<R>().template as<Type>();
173 template<
typename A0,
typename A1,
typename R>
179 const std::string&
get_label()
const override;
182 std::string
get_key()
override;
187 std::function<R(A0, A1)>
function;
194 template<
typename A0,
typename A1,
typename R>
196 label = std::move(new_label);
198 template<
typename A0,
typename A1,
typename R>
202 template<
typename A0,
typename A1,
typename R>
206 template<
typename A0,
typename A1,
typename R>
210 template<
typename A0,
typename A1,
typename R>
214 template<
typename A0,
typename A1,
typename R>
216 return get_ttype<A0>().template as<Type>();
218 template<
typename A0,
typename A1,
typename R>
220 return get_ttype<A1>().template as<Type>();
222 template<
typename A0,
typename A1,
typename R>
224 return get_ttype<R>().template as<Type>();
227 template<
typename A0>
233 const std::string&
get_label()
const override;
236 std::string
get_key()
override;
240 std::function<bool(A0)>
function;
247 template<
typename A0>
249 label = std::move(new_label);
251 template<
typename A0>
255 template<
typename A0>
259 template<
typename A0>
263 template<
typename A0>
267 template<
typename A0>
269 return get_ttype<A0>().template as<Type>();
271 template<
typename A0>
273 return BOOL.template as<Type>();
Binary operation with 2-arity.
Definition: op.hpp:73
Select operation with 1-arity and bool return type.
Definition: op.hpp:87
Unary operation with 1-arity.
Definition: op.hpp:60
std::string source
Definition: top.hpp:189
~TOpBinary() override=default
std::string name
Definition: top.hpp:188
std::string key
Definition: top.hpp:190
std::string label
Definition: top.hpp:191
~TOpSelect() override=default
std::string source
Definition: top.hpp:242
std::string name
Definition: top.hpp:241
std::string label
Definition: top.hpp:244
std::string key
Definition: top.hpp:243
std::string source
Definition: top.hpp:139
std::string label
Definition: top.hpp:141
std::string key
Definition: top.hpp:140
~TOpUnary() override=default
std::string name
Definition: top.hpp:138
Automates reference counting and behaves as shared smart pointer.
Definition: ref.hpp:117
std::string get_key() override
Definition: top.hpp:264
std::string get_source_cl() override
Definition: top.hpp:260
ref_ptr< Type > get_type_res() override
Definition: top.hpp:272
std::string get_name() override
Definition: top.hpp:256
ref_ptr< Type > get_type_arg_0() override
Definition: top.hpp:215
std::string get_name() override
Definition: top.hpp:203
const std::string & get_label() const override
Definition: top.hpp:252
ref_ptr< Type > get_type_res() override
Definition: top.hpp:223
ref_ptr< Type > get_type_arg_1() override
Definition: top.hpp:219
std::string get_source_cl() override
Definition: top.hpp:157
void set_label(std::string label) override
Definition: top.hpp:145
const std::string & get_label() const override
Definition: top.hpp:149
std::string get_source_cl() override
Definition: top.hpp:207
ref_ptr< Type > get_type_arg_0() override
Definition: top.hpp:165
void register_ops()
Register all ops on library initialization.
Definition: op.cpp:157
std::string get_name() override
Definition: top.hpp:153
ref_ptr< Type > get_type_arg_0() override
Definition: top.hpp:268
ref_ptr< Type > get_type_res() override
Definition: top.hpp:169
std::string get_key() override
Definition: top.hpp:211
const std::string & get_label() const override
Definition: top.hpp:199
void set_label(std::string label) override
Definition: top.hpp:195
std::string get_key() override
Definition: top.hpp:161
void set_label(std::string label) override
Definition: top.hpp:248
ref_ptr< Type > BOOL
Definition: type.cpp:32
Definition: algorithm.hpp:37