22
22
23
23
bvt map_bv (const bv_endianness_mapt &map, const bvt &src)
24
24
{
25
- assert (map.number_of_bits ()==src.size ());
26
-
25
+ PRECONDITION (map.number_of_bits () == src.size ());
27
26
bvt result;
28
27
result.resize (src.size (), const_literal (false ));
29
28
30
29
for (std::size_t i=0 ; i<src.size (); i++)
31
30
{
32
- size_t mapped_index= map.map_bit (i);
33
- assert (mapped_index< src.size ());
31
+ const size_t mapped_index = map.map_bit (i);
32
+ CHECK_RETURN (mapped_index < src.size ());
34
33
result[i]=src[mapped_index];
35
34
}
36
35
@@ -39,15 +38,14 @@ bvt map_bv(const bv_endianness_mapt &map, const bvt &src)
39
38
40
39
bvt boolbvt::convert_byte_extract (const byte_extract_exprt &expr)
41
40
{
42
- if (expr.operands ().size ()!=2 )
43
- throw " byte_extract takes two operands" ;
41
+ PRECONDITION (expr.operands ().size () == 2 );
44
42
45
43
// if we extract from an unbounded array, call the flattening code
46
44
if (is_unbounded_array (expr.op ().type ()))
47
45
{
48
46
try
49
47
{
50
- exprt tmp = flatten_byte_extract (expr, ns);
48
+ const exprt tmp = flatten_byte_extract (expr, ns);
51
49
return convert_bv (tmp);
52
50
}
53
51
catch (const flatten_byte_extract_exceptiont &byte_extract_flatten_exception)
@@ -57,7 +55,7 @@ bvt boolbvt::convert_byte_extract(const byte_extract_exprt &expr)
57
55
}
58
56
}
59
57
60
- std::size_t width= boolbv_width (expr.type ());
58
+ const std::size_t width = boolbv_width (expr.type ());
61
59
62
60
// special treatment for bit-fields and big-endian:
63
61
// we need byte granularity
@@ -80,22 +78,10 @@ bvt boolbvt::convert_byte_extract(const byte_extract_exprt &expr)
80
78
81
79
const exprt &op=expr.op ();
82
80
const exprt &offset=expr.offset ();
83
-
84
- bool little_endian;
85
-
86
- if (expr.id ()==ID_byte_extract_little_endian)
87
- little_endian=true ;
88
- else if (expr.id ()==ID_byte_extract_big_endian)
89
- little_endian=false ;
90
- else
91
- {
92
- little_endian=false ;
93
- assert (false );
94
- }
81
+ const bool little_endian = expr.id () == ID_byte_extract_little_endian;
95
82
96
83
// first do op0
97
-
98
- bv_endianness_mapt op_map (op.type (), little_endian, ns, boolbv_width);
84
+ const bv_endianness_mapt op_map (op.type (), little_endian, ns, boolbv_width);
99
85
const bvt op_bv=map_bv (op_map, convert_bv (op));
100
86
101
87
// do result
0 commit comments