22#ifndef ATTRIBUTE_MAPPER_AST_EVAL_HPP
23#define ATTRIBUTE_MAPPER_AST_EVAL_HPP
28#include <boost/optional.hpp>
43struct attribute_path_subscript;
73template<
typename T>
struct eval {
128 return boost::apply_visitor(*
this, x.
operand_);
136 return lhs.value() + rhs.value();
138 return lhs.value() - rhs.value();
140 return lhs.value() * rhs.value();
142 return lhs.value() / rhs.value();
144 return trunc(1000. * lhs.value()) == trunc(1000. * rhs.value());
146 return lhs.value() <= rhs.value();
148 return lhs.value() >= rhs.value();
150 return lhs.value() < rhs.value();
152 return lhs.value() > rhs.value();
154 return ((
int)round(lhs.value())) & ((int)round(rhs.value()));
156 return ((
int)round(lhs.value())) | ((
int)round(rhs.value()));
158 return ((
int)round(lhs.value())) ^ ((
int)round(rhs.value()));
160 return fmod(lhs.value(), rhs.value());
162 return pow(lhs.value(), rhs.value());
164 return lhs.value() != rhs.value();
199 state = (*this)(oper, state);
211 return boost::apply_visitor(*
this, x.
cond_true);
213 return boost::apply_visitor(*
this, x.
cond_false);
240 if (result != FLT_MIN) {
253 std::vector<result_type> results;
255 results.push_back((*
this)(argument));
259 const auto &functions = get_built_in_functions<T>();
263 "Unknown function (%s), returning undefined",
attribute store C++ wrapper.
number_t attribute_store_get_reported_number(attribute_store_node_t node)
Gets a numerical value from an Attribute Store node.
Definition: attribute_store_helper.c:796
number_t attribute_store_get_desired_number(attribute_store_node_t node)
Gets a numerical value from an Attribute Store node.
Definition: attribute_store_helper.c:801
#define sl_log_error(tag, fmtstr,...)
Definition: sl_log.h:145
Definition: attribute_mapper_ast.hpp:39
@ operator_modulo
Definition: attribute_mapper_ast.hpp:72
@ operator_div
Definition: attribute_mapper_ast.hpp:65
@ operator_bitand
Definition: attribute_mapper_ast.hpp:66
@ operator_bitxor
Definition: attribute_mapper_ast.hpp:68
@ operator_minus
Definition: attribute_mapper_ast.hpp:62
@ operator_bitor
Definition: attribute_mapper_ast.hpp:67
@ operator_mult
Definition: attribute_mapper_ast.hpp:64
@ operator_or
Definition: attribute_mapper_ast.hpp:71
@ operator_less_than_or_eq
Definition: attribute_mapper_ast.hpp:75
@ operator_exponent
Definition: attribute_mapper_ast.hpp:73
@ operator_greater_than_or_eq
Definition: attribute_mapper_ast.hpp:76
@ operator_greater_than
Definition: attribute_mapper_ast.hpp:70
@ operator_plus
Definition: attribute_mapper_ast.hpp:61
@ operator_less_than
Definition: attribute_mapper_ast.hpp:69
@ operator_equals
Definition: attribute_mapper_ast.hpp:63
@ operator_neq
Definition: attribute_mapper_ast.hpp:74
The attribute path evaluator evalues a full attribute path and returns the matching attribute store a...
Definition: attribute_mapper_ast_path_eval.hpp:51
bool all_elements_parsed() const
Definition: attribute_mapper_ast_path_eval.hpp:81
Attribute.
Definition: attribute_mapper_ast.hpp:177
std::vector< attribute_path_element > attribute_path
Definition: attribute_mapper_ast.hpp:179
char value_type
Definition: attribute_mapper_ast.hpp:178
Condition.
Definition: attribute_mapper_ast.hpp:147
operand cond_true
Truth value.
Definition: attribute_mapper_ast.hpp:149
operand cond_false
False value.
Definition: attribute_mapper_ast.hpp:150
operand cond_value
Selector value.
Definition: attribute_mapper_ast.hpp:148
AST evaluator.
Definition: attribute_mapper_ast_eval.hpp:73
result_type operator()(const function_invokation &f) const
Evaluates Function invokation.
Definition: attribute_mapper_ast_eval.hpp:250
result_type operator()(const expression &x) const
Condition.
Definition: attribute_mapper_ast_eval.hpp:195
attribute_store::attribute context
Definition: attribute_mapper_ast_eval.hpp:272
result_type operator()(const operation &x, result_type lhs) const
An operation.
Definition: attribute_mapper_ast_eval.hpp:118
result_type operator()(const condition &x) const
The normal entry point of the evaluator.
Definition: attribute_mapper_ast_eval.hpp:207
result_type operator()(const uint32_t n) const
a literal number
Definition: attribute_mapper_ast_eval.hpp:96
result_type operator()(const nil &) const
the undefined keyword
Definition: attribute_mapper_ast_eval.hpp:88
result_type operator()(const signed_ &x) const
Unary operation.
Definition: attribute_mapper_ast_eval.hpp:176
result_type operator()(const attribute &a) const
an attribute read from the attribute store
Definition: attribute_mapper_ast_eval.hpp:220
boost::optional< T > result_type
Definition: attribute_mapper_ast_eval.hpp:75
eval(const attribute_store::attribute context=0)
Construct a new eval object.
Definition: attribute_mapper_ast_eval.hpp:82
result_type operator()(const float n) const
a literal number
Definition: attribute_mapper_ast_eval.hpp:104
Expression.
Definition: attribute_mapper_ast.hpp:134
operand first
Definition: attribute_mapper_ast.hpp:135
std::list< operation > rest
Definition: attribute_mapper_ast.hpp:136
Built-in function invokation Example : fn_min_value(r'3, 5, d'5 or 20)
Definition: attribute_mapper_ast.hpp:209
std::vector< expression > arguments
Definition: attribute_mapper_ast.hpp:211
std::string function_name
Definition: attribute_mapper_ast.hpp:210
Definition: attribute_mapper_ast.hpp:42
Operation An operation consists of an operator and an right hand side operand. When operations are ev...
Definition: attribute_mapper_ast.hpp:123
operator_ids operator_
+,-,*,/ etc.
Definition: attribute_mapper_ast.hpp:124
operand operand_
right hand side operand
Definition: attribute_mapper_ast.hpp:125
Uniary signed operand.
Definition: attribute_mapper_ast.hpp:111
char sign
Definition: attribute_mapper_ast.hpp:112
operand operand_
Definition: attribute_mapper_ast.hpp:113
pthread_cond_t cond
Definition: uic_stdin_process.c:53