File eval_impl.hpp¶
File List > backends > cxx > include > zmbt > expr > eval_impl.hpp
Go to the documentation of this file
#ifndef ZMBT_EXPR_EVAL_IMPL_HPP_
#define ZMBT_EXPR_EVAL_IMPL_HPP_
#include "expression.hpp"
#include "eval_context.hpp"
#include "eval_params.hpp"
#include "eval_validator.hpp"
#include "keyword.hpp"
#include "keyword_info.hpp"
namespace zmbt {
namespace lang {
template <Keyword K>
struct EvalImpl; // specializations shall use CRTP : public EvalImplBase<K>
// {
// Expression impl() const;
// };
template <Keyword K, class Validator = EvalValidator<K>>
class EvalImplBase : public FixedEvalParams<K>
{
EvalContext curr_ctx_;
public:
EvalContext curr_ctx() const { return curr_ctx_; }
EvalImplBase(ExpressionView const& e, ExpressionView const& x, EvalContext ctx)
: FixedEvalParams<K>(e, x, ctx)
, curr_ctx_{++ctx}
{
}
Expression operator()() &&
{
auto const v = Validator{this->lhs(), this->rhs()};
if (v.is_invalid()) return v.status();
auto ctx = this->context();
auto const result = static_cast<EvalImpl<K> const*>(this)->impl();
ctx.log.push(this->self(), this->x(), result, ctx.depth);
return result;
}
};
template <Keyword K>
Expression dispatch_eval(ExpressionView const& self, ExpressionView const& x, EvalContext context);
} // namespace lang
} // namespace zmbt
#endif