Commit d7c4602a authored by Paul's avatar Paul
Browse files

Only call can_eval once

parent 5387920b
...@@ -74,7 +74,7 @@ struct instruction ...@@ -74,7 +74,7 @@ struct instruction
bool can_eval() const; bool can_eval() const;
argument eval() const; argument eval(bool check_eval=true) const;
void finalize(context& ctx); void finalize(context& ctx);
......
...@@ -179,19 +179,21 @@ bool instruction::can_eval() const ...@@ -179,19 +179,21 @@ bool instruction::can_eval() const
} }
} }
argument instruction::eval() const argument instruction::eval(bool check_eval) const
{ {
if(op.name() == "@literal") if(op.name() == "@literal")
{ {
return this->get_literal().get_argument(); return this->get_literal().get_argument();
} }
if(is_context_free(op) and this->can_eval()) if(is_context_free(op))
{ {
if (check_eval and not this->can_eval())
return {};
std::vector<argument> args; std::vector<argument> args;
std::transform(this->inputs().begin(), std::transform(this->inputs().begin(),
this->inputs().end(), this->inputs().end(),
std::back_inserter(args), std::back_inserter(args),
[](auto arg) { return arg->eval(); }); [](auto arg) { return arg->eval(false); });
return op.compute(result, args); return op.compute(result, args);
} }
return {}; return {};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment