Skip to content

Commit 7aa80ad

Browse files
Remove lookup_impl - it won't work for recording symbol table and adds complexity
1 parent cdbac8c commit 7aa80ad

File tree

1 file changed

+8
-22
lines changed

1 file changed

+8
-22
lines changed

src/util/symbol_table.h

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ class symbol_tablet
112112
/// \return a pointer to the found symbol if it exists, nullptr otherwise.
113113
const symbolt *lookup(const irep_idt &name) const
114114
{
115-
return lookup_impl(name);
115+
symbolst::const_iterator it = symbols.find(name);
116+
return it != symbols.end() ? &it->second : nullptr;
116117
}
117118

118119
/// Find a symbol in the symbol table for read-only access.
@@ -129,7 +130,8 @@ class symbol_tablet
129130
/// \return a pointer to the found symbol if it exists, nullptr otherwise.
130131
symbolt *get_writeable(const irep_idt &name)
131132
{
132-
return lookup_impl(name);
133+
symbolst::iterator it = internal_symbols.find(name);
134+
return it != internal_symbols.end() ? &it->second : nullptr;
133135
}
134136

135137
/// Find a symbol in the symbol table for read-write access.
@@ -138,7 +140,10 @@ class symbol_tablet
138140
/// \throw `std::out_of_range` if no such symbol exists
139141
symbolt &get_writeable_ref(const irep_idt &name)
140142
{
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;
142147
}
143148

144149
bool add(const symbolt &symbol);
@@ -155,25 +160,6 @@ class symbol_tablet
155160
}
156161

157162
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-
}
177163
};
178164

179165
std::ostream &operator<<(std::ostream &out, const symbol_tablet &symbol_table);

0 commit comments

Comments
 (0)