Verified Commit 48466f0e authored by Houtan Bastani's avatar Houtan Bastani
Browse files

macro processor: remove double evaluations of ExpressionPtr

parent 92f18f58
Pipeline #1633 passed with stage
in 1 minute and 38 seconds
......@@ -215,8 +215,9 @@ If::interpret(ostream &output, bool no_line_macro)
for (auto & it : expr_and_body)
try
{
RealPtr dp = dynamic_pointer_cast<Real>(it.first->eval());
BoolPtr bp = dynamic_pointer_cast<Bool>(it.first->eval());
auto tmp = it.first->eval();
RealPtr dp = dynamic_pointer_cast<Real>(tmp);
BoolPtr bp = dynamic_pointer_cast<Bool>(tmp);
if (!bp && !dp)
error(StackTrace("@#if",
"The condition must evaluate to a boolean or a double", location));
......
......@@ -1029,8 +1029,9 @@ Comprehension::eval()
BoolPtr bp;
try
{
dp = dynamic_pointer_cast<Real>(c_when->eval());
bp = dynamic_pointer_cast<Bool>(c_when->eval());
auto tmp = c_when->eval();
dp = dynamic_pointer_cast<Real>(tmp);
bp = dynamic_pointer_cast<Bool>(tmp);
if (!bp && !dp)
throw StackTrace("The condition must evaluate to a boolean or a real");
}
......
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