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:
25 
26 public:
32  {
33  }
34 
44  {
45  }
46 
49  {
50  // Copy to temp and then call move assignment
51  return *this=symbol_tablet(other);
52  }
53 
63  {
64  }
65 
68  {
69  internal_symbols = std::move(other.internal_symbols);
70  internal_symbol_base_map = std::move(other.internal_symbol_base_map);
71  internal_symbol_module_map = std::move(other.internal_symbol_module_map);
72  return *this;
73  }
74 
77  void swap(symbol_tablet &other)
78  {
82  }
83 
84 public:
85  virtual const symbol_tablet &get_symbol_table() const override
86  {
87  return *this;
88  }
89 
93  virtual symbolt *get_writeable(const irep_idt &name) override
94  {
95  symbolst::iterator it = internal_symbols.find(name);
96  return it != internal_symbols.end() ? &it->second : nullptr;
97  }
98 
99  virtual std::pair<symbolt &, bool> insert(symbolt symbol) override;
100  virtual bool move(symbolt &symbol, symbolt *&new_symbol) override;
101 
102  virtual void erase(const symbolst::const_iterator &entry) override;
104  virtual void clear() override
105  {
106  internal_symbols.clear();
107  internal_symbol_base_map.clear();
109  }
110 
111  virtual iteratort begin() override
112  {
113  return iteratort(internal_symbols.begin());
114  }
115  virtual iteratort end() override
116  {
117  return iteratort(internal_symbols.end());
118  }
119 
122 
123  bool operator==(const symbol_tablet &other) const;
124 };
125 
126 #endif // CPROVER_UTIL_SYMBOL_TABLE_H
symbolst internal_symbols
Definition: symbol_table.h:22
virtual void clear() override
Wipe internal state of the symbol table.
Definition: symbol_table.h:104
std::multimap< irep_idt, irep_idt > symbol_base_mapt
virtual const symbol_tablet & get_symbol_table() const override
Definition: symbol_table.h:85
STL namespace.
Symbol table entry.
Definition: symbol.h:27
symbol_tablet & operator=(const symbol_tablet &other)
Copy assignment operator.
Definition: symbol_table.h:48
std::multimap< irep_idt, irep_idt > symbol_module_mapt
virtual symbolt * get_writeable(const irep_idt &name) override
Find a symbol in the symbol table for read-write access.
Definition: symbol_table.h:93
symbol_tablet(symbol_tablet &&other)
Move constructor.
Definition: symbol_table.h:55
symbol_module_mapt internal_symbol_module_map
Definition: symbol_table.h:24
virtual bool move(symbolt &symbol, symbolt *&new_symbol) override
Move a symbol into the symbol table.
std::unordered_map< irep_idt, symbolt > symbolst
The symbol table.
Definition: symbol_table.h:19
virtual iteratort begin() override
Definition: symbol_table.h:111
void validate(const validation_modet vm=validation_modet::INVARIANT) const
Check that the symbol table is well-formed.
virtual iteratort end() override
Definition: symbol_table.h:115
symbol_tablet & operator=(symbol_tablet &&other)
Move assignment operator.
Definition: symbol_table.h:67
dstringt has one field, an unsigned integer no which is an index into a static table of strings...
Definition: dstring.h:35
virtual void erase(const symbolst::const_iterator &entry) override
Remove a symbol from the symbol table.
bool operator==(const symbol_tablet &other) const
symbol_base_mapt internal_symbol_base_map
Definition: symbol_table.h:23
Author: Diffblue Ltd.
The symbol table base class interface.
symbol_tablet(const symbol_tablet &other)
Copy constructor.
Definition: symbol_table.h:36
validation_modet
void swap(symbol_tablet &other)
Swap symbol maps between two symbol tables.
Definition: symbol_table.h:77
virtual std::pair< symbolt &, bool > insert(symbolt symbol) override
Author: Diffblue Ltd.