Skip to content

Commit

Permalink
Refactoring in boolbvt::convert_bitwise
Browse files Browse the repository at this point in the history
  • Loading branch information
romainbrenguier committed Jun 4, 2018
1 parent adc2d5d commit 1b43ee9
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions src/solvers/flattening/boolbv_bitwise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,16 @@ Author: Daniel Kroening, [email protected]

bvt boolbvt::convert_bitwise(const exprt &expr)
{
std::size_t width=boolbv_width(expr.type());

const std::size_t width = boolbv_width(expr.type());
if(width==0)
return conversion_failed(expr);

if(expr.id()==ID_bitnot)
{
if(expr.operands().size()!=1)
throw "bitnot takes one operand";

DATA_INVARIANT(expr.operands().size() == 1, "bitnot takes one operand");
const exprt &op0=expr.op0();

const bvt &op_bv=convert_bv(op0);

if(op_bv.size()!=width)
throw "convert_bitwise: unexpected operand width";

CHECK_RETURN(op_bv.size() == width);
return bv_utils.inverted(op_bv);
}
else if(expr.id()==ID_bitand || expr.id()==ID_bitor ||
Expand All @@ -41,9 +34,7 @@ bvt boolbvt::convert_bitwise(const exprt &expr)
forall_operands(it, expr)
{
const bvt &op=convert_bv(*it);

if(op.size()!=width)
throw "convert_bitwise: unexpected operand width";
CHECK_RETURN(op.size() == width);

if(it==expr.operands().begin())
bv=op;
Expand All @@ -64,13 +55,13 @@ bvt boolbvt::convert_bitwise(const exprt &expr)
else if(expr.id()==ID_bitxnor)
bv[i]=prop.lequal(bv[i], op[i]);
else
throw "unexpected operand";
UNIMPLEMENTED;
}
}
}

return bv;
}

throw "unexpected bitwise operand";
UNIMPLEMENTED;
}

0 comments on commit 1b43ee9

Please sign in to comment.