Skip to content

Commit 69f31c1

Browse files
Add eval function to string_dependenciest
1 parent 357cb44 commit 69f31c1

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/solvers/refinement/string_refinement_util.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,21 @@ string_dependenciest::get_string_node(node_indext i) const
481481
return {};
482482
}
483483

484+
optionalt<exprt> string_dependenciest::eval(
485+
const array_string_exprt &s,
486+
const std::function<exprt(const exprt &)> &get_value) const
487+
{
488+
const auto node = node_at(s);
489+
if(node && node->dependencies.size() == 1)
490+
{
491+
const auto &f = get_builtin_function(node->dependencies[0]);
492+
const auto result = f.string_result();
493+
if(result && *result == s)
494+
return f.eval(get_value);
495+
}
496+
return {};
497+
}
498+
484499
bool add_node(
485500
string_dependenciest &dependencies,
486501
const equal_exprt &equation,

src/solvers/refinement/string_refinement_util.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,12 @@ class string_dependenciest
306306
/// Mark node for `e` as depending on unknown builtin_function
307307
void add_unknown_dependency(const array_string_exprt &e);
308308

309+
/// Attempt to evaluate the given string from the dependencies and valuation
310+
/// of strings on which it depends
311+
optionalt<exprt> eval(
312+
const array_string_exprt &s,
313+
const std::function<exprt(const exprt &)> &get_value) const;
314+
309315
void output_dot(std::ostream &stream) const;
310316

311317
private:

0 commit comments

Comments
 (0)