22 if(expr.
id()==ID_symbol ||
23 expr.
id()==ID_nondet_symbol)
29 if(map_entry_opt.has_value())
49 const typet &type)
const
53 assert(bv.size()>=offset+width);
55 if(type.
id()==ID_bool)
69 if(bvtype==bvtypet::IS_UNKNOWN)
71 if(type.
id()==ID_array)
78 const typet &subtype = array_type.element_type();
84 op.reserve(width/sub_width);
86 for(std::size_t new_offset=0;
88 new_offset+=sub_width)
92 from_integer(new_offset / sub_width, array_type.index_type())};
93 op.push_back(
bv_get_rec(index, bv, offset + new_offset, subtype));
105 else if(type.
id()==ID_struct_tag)
109 result.
type() = type;
112 else if(type.
id()==ID_union_tag)
116 result.
type() = type;
119 else if(type.
id()==ID_struct)
123 std::size_t new_offset=0;
125 op.reserve(components.size());
127 for(
const auto &c : components)
129 const typet &subtype = c.type();
132 op.push_back(
bv_get_rec(member, bv, offset + new_offset, subtype));
136 new_offset+=sub_width;
141 else if(type.
id()==ID_union)
146 if(components.empty())
150 std::size_t component_nr=0;
152 const typet &subtype = components[component_nr].type();
155 expr, components[component_nr].get_name(), subtype};
157 components[component_nr].get_name(),
161 else if(type.
id()==ID_vector)
164 const typet &element_type = vector_type.element_type();
167 if(element_width != 0 && width % element_width == 0)
169 std::size_t size = width / element_width;
173 for(std::size_t i=0; i<size; i++)
178 bv_get_rec(index, bv, i * element_width, element_type));
181 return std::move(value);
184 else if(type.
id()==ID_complex)
189 if(sub_width!=0 && width==sub_width*2)
204 for(std::size_t bit_nr=offset; bit_nr<offset+width; bit_nr++)
221 case bvtypet::IS_UNKNOWN:
223 if(type.
id()==ID_string)
234 else if(type.
id() == ID_empty)
240 case bvtypet::IS_RANGE:
249 case bvtypet::IS_C_BIT_FIELD:
250 case bvtypet::IS_VERILOG_UNSIGNED:
251 case bvtypet::IS_VERILOG_SIGNED:
252 case bvtypet::IS_C_BOOL:
253 case bvtypet::IS_FIXED:
254 case bvtypet::IS_FLOAT:
255 case bvtypet::IS_UNSIGNED:
256 case bvtypet::IS_SIGNED:
258 case bvtypet::IS_C_ENUM:
261 width, [&value](
size_t i) {
return value[value.size() - i - 1] ==
'1'; });
276 if(expr.
type().
id()==ID_bool)
280 bv_cachet::const_iterator it=
bv_cache.find(expr);
299 const auto size_opt = numeric_cast<mp_integer>(size);
300 if(size_opt.has_value() && *size_opt >= 0)
301 size_mpint = *size_opt;
306 typedef std::map<mp_integer, exprt> valuest;
310 if(opt_num.has_value())
316 index_mapt::const_iterator it=
index_map.find(number);
320 for(index_sett::const_iterator it1=
322 it1!=index_set.end();
332 const auto index_mpint = numeric_cast<mp_integer>(index_value);
334 if(index_mpint.has_value())
337 values[*index_mpint] =
340 values[*index_mpint] = value;
348 if(values.size() != size_mpint)
352 result.
operands().reserve(values.size()*2);
354 for(valuest::const_iterator it=values.begin();
365 result=
exprt(ID_array, type);
368 std::size_t size_int = numeric_cast_v<std::size_t>(size_mpint);
373 for(valuest::iterator it=values.begin();
376 if(it->first>=0 && it->first<size_mpint)
377 result.
operands()[numeric_cast_v<std::size_t>(it->first)].swap(
392 for(std::size_t bit_nr=offset; bit_nr<offset+width; bit_nr++)
394 assert(bit_nr<bv.size());
400 default: assert(
false);
bvtypet get_bvtype(const typet &type)
const union_typet & to_union_type(const typet &type)
Cast a typet to a union_typet.
const union_tag_typet & to_union_tag_type(const typet &type)
Cast a typet to a union_tag_typet.
Array constructor from list of elements.
Array constructor from a list of index-element pairs Operands are index/value pairs,...
const exprt & size() const
union_find< exprt, irep_hash > arrays
std::set< exprt > index_sett
optionalt< std::reference_wrapper< const map_entryt > > get_map_entry(const irep_idt &identifier) const
bool is_unbounded_array(const typet &type) const override
exprt bv_get(const bvt &bv, const typet &type) const
numberingt< irep_idt > string_numbering
virtual exprt bv_get_unbounded_array(const exprt &) const
exprt get(const exprt &expr) const override
Return expr with variables replaced by values from satisfying assignment if available.
exprt bv_get_cache(const exprt &expr) const
virtual std::size_t boolbv_width(const typet &type) const
virtual exprt bv_get_rec(const exprt &expr, const bvt &bv, std::size_t offset, const typet &type) const
mp_integer get_value(const bvt &bv)
Complex constructor from a pair of numbers.
Imaginary part of the expression describing a complex number.
Real part of the expression describing a complex number.
A constant literal expression.
virtual exprt get(const exprt &expr) const =0
Return expr with variables replaced by values from satisfying assignment if available.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Union constructor to support unions without any member (a GCC/Clang feature).
Base class for all expressions.
std::vector< exprt > operandst
void copy_to_operands(const exprt &expr)
Copy the given argument to the end of exprt's operands.
void reserve_operands(operandst::size_type n)
typet & type()
Return the type of the expression.
The Boolean constant false.
const irep_idt & get(const irep_idt &name) const
const irep_idt & id() const
const std::string & get_string(const irep_idt &name) const
Extract member of struct or union.
const union_typet & follow_tag(const union_tag_typet &) const
Follow type tag of union type.
virtual tvt l_get(literalt a) const =0
Struct constructor from list of elements.
Structure type, corresponds to C style structs.
const componentst & components() const
std::vector< componentt > componentst
The Boolean constant true.
tv_enumt get_value() const
const typet & subtype() const
The type of an expression, extends irept.
Union constructor from single element.
size_type find_number(const_iterator it) const
optionalt< number_type > get_number(const T &a) const
Vector constructor from list of elements.
std::vector< literalt > bvt
const mp_integer binary2integer(const std::string &n, bool is_signed)
convert binary string representation to mp_integer
const mp_integer string2integer(const std::string &n, unsigned base)
const std::string integer2string(const mp_integer &n, unsigned base)
exprt simplify_expr(exprt src, const namespacet &ns)
#define CHECK_RETURN(CONDITION)
#define UNREACHABLE
This should be used to mark dead code.
#define PRECONDITION(CONDITION)
API to expression classes.
const vector_typet & to_vector_type(const typet &type)
Cast a typet to a vector_typet.
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
const struct_tag_typet & to_struct_tag_type(const typet &type)
Cast a typet to a struct_tag_typet.
const complex_typet & to_complex_type(const typet &type)
Cast a typet to a complex_typet.
const array_typet & to_array_type(const typet &type)
Cast a typet to an array_typet.