forked from diffblue/cbmc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring in boolbvt::convert_bitwise
- Loading branch information
1 parent
adc2d5d
commit 1b43ee9
Showing
1 changed file
with
6 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 || | ||
|
@@ -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; | ||
|
@@ -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; | ||
} |