|
6 | 6 |
|
7 | 7 | \*******************************************************************/
|
8 | 8 |
|
9 |
| -#include "boolbv.h" |
10 |
| - |
11 | 9 | #include <util/arith_tools.h>
|
| 10 | +#include <util/bitvector_expr.h> |
12 | 11 | #include <util/c_types.h>
|
13 | 12 | #include <util/namespace.h>
|
14 | 13 | #include <util/std_expr.h>
|
15 | 14 |
|
| 15 | +#include "boolbv.h" |
| 16 | + |
16 | 17 | bvt boolbvt::convert_with(const with_exprt &expr)
|
17 | 18 | {
|
| 19 | + auto &type = expr.type(); |
| 20 | + |
| 21 | + if( |
| 22 | + type.id() == ID_bv || type.id() == ID_unsignedbv || |
| 23 | + type.id() == ID_signedbv) |
| 24 | + { |
| 25 | + PRECONDITION(expr.operands().size() == 3); |
| 26 | + return convert_bv( |
| 27 | + update_bits_exprt(expr.old(), expr.where(), expr.new_value())); |
| 28 | + } |
| 29 | + |
18 | 30 | bvt bv = convert_bv(expr.old());
|
19 | 31 |
|
20 |
| - std::size_t width=boolbv_width(expr.type()); |
| 32 | + std::size_t width = boolbv_width(type); |
21 | 33 |
|
22 | 34 | if(width==0)
|
23 | 35 | {
|
@@ -62,7 +74,10 @@ void boolbvt::convert_with(
|
62 | 74 | else if(type.id()==ID_bv ||
|
63 | 75 | type.id()==ID_unsignedbv ||
|
64 | 76 | type.id()==ID_signedbv)
|
65 |
| - return convert_with_bv(where, new_value, prev_bv, next_bv); |
| 77 | + { |
| 78 | + // already done |
| 79 | + PRECONDITION(false); |
| 80 | + } |
66 | 81 | else if(type.id()==ID_struct)
|
67 | 82 | return convert_with_struct(
|
68 | 83 | to_struct_type(type), where, new_value, prev_bv, next_bv);
|
@@ -151,36 +166,6 @@ void boolbvt::convert_with_array(
|
151 | 166 | }
|
152 | 167 | }
|
153 | 168 |
|
154 |
| -void boolbvt::convert_with_bv( |
155 |
| - const exprt &index, |
156 |
| - const exprt &new_value, |
157 |
| - const bvt &prev_bv, |
158 |
| - bvt &next_bv) |
159 |
| -{ |
160 |
| - literalt l = convert(new_value); |
161 |
| - |
162 |
| - if(const auto index_value_opt = numeric_cast<mp_integer>(index)) |
163 |
| - { |
164 |
| - next_bv=prev_bv; |
165 |
| - |
166 |
| - if(*index_value_opt >= 0 && *index_value_opt < next_bv.size()) |
167 |
| - next_bv[numeric_cast_v<std::size_t>(*index_value_opt)] = l; |
168 |
| - |
169 |
| - return; |
170 |
| - } |
171 |
| - |
172 |
| - typet counter_type = index.type(); |
173 |
| - |
174 |
| - for(std::size_t i=0; i<prev_bv.size(); i++) |
175 |
| - { |
176 |
| - exprt counter=from_integer(i, counter_type); |
177 |
| - |
178 |
| - literalt eq_lit = convert(equal_exprt(index, counter)); |
179 |
| - |
180 |
| - next_bv[i]=prop.lselect(eq_lit, l, prev_bv[i]); |
181 |
| - } |
182 |
| -} |
183 |
| - |
184 | 169 | void boolbvt::convert_with_struct(
|
185 | 170 | const struct_typet &type,
|
186 | 171 | const exprt &where,
|
|
0 commit comments