32 if(pointer.
type().
id()!=ID_pointer)
33 throw "dereference expected pointer type, but got "+
40 std::cout <<
"DEREF: " <<
from_expr(
ns,
"", pointer) <<
'\n';
76 if(
object.
id()==ID_index)
86 throw "dereference failed to get object size for index";
95 else if(
object.
id()==ID_member)
99 const typet &compound_type=
102 if(compound_type.
id()==ID_struct)
111 throw "dereference failed to get member offset";
119 else if(compound_type.
id()==ID_union)
128 if(object_type.
id()==ID_array &&
138 !
to_integer(simplified_offset, offset_constant) &&
139 (offset_constant%size_constant)==0)
142 mp_integer index_constant=offset_constant/size_constant;
154 const exprt &address,
158 if(address.
id()==ID_address_of)
166 else if(address.
id()==ID_typecast)
172 else if(address.
id()==ID_plus)
176 throw "plus with less than two operands";
180 else if(address.
id()==ID_if)
186 else if(address.
id()==ID_constant)
199 throw "dereferencet: unexpected pointer constant "+address.
pretty();
203 throw "failed to dereference `"+address.
id_string()+
"'";
230 assert(expr.
op0().
type().
id()==ID_pointer);
238 std::swap(pointer, integer);
243 throw "dereference failed to get object size for pointer arithmetic";
263 if(op_type.
id()==ID_pointer)
265 else if(op_type.
id()==ID_signedbv || op_type.
id()==ID_unsignedbv)
283 throw "dereferencet: unexpected cast";
287 const typet &object_type,
288 const typet &dereference_type)
const 290 if(dereference_type.
id()==ID_empty)
298 if(object_type.
id()==ID_struct &&
299 dereference_type.
id()==ID_struct)
307 if(dereference_type.
id()==ID_code &&
308 object_type.
id()==ID_code)
312 if((object_type.
id()==ID_signedbv || object_type.
id()==ID_unsignedbv) &&
313 (dereference_type.
id()==ID_signedbv ||
314 dereference_type.
id()==ID_unsignedbv))
316 return object_type.
get(ID_width)==dereference_type.
get(ID_width);
321 if(object_type.
id()==ID_pointer &&
322 dereference_type.
id()==ID_pointer)
The type of an expression.
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast a generic exprt to a typecast_exprt.
exprt size_of_expr(const typet &type, const namespacet &ns)
const typet & follow(const typet &src) const
exprt member_offset_expr(const member_exprt &member_expr, const namespacet &ns)
pointer_typet pointer_type(const typet &subtype)
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
exprt simplify_expr(const exprt &src, const namespacet &ns)
exprt dereference_rec(const exprt &address, const exprt &offset, const typet &type)
bool base_type_eq(const typet &type1, const typet &type2, const namespacet &ns)
mp_integer member_offset(const struct_typet &type, const irep_idt &member, const namespacet &ns)
std::string from_expr(const namespacet &ns, const irep_idt &identifier, const exprt &expr)
exprt dereference_if(const if_exprt &expr, const exprt &offset, const typet &type)
const member_exprt & to_member_expr(const exprt &expr)
Cast a generic exprt to a member_exprt.
const irep_idt & get_value() const
The trinary if-then-else operator.
exprt dereference_typecast(const typecast_exprt &expr, const exprt &offset, const typet &type)
Extract member of struct or union.
const index_exprt & to_index_expr(const exprt &expr)
Cast a generic exprt to an index_exprt.
const irep_idt & id() const
const address_of_exprt & to_address_of_expr(const exprt &expr)
Cast a generic exprt to an address_of_exprt.
Expression classes for byte-level operators.
bool type_compatible(const typet &object_type, const typet &dereference_type) const
A generic base class for binary expressions.
const if_exprt & to_if_expr(const exprt &expr)
Cast a generic exprt to an if_exprt.
Operator to dereference a pointer.
API to expression classes.
const irep_idt & get(const irep_namet &name) const
irep_idt byte_extract_id()
bitvector_typet index_type()
Operator to return the address of an object.
std::vector< exprt > operandst
const struct_typet & to_struct_type(const typet &type)
Cast a generic typet to a struct_typet.
bool is_prefix_of(const struct_typet &other) const
Base class for all expressions.
const exprt & struct_op() const
exprt dereference_plus(const exprt &expr, const exprt &offset, const typet &type)
irep_idt get_component_name() const
const std::string & id_string() const
const constant_exprt & to_constant_expr(const exprt &expr)
Cast a generic exprt to a constant_exprt.
const typet & subtype() const
exprt operator()(const exprt &pointer)
void make_typecast(const typet &_type)
exprt read_object(const exprt &object, const exprt &offset, const typet &type)