mirror of
https://github.com/Z3Prover/z3
synced 2025-06-13 17:36:15 +00:00
make it easier to use string literals
This commit is contained in:
parent
31b7ad3012
commit
7dd7d83a36
2 changed files with 13 additions and 1 deletions
|
@ -1100,6 +1100,10 @@ def _coerce_expr_merge(s, a):
|
||||||
if z3_debug():
|
if z3_debug():
|
||||||
_z3_assert(s1.ctx == s.ctx, "context mismatch")
|
_z3_assert(s1.ctx == s.ctx, "context mismatch")
|
||||||
_z3_assert(False, "sort mismatch")
|
_z3_assert(False, "sort mismatch")
|
||||||
|
elif s:
|
||||||
|
return s
|
||||||
|
elif isinstance(a, str):
|
||||||
|
return StringSort()
|
||||||
else:
|
else:
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
@ -1107,6 +1111,10 @@ def _coerce_exprs(a, b, ctx=None):
|
||||||
if not is_expr(a) and not is_expr(b):
|
if not is_expr(a) and not is_expr(b):
|
||||||
a = _py2expr(a, ctx)
|
a = _py2expr(a, ctx)
|
||||||
b = _py2expr(b, ctx)
|
b = _py2expr(b, ctx)
|
||||||
|
if isinstance(a, str):
|
||||||
|
a = StringVal(a, ctx)
|
||||||
|
if isinstance(b, str):
|
||||||
|
b = StringVal(b, ctx)
|
||||||
s = None
|
s = None
|
||||||
s = _coerce_expr_merge(s, a)
|
s = _coerce_expr_merge(s, a)
|
||||||
s = _coerce_expr_merge(s, b)
|
s = _coerce_expr_merge(s, b)
|
||||||
|
@ -2934,6 +2942,8 @@ def _py2expr(a, ctx=None):
|
||||||
return IntVal(a, ctx)
|
return IntVal(a, ctx)
|
||||||
if isinstance(a, float):
|
if isinstance(a, float):
|
||||||
return RealVal(a, ctx)
|
return RealVal(a, ctx)
|
||||||
|
if isinstance(a, str):
|
||||||
|
return StringVal(a, ctx)
|
||||||
if is_expr(a):
|
if is_expr(a):
|
||||||
return a
|
return a
|
||||||
if z3_debug():
|
if z3_debug():
|
||||||
|
|
|
@ -180,8 +180,10 @@ bool zstring::uses_unicode() const {
|
||||||
|
|
||||||
bool zstring::well_formed() const {
|
bool zstring::well_formed() const {
|
||||||
for (unsigned ch : m_buffer) {
|
for (unsigned ch : m_buffer) {
|
||||||
if (ch > unicode_max_char())
|
if (ch > unicode_max_char()) {
|
||||||
|
IF_VERBOSE(0, verbose_stream() << "large character: " << ch << "\n";);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue