Skip to content

Commit 0da5dc9

Browse files
author
Joel Allred
committed
Pass array_pool arg to get_array
String length will be queried from array_pool in future commit.
1 parent d2a3541 commit 0da5dc9

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

src/solvers/strings/string_refinement.cpp

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ static optionalt<exprt> get_array(
105105
const std::function<exprt(const exprt &)> &super_get,
106106
const namespacet &ns,
107107
messaget::mstreamt &stream,
108-
const array_string_exprt &arr);
108+
const array_string_exprt &arr,
109+
const array_poolt &array_pool);
109110

110111
static exprt substitute_array_access(
111112
const index_exprt &index_expr,
@@ -955,12 +956,14 @@ void string_refinementt::add_lemma(
955956
/// \param ns: namespace
956957
/// \param stream: output stream for warning messages
957958
/// \param arr: expression of type array representing a string
959+
/// \param array_pool: pool of arrays representing strings
958960
/// \return an optional array expression or array_of_exprt
959961
static optionalt<exprt> get_array(
960962
const std::function<exprt(const exprt &)> &super_get,
961963
const namespacet &ns,
962964
messaget::mstreamt &stream,
963-
const array_string_exprt &arr)
965+
const array_string_exprt &arr,
966+
const array_poolt &array_pool)
964967
{
965968
const exprt &size = arr.length();
966969
exprt arr_val = simplify_expr(adjust_if_recursive(super_get(arr), ns), ns);
@@ -1028,17 +1031,19 @@ static std::string string_of_array(const array_exprt &arr)
10281031
/// \param ns: namespace
10291032
/// \param stream: output stream
10301033
/// \param arr: array expression
1034+
/// \param array_pool: pool of arrays representing strings
10311035
/// \return expression corresponding to `arr` in the model
10321036
static exprt get_char_array_and_concretize(
10331037
const std::function<exprt(const exprt &)> &super_get,
10341038
const namespacet &ns,
10351039
messaget::mstreamt &stream,
1036-
const array_string_exprt &arr)
1040+
const array_string_exprt &arr,
1041+
array_poolt &array_pool)
10371042
{
10381043
stream << "- " << format(arr) << ":\n";
10391044
stream << std::string(4, ' ') << "- type: " << format(arr.type())
10401045
<< messaget::eom;
1041-
const auto arr_model_opt = get_array(super_get, ns, stream, arr);
1046+
const auto arr_model_opt = get_array(super_get, ns, stream, arr, array_pool);
10421047
if(arr_model_opt)
10431048
{
10441049
stream << std::string(4, ' ') << "- char_array: " << format(*arr_model_opt)
@@ -1049,8 +1054,8 @@ static exprt get_char_array_and_concretize(
10491054
stream << std::string(4, ' ')
10501055
<< "- simplified_char_array: " << format(simple) << messaget::eom;
10511056
if(
1052-
const auto concretized_array =
1053-
get_array(super_get, ns, stream, to_array_string_expr(simple)))
1057+
const auto concretized_array = get_array(
1058+
super_get, ns, stream, to_array_string_expr(simple), array_pool))
10541059
{
10551060
stream << std::string(4, ' ')
10561061
<< "- concretized_char_array: " << format(*concretized_array)
@@ -1081,14 +1086,15 @@ void debug_model(
10811086
messaget::mstreamt &stream,
10821087
const namespacet &ns,
10831088
const std::function<exprt(const exprt &)> &super_get,
1084-
const std::vector<symbol_exprt> &symbols)
1089+
const std::vector<symbol_exprt> &symbols,
1090+
array_poolt &array_pool)
10851091
{
10861092
stream << "debug_model:" << '\n';
10871093
for(const auto &pointer_array : generator.array_pool.get_arrays_of_pointers())
10881094
{
10891095
const auto arr = pointer_array.second;
10901096
const exprt model =
1091-
get_char_array_and_concretize(super_get, ns, stream, arr);
1097+
get_char_array_and_concretize(super_get, ns, stream, arr, array_pool);
10921098

10931099
stream << "- " << format(arr) << ":\n"
10941100
<< " - pointer: " << format(pointer_array.first) << "\n"
@@ -1333,7 +1339,12 @@ static std::pair<bool, std::vector<exprt>> check_axioms(
13331339

13341340
#ifdef DEBUG
13351341
debug_model(
1336-
generator, stream, ns, get, generator.fresh_symbol.created_symbols);
1342+
generator,
1343+
stream,
1344+
ns,
1345+
get,
1346+
generator.fresh_symbol.created_symbols,
1347+
generator.array_pool);
13371348
#endif
13381349

13391350
// Maps from indexes of violated universal axiom to a witness of violation
@@ -1831,7 +1842,9 @@ exprt string_refinementt::get(const exprt &expr) const
18311842
dependencies.eval(arr, [&](const exprt &expr) { return get(expr); }))
18321843
return *from_dependencies;
18331844

1834-
if(const auto arr_model_opt = get_array(super_get, ns, log.debug(), arr))
1845+
if(
1846+
const auto arr_model_opt =
1847+
get_array(super_get, ns, log.debug(), arr, generator.array_pool))
18351848
return *arr_model_opt;
18361849

18371850
if(

0 commit comments

Comments
 (0)