cprover
symbol_table.h
Go to the documentation of this file.
1 
5 
6 #ifndef CPROVER_UTIL_SYMBOL_TABLE_H
7 #define CPROVER_UTIL_SYMBOL_TABLE_H
8 
9 #include "symbol_table_base.h"
10 
11 #define forall_symbol_base_map(it, expr, base_name) \
12  for(symbol_base_mapt::const_iterator it=(expr).lower_bound(base_name), \
13  it_end=(expr).upper_bound(base_name); \
14  it!=it_end; ++it)
15 
16 
20 {
21 private:
28 
29 public:
35  {
36  }
37 
47  {
48  }
49 
52  {
53  // Copy to temp and then call move assignment
54  return *this=symbol_tablet(other);
55  }
56 
66  {
67  }
68 
71  {
72  internal_symbols = std::move(other.internal_symbols);
73  internal_symbol_base_map = std::move(other.internal_symbol_base_map);
74  internal_symbol_module_map = std::move(other.internal_symbol_module_map);
75  return *this;
76  }
77 
80  void swap(symbol_tablet &other)
81  {
85  }
86 
87 public:
88  virtual const symbol_tablet &get_symbol_table() const override
89  {
90  return *this;
91  }
92 
96  virtual symbolt *get_writeable(const irep_idt &name) override
97  {
98  symbolst::iterator it = internal_symbols.find(name);
99  return it != internal_symbols.end() ? &it->second : nullptr;
100  }
101 
102  virtual std::pair<symbolt &, bool> insert(symbolt symbol) override;
103  virtual bool move(symbolt &symbol, symbolt *&new_symbol) override;
104 
105  virtual void erase(const symbolst::const_iterator &entry) override;
107  virtual void clear() override
108  {
109  internal_symbols.clear();
110  internal_symbol_base_map.clear();
112  }
113 
114  virtual iteratort begin() override
115  {
116  return iteratort(internal_symbols.begin());
117  }
118  virtual iteratort end() override
119  {
120  return iteratort(internal_symbols.end());
121  }
122 
125 
128 
129  bool operator==(const symbol_tablet &other) const;
130 };
131 
132 #endif // CPROVER_UTIL_SYMBOL_TABLE_H
symbol_tablet::internal_symbol_module_map
symbol_module_mapt internal_symbol_module_map
Value referenced by symbol_table_baset::symbol_module_map.
Definition: symbol_table.h:27
dstringt
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:36
symbol_tablet
The symbol table.
Definition: symbol_table.h:19
symbol_tablet::symbol_tablet
symbol_tablet(const symbol_tablet &other)
Copy constructor.
Definition: symbol_table.h:39
symbol_tablet::operator=
symbol_tablet & operator=(symbol_tablet &&other)
Move assignment operator.
Definition: symbol_table.h:70
symbol_tablet::internal_symbol_base_map
symbol_base_mapt internal_symbol_base_map
Value referenced by symbol_table_baset::symbol_base_map.
Definition: symbol_table.h:25
symbol_tablet::operator=
symbol_tablet & operator=(const symbol_tablet &other)
Copy assignment operator.
Definition: symbol_table.h:51
symbol_base_mapt
std::multimap< irep_idt, irep_idt > symbol_base_mapt
Definition: symbol_table_base.h:14
symbol_tablet::symbol_tablet
symbol_tablet(symbol_tablet &&other)
Move constructor.
Definition: symbol_table.h:58
symbol_module_mapt
std::multimap< irep_idt, irep_idt > symbol_module_mapt
Definition: symbol_table_base.h:15
symbol_tablet::validate
void validate(const validation_modet vm=validation_modet::INVARIANT) const
Check that the symbol table is well-formed.
Definition: symbol_table.cpp:132
symbol_tablet::internal_symbols
symbolst internal_symbols
Value referenced by symbol_table_baset::symbols.
Definition: symbol_table.h:23
symbol_tablet::get_symbol_table
virtual const symbol_tablet & get_symbol_table() const override
Definition: symbol_table.h:88
symbol_tablet::begin
virtual iteratort begin() override
Definition: symbol_table.h:114
symbol_tablet::end
virtual iteratort end() override
Definition: symbol_table.h:118
symbol_table_baset
The symbol table base class interface.
Definition: symbol_table_base.h:21
symbol_table_baset::end
virtual iteratort end()=0
symbol_tablet::insert
virtual std::pair< symbolt &, bool > insert(symbolt symbol) override
Author: Diffblue Ltd.
Definition: symbol_table.cpp:19
validation_modet
validation_modet
Definition: validation_mode.h:12
symbol_tablet::clear
virtual void clear() override
Wipe internal state of the symbol table.
Definition: symbol_table.h:107
symbol_tablet::move
virtual bool move(symbolt &symbol, symbolt *&new_symbol) override
Move a symbol into the symbol table.
Definition: symbol_table.cpp:69
symbol_tablet::get_writeable
virtual symbolt * get_writeable(const irep_idt &name) override
Find a symbol in the symbol table for read-write access.
Definition: symbol_table.h:96
symbol_table_baset::iteratort
Definition: symbol_table_base.h:154
symbol_table_baset::begin
virtual iteratort begin()=0
symbolt
Symbol table entry.
Definition: symbol.h:27
symbol_tablet::swap
void swap(symbol_tablet &other)
Swap symbol maps between two symbol tables.
Definition: symbol_table.h:80
symbol_table_baset::symbolst
std::unordered_map< irep_idt, symbolt > symbolst
Definition: symbol_table_base.h:24
symbol_tablet::erase
virtual void erase(const symbolst::const_iterator &entry) override
Remove a symbol from the symbol table.
Definition: symbol_table.cpp:92
symbol_table_base.h
Author: Diffblue Ltd.
symbol_tablet::symbol_tablet
symbol_tablet()
Definition: symbol_table.h:30
symbol_tablet::operator==
bool operator==(const symbol_tablet &other) const
Definition: symbol_table.cpp:232
validation_modet::INVARIANT