CBMC
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 
14 {
15 private:
22 
23 public:
29  {
30  }
31 
41  {
42  }
43 
46  {
47  // Copy to temp and then call move assignment
48  return *this=symbol_tablet(other);
49  }
50 
60  {
61  }
62 
65  {
66  internal_symbols = std::move(other.internal_symbols);
67  internal_symbol_base_map = std::move(other.internal_symbol_base_map);
68  internal_symbol_module_map = std::move(other.internal_symbol_module_map);
69  return *this;
70  }
71 
74  void swap(symbol_tablet &other)
75  {
79  }
80 
81 public:
82  virtual const symbol_tablet &get_symbol_table() const override
83  {
84  return *this;
85  }
86 
90  virtual symbolt *get_writeable(const irep_idt &name) override
91  {
92  symbolst::iterator it = internal_symbols.find(name);
93  return it != internal_symbols.end() ? &it->second : nullptr;
94  }
95 
96  virtual std::pair<symbolt &, bool> insert(symbolt symbol) override;
97  virtual bool move(symbolt &symbol, symbolt *&new_symbol) override;
98 
99  virtual void erase(const symbolst::const_iterator &entry) override;
101  virtual void clear() override
102  {
103  internal_symbols.clear();
104  internal_symbol_base_map.clear();
106  }
107 
108  virtual iteratort begin() override
109  {
110  return iteratort(internal_symbols.begin());
111  }
112  virtual iteratort end() override
113  {
114  return iteratort(internal_symbols.end());
115  }
116 
119 
121  void validate(
122  const validation_modet vm = validation_modet::INVARIANT) const override;
123 
124  bool operator==(const symbol_tablet &other) const;
125 };
126 
127 #endif // CPROVER_UTIL_SYMBOL_TABLE_H
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:38
The symbol table base class interface.
virtual iteratort begin()=0
std::unordered_map< irep_idt, symbolt > symbolst
virtual iteratort end()=0
The symbol table.
Definition: symbol_table.h:14
bool operator==(const symbol_tablet &other) const
symbolst internal_symbols
Value referenced by symbol_table_baset::symbols.
Definition: symbol_table.h:17
virtual void erase(const symbolst::const_iterator &entry) override
Remove a symbol from the symbol table.
virtual iteratort begin() override
Definition: symbol_table.h:108
symbol_tablet(symbol_tablet &&other)
Move constructor.
Definition: symbol_table.h:52
symbol_tablet & operator=(const symbol_tablet &other)
Copy assignment operator.
Definition: symbol_table.h:45
symbol_tablet(const symbol_tablet &other)
Copy constructor.
Definition: symbol_table.h:33
virtual const symbol_tablet & get_symbol_table() const override
Definition: symbol_table.h:82
virtual void clear() override
Wipe internal state of the symbol table.
Definition: symbol_table.h:101
void swap(symbol_tablet &other)
Swap symbol maps between two symbol tables.
Definition: symbol_table.h:74
virtual symbolt * get_writeable(const irep_idt &name) override
Find a symbol in the symbol table for read-write access.
Definition: symbol_table.h:90
symbol_module_mapt internal_symbol_module_map
Value referenced by symbol_table_baset::symbol_module_map.
Definition: symbol_table.h:21
virtual bool move(symbolt &symbol, symbolt *&new_symbol) override
Move a symbol into the symbol table.
symbol_base_mapt internal_symbol_base_map
Value referenced by symbol_table_baset::symbol_base_map.
Definition: symbol_table.h:19
virtual iteratort end() override
Definition: symbol_table.h:112
virtual std::pair< symbolt &, bool > insert(symbolt symbol) override
Author: Diffblue Ltd.
symbol_tablet & operator=(symbol_tablet &&other)
Move assignment operator.
Definition: symbol_table.h:64
void validate(const validation_modet vm=validation_modet::INVARIANT) const override
Check that the symbol table is well-formed.
Symbol table entry.
Definition: symbol.h:28
Author: Diffblue Ltd.
std::multimap< irep_idt, irep_idt > symbol_base_mapt
std::multimap< irep_idt, irep_idt > symbol_module_mapt
validation_modet