Skip to content

Commit 412d755

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 f274d61 commit 412d755

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/solvers/smt2/smt2_parser.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,19 @@ exprt smt2_parsert::let_expression()
189189
if(next_token() != smt2_tokenizert::CLOSE)
190190
throw error("expected ')' at end of bindings");
191191

192-
// save the renaming map
193-
renaming_mapt old_renaming_map=renaming_map;
192+
id_mapt old_ids;
194193

195-
// go forwards, add to id_map, renaming if need be
194+
// go forwards, add to id_map, but first saving the old id, if any
196195
for(auto &b : bindings)
197196
{
198-
// get a fresh id for it
199-
b.first = add_fresh_id(b.first, b.second);
197+
auto id_map_it = id_map.find(b.first); // already there?
198+
if(id_map_it == id_map.end()) // not there yet
199+
id_map.insert({b.first, idt(b.second)});
200+
else
201+
{
202+
old_ids.insert(*id_map_it); // save old ID
203+
id_map_it->second = idt(b.second); // overwrite
204+
}
200205
}
201206

202207
exprt expr=expression();
@@ -216,11 +221,9 @@ exprt smt2_parsert::let_expression()
216221
result=let;
217222
}
218223

219-
// we keep these in the id_map in order to retain globally
220-
// unique identifiers
221-
222-
// restore renamings
223-
renaming_map=old_renaming_map;
224+
// restore identifiers
225+
for(auto &old_id : old_ids)
226+
id_map.at(old_id.first) = std::move(old_id.second);
224227

225228
return result;
226229
}

0 commit comments

Comments
 (0)