cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
write_stack_entry.cpp
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module: Analyses Variable Sensitivity
4
5
Author: DiffBlue Limited.
6
7
\*******************************************************************/
8
11
12
#include <unordered_set>
13
14
#include "
abstract_environment.h
"
15
#include "
write_stack_entry.h
"
16
22
bool
write_stack_entryt::try_squash_in
(
23
std::shared_ptr<const write_stack_entryt> new_entry,
24
const
abstract_environmentt
&enviroment,
25
const
namespacet
&ns)
26
{
27
return
false
;
28
}
29
32
simple_entryt::simple_entryt
(
exprt
expr) :
simple_entry
(expr)
33
{
34
// Invalid simple expression added to the stack
35
PRECONDITION
(
36
expr.
id
() == ID_member || expr.
id
() == ID_symbol ||
37
expr.
id
() == ID_dynamic_object);
38
}
39
43
std::pair<exprt, bool>
simple_entryt::get_access_expr
()
const
44
{
45
return
{
simple_entry
,
false
};
46
}
47
48
offset_entryt::offset_entryt
(
abstract_object_pointert
offset_value)
49
:
offset
(offset_value)
50
{
51
// The type of the abstract object should be an integral number
52
static
const
std::unordered_set<irep_idt, irep_id_hash> integral_types = {
53
ID_signedbv, ID_unsignedbv, ID_integer};
54
PRECONDITION
(
55
integral_types.find(offset_value->type().id()) != integral_types.cend());
56
}
57
61
std::pair<exprt, bool>
offset_entryt::get_access_expr
()
const
62
{
63
return
{
offset
->to_constant(),
true
};
64
}
65
73
bool
offset_entryt::try_squash_in
(
74
std::shared_ptr<const write_stack_entryt> new_entry,
75
const
abstract_environmentt
&enviroment,
76
const
namespacet
&ns)
77
{
78
std::shared_ptr<const offset_entryt> cast_entry =
79
std::dynamic_pointer_cast<const offset_entryt>(new_entry);
80
if
(cast_entry)
81
{
82
plus_exprt
result_offset(
83
cast_entry->offset->to_constant(),
offset
->to_constant());
84
offset
= enviroment.
eval
(result_offset, ns);
85
return
true
;
86
}
87
return
false
;
88
}
abstract_environment.h
An abstract version of a program environment.
abstract_object_pointert
sharing_ptrt< class abstract_objectt > abstract_object_pointert
Definition
abstract_object.h:69
abstract_environmentt
Definition
abstract_environment.h:39
abstract_environmentt::eval
virtual abstract_object_pointert eval(const exprt &expr, const namespacet &ns) const
These three are really the heart of the method.
Definition
abstract_environment.cpp:101
exprt
Base class for all expressions.
Definition
expr.h:57
irept::id
const irep_idt & id() const
Definition
irep.h:388
namespacet
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition
namespace.h:91
offset_entryt::offset_entryt
offset_entryt(abstract_object_pointert offset_value)
Definition
write_stack_entry.cpp:48
offset_entryt::get_access_expr
std::pair< exprt, bool > get_access_expr() const override
Get the expression part needed to read this stack entry.
Definition
write_stack_entry.cpp:61
offset_entryt::try_squash_in
bool try_squash_in(std::shared_ptr< const write_stack_entryt > new_entry, const abstract_environmentt &enviroment, const namespacet &ns) override
Try to combine a new stack element with the current top of the stack.
Definition
write_stack_entry.cpp:73
offset_entryt::offset
abstract_object_pointert offset
Definition
write_stack_entry.h:52
plus_exprt
The plus expression Associativity is not specified.
Definition
std_expr.h:996
simple_entryt::get_access_expr
std::pair< exprt, bool > get_access_expr() const override
Get the expression part needed to read this stack entry.
Definition
write_stack_entry.cpp:43
simple_entryt::simple_entryt
simple_entryt(exprt expr)
Build a simple entry based off a single expression.
Definition
write_stack_entry.cpp:32
simple_entryt::simple_entry
exprt simple_entry
Definition
write_stack_entry.h:38
write_stack_entryt::try_squash_in
virtual bool try_squash_in(std::shared_ptr< const write_stack_entryt > new_entry, const abstract_environmentt &enviroment, const namespacet &ns)
Try to combine a new stack element with the current top of the stack.
Definition
write_stack_entry.cpp:22
PRECONDITION
#define PRECONDITION(CONDITION)
Definition
invariant.h:463
write_stack_entry.h
Represents an entry in the write_stackt.
analyses
variable-sensitivity
write_stack_entry.cpp
Generated by
1.17.0