Skip to content

Commit c20fce0

Browse files
author
Daniel Kroening
committed
boolbvt: introduce scopes
1 parent bd0a77c commit c20fce0

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

src/solvers/flattening/boolbv.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ class boolbvt:public arrayst
119119
typedef std::unordered_map<const exprt, bvt, irep_hash> bv_cachet;
120120
bv_cachet bv_cache;
121121

122+
// record the subexpressions that use the scoped variable,
123+
// in order to clear them from the cache after we are done
124+
std::vector<bv_cachet::iterator> bv_cache_iterators;
125+
122126
bool type_conversion(
123127
const typet &src_type, const bvt &src,
124128
const typet &dest_type, bvt &dest);

src/solvers/flattening/boolbv_let.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,30 @@ bvt boolbvt::convert_let(const let_exprt &expr)
1515
{
1616
const bvt value_bv=convert_bv(expr.value());
1717

18-
// We expect the identifiers of the bound symbols to be unique,
19-
// and thus, these can go straight into the symbol to literal map.
20-
// This property also allows us to cache any subexpressions.
21-
const irep_idt &id=expr.symbol().get_identifier();
18+
const irep_idt &id = expr.symbol().get_identifier();
19+
//auto emplace_result = symbols.emplace(id, literalt());
20+
//literalt old_variable;
21+
22+
// We do not expect the identifier to be unique; in particular, nesting
23+
// is supported. Thus, do we need to save a value from an outer scope?
2224

2325
// the symbol shall be visible during the recursive call
2426
// to convert_bv
2527
map.set_literals(id, expr.symbol().type(), value_bv);
28+
29+
bool previous_record_cache_iterators = record_cache_iterators;
30+
std::size_t previous_prop_cache_iterators_size = prop_cache_iterators.size();
31+
std::size_t previous_bv_cache_iterators_size = bv_cache_iterators.size();
32+
record_cache_iterators = true;
33+
34+
// recursive call
2635
bvt result_bv=convert_bv(expr.where());
2736

37+
// clear cache_iterators that use the bound symbol from the cache
38+
bv_cache_iterators.resize(previous_prop_cache_iterators_size);
39+
bv_cache_iterators.resize(previous_bv_cache_iterators_size);
40+
record_cache_iterators = previous_record_cache_iterators;
41+
2842
// now remove, no longer needed
2943
map.erase_literals(id, expr.symbol().type());
3044

0 commit comments

Comments
 (0)