19 auto &type = expr.
type();
22 type.id() == ID_bv || type.id() == ID_unsignedbv ||
23 type.id() == ID_signedbv)
27 std::size_t s = expr.
operands().size();
65 "unexpected operand 0 width",
69 prev_bv.resize(width);
73 for(std::size_t op_no=1; op_no<ops.size(); op_no+=2)
86 const exprt &new_value,
92 next_bv.resize(prev_bv.size());
94 if(type.
id()==ID_array)
97 else if(type.
id()==ID_bv ||
98 type.
id()==ID_unsignedbv ||
99 type.
id()==ID_signedbv)
104 else if(type.
id()==ID_struct)
107 else if(type.
id() == ID_struct_tag)
114 else if(type.
id()==ID_union)
116 else if(type.
id() == ID_union_tag)
131 const exprt &new_value,
138 "convert_with_array called for unbounded array",
143 const auto size = numeric_cast<mp_integer>(array_size);
147 "convert_with_array expects constant array size",
153 *size * new_value_bv.size() == prev_bv.size(),
154 "convert_with_array: unexpected new_value operand width",
158 if(
const auto index_value_opt = numeric_cast<mp_integer>(index))
163 if(*index_value_opt >= 0 && *index_value_opt < *size)
165 const std::size_t offset =
166 numeric_cast_v<std::size_t>(*index_value_opt * new_value_bv.size());
168 for(std::size_t j = 0; j < new_value_bv.size(); j++)
169 next_bv[offset + j] = new_value_bv[j];
183 const std::size_t offset =
184 numeric_cast_v<std::size_t>(i * new_value_bv.size());
186 for(std::size_t j = 0; j < new_value_bv.size(); j++)
187 next_bv[offset + j] =
188 prop.
lselect(eq_lit, new_value_bv[j], prev_bv[offset + j]);
195 const exprt &new_value,
203 const irep_idt &component_name = where.
get(ID_component_name);
207 std::size_t offset=0;
209 for(
const auto &c : components)
211 const typet &subtype = c.type();
215 if(c.get_name() == component_name)
218 subtype == new_value.
type(),
219 "with/struct: component '" +
id2string(component_name) +
220 "' type does not match",
225 sub_width == new_value_bv.size(),
226 "convert_with_struct: unexpected new_value operand width",
229 for(std::size_t i=0; i<sub_width; i++)
230 next_bv[offset + i] = new_value_bv[i];
241 const exprt &new_value,
250 next_bv.size() >= new_value_bv.size(),
251 "convert_with_union: unexpected new_value operand width",
257 for(std::size_t i = 0; i < new_value_bv.size(); i++)
258 next_bv[map_u.
map_bit(i)] = new_value_bv[map_new_value.
map_bit(i)];
API to expression classes for bitvectors.
const union_tag_typet & to_union_tag_type(const typet &type)
Cast a typet to a union_tag_typet.
const union_typet & to_union_type(const typet &type)
Cast a typet to a union_typet.
const exprt & size() const
virtual bvt convert_with(const with_exprt &expr)
virtual const bvt & convert_bv(const exprt &expr, const std::optional< std::size_t > expected_width={})
Convert expression to vector of literalts, using an internal cache to speed up conversion if availabl...
void convert_with_array(const array_typet &type, const exprt &index, const exprt &new_value, const bvt &prev_bv, bvt &next_bv)
bool is_unbounded_array(const typet &type) const override
void convert_with_union(const union_typet &type, const exprt &new_value, const bvt &prev_bv, bvt &next_bv)
virtual endianness_mapt endianness_map(const typet &type, bool little_endian) const
virtual std::size_t boolbv_width(const typet &type) const
void convert_with_struct(const struct_typet &type, const exprt &where, const exprt &new_value, const bvt &prev_bv, bvt &next_bv)
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Maps a big-endian offset to a little-endian offset.
size_t map_bit(size_t bit) const
Base class for all expressions.
std::vector< exprt > operandst
typet & type()
Return the type of the expression.
const irep_idt & get(const irep_idt &name) const
const irep_idt & id() const
const union_typet & follow_tag(const union_tag_typet &) const
Follow type tag of union type.
literalt convert(const exprt &expr) override
Convert a Boolean expression and return the corresponding literal.
virtual literalt lselect(literalt a, literalt b, literalt c)=0
Structure type, corresponds to C style structs.
const componentst & components() const
std::vector< componentt > componentst
The type of an expression, extends irept.
Replaces a sub-range of a bit-vector operand.
Replaces a sub-range of a bit-vector operand.
Operator to update elements in structs and arrays.
const std::string & id2string(const irep_idt &d)
std::vector< literalt > bvt
#define PRECONDITION(CONDITION)
#define DATA_INVARIANT_WITH_DIAGNOSTICS(CONDITION, REASON,...)
API to expression classes.
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
const array_typet & to_array_type(const typet &type)
Cast a typet to an array_typet.
const struct_tag_typet & to_struct_tag_type(const typet &type)
Cast a typet to a struct_tag_typet.