Skip to content

Commit 258f38a

Browse files
Evaluate strings that are if expression
This makes the evalutation of string be able to handle if-then-else expressions.
1 parent fa2b500 commit 258f38a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/solvers/refinement/string_refinement_util.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,17 @@ optionalt<std::vector<mp_integer>> eval_string(
223223
const array_string_exprt &a,
224224
const std::function<exprt(const exprt&)> &get_value)
225225
{
226+
if(a.id() == ID_if)
227+
{
228+
const if_exprt &ite = to_if_expr(a);
229+
const exprt cond = get_value(ite.cond());
230+
if(!cond.is_constant())
231+
return {};
232+
return cond.is_true()
233+
? eval_string(to_array_string_expr(ite.true_case()), get_value)
234+
: eval_string(to_array_string_expr(ite.false_case()), get_value);
235+
}
236+
226237
const auto size = numeric_cast<std::size_t>(get_value(a.length()));
227238
const exprt content = get_value(a.content());
228239
const auto &array = expr_try_dynamic_cast<array_exprt>(content);

0 commit comments

Comments
 (0)