24 error() <<
"with takes at least three operands" <<
eom;
31 error() <<
"with takes an odd number of operands" <<
eom;
51 error() <<
"unexpected operand 0 width" <<
eom;
56 prev_bv.resize(width);
60 for(std::size_t op_no=1; op_no<ops.size(); op_no+=2)
84 next_bv.resize(prev_bv.size());
86 if(type.
id()==ID_array)
88 else if(type.
id()==ID_bv ||
89 type.
id()==ID_unsignedbv ||
90 type.
id()==ID_signedbv)
92 else if(type.
id()==ID_struct)
95 else if(type.
id()==ID_union)
97 else if(type.
id()==ID_symbol)
101 error() <<
"unexpected with type: " << type.
id();
116 error() <<
"convert_with_array called for unbounded array" <<
eom;
127 error() <<
"convert_with_array expects constant array size" <<
eom;
133 if(size*op2_bv.size()!=prev_bv.size())
136 error() <<
"convert_with_array: unexpected operand 2 width" <<
eom;
147 if(op1_value>=0 && op1_value<size)
151 for(std::size_t j=0; j<op2_bv.size(); j++)
152 next_bv[offset+j]=op2_bv[j];
168 for(std::size_t j=0; j<op2_bv.size(); j++)
170 prop.
lselect(eq_lit, op2_bv[j], prev_bv[offset+j]);
188 if(op1_value<next_bv.size())
196 for(std::size_t i=0; i<prev_bv.size(); i++)
217 const irep_idt &component_name=op1.
get(ID_component_name);
221 std::size_t offset=0;
223 for(struct_typet::componentst::const_iterator
224 it=components.begin();
225 it!=components.end();
228 const typet &subtype=it->type();
232 if(it->get_name()==component_name)
237 error() <<
"with/struct: component `" << component_name
238 <<
"' type does not match: " 239 << subtype.
pretty() <<
" vs. " 244 if(sub_width!=op2_bv.size())
247 error() <<
"convert_with_struct: unexpected operand op2 width" 252 for(std::size_t i=0; i<sub_width; i++)
253 next_bv[offset+i]=op2_bv[i];
273 if(next_bv.size()<op2_bv.size())
276 error() <<
"convert_with_union: unexpected operand op2 width" <<
eom;
282 for(std::size_t i=0; i<op2_bv.size(); i++)
283 next_bv[i]=op2_bv[i];
293 for(std::size_t i=0; i<op2_bv.size(); i++)
294 next_bv[map_u.
map_bit(i)]=op2_bv[map_op2.map_bit(i)];
The type of an expression.
struct configt::ansi_ct ansi_c
virtual bvt convert_with(const exprt &expr)
literalt convert(const exprt &expr) override
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
void convert_with_array(const array_typet &type, const exprt &op1, const exprt &op2, const bvt &prev_bv, bvt &next_bv)
bool base_type_eq(const typet &type1, const typet &type2, const namespacet &ns)
boolbv_widtht boolbv_width
bool is_unbounded_array(const typet &type) const override
std::vector< componentt > componentst
const componentst & components() const
static mstreamt & eom(mstreamt &m)
const irep_idt & id() const
void convert_with_union(const union_typet &type, const exprt &op1, const exprt &op2, const bvt &prev_bv, bvt &next_bv)
virtual const bvt & convert_bv(const exprt &expr)
const source_locationt & find_source_location() const
source_locationt source_location
API to expression classes.
void conversion_failed(const exprt &expr, bvt &bv)
const irep_idt & get(const irep_namet &name) const
const exprt & size() const
const typet & follow(const typet &) const
const struct_typet & to_struct_type(const typet &type)
Cast a generic typet to a struct_typet.
Map bytes according to the configured endianness.
std::vector< exprt > operandst
const source_locationt & source_location() const
void convert_with_struct(const struct_typet &type, const exprt &op1, const exprt &op2, const bvt &prev_bv, bvt &next_bv)
unsigned integer2unsigned(const mp_integer &n)
void convert_with_bv(const typet &type, const exprt &op1, const exprt &op2, const bvt &prev_bv, bvt &next_bv)
const array_typet & to_array_type(const typet &type)
Cast a generic typet to an array_typet.
Base class for all expressions.
const union_typet & to_union_type(const typet &type)
Cast a generic typet to a union_typet.
size_t map_bit(size_t bit) const
virtual literalt lselect(literalt a, literalt b, literalt c)=0
std::size_t integer2size_t(const mp_integer &n)
const typet & subtype() const
std::vector< literalt > bvt