37 (op.
type().
id() == ID_struct || op.
type().
id() == ID_struct_tag))
41 while(new_operands.size() > 1)
43 exprt &op1 = new_operands[new_operands.size() - 2];
44 exprt &op2 = new_operands[new_operands.size() - 1];
46 if(op1.
get(ID_component_name)==component_name)
51 "member expression type must match component type");
56 new_operands.resize(new_operands.size() - 2);
59 DATA_INVARIANT(new_operands.size() == 1,
"post-condition of loop");
61 auto new_member_expr = expr;
62 new_member_expr.
struct_op() = new_operands.front();
66 else if(op.
type().
id() == ID_union || op.
type().
id() == ID_union_tag)
70 if(with_expr.
where().
get(ID_component_name)==component_name)
77 else if(op.
id()==ID_update)
81 (op.
type().
id() == ID_struct || op.
type().
id() == ID_struct_tag))
87 if(designator.size()==1 &&
88 designator.front().id()==ID_member_designator)
90 if(designator.front().get(ID_component_name)==component_name)
97 else if(op.
type().
id() == ID_struct || op.
type().
id() == ID_struct_tag)
100 auto new_expr = expr;
109 else if(op.
id() == ID_struct)
113 op.
type().
id() == ID_struct_tag
121 "struct expression must have sufficiently many operands");
124 "member expression type must match component type");
128 else if(op.
id()==ID_byte_extract_little_endian ||
129 op.
id()==ID_byte_extract_big_endian)
133 if(op.
type().
id() == ID_struct || op.
type().
id() == ID_struct_tag)
139 op.
type().
id() == ID_struct_tag
154 if(!offset_int.has_value())
157 const exprt &struct_offset = byte_extract_expr.offset();
164 byte_extract_expr.op(),
166 byte_extract_expr.get_bits_per_byte(),
171 else if(op.
type().
id() == ID_union || op.
type().
id() == ID_union_tag)
175 if(byte_extract_expr.offset().is_zero())
178 op.
type().
id() == ID_union_tag
183 if(subtype == byte_extract_expr.op().type())
184 return byte_extract_expr.op();
189 op.
id() == ID_union &&
190 (op.
type().
id() == ID_union || op.
type().
id() == ID_union_tag))
199 if(target_size.has_value())
204 if(bits.has_value() &&
207 std::string bits_cut =
208 std::string(*bits, 0, numeric_cast_v<std::size_t>(target_bits));
213 return std::move(*tmp);
217 else if(op.
id() == ID_typecast)
223 if(op.
type() == typecast_expr.op().type())
225 auto new_expr = expr;
226 new_expr.
struct_op() = typecast_expr.op();
234 if(op.
type().
id() == ID_struct || op.
type().
id() == ID_struct_tag)
237 op.
type().
id() == ID_struct_tag
240 std::optional<mp_integer> requested_offset =
242 if(requested_offset.has_value())
245 typecast_expr.op(), *requested_offset, expr.
type(),
ns);
250 equivalent_member.has_value() &&
251 equivalent_member.value().id() != ID_byte_extract_little_endian &&
252 equivalent_member.value().id() != ID_byte_extract_big_endian)
254 auto tmp = equivalent_member.value();
260 else if(op.
id() == ID_let)
283 if(compound.
id() == ID_if)
291 if(r_it.has_changed())
Expression classes for byte-level operators.
const byte_extract_exprt & to_byte_extract_expr(const exprt &expr)
const union_tag_typet & to_union_tag_type(const typet &type)
Cast a typet to a union_tag_typet.
const union_typet & to_union_type(const typet &type)
Cast a typet to a union_typet.
struct configt::ansi_ct ansi_c
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Base class for all expressions.
std::vector< exprt > operandst
typet & type()
Return the type of the expression.
The trinary if-then-else operator.
const irep_idt & get(const irep_idt &name) const
const irep_idt & id() const
exprt & where()
convenience accessor for binding().where()
Extract member of struct or union.
const exprt & compound() const
const exprt & struct_op() const
irep_idt get_component_name() const
const union_typet & follow_tag(const union_tag_typet &) const
Follow type tag of union type.
The plus expression Associativity is not specified.
resultt simplify_byte_extract(const byte_extract_exprt &)
resultt simplify_member_preorder(const member_exprt &)
static resultt changed(resultt<> result)
resultt simplify_rec(const exprt &)
resultt simplify_member(const member_exprt &)
static resultt unchanged(exprt expr)
resultt simplify_plus(const plus_exprt &)
resultt simplify_if_preorder(const if_exprt &expr)
Structure type, corresponds to C style structs.
const typet & component_type(const irep_idt &component_name) const
const componentt & get_component(const irep_idt &component_name) const
Get the reference to a component with given name.
bool has_component(const irep_idt &component_name) const
std::size_t component_number(const irep_idt &component_name) const
Return the sequence number of the component with given name.
The type of an expression, extends irept.
Operator to update elements in structs and arrays.
exprt::operandst & designator()
Operator to update elements in structs and arrays.
if_exprt lift_if(const exprt &src, std::size_t operand_number)
lift up an if_exprt one level
Deprecated expression utility functions.
std::optional< mp_integer > member_offset(const struct_typet &type, const irep_idt &member, const namespacet &ns)
std::optional< exprt > get_subexpression_at_offset(const exprt &expr, const mp_integer &offset_bytes, const typet &target_type_raw, const namespacet &ns)
std::optional< mp_integer > pointer_offset_size(const typet &type, const namespacet &ns)
Compute the size of a type in bytes, rounding up to full bytes.
std::optional< std::string > expr2bits(const exprt &expr, bool little_endian, const namespacet &ns)
std::optional< exprt > bits2expr(const std::string &bits, const typet &type, bool little_endian, const namespacet &ns)
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
auto component(T &struct_expr, const irep_idt &name, const namespacet &ns) -> decltype(struct_expr.op0())
API to expression classes.
const update_exprt & to_update_expr(const exprt &expr)
Cast an exprt to an update_exprt.
const let_exprt & to_let_expr(const exprt &expr)
Cast an exprt to a let_exprt.
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast an exprt to a typecast_exprt.
const union_exprt & to_union_expr(const exprt &expr)
Cast an exprt to a union_exprt.
const with_exprt & to_with_expr(const exprt &expr)
Cast an exprt to a with_exprt.
const member_exprt & to_member_expr(const exprt &expr)
Cast an exprt to a member_exprt.
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.