Go to the documentation of this file.
35 op_type.
id()==ID_struct)
39 while(new_operands.size() > 1)
41 exprt &op1 = new_operands[new_operands.size() - 2];
42 exprt &op2 = new_operands[new_operands.size() - 1];
44 if(op1.
get(ID_component_name)==component_name)
49 "member expression type must match component type");
54 new_operands.resize(new_operands.size() - 2);
57 DATA_INVARIANT(new_operands.size() == 1,
"post-condition of loop");
59 auto new_member_expr = expr;
60 new_member_expr.
struct_op() = new_operands.front();
64 else if(op_type.
id()==ID_union)
68 if(with_expr.
where().
get(ID_component_name)==component_name)
75 else if(op.
id()==ID_update)
78 op_type.
id()==ID_struct)
84 if(designator.size()==1 &&
85 designator.front().id()==ID_member_designator)
87 if(designator.front().get(ID_component_name)==component_name)
94 else if(op_type.
id()==ID_struct)
106 else if(op.
id()==ID_struct ||
107 op.
id()==ID_constant)
109 if(op_type.
id()==ID_struct)
118 "member expression type must match component type");
123 else if(op.
id()==ID_byte_extract_little_endian ||
124 op.
id()==ID_byte_extract_big_endian)
128 if(op_type.
id()==ID_struct)
146 if(!offset_int.has_value())
149 const exprt &struct_offset = byte_extract_expr.offset();
155 op.
id(), byte_extract_expr.op(), final_offset, expr.
type());
159 else if(op_type.
id() == ID_union)
163 if(byte_extract_expr.offset().is_zero())
168 if(subtype == byte_extract_expr.op().type())
169 return byte_extract_expr.op();
173 else if(op.
id()==ID_union && op_type.
id()==ID_union)
182 if(target_size.has_value())
184 mp_integer target_bits = target_size.value() * 8;
187 if(bits.has_value() &&
190 std::string bits_cut =
191 std::string(*bits, 0, numeric_cast_v<std::size_t>(target_bits));
196 return std::move(*tmp);
200 else if(op.
id() == ID_typecast)
206 if(op_type == typecast_expr.op().type())
208 auto new_expr = expr;
209 new_expr.
struct_op() = typecast_expr.op();
217 if(op_type.
id() == ID_struct)
221 if(requested_offset.has_value())
224 typecast_expr.op(), *requested_offset, expr.
type(),
ns);
229 equivalent_member.has_value() &&
230 equivalent_member.value().id() != ID_byte_extract_little_endian &&
231 equivalent_member.value().id() != ID_byte_extract_big_endian)
233 auto tmp = equivalent_member.value();
239 else if(op.
id()==ID_if)
250 auto tmp =
if_exprt(cond, member_true, member_false, expr.
type());
253 else if(op.
id() == ID_let)
Operator to update elements in structs and arrays.
resultt simplify_rec(const exprt &)
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
const union_typet & to_union_type(const typet &type)
Cast a typet to a union_typet.
const update_exprt & to_update_expr(const exprt &expr)
Cast an exprt to an update_exprt.
const componentt & get_component(const irep_idt &component_name) const
Get the reference to a component with given name.
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
The type of an expression, extends irept.
const byte_extract_exprt & to_byte_extract_expr(const exprt &expr)
const if_exprt & to_if_expr(const exprt &expr)
Cast an exprt to an if_exprt.
optionalt< exprt > bits2expr(const std::string &bits, const typet &type, bool little_endian, const namespacet &ns)
The trinary if-then-else operator.
The plus expression Associativity is not specified.
const typet & component_type(const irep_idt &component_name) const
Base class for all expressions.
const union_exprt & to_union_expr(const exprt &expr)
Cast an exprt to a union_exprt.
auto component(T &struct_expr, const irep_idt &name, const namespacet &ns) -> decltype(struct_expr.op0())
resultt simplify_plus(const plus_exprt &)
std::size_t component_number(const irep_idt &component_name) const
Return the sequence number of the component with given name.
resultt simplify_byte_extract(const byte_extract_exprt &)
static resultt unchanged(exprt expr)
const irep_idt & get(const irep_idt &name) const
typet & type()
Return the type of the expression.
Expression classes for byte-level operators.
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
const exprt & compound() const
const exprt & struct_op() const
static resultt changed(resultt<> result)
const let_exprt & to_let_expr(const exprt &expr)
Cast an exprt to a let_exprt.
bool has_component(const irep_idt &component_name) const
const irep_idt & id() const
std::vector< exprt > operandst
nonstd::optional< T > optionalt
const with_exprt & to_with_expr(const exprt &expr)
Cast an exprt to a with_exprt.
Operator to update elements in structs and arrays.
exprt::operandst & designator()
optionalt< std::string > expr2bits(const exprt &expr, bool little_endian, const namespacet &ns)
Extract member of struct or union.
resultt simplify_member(const member_exprt &)
Structure type, corresponds to C style structs.
optionalt< mp_integer > pointer_offset_size(const typet &type, const namespacet &ns)
Compute the size of a type in bytes, rounding up to full bytes.
const typet & follow(const typet &) const
Resolve type symbol to the type it points to.
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast an exprt to a typecast_exprt.
optionalt< exprt > get_subexpression_at_offset(const exprt &expr, const mp_integer &offset_bytes, const typet &target_type_raw, const namespacet &ns)
const member_exprt & to_member_expr(const exprt &expr)
Cast an exprt to a member_exprt.
irep_idt get_component_name() const
exprt & where()
convenience accessor for binding().where()
optionalt< mp_integer > member_offset(const struct_typet &type, const irep_idt &member, const namespacet &ns)