Go to the documentation of this file.
6 #ifndef CPROVER_UTIL_SYMBOL_TABLE_BASE_H
7 #define CPROVER_UTIL_SYMBOL_TABLE_BASE_H
10 #include <unordered_map>
24 typedef std::unordered_map<irep_idt, symbolt>
symbolst;
97 symbolst::const_iterator it =
symbols.find(name);
98 return it !=
symbols.end() ? &it->second :
nullptr;
108 symbol,
"`" +
id2string(name) +
"' must exist in the symbol table.");
124 if(symbol ==
nullptr)
125 throw std::out_of_range(
"name not found in symbol_table");
139 virtual std::pair<symbolt &, bool>
insert(
symbolt symbol) = 0;
145 virtual void erase(
const symbolst::const_iterator &entry) = 0;
146 virtual void clear() = 0;
148 void show(std::ostream &out)
const;
157 symbolst::iterator
it;
175 typedef symbolst::const_iterator::pointer
pointer;
181 return it != other.
it;
186 return it == other.
it;
235 virtual iteratort
begin() = 0;
236 virtual iteratort
end() = 0;
247 #endif // CPROVER_UTIL_SYMBOL_TABLE_BASE_H
bool operator==(const iteratort &other) const
bool has_symbol(const irep_idt &name) const
Check whether a symbol exists in the symbol table.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
const symbolt & lookup_ref(const irep_idt &name) const
Find a symbol in the symbol table for read-only access.
pointer operator->() const
Dereference operator (member access)
virtual symbolt * get_writeable(const irep_idt &name)=0
Find a symbol in the symbol table for read-write access.
bool operator!=(const iteratort &other) const
const symbol_base_mapt & symbol_base_map
Read-only field, used to look up symbol names given their base names.
symbol_table_baset(const symbolst &symbols, const symbol_base_mapt &symbol_base_map, const symbol_module_mapt &symbol_module_map)
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...
std::ostream & operator<<(std::ostream &out, const symbol_table_baset &symbol_table)
Print the contents of the symbol table.
void show(std::ostream &out) const
Print the contents of the symbol table.
const symbol_module_mapt & symbol_module_map
Read-only field, used to look up symbol names given their modules.
std::multimap< irep_idt, irep_idt > symbol_base_mapt
symbolst::iterator::iterator_category iterator_category
virtual void erase(const symbolst::const_iterator &entry)=0
Remove a symbol from the symbol table.
std::multimap< irep_idt, irep_idt > symbol_module_mapt
std::string to_string(const string_not_contains_constraintt &expr)
Used for debug printing.
virtual iteratort begin()=0
virtual ~symbol_table_baset()
Author: Diffblue Ltd.
virtual std::size_t next_unused_suffix(const std::string &prefix) const
symbolst::const_iterator::pointer pointer
symbolt & get_writeable_ref(const irep_idt &name)
Find a symbol in the symbol table for read-write access.
const std::string & id2string(const irep_idt &d)
symbolst::const_iterator const_iteratort
symbolt & get_writeable_symbol()
Whereas the dereference operator gives a constant reference to the current symbol,...
The symbol table base class interface.
reference operator*() const
Dereference operator.
iteratort operator++(int)
Post-increment operator.
std::function< void(const irep_idt &id)> on_get_writeable
bool remove(const irep_idt &name)
Remove a symbol from the symbol table.
symbolst::const_iterator::reference reference
bool add(const symbolt &symbol)
Add a new symbol to the symbol table.
virtual iteratort end()=0
const symbolst & symbols
Read-only field, used to look up symbols given their names.
std::unordered_map< irep_idt, symbolt > symbolst
symbolst::iterator::difference_type difference_type
iteratort(const iteratort &it, std::function< void(const irep_idt &id)> on_get_writeable)
symbol_table_baset & operator=(const symbol_table_baset &other)=delete
iteratort(symbolst::iterator it)
virtual std::pair< symbolt &, bool > insert(symbolt symbol)=0
Move or copy a new symbol to the symbol table.
const symbolt * lookup(const irep_idt &name) const
Find a symbol in the symbol table for read-only access.
virtual bool move(symbolt &symbol, symbolt *&new_symbol)=0
std::size_t next_unused_suffix(const std::string &prefix, std::size_t start_number) const
Find smallest unused integer i so that prefix + std::to_string(i) does not exist in the list symbols.
iteratort & operator++()
Preincrement operator Do not call on the end() iterator.
symbolst::const_iterator::value_type value_type
virtual const symbol_tablet & get_symbol_table() const =0