@@ -14,6 +14,14 @@ bool symbol_tablet::add(const symbolt &symbol)
1414 return !insert (symbol).second ;
1515}
1616
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.
1725std::pair<symbolt &, bool > symbol_tablet::insert (symbolt symbol)
1826{
1927 // 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)
8492// / Remove a symbol from the symbol table
8593// / \param name: The name of the symbol to remove
8694// / \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.
8796bool symbol_tablet::remove (const irep_idt &name)
8897{
8998 symbolst::const_iterator entry=symbols.find (name);
@@ -93,6 +102,8 @@ bool symbol_tablet::remove(const irep_idt &name)
93102 return false ;
94103}
95104
105+ // / Remove a symbol from the symbol table
106+ // / \param entry: an iterator pointing at the symbol to remove
96107void symbol_tablet::erase (const symbolst::const_iterator &entry)
97108{
98109 const symbolt &symbol=entry->second ;
@@ -137,10 +148,9 @@ void symbol_tablet::show(std::ostream &out) const
137148 out << it->second ;
138149}
139150
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.
142152// / \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.
144154symbol_tablet::opt_const_symbol_reft symbol_tablet::lookup (
145155 const irep_idt &identifier) const
146156{
@@ -150,9 +160,9 @@ symbol_tablet::opt_const_symbol_reft symbol_tablet::lookup(
150160 return std::ref (it->second );
151161}
152162
153- // / Find a symbol in the symbol table.
163+ // / Find a symbol in the symbol table for read-write access .
154164// / \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.
156166symbol_tablet::opt_symbol_reft symbol_tablet::get_writeable (
157167 const irep_idt &identifier)
158168{
0 commit comments