@@ -14,6 +14,14 @@ bool symbol_tablet::add(const symbolt &symbol)
14
14
return !insert (symbol).second ;
15
15
}
16
16
17
+ // / Move or copy a new symbol to the symbol table
18
+ // / \remark: This is a nicer interface than move and achieves the same
19
+ // / result as both move and add
20
+ // / \param symbol: The symbol to be added to the symbol table - can be
21
+ // / moved or copied in
22
+ // / \return Returns a reference to the newly inserted symbol or to the
23
+ // / existing symbol if a symbol with the same name already exists in the
24
+ // / symbol table, along with a bool that is true if a new symbol was inserted.
17
25
std::pair<symbolt &, bool > symbol_tablet::insert (symbolt symbol)
18
26
{
19
27
// Add the symbol to the table or retrieve existing symbol with the same name
@@ -84,6 +92,7 @@ bool symbol_tablet::move(symbolt &symbol, symbolt *&new_symbol)
84
92
// / Remove a symbol from the symbol table
85
93
// / \param name: The name of the symbol to remove
86
94
// / \return Returns a boolean indicating whether the process failed
95
+ // / i.e. false if the symbol was removed, or true if it didn't exist.
87
96
bool symbol_tablet::remove (const irep_idt &name)
88
97
{
89
98
symbolst::const_iterator entry=symbols.find (name);
@@ -93,6 +102,8 @@ bool symbol_tablet::remove(const irep_idt &name)
93
102
return false ;
94
103
}
95
104
105
+ // / Remove a symbol from the symbol table
106
+ // / \param entry: an iterator pointing at the symbol to remove
96
107
void symbol_tablet::erase (const symbolst::const_iterator &entry)
97
108
{
98
109
const symbolt &symbol=entry->second ;
@@ -137,10 +148,9 @@ void symbol_tablet::show(std::ostream &out) const
137
148
out << it->second ;
138
149
}
139
150
140
- // / Find a symbol in the symbol table. Throws a string if no such symbol is
141
- // / found.
151
+ // / Find a symbol in the symbol table for read-only access.
142
152
// / \param identifier: The name of the symbol to look for
143
- // / \return The symbol in the symbol table with the correct name
153
+ // / \return an optional reference, set if found, unset otherwise.
144
154
symbol_tablet::opt_const_symbol_reft symbol_tablet::lookup (
145
155
const irep_idt &identifier) const
146
156
{
@@ -150,9 +160,9 @@ symbol_tablet::opt_const_symbol_reft symbol_tablet::lookup(
150
160
return std::ref (it->second );
151
161
}
152
162
153
- // / Find a symbol in the symbol table.
163
+ // / Find a symbol in the symbol table for read-write access .
154
164
// / \param identifier: The name of the symbol to look for
155
- // / \return The symbol in the symbol table with the correct name
165
+ // / \return an optional reference, set if found, unset otherwise.
156
166
symbol_tablet::opt_symbol_reft symbol_tablet::get_writeable (
157
167
const irep_idt &identifier)
158
168
{
0 commit comments