cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
symbol.h
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module:
4
5
Author: Daniel Kroening, kroening@kroening.com
6
7
\*******************************************************************/
8
9
10
#ifndef CPROVER_UTIL_SYMBOL_H
11
#define CPROVER_UTIL_SYMBOL_H
12
17
18
#include <iosfwd>
19
20
#include "
expr.h
"
21
#include "
invariant.h
"
22
27
class
symbolt
28
{
29
public
:
31
typet
type
;
32
34
exprt
value
;
35
37
source_locationt
location
;
38
40
irep_idt
name
;
41
43
irep_idt
module
;
44
46
irep_idt
base_name
;
47
49
irep_idt
mode
;
50
52
irep_idt
pretty_name
;
53
55
const
irep_idt
&
display_name
()
const
56
{
57
return
pretty_name
.empty()?
name
:
pretty_name
;
58
}
59
60
// global use
61
bool
is_type
=
false
;
62
bool
is_macro
=
false
;
63
bool
is_exported
=
false
;
64
bool
is_input
=
false
;
65
bool
is_output
=
false
;
66
bool
is_state_var
=
false
;
67
bool
is_property
=
false
;
68
69
// ANSI-C
70
bool
is_static_lifetime
=
false
;
71
bool
is_thread_local
=
false
;
72
bool
is_lvalue
=
false
;
73
bool
is_file_local
=
false
;
74
bool
is_extern
=
false
;
75
bool
is_volatile
=
false
;
76
bool
is_parameter
=
false
;
77
bool
is_auxiliary
=
false
;
78
bool
is_weak
=
false
;
79
80
symbolt
()
81
:
type
(static_cast<const
typet
&>(
get_nil_irep
())),
82
value
(static_cast<const
exprt
&>(
get_nil_irep
())),
83
location
(
source_locationt
::nil())
84
{
85
}
86
87
symbolt
(
const
irep_idt
&_name,
typet
_type,
const
irep_idt
&_mode)
88
:
type
(
std
::move(_type)),
89
value
(static_cast<const
exprt
&>(
get_nil_irep
())),
90
location
(
source_locationt
::nil()),
91
name
(_name),
92
mode
(_mode)
93
{
94
}
95
96
void
swap
(
symbolt
&b);
97
void
show
(std::ostream &out)
const
;
98
99
class
symbol_exprt
symbol_expr
() const;
100
101
bool
is_shared
()
const
102
{
103
return
!
is_thread_local
;
104
}
105
106
bool
is_function
()
const
107
{
108
return
!
is_type
&& !
is_macro
&&
type
.id()==ID_code;
109
}
110
113
bool
is_compiled
()
const
114
{
115
return
type
.id() == ID_code &&
value
==
exprt
(ID_compiled);
116
}
117
120
void
set_compiled
()
121
{
122
PRECONDITION
(
type
.id() == ID_code);
123
value
=
exprt
(ID_compiled);
124
}
125
127
bool
is_well_formed
()
const
;
128
129
bool
operator==
(
const
symbolt
&other)
const
;
130
bool
operator!=
(
const
symbolt
&other)
const
;
131
};
132
133
std::ostream &
operator<<
(std::ostream &out,
const
symbolt
&symbol);
134
138
class
type_symbolt
:
public
symbolt
139
{
140
public
:
141
type_symbolt
(
const
irep_idt
&_name,
typet
_type,
const
irep_idt
&_mode)
142
:
symbolt
(_name, _type, _mode)
143
{
144
is_type
=
true
;
145
}
146
};
147
152
class
auxiliary_symbolt
:
public
symbolt
153
{
154
public
:
155
auxiliary_symbolt
()
156
{
157
is_lvalue
=
true
;
158
is_state_var
=
true
;
159
is_thread_local
=
true
;
160
is_file_local
=
true
;
161
is_auxiliary
=
true
;
162
}
163
164
auxiliary_symbolt
(
const
irep_idt
&
name
,
typet
type
,
const
irep_idt
&
mode
)
165
:
symbolt
(
name
,
type
,
mode
)
166
{
167
is_lvalue
=
true
;
168
is_state_var
=
true
;
169
is_thread_local
=
true
;
170
is_file_local
=
true
;
171
is_auxiliary
=
true
;
172
}
173
};
174
178
class
parameter_symbolt
:
public
symbolt
179
{
180
public
:
181
parameter_symbolt
()
182
{
183
is_lvalue
=
true
;
184
is_state_var
=
true
;
185
is_thread_local
=
true
;
186
is_file_local
=
true
;
187
is_parameter
=
true
;
188
}
189
};
190
191
#endif
// CPROVER_UTIL_SYMBOL_H
auxiliary_symbolt::auxiliary_symbolt
auxiliary_symbolt(const irep_idt &name, typet type, const irep_idt &mode)
Definition
symbol.h:164
auxiliary_symbolt::auxiliary_symbolt
auxiliary_symbolt()
Definition
symbol.h:155
exprt
Base class for all expressions.
Definition
expr.h:57
parameter_symbolt::parameter_symbolt
parameter_symbolt()
Definition
symbol.h:181
source_locationt
Definition
source_location.h:20
symbol_exprt
Expression to hold a symbol (variable).
Definition
std_expr.h:132
symbolt
Symbol table entry.
Definition
symbol.h:28
symbolt::base_name
irep_idt base_name
Base (non-scoped) name.
Definition
symbol.h:46
symbolt::swap
void swap(symbolt &b)
Swap values between two symbols.
Definition
symbol.cpp:85
symbolt::is_auxiliary
bool is_auxiliary
Definition
symbol.h:77
symbolt::is_volatile
bool is_volatile
Definition
symbol.h:75
symbolt::symbolt
symbolt()
Definition
symbol.h:80
symbolt::is_extern
bool is_extern
Definition
symbol.h:74
symbolt::is_macro
bool is_macro
Definition
symbol.h:62
symbolt::operator==
bool operator==(const symbolt &other) const
Definition
symbol.cpp:202
symbolt::show
void show(std::ostream &out) const
Dump the state of a symbol object to a given output stream.
Definition
symbol.cpp:19
symbolt::is_file_local
bool is_file_local
Definition
symbol.h:73
symbolt::is_well_formed
bool is_well_formed() const
Check that a symbol is well formed.
Definition
symbol.cpp:128
symbolt::module
irep_idt module
Name of module the symbol belongs to.
Definition
symbol.h:43
symbolt::is_static_lifetime
bool is_static_lifetime
Definition
symbol.h:70
symbolt::symbolt
symbolt(const irep_idt &_name, typet _type, const irep_idt &_mode)
Definition
symbol.h:87
symbolt::set_compiled
void set_compiled()
Set the symbol's value to "compiled"; to be used once the code-typed value has been converted to a go...
Definition
symbol.h:120
symbolt::is_property
bool is_property
Definition
symbol.h:67
symbolt::is_parameter
bool is_parameter
Definition
symbol.h:76
symbolt::is_thread_local
bool is_thread_local
Definition
symbol.h:71
symbolt::is_type
bool is_type
Definition
symbol.h:61
symbolt::location
source_locationt location
Source code location of definition of symbol.
Definition
symbol.h:37
symbolt::is_compiled
bool is_compiled() const
Returns true iff the the symbol's value has been compiled to a goto program.
Definition
symbol.h:113
symbolt::is_state_var
bool is_state_var
Definition
symbol.h:66
symbolt::symbol_expr
class symbol_exprt symbol_expr() const
Produces a symbol_exprt for a symbol.
Definition
symbol.cpp:121
symbolt::is_function
bool is_function() const
Definition
symbol.h:106
symbolt::is_output
bool is_output
Definition
symbol.h:65
symbolt::type
typet type
Type of symbol.
Definition
symbol.h:31
symbolt::is_weak
bool is_weak
Definition
symbol.h:78
symbolt::name
irep_idt name
The unique identifier.
Definition
symbol.h:40
symbolt::is_exported
bool is_exported
Definition
symbol.h:63
symbolt::pretty_name
irep_idt pretty_name
Language-specific display name.
Definition
symbol.h:52
symbolt::operator!=
bool operator!=(const symbolt &other) const
Definition
symbol.cpp:233
symbolt::is_shared
bool is_shared() const
Definition
symbol.h:101
symbolt::display_name
const irep_idt & display_name() const
Return language specific display name if present.
Definition
symbol.h:55
symbolt::is_lvalue
bool is_lvalue
Definition
symbol.h:72
symbolt::value
exprt value
Initial value of symbol.
Definition
symbol.h:34
symbolt::mode
irep_idt mode
Language mode.
Definition
symbol.h:49
symbolt::is_input
bool is_input
Definition
symbol.h:64
type_symbolt::type_symbolt
type_symbolt(const irep_idt &_name, typet _type, const irep_idt &_mode)
Definition
symbol.h:141
typet
The type of an expression, extends irept.
Definition
type.h:29
expr.h
get_nil_irep
const irept & get_nil_irep()
Definition
irep.cpp:19
std
STL namespace.
invariant.h
PRECONDITION
#define PRECONDITION(CONDITION)
Definition
invariant.h:463
operator<<
std::ostream & operator<<(std::ostream &out, const symbolt &symbol)
Overload of stream operator to work with symbols.
Definition
symbol.cpp:76
irep_idt
dstringt irep_idt
Definition
verification_result.h:16
util
symbol.h
Generated by
1.17.0