Skip to content

Commit

Permalink
Refactor conjunction.cpp to handle null cost in compute_cost method
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardodebenedictis committed Jun 25, 2024
1 parent 6e61240 commit ff41369
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/conjunction.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
#include "conjunction.hpp"
#include "statement.hpp"
#include "core.hpp"

namespace riddle
{
conjunction::conjunction(scope &parent, std::shared_ptr<env> ctx, const conjunction_statement &conj) : scope(parent.get_core(), parent), ctx(ctx), conj(conj) {}

void conjunction::execute() { conj.execute(*this, ctx); }

std::shared_ptr<arith_item> conjunction::compute_cost() const noexcept { return std::static_pointer_cast<arith_item>(conj.get_cost()->evaluate(*this, ctx)); }
std::shared_ptr<arith_item> conjunction::compute_cost() const noexcept
{
if (conj.get_cost())
return std::static_pointer_cast<arith_item>(conj.get_cost()->evaluate(*this, ctx));
else
return get_core().new_real(utils::rational::one);
}
} // namespace riddle

0 comments on commit ff41369

Please sign in to comment.