2323
2424bvt map_bv (const bv_endianness_mapt &map, const bvt &src)
2525{
26- assert (map.number_of_bits ()==src.size ());
27-
26+ PRECONDITION (map.number_of_bits () == src.size ());
2827 bvt result;
29- result.resize (src.size (), const_literal ( false ));
28+ result.reserve (src.size ());
3029
3130 for (std::size_t i=0 ; i<src.size (); i++)
3231 {
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]) ;
3635 }
3736
3837 return result;
3938}
4039
4140bvt boolbvt::convert_byte_extract (const byte_extract_exprt &expr)
4241{
43- if (expr.operands ().size ()!=2 )
44- throw " byte_extract takes two operands" ;
42+ PRECONDITION (expr.operands ().size () == 2 );
4543
4644 // if we extract from an unbounded array, call the flattening code
4745 if (is_unbounded_array (expr.op ().type ()))
4846 {
4947 try
5048 {
51- exprt tmp = flatten_byte_extract (expr, ns);
49+ const exprt tmp = flatten_byte_extract (expr, ns);
5250 return convert_bv (tmp);
5351 }
5452 catch (const flatten_byte_extract_exceptiont &byte_extract_flatten_exception)
@@ -58,7 +56,7 @@ bvt boolbvt::convert_byte_extract(const byte_extract_exprt &expr)
5856 }
5957 }
6058
61- std::size_t width= boolbv_width (expr.type ());
59+ const std::size_t width = boolbv_width (expr.type ());
6260
6361 // special treatment for bit-fields and big-endian:
6462 // we need byte granularity
@@ -105,22 +103,10 @@ bvt boolbvt::convert_byte_extract(const byte_extract_exprt &expr)
105103
106104 const exprt &op=expr.op ();
107105 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;
120107
121108 // 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);
124110 const bvt op_bv=map_bv (op_map, convert_bv (op));
125111
126112 // do result
0 commit comments