Skip to content

Commit a468227

Browse files
Make node point to builtin func they result from
This make finding the function the string results from easier.
1 parent 1c8a08c commit a468227

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/solvers/refinement/string_refinement_util.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -496,17 +496,14 @@ optionalt<exprt> string_dependenciest::eval(
496496
return eval_string_cache[it->second];
497497

498498
const auto node = string_nodes[it->second];
499-
500-
if(node.dependencies.size() == 1)
499+
const auto &f = node.result_from;
500+
if(
501+
f && node.dependencies.size() == 1 &&
502+
!node.depends_on_unknown_builtin_function)
501503
{
502-
const auto &f = get_builtin_function(node.dependencies[0]);
503-
const auto result = f.string_result();
504-
if(result && *result == s)
505-
{
506-
const auto value_opt = f.eval(get_value);
507-
eval_string_cache[it->second] = value_opt;
508-
return value_opt;
509-
}
504+
const auto value_opt = get_builtin_function(*f).eval(get_value);
505+
eval_string_cache[it->second] = value_opt;
506+
return value_opt;
510507
}
511508
return {};
512509
}
@@ -543,7 +540,11 @@ bool add_node(
543540
if(
544541
const auto &string_result =
545542
dependencies.get_builtin_function(builtin_function_node).string_result())
543+
{
546544
dependencies.add_dependency(*string_result, builtin_function_node);
545+
auto &node = dependencies.get_node(*string_result);
546+
node.result_from = builtin_function_node;
547+
}
547548
else
548549
add_dependency_to_string_subexprs(
549550
dependencies, *fun_app, builtin_function_node, array_pool);

src/solvers/refinement/string_refinement_util.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,8 @@ class string_dependenciest
316316
std::size_t index;
317317
// builtin functions on which it depends
318318
std::vector<builtin_function_nodet> dependencies;
319+
// builtin function of which it is the result
320+
optionalt<builtin_function_nodet> result_from;
319321
// In case it depends on a builtin_function we don't support yet
320322
bool depends_on_unknown_builtin_function = false;
321323

0 commit comments

Comments
 (0)