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" ;
45
-
46
42
// if we extract from an unbounded array, call the flattening code
47
43
if (is_unbounded_array (expr.op ().type ()))
48
44
{
49
45
try
50
46
{
51
- exprt tmp = flatten_byte_extract (expr, ns);
52
- return convert_bv (tmp);
47
+ return convert_bv (flatten_byte_extract (expr, ns));
53
48
}
54
49
catch (const flatten_byte_extract_exceptiont &byte_extract_flatten_exception)
55
50
{
@@ -58,7 +53,7 @@ bvt boolbvt::convert_byte_extract(const byte_extract_exprt &expr)
58
53
}
59
54
}
60
55
61
- std::size_t width= boolbv_width (expr.type ());
56
+ const std::size_t width = boolbv_width (expr.type ());
62
57
63
58
// special treatment for bit-fields and big-endian:
64
59
// we need byte granularity
@@ -105,22 +100,10 @@ bvt boolbvt::convert_byte_extract(const byte_extract_exprt &expr)
105
100
106
101
const exprt &op=expr.op ();
107
102
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
- }
103
+ const bool little_endian = expr.id () == ID_byte_extract_little_endian;
120
104
121
105
// first do op0
122
-
123
- bv_endianness_mapt op_map (op.type (), little_endian, ns, boolbv_width);
106
+ const bv_endianness_mapt op_map (op.type (), little_endian, ns, boolbv_width);
124
107
const bvt op_bv=map_bv (op_map, convert_bv (op));
125
108
126
109
// do result
0 commit comments