Skip to content

Commit 20b5366

Browse files
Add validate and can_cast method to string_exprt
1 parent a61ea38 commit 20b5366

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/util/string_expr.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,4 +241,18 @@ inline const refined_string_exprt &to_string_expr(const exprt &expr)
241241
return static_cast<const refined_string_exprt &>(expr);
242242
}
243243

244+
template <>
245+
inline bool can_cast_expr<refined_string_exprt>(const exprt &base)
246+
{
247+
return base.id() == ID_struct && base.operands().size() == 2;
248+
}
249+
250+
inline void validate_expr(const refined_string_exprt &x)
251+
{
252+
INVARIANT(x.id() == ID_struct, "refined string exprs are struct");
253+
validate_operands(x, 2, "refined string expr has length and content fields");
254+
INVARIANT(x.length().type().id() == ID_signedbv, "length is an unsigned int");
255+
INVARIANT(x.content().type().id() == ID_array, "content is an array");
256+
}
257+
244258
#endif

0 commit comments

Comments
 (0)