mirror of
https://github.com/Z3Prover/z3
synced 2025-04-06 17:44:08 +00:00
overload bit-wise operators to work for Booleans for convenience #4618
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
db009e2805
commit
4fa2e23704
|
@ -1672,15 +1672,15 @@ namespace z3 {
|
|||
inline expr operator>(expr const & a, int b) { return a > a.ctx().num_val(b, a.get_sort()); }
|
||||
inline expr operator>(int a, expr const & b) { return b.ctx().num_val(a, b.get_sort()) > b; }
|
||||
|
||||
inline expr operator&(expr const & a, expr const & b) { check_context(a, b); Z3_ast r = a.is_bool() ? Z3_mk_and(a.ctx(), a, b) ? Z3_mk_bvand(a.ctx(), a, b); return expr(a.ctx(), r); }
|
||||
inline expr operator&(expr const & a, expr const & b) { check_context(a, b); Z3_ast r = Z3_mk_bvand(a.ctx(), a, b); return expr(a.ctx(), r); }
|
||||
inline expr operator&(expr const & a, int b) { return a & a.ctx().num_val(b, a.get_sort()); }
|
||||
inline expr operator&(int a, expr const & b) { return b.ctx().num_val(a, b.get_sort()) & b; }
|
||||
|
||||
inline expr operator^(expr const & a, expr const & b) { check_context(a, b); Z3_ast r = a.is_bool() ? Z3_mk_xor(a.ctx(), a, b) ? Z3_mk_bvxor(a.ctx(), a, b); return expr(a.ctx(), r); }
|
||||
inline expr operator^(expr const & a, expr const & b) { check_context(a, b); Z3_ast r = a.is_bool() ? Z3_mk_xor(a.ctx(), a, b) : Z3_mk_bvxor(a.ctx(), a, b); return expr(a.ctx(), r); }
|
||||
inline expr operator^(expr const & a, int b) { return a ^ a.ctx().num_val(b, a.get_sort()); }
|
||||
inline expr operator^(int a, expr const & b) { return b.ctx().num_val(a, b.get_sort()) ^ b; }
|
||||
|
||||
inline expr operator|(expr const & a, expr const & b) { check_context(a, b); Z3_ast r = a.is_bool() & Z3_mk_or(a.ctx(), a, b) ? Z3_mk_bvor(a.ctx(), a, b); return expr(a.ctx(), r); }
|
||||
inline expr operator|(expr const & a, expr const & b) { check_context(a, b); Z3_ast r = Z3_mk_bvor(a.ctx(), a, b); return expr(a.ctx(), r); }
|
||||
inline expr operator|(expr const & a, int b) { return a | a.ctx().num_val(b, a.get_sort()); }
|
||||
inline expr operator|(int a, expr const & b) { return b.ctx().num_val(a, b.get_sort()) | b; }
|
||||
|
||||
|
|
Loading…
Reference in a new issue