@@ -68,27 +68,39 @@ class symbol_tablet
68
68
}
69
69
70
70
// / Find a symbol in the symbol table for read-only access.
71
- // / \param id: The name of the symbol to look for
72
- // / \return an optional reference, set if found, nullptr otherwise.
73
- const symbolt *lookup (const irep_idt &identifier) const ;
71
+ // / \param identifier: The name of the symbol to look for
72
+ // / \return an optional pointer, set if found, nullptr otherwise.
73
+ const symbolt *lookup (const irep_idt &identifier) const
74
+ {
75
+ symbolst::const_iterator it=symbols.find (identifier);
76
+ if (it==symbols.end ())
77
+ return nullptr ;
78
+ return &it->second ;
79
+ }
74
80
75
81
// / Find a symbol in the symbol table for read-write access.
76
- // / \param id : The name of the symbol to look for
77
- // / \return an optional reference , set if found, unset otherwise.
82
+ // / \param identifier : The name of the symbol to look for
83
+ // / \return an optional pointer , set if found, nullptr otherwise.
78
84
virtual symbolt *get_writeable (const irep_idt &identifier)=0;
79
85
80
86
// / Find a symbol in the symbol table for read-only access.
81
- // / \param id : The name of the symbol to look for
87
+ // / \param identifier : The name of the symbol to look for
82
88
// / \return A reference to the symbol
83
89
// / \throw `std::out_of_range` if no such symbol exists
84
- const symbolt &lookup_ref (const irep_idt &id ) const
85
- { return symbols.at (id ); }
90
+ const symbolt &lookup_ref (const irep_idt &identifier ) const
91
+ { return symbols.at (identifier ); }
86
92
87
93
// / Find a symbol in the symbol table for read-write access.
88
- // / \param id : The name of the symbol to look for
94
+ // / \param identifier : The name of the symbol to look for
89
95
// / \return A reference to the symbol
90
96
// / \throw `std::out_of_range` if no such symbol exists
91
- virtual symbolt &get_writeable_ref (const irep_idt &id)=0;
97
+ symbolt &get_writeable_ref (const irep_idt &identifier)
98
+ {
99
+ symbolt *symbol=get_writeable (identifier);
100
+ if (symbol==nullptr )
101
+ throw std::out_of_range (" identifier not found in symbol_table" );
102
+ return *symbol;
103
+ }
92
104
93
105
bool add (const symbolt &symbol);
94
106
// / Move or copy a new symbol to the symbol table
@@ -103,6 +115,8 @@ class symbol_tablet
103
115
bool move (symbolt &symbol, symbolt *&new_symbol);
104
116
105
117
bool remove (const irep_idt &name);
118
+ // / Remove a symbol from the symbol table
119
+ // / \param entry: an iterator pointing at the symbol to remove
106
120
virtual void erase (const symbolst::const_iterator &entry)=0;
107
121
virtual void clear ()=0;
108
122
@@ -187,8 +201,6 @@ class concrete_symbol_tablet:public symbol_tablet
187
201
}
188
202
189
203
virtual symbolt *get_writeable (const irep_idt &identifier) override ;
190
- virtual symbolt &get_writeable_ref (const irep_idt &identifier) override
191
- { return internal_symbols.at (identifier); }
192
204
193
205
virtual std::pair<symbolt &, bool > insert (symbolt symbol) override ;
194
206
0 commit comments