Object Cond::eval(Environment& env) const { size_t idx = 0; static const varlisp::keywords_t kw_else = varlisp::keywords_t(varlisp::keywords_t::kw_ELSE); for (const auto item : conditions) { if (idx == conditions.size() - 1) { if (auto * p_v = boost::get<varlisp::keywords_t>(&item.first)) { if (*p_v == kw_else) { return boost::apply_visitor(eval_visitor(env), item.second); } } } Object res = boost::apply_visitor(eval_visitor(env), item.first); bool is_condition = boost::apply_visitor(cast2bool_visitor(env), res); if (is_condition) { return boost::apply_visitor(eval_visitor(env), item.second); } ++idx; } return Object(); }
value_t eval ( env_t* env, expression_t const& ast) { return boost::apply_visitor (eval_visitor (env), ast); }