cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
symbol_table_base.cpp
Go to the documentation of this file.
1
2
3
#include "
symbol_table_base.h
"
4
5
#include <ostream>
6
#include <algorithm>
7
9
symbol_table_baset::~symbol_table_baset
()
10
{
11
}
12
13
18
bool
symbol_table_baset::add
(
const
symbolt
&symbol)
19
{
20
return
!
insert
(symbol).second;
21
}
22
27
bool
symbol_table_baset::remove
(
const
irep_idt
&name)
28
{
29
symbolst::const_iterator entry =
symbols
.find(name);
30
if
(entry ==
symbols
.end())
31
return
true
;
32
erase
(entry);
33
return
false
;
34
}
35
36
std::vector<irep_idt>
symbol_table_baset::sorted_symbol_names
()
const
37
{
38
std::vector<irep_idt> sorted_names;
39
sorted_names.reserve(
symbols
.size());
40
41
for
(
const
auto
&elem :
symbols
)
42
sorted_names.push_back(elem.first);
43
44
std::sort(
45
sorted_names.begin(),
46
sorted_names.end(),
47
[](
const
irep_idt
&a,
const
irep_idt
&b) { return a.compare(b) < 0; });
48
49
return
sorted_names;
50
}
51
54
void
symbol_table_baset::show
(std::ostream &out)
const
55
{
56
out <<
"\n"
57
<<
"Symbols:"
58
<<
"\n"
;
59
for
(
const
auto
&name :
sorted_symbol_names
())
60
out <<
symbols
.at(name);
61
}
62
63
symbol_table_baset::const_iteratort
symbol_table_baset::end
()
const
64
{
65
return
symbols
.end();
66
}
67
68
symbol_table_baset::const_iteratort
symbol_table_baset::begin
()
const
69
{
70
return
symbols
.begin();
71
}
72
76
std::ostream &
77
operator<<
(std::ostream &out,
const
symbol_table_baset
&symbol_table)
78
{
79
symbol_table.
show
(out);
80
return
out;
81
}
symbol_table_baset
The symbol table base class interface.
Definition
symbol_table_base.h:23
symbol_table_baset::sorted_symbol_names
std::vector< irep_idt > sorted_symbol_names() const
Build and return a lexicographically sorted vector of symbol names from all symbols stored in this sy...
Definition
symbol_table_base.cpp:36
symbol_table_baset::remove
bool remove(const irep_idt &name)
Remove a symbol from the symbol table.
Definition
symbol_table_base.cpp:27
symbol_table_baset::insert
virtual std::pair< symbolt &, bool > insert(symbolt symbol)=0
Move or copy a new symbol to the symbol table.
symbol_table_baset::erase
virtual void erase(const symbolst::const_iterator &entry)=0
Remove a symbol from the symbol table.
symbol_table_baset::begin
virtual iteratort begin()=0
symbol_table_baset::const_iteratort
symbolst::const_iterator const_iteratort
Definition
symbol_table_base.h:271
symbol_table_baset::show
void show(std::ostream &out) const
Print the contents of the symbol table.
Definition
symbol_table_base.cpp:54
symbol_table_baset::symbols
const symbolst & symbols
Read-only field, used to look up symbols given their names.
Definition
symbol_table_base.h:31
symbol_table_baset::end
virtual iteratort end()=0
symbol_table_baset::add
bool add(const symbolt &symbol)
Add a new symbol to the symbol table.
Definition
symbol_table_base.cpp:18
symbol_table_baset::~symbol_table_baset
virtual ~symbol_table_baset()
Author: Diffblue Ltd.
Definition
symbol_table_base.cpp:9
symbolt
Symbol table entry.
Definition
symbol.h:28
operator<<
std::ostream & operator<<(std::ostream &out, const symbol_table_baset &symbol_table)
Print the contents of the symbol table.
Definition
symbol_table_base.cpp:77
symbol_table_base.h
Author: Diffblue Ltd.
irep_idt
dstringt irep_idt
Definition
verification_result.h:16
util
symbol_table_base.cpp
Generated by
1.17.0