@@ -23,32 +23,30 @@ Author: Daniel Kroening, kroening@kroening.com
23
23
24
24
bvt map_bv (const bv_endianness_mapt &map, const bvt &src)
25
25
{
26
- assert (map.number_of_bits ()==src.size ());
27
-
26
+ PRECONDITION (map.number_of_bits () == src.size ());
28
27
bvt result;
29
- result.resize (src.size (), const_literal ( false ));
28
+ result.reserve (src.size ());
30
29
31
30
for (std::size_t i=0 ; i<src.size (); i++)
32
31
{
33
- size_t mapped_index= map.map_bit (i);
34
- assert (mapped_index< src.size ());
35
- result[i]= src[mapped_index];
32
+ const size_t mapped_index = map.map_bit (i);
33
+ CHECK_RETURN (mapped_index < src.size ());
34
+ result. push_back ( src[mapped_index]) ;
36
35
}
37
36
38
37
return result;
39
38
}
40
39
41
40
bvt boolbvt::convert_byte_extract (const byte_extract_exprt &expr)
42
41
{
43
- if (expr.operands ().size ()!=2 )
44
- throw " byte_extract takes two operands" ;
42
+ PRECONDITION (expr.operands ().size () == 2 );
45
43
46
44
// if we extract from an unbounded array, call the flattening code
47
45
if (is_unbounded_array (expr.op ().type ()))
48
46
{
49
47
try
50
48
{
51
- exprt tmp = flatten_byte_extract (expr, ns);
49
+ const exprt tmp = flatten_byte_extract (expr, ns);
52
50
return convert_bv (tmp);
53
51
}
54
52
catch (const flatten_byte_extract_exceptiont &byte_extract_flatten_exception)
@@ -58,7 +56,7 @@ bvt boolbvt::convert_byte_extract(const byte_extract_exprt &expr)
58
56
}
59
57
}
60
58
61
- std::size_t width= boolbv_width (expr.type ());
59
+ const std::size_t width = boolbv_width (expr.type ());
62
60
63
61
// special treatment for bit-fields and big-endian:
64
62
// we need byte granularity
@@ -105,22 +103,10 @@ bvt boolbvt::convert_byte_extract(const byte_extract_exprt &expr)
105
103
106
104
const exprt &op=expr.op ();
107
105
const exprt &offset=expr.offset ();
108
-
109
- bool little_endian;
110
-
111
- if (expr.id ()==ID_byte_extract_little_endian)
112
- little_endian=true ;
113
- else if (expr.id ()==ID_byte_extract_big_endian)
114
- little_endian=false ;
115
- else
116
- {
117
- little_endian=false ;
118
- assert (false );
119
- }
106
+ const bool little_endian = expr.id () == ID_byte_extract_little_endian;
120
107
121
108
// first do op0
122
-
123
- bv_endianness_mapt op_map (op.type (), little_endian, ns, boolbv_width);
109
+ const bv_endianness_mapt op_map (op.type (), little_endian, ns, boolbv_width);
124
110
const bvt op_bv=map_bv (op_map, convert_bv (op));
125
111
126
112
// do result
0 commit comments