25 throw "update takes at three operands";
35 throw "update: unexpected operand 0 width";
49 const exprt &new_value,
52 if(type.
id()==ID_symbol)
54 designators, d,
ns.
follow(type), offset, new_value, bv);
56 if(d>=designators.size())
62 if(new_value_width!=new_value_bv.size())
63 throw "convert_update_rec: unexpected new_value size";
66 for(std::size_t i=0; i<new_value_width; i++)
68 assert(offset+i<bv.size());
69 bv[offset+i]=new_value_bv[i];
75 const exprt &designator=designators[d];
77 if(designator.
id()==ID_index_designator)
79 if(type.
id()!=ID_array)
80 throw "update: index designator needs array";
83 throw "update: index designator takes one operand";
96 throw "update: failed to get array size";
102 std::size_t new_offset=offset+i*element_size;
105 designators, d+1, subtype, new_offset, new_value, tmp_bv);
110 for(std::size_t j=0; j<element_size; j++)
112 std::size_t idx=new_offset+j;
113 assert(idx<bv.size());
118 else if(designator.
id()==ID_member_designator)
120 const irep_idt &component_name=designator.
get(ID_component_name);
122 if(type.
id()==ID_struct)
127 std::size_t struct_offset=0;
135 for(struct_typet::componentst::const_iterator
136 it=components.begin();
137 it!=components.end();
140 const typet &subtype=it->type();
143 if(it->get_name()==component_name)
149 struct_offset+=sub_width;
153 throw "update: failed to find struct component";
157 std::size_t new_offset=offset+struct_offset;
161 designators, d+1, new_type, new_offset, new_value, bv);
163 else if(type.
id()==ID_union)
172 throw "update: failed to find union component";
180 designators, d+1, new_type, offset, new_value, bv);
183 throw "update: member designator needs struct or union";
186 throw "update: unexpected designator";
The type of an expression.
const typet & follow(const typet &src) const
literalt equal(const bvt &op0, const bvt &op1)
Bit-blasting ID_equal and use in other encodings.
const union_typet & to_union_type(const typet &type)
Cast a generic typet to a union_typet.
boolbv_widtht boolbv_width
std::vector< componentt > componentst
const componentst & components() const
virtual bvt convert_update(const exprt &expr)
const irep_idt & id() const
const array_typet & to_array_type(const typet &type)
Cast a generic typet to an array_typet.
virtual const bvt & convert_bv(const exprt &expr)
API to expression classes.
void conversion_failed(const exprt &expr, bvt &bv)
const irep_idt & get(const irep_namet &name) const
std::vector< exprt > operandst
const struct_typet & to_struct_type(const typet &type)
Cast a generic typet to a struct_typet.
void convert_update_rec(const exprt::operandst &designator, std::size_t d, const typet &type, std::size_t offset, const exprt &new_value, bvt &bv)
Base class for all expressions.
virtual literalt lselect(literalt a, literalt b, literalt c)=0
std::size_t integer2size_t(const mp_integer &n)
std::vector< literalt > bvt
bvt build_constant(const mp_integer &i, std::size_t width)
const componentt & get_component(const irep_idt &component_name) const