Skip to content

Commit cd1bb95

Browse files
author
Daniel Kroening
committed
smt2_parser: no longer need to rename bindings
The back end now supports scoping, which eliminates the need for the SMT-LIB2 front-end to perform its own renaming.
1 parent cdf1925 commit cd1bb95

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/solvers/smt2/smt2_parser.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,21 @@ exprt smt2_parsert::let_expression()
198198
if(next_token() != smt2_tokenizert::CLOSE)
199199
throw error("expected ')' at end of bindings");
200200

201-
// save the renaming map
202-
renaming_mapt old_renaming_map=renaming_map;
201+
id_mapt old_ids;
203202

204-
// go forwards, add to id_map, renaming if need be
203+
// go forwards, add to id_map, but first saving the old id, if any
205204
for(auto &b : bindings)
206205
{
207-
// get a fresh id for it
208-
b.first = add_fresh_id(b.first, b.second);
206+
auto id_map_it = id_map.find(b.first); // already there?
207+
if(id_map_it == id_map.end()) // not there yet
208+
{
209+
id_map.insert({b.first, idt(b.second)});
210+
}
211+
else
212+
{
213+
old_ids.emplace(*id_map_it); // save old ID
214+
id_map_it->second = idt(b.second); // overwrite
215+
}
209216
}
210217

211218
exprt expr=expression();
@@ -225,11 +232,9 @@ exprt smt2_parsert::let_expression()
225232
result=let;
226233
}
227234

228-
// we keep these in the id_map in order to retain globally
229-
// unique identifiers
230-
231-
// restore renamings
232-
renaming_map=old_renaming_map;
235+
// restore identifiers
236+
for(auto &old_id : old_ids)
237+
id_map.at(old_id.first) = std::move(old_id.second);
233238

234239
return result;
235240
}

0 commit comments

Comments
 (0)