{CVC4::Kind::LAST_KIND, LAST_KIND},
};
+/* Set of kinds for indexed operators */
+const static std::unordered_set<Kind, KindHashFunction> s_indexed_kinds(
+ {CHAIN,
+ RECORD_UPDATE,
+ DIVISIBLE,
+ BITVECTOR_REPEAT,
+ BITVECTOR_ZERO_EXTEND,
+ BITVECTOR_SIGN_EXTEND,
+ BITVECTOR_ROTATE_LEFT,
+ BITVECTOR_ROTATE_RIGHT,
+ INT_TO_BITVECTOR,
+ FLOATINGPOINT_TO_UBV,
+ FLOATINGPOINT_TO_UBV_TOTAL,
+ FLOATINGPOINT_TO_SBV,
+ FLOATINGPOINT_TO_SBV_TOTAL,
+ TUPLE_UPDATE,
+ BITVECTOR_EXTRACT,
+ FLOATINGPOINT_TO_FP_IEEE_BITVECTOR,
+ FLOATINGPOINT_TO_FP_FLOATINGPOINT,
+ FLOATINGPOINT_TO_FP_REAL,
+ FLOATINGPOINT_TO_FP_SIGNED_BITVECTOR,
+ FLOATINGPOINT_TO_FP_UNSIGNED_BITVECTOR,
+ FLOATINGPOINT_TO_FP_GENERIC});
+
namespace {
bool isDefinedKind(Kind k) { return k > UNDEFINED_KIND && k < LAST_KIND; }
/* Public methods */
bool Op::operator==(const Op& t) const
{
- if (d_expr->isNull() || t.d_expr->isNull())
+ if (d_expr->isNull() && t.d_expr->isNull())
+ {
+ return (d_kind == t.d_kind);
+ }
+ else if (d_expr->isNull() || t.d_expr->isNull())
{
return false;
}
/* Create operators */
/* -------------------------------------------------------------------------- */
+Op Solver::mkOp(Kind kind) const
+{
+ CVC4_API_SOLVER_TRY_CATCH_BEGIN;
+ CVC4_API_CHECK(s_indexed_kinds.find(kind) == s_indexed_kinds.end())
+ << "Expected a kind for a non-indexed operator.";
+ return Op(kind);
+ CVC4_API_SOLVER_TRY_CATCH_END
+}
+
Op Solver::mkOp(Kind kind, Kind k) const
{
CVC4_API_SOLVER_TRY_CATCH_BEGIN;
const std::vector<Term>& terms) const;
/* .................................................................... */
- /* Create Operator Terms */
+ /* Create Operators */
/* .................................................................... */
+ /**
+ * Create an operator for a builtin Kind
+ * The Kind may not be the Kind for an indexed operator
+ * (e.g. BITVECTOR_EXTRACT)
+ * Note: in this case, the Op simply wraps the Kind.
+ * The Kind can be used in mkTerm directly without
+ * creating an op first.
+ * @param kind the kind to wrap
+ */
+ Op mkOp(Kind kind) const;
+
/**
* Create operator of kind:
* - CHAIN
Op plus(PLUS);
TS_ASSERT(!plus.isIndexed());
TS_ASSERT_THROWS(plus.getIndices<uint32_t>(), CVC4ApiException&);
+
+ TS_ASSERT_THROWS_NOTHING(d_solver.mkOp(PLUS));
+ TS_ASSERT_EQUALS(plus, d_solver.mkOp(PLUS));
+ TS_ASSERT_THROWS(d_solver.mkOp(BITVECTOR_EXTRACT), CVC4ApiException&);
}
void OpBlack::testGetIndicesString()