Go to the documentation of this file.
56 bool did_initialize_values =
false;
57 auto struct_type_it = struct_type_def.
components().begin();
59 ++param_it, ++struct_type_it)
62 struct_type_it->get_name(),
64 did_initialize_values =
true;
67 if(did_initialize_values)
81 std::cout <<
"Reading component " << member_expr.get_component_name() <<
'\n';
104 member_expr.
type(), ns,
true,
false);
112 const std::stack<exprt> &stack,
115 bool merging_write)
const
118 std::cout <<
"Writing component " << member_expr.get_component_name() <<
'\n';
124 return std::make_shared<full_struct_abstract_objectt>(
129 std::dynamic_pointer_cast<full_struct_abstract_objectt>(
mutable_clone());
135 auto const old_value =
map.
find(c);
136 if(!old_value.has_value())
139 member_expr.
type(), ns,
true,
false);
141 c, environment.
write(starting_value, value, stack, ns, merging_write));
147 environment.
write(old_value.value(), value, stack, ns, merging_write));
150 result->set_not_top();
151 DATA_INVARIANT(result->verify(),
"Structural invariants maintained");
157 std::cout <<
"Setting component" << std::endl;
161 auto const old_value = result->map.find(c);
167 DATA_INVARIANT(result->verify(),
"Structural invariants maintained");
171 INVARIANT(!result->map.empty(),
"If not top, map cannot be empty");
173 if(!old_value.has_value())
175 DATA_INVARIANT(result->verify(),
"Structural invariants maintained");
183 if(old_value.has_value())
185 result->map.replace(c, value);
189 result->map.insert(c, value);
191 result->set_not_top();
192 INVARIANT(!result->is_bottom(),
"top != bottom");
195 DATA_INVARIANT(result->verify(),
"Structural invariants maintained");
214 for(
const auto &field : type_decl.
components())
216 auto value =
map.
find(field.get_name());
217 if(value.has_value())
223 out <<
'.' << field.get_name() <<
'=';
243 std::dynamic_pointer_cast<const full_struct_abstract_objectt>(other);
260 return std::make_shared<full_struct_abstract_objectt>(*other);
265 std::dynamic_pointer_cast<full_struct_abstract_objectt>(
mutable_clone());
272 return shared_from_this();
276 INVARIANT(!result->is_top(),
"Merge of maps will not generate top");
277 INVARIANT(!result->is_bottom(),
"Merge of maps will not generate bottom");
278 DATA_INVARIANT(result->verify(),
"Structural invariants maintained");
288 std::dynamic_pointer_cast<full_struct_abstract_objectt>(
mutable_clone());
290 bool modified =
false;
293 result->map.get_view(view);
295 for(
auto &item : view)
297 auto newval = visitor.
visit(item.second);
298 if(newval != item.second)
300 result->map.replace(item.first, newval);
311 return shared_from_this();
323 for(
auto const &
object : view)
325 if(visited.find(
object.second) == visited.end())
327 object.second->get_statistics(
statistics, visited, env, ns);
const componentst & components() const
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
sharing_ptrt< class abstract_objectt > abstract_object_pointert
virtual bool is_top() const
Find out if the abstract object is top.
abstract_object_pointert visit_sub_elements(const abstract_object_visitort &visitor) const override
Apply a visitor operation to all sub elements of this abstract_object.
static abstract_object_pointert merge(abstract_object_pointert op1, abstract_object_pointert op2, bool &out_modifications)
Clones the first parameter and merges it with the second.
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
virtual abstract_object_pointert write(const abstract_object_pointert &lhs, const abstract_object_pointert &rhs, std::stack< exprt > remaining_stack, const namespacet &ns, bool merge_write)
Used within assign to do the actual dispatch.
const struct_union_typet & to_struct_union_type(const typet &type)
Cast a typet to a struct_union_typet.
sharing_ptrt< full_struct_abstract_objectt > constant_struct_pointert
The type of an expression, extends irept.
void get_view(V &view) const
Get a view of the elements in the map A view is a list of pairs with the components being const refer...
Base type for structs and unions.
virtual const typet & type() const
Get the real type of the variable this abstract object is representing.
CLONE abstract_object_pointert read_component(const abstract_environmentt &environment, const exprt &expr, const namespacet &ns) const override
A helper function to evaluate the abstract object contained within a struct.
Base class for all expressions.
full_struct_abstract_objectt(const full_struct_abstract_objectt &ao)
Explicit copy-constructor to make it clear that the shared_map used to store the values of fields is ...
abstract_object_pointert merge(abstract_object_pointert other) const override
To merge an abstract object into this abstract object.
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
typet & type()
Return the type of the expression.
An abstraction of a structure that stores one abstract object per field.
std::vector< view_itemt > viewt
View of the key-value pairs in the map.
void statistics(abstract_object_statisticst &statistics, abstract_object_visitedt &visited, const abstract_environmentt &env, const namespacet &ns) const override
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
const exprt & compound() const
static bool merge_shared_maps(const sharing_mapt< keyt, abstract_object_pointert, false, hash > &map1, const sharing_mapt< keyt, abstract_object_pointert, false, hash > &map2, sharing_mapt< keyt, abstract_object_pointert, false, hash > &out_map)
virtual abstract_object_pointert abstract_object_factory(const typet &type, const namespacet &ns, bool top, bool bottom) const
Look at the configuration for the sensitivity and create an appropriate abstract_object.
void output(std::ostream &out, const class ai_baset &ai, const class namespacet &ns) const override
To provide a human readable string to the out representing the current known value about this object.
#define PRECONDITION(CONDITION)
An abstract version of a program environment.
void insert_or_replace(const key_type &k, valueU &&m)
bool empty() const
Check if map is empty.
const irep_idt & id() const
std::set< abstract_object_pointert > abstract_object_visitedt
Pure virtual interface required of a client that can apply a copy-on-write operation to a given abstr...
Extract member of struct or union.
Structure type, corresponds to C style structs.
const typet & follow(const typet &) const
Resolve type symbol to the type it points to.
This is the basic interface of the abstract interpreter with default implementations of the core func...
abstract_object_pointert write_component(abstract_environmentt &environment, const namespacet &ns, const std::stack< exprt > &stack, const exprt &expr, const abstract_object_pointert &value, bool merging_write) const override
A helper function to evaluate writing to a component of a struct.
const member_exprt & to_member_expr(const exprt &expr)
Cast an exprt to a member_exprt.
irep_idt get_component_name() const
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
virtual bool is_bottom() const
Find out if the abstract object is bottom.
abstract_object_pointert merge_constant_structs(constant_struct_pointert other) const
Performs an element wise merge of the map for each struct.
bool verify() const override
Function: full_struct_abstract_objectt::verify.
API to expression classes.
virtual abstract_object_pointert visit(const abstract_object_pointert element) const =0
static memory_sizet from_bytes(std::size_t bytes)
virtual internal_abstract_object_pointert mutable_clone() const
typet t
To enforce copy-on-write these are private and have read-only accessors.
optionalt< std::reference_wrapper< const mapped_type > > find(const key_type &k) const
Find element.