@@ -112,7 +112,8 @@ class symbol_tablet
112
112
// / \return a pointer to the found symbol if it exists, nullptr otherwise.
113
113
const symbolt *lookup (const irep_idt &name) const
114
114
{
115
- return lookup_impl (name);
115
+ symbolst::const_iterator it = symbols.find (name);
116
+ return it != symbols.end () ? &it->second : nullptr ;
116
117
}
117
118
118
119
// / Find a symbol in the symbol table for read-only access.
@@ -129,7 +130,8 @@ class symbol_tablet
129
130
// / \return a pointer to the found symbol if it exists, nullptr otherwise.
130
131
symbolt *get_writeable (const irep_idt &name)
131
132
{
132
- return lookup_impl (name);
133
+ symbolst::iterator it = internal_symbols.find (name);
134
+ return it != internal_symbols.end () ? &it->second : nullptr ;
133
135
}
134
136
135
137
// / Find a symbol in the symbol table for read-write access.
@@ -138,7 +140,10 @@ class symbol_tablet
138
140
// / \throw `std::out_of_range` if no such symbol exists
139
141
symbolt &get_writeable_ref (const irep_idt &name)
140
142
{
141
- return internal_symbols.at (name);
143
+ symbolt *symbol = get_writeable (name);
144
+ if (symbol == nullptr )
145
+ throw std::out_of_range (" name not found in symbol_table" );
146
+ return *symbol;
142
147
}
143
148
144
149
bool add (const symbolt &symbol);
@@ -155,25 +160,6 @@ class symbol_tablet
155
160
}
156
161
157
162
void show (std::ostream &out) const ;
158
-
159
- private:
160
- const symbolt *lookup_impl (const irep_idt &name) const
161
- {
162
- return lookup_impl (*this , name);
163
- }
164
-
165
- symbolt *lookup_impl (const irep_idt &name)
166
- {
167
- return lookup_impl (*this , name);
168
- }
169
-
170
- template <typename T>
171
- static auto lookup_impl (T &t, const irep_idt &name)
172
- -> decltype(std::declval<T>().lookup_impl(name))
173
- {
174
- const auto it = t.internal_symbols .find (name);
175
- return it==t.internal_symbols .end ()?nullptr :&it->second ;
176
- }
177
163
};
178
164
179
165
std::ostream &operator <<(std::ostream &out, const symbol_tablet &symbol_table);
0 commit comments