27 std::pair<cachet::iterator, bool> cache_result =
30 auto &cache_entry = cache_result.first->second;
32 if(!cache_result.second)
37 if(type_id==ID_struct)
44 entry.
members.resize(components.size());
46 for(std::size_t i=0; i<entry.members.size(); i++)
49 if(!sub_width.has_value())
51 entry.members[i].offset=offset;
52 entry.members[i].width = *sub_width;
56 entry.total_width=offset;
58 cache_entry = std::move(entry);
60 else if(type_id==ID_union)
66 entry.
members.resize(components.size());
68 std::size_t max_width=0;
70 for(std::size_t i=0; i<entry.members.size(); i++)
73 if(!sub_width.has_value())
75 entry.members[i].width = *sub_width;
76 max_width = std::max(max_width, *sub_width);
79 entry.total_width=max_width;
81 cache_entry = std::move(entry);
83 else if(type_id==ID_bool)
87 else if(type_id==ID_c_bool)
91 else if(type_id==ID_signedbv)
95 else if(type_id==ID_unsignedbv)
99 else if(type_id==ID_floatbv)
103 else if(type_id==ID_fixedbv)
107 else if(type_id==ID_bv)
111 else if(type_id==ID_verilog_signedbv ||
112 type_id==ID_verilog_unsignedbv)
117 size > 0,
"verilog bitvector width shall be greater than zero");
120 else if(type_id==ID_range)
134 else if(type_id==ID_array)
138 if(!sub_width.has_value())
141 const auto array_size = numeric_cast<mp_integer>(array_type.
size());
143 if(!array_size.has_value() || *array_size < 0)
147 if(total > (1 << 30))
152 else if(type_id==ID_complex)
155 if(!sub_width.has_value())
160 else if(type_id==ID_code)
164 else if(type_id==ID_enumeration)
173 else if(type_id==ID_c_enum)
180 else if(type_id==ID_pointer)
183 defined_entryt{type_checked_cast<pointer_typet>(type).get_width()};
185 else if(type_id==ID_struct_tag)
189 else if(type_id==ID_union_tag)
193 else if(type_id==ID_c_enum_tag)
197 else if(type_id==ID_c_bit_field)
201 else if(type_id==ID_string)
205 else if(type_id == ID_empty)
212 "boolbv_widtht::get_entry(" +
id2string(type_id) +
")");
225 PRECONDITION(entry_opt->members.size() > component_number);
227 return entry_opt->members[component_number];
const floatbv_typet & to_floatbv_type(const typet &type)
Cast a typet to a floatbv_typet.
const signedbv_typet & to_signedbv_type(const typet &type)
Cast a typet to a signedbv_typet.
const bitvector_typet & to_bitvector_type(const typet &type)
Cast a typet to a bitvector_typet.
const fixedbv_typet & to_fixedbv_type(const typet &type)
Cast a typet to a fixedbv_typet.
const unsignedbv_typet & to_unsignedbv_type(const typet &type)
Cast a typet to an unsignedbv_typet.
const bv_typet & to_bv_type(const typet &type)
Cast a typet to a bv_typet.
const c_enum_typet & to_c_enum_type(const typet &type)
Cast a typet to a c_enum_typet.
const union_tag_typet & to_union_tag_type(const typet &type)
Cast a typet to a union_tag_typet.
const c_bit_field_typet & to_c_bit_field_type(const typet &type)
Cast a typet to a c_bit_field_typet.
const union_typet & to_union_type(const typet &type)
Cast a typet to a union_typet.
const c_enum_tag_typet & to_c_enum_tag_type(const typet &type)
Cast a typet to a c_enum_tag_typet.
const c_bool_typet & to_c_bool_type(const typet &type)
Cast a typet to a c_bool_typet.
Thrown when an unexpected error occurs during the analysis (e.g., when the SAT solver returns an erro...
const typet & element_type() const
The type of the elements of the array.
const exprt & size() const
std::size_t get_width() const
virtual std::optional< std::size_t > get_width_opt(const typet &type) const
boolbv_widtht(const namespacet &_ns)
const entryt & get_entry(const typet &type) const
std::optional< defined_entryt > entryt
const membert & get_member(const struct_typet &type, const irep_idt &member) const
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
const irept::subt & elements() const
const irep_idt & id() const
const std::string & get_string(const irep_idt &name) const
const union_typet & follow_tag(const union_tag_typet &) const
Follow type tag of union type.
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Structure type, corresponds to C style structs.
const componentst & components() const
std::size_t component_number(const irep_idt &component_name) const
Return the sequence number of the component with given name.
std::vector< componentt > componentst
The type of an expression, extends irept.
const std::string & id2string(const irep_idt &d)
const mp_integer string2integer(const std::string &n, unsigned base)
#define UNIMPLEMENTED_FEATURE(FEATURE)
#define CHECK_RETURN(CONDITION)
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
#define PRECONDITION(CONDITION)
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 complex_typet & to_complex_type(const typet &type)
Cast a typet to a complex_typet.
const struct_tag_typet & to_struct_tag_type(const typet &type)
Cast a typet to a struct_tag_typet.
const enumeration_typet & to_enumeration_type(const typet &type)
Cast a typet to a enumeration_typet.
std::vector< membert > members