6 #ifndef CPROVER_UTIL_SYMBOL_TABLE_BASE_H
7 #define CPROVER_UTIL_SYMBOL_TABLE_BASE_H
13 #include <unordered_map>
25 typedef std::unordered_map<irep_idt, symbolt>
symbolst;
98 symbolst::const_iterator it =
symbols.find(name);
99 return it !=
symbols.end() ? &it->second :
nullptr;
109 symbol,
"`" +
id2string(name) +
"' must exist in the symbol table.");
115 std::list<symbolst::const_iterator>
118 std::list<symbolst::const_iterator> results;
120 auto name_it =
symbols.find(
id);
122 results.push_back(name_it);
125 for(
auto base_name_it = base_name_it_pair.first;
126 base_name_it != base_name_it_pair.second;
129 name_it =
symbols.find(base_name_it->second);
133 if(base_name_it->first != base_name_it->second)
134 results.push_back(name_it);
152 if(symbol ==
nullptr)
153 throw std::out_of_range(
"name not found in symbol_table");
173 virtual void erase(
const symbolst::const_iterator &entry) = 0;
176 void show(std::ostream &out)
const;
185 symbolst::iterator
it;
200 operator symbolst::const_iterator()
const
202 return symbolst::const_iterator{
it};
208 typedef symbolst::const_iterator::pointer
pointer;
214 return it != other.
it;
219 return it == other.
it;
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
symbolt & get_writeable_symbol()
Whereas the dereference operator gives a constant reference to the current symbol,...
bool operator==(const iteratort &other) const
std::function< void(const irep_idt &id)> on_get_writeable
iteratort operator++(int)
Post-increment operator.
bool operator!=(const iteratort &other) const
symbolst::iterator::iterator_category iterator_category
iteratort & operator++()
Preincrement operator Do not call on the end() iterator.
symbolst::const_iterator::reference reference
symbolst::const_iterator::value_type value_type
symbolst::const_iterator::pointer pointer
iteratort(const iteratort &it, std::function< void(const irep_idt &id)> on_get_writeable)
iteratort(symbolst::iterator it)
pointer operator->() const
Dereference operator (member access)
reference operator*() const
Dereference operator.
symbolst::iterator::difference_type difference_type
The symbol table base class interface.
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...
const symbol_base_mapt & symbol_base_map
Read-only field, used to look up symbol names given their base names.
bool remove(const irep_idt &name)
Remove a symbol from the symbol table.
virtual void validate(const validation_modet vm=validation_modet::INVARIANT) const =0
symbol_table_baset(const symbolst &symbols, const symbol_base_mapt &symbol_base_map, const symbol_module_mapt &symbol_module_map)
virtual bool move(symbolt &symbol, symbolt *&new_symbol)=0
symbolt & get_writeable_ref(const irep_idt &name)
Find a symbol in the symbol table for read-write access.
virtual void erase(const symbolst::const_iterator &entry)=0
Remove a symbol from the symbol table.
const symbol_module_mapt & symbol_module_map
Read-only field, used to look up symbol names given their modules.
virtual iteratort begin()=0
symbolst::const_iterator const_iteratort
const symbolt * lookup(const irep_idt &name) const
Find a symbol in the symbol table for read-only access.
std::unordered_map< irep_idt, symbolt > symbolst
void show(std::ostream &out) const
Print the contents of the symbol table.
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.
const symbolst & symbols
Read-only field, used to look up symbols given their names.
virtual const symbol_tablet & get_symbol_table() const =0
const symbolt & lookup_ref(const irep_idt &name) const
Find a symbol in the symbol table for read-only access.
virtual iteratort end()=0
std::list< symbolst::const_iterator > match_name_or_base_name(const irep_idt &id) const
Collect all symbols the name of which matches id or the base name of which matches id.
bool has_symbol(const irep_idt &name) const
Check whether a symbol exists in the symbol table.
bool add(const symbolt &symbol)
Add a new symbol to the symbol table.
virtual symbolt * get_writeable(const irep_idt &name)=0
Find a symbol in the symbol table for read-write access.
virtual ~symbol_table_baset()
Author: Diffblue Ltd.
virtual std::pair< symbolt &, bool > insert(symbolt symbol)=0
Move or copy a new symbol to the symbol table.
symbol_table_baset & operator=(const symbol_table_baset &other)=delete
virtual std::size_t next_unused_suffix(const std::string &prefix) const
symbol_table_baset(const symbol_table_baset &other)=delete
const std::string & id2string(const irep_idt &d)
#define CHECK_RETURN(CONDITION)
std::string to_string(const string_not_contains_constraintt &expr)
Used for debug printing.
std::multimap< irep_idt, irep_idt > symbol_base_mapt
std::ostream & operator<<(std::ostream &out, const symbol_table_baset &symbol_table)
Print the contents of the symbol table.
std::multimap< irep_idt, irep_idt > symbol_module_mapt