mirror of
https://github.com/Z3Prover/z3
synced 2025-08-23 11:37:54 +00:00
streamline unicode/ascii toggling. Fix bit-width for unicode to 18
This commit is contained in:
parent
90eb4de526
commit
03fd251ccb
6 changed files with 36 additions and 22 deletions
|
@ -1950,7 +1950,7 @@ br_status seq_rewriter::mk_str_lt(expr* a, expr* b, expr_ref& result) {
|
|||
br_status seq_rewriter::mk_str_from_code(expr* a, expr_ref& result) {
|
||||
rational r;
|
||||
if (m_autil.is_numeral(a, r)) {
|
||||
if (r.is_neg() || r > zstring::max_char()) {
|
||||
if (r.is_neg() || r > u().max_char()) {
|
||||
result = str().mk_string(symbol(""));
|
||||
}
|
||||
else {
|
||||
|
@ -3979,19 +3979,19 @@ void seq_rewriter::elim_condition(expr* elem, expr_ref& cond) {
|
|||
if (u().is_char(elem)) {
|
||||
unsigned ch = 0;
|
||||
svector<std::pair<unsigned, unsigned>> ranges, ranges1;
|
||||
ranges.push_back(std::make_pair(0, zstring::max_char()));
|
||||
ranges.push_back(std::make_pair(0, u().max_char()));
|
||||
auto exclude_char = [&](unsigned ch) {
|
||||
if (ch == 0) {
|
||||
intersect(1, zstring::max_char(), ranges);
|
||||
intersect(1, u().max_char(), ranges);
|
||||
}
|
||||
else if (ch == zstring::max_char()) {
|
||||
else if (ch == u().max_char()) {
|
||||
intersect(0, ch-1, ranges);
|
||||
}
|
||||
else {
|
||||
ranges1.reset();
|
||||
ranges1.append(ranges);
|
||||
intersect(0, ch - 1, ranges);
|
||||
intersect(ch + 1, zstring::max_char(), ranges1);
|
||||
intersect(ch + 1, u().max_char(), ranges1);
|
||||
ranges.append(ranges1);
|
||||
}
|
||||
};
|
||||
|
@ -4007,7 +4007,7 @@ void seq_rewriter::elim_condition(expr* elem, expr_ref& cond) {
|
|||
intersect(0, ch, ranges);
|
||||
}
|
||||
else if (u().is_char_le(e, lhs, rhs) && elem == rhs && u().is_const_char(lhs, ch)) {
|
||||
intersect(ch, zstring::max_char(), ranges);
|
||||
intersect(ch, u().max_char(), ranges);
|
||||
}
|
||||
else if (m().is_not(e, e1) && m().is_eq(e1, lhs, rhs) && elem == lhs && u().is_const_char(rhs, ch)) {
|
||||
exclude_char(ch);
|
||||
|
@ -4017,10 +4017,10 @@ void seq_rewriter::elim_condition(expr* elem, expr_ref& cond) {
|
|||
}
|
||||
else if (m().is_not(e, e1) && u().is_char_le(e1, lhs, rhs) && elem == lhs && u().is_const_char(rhs, ch)) {
|
||||
// not (e <= ch)
|
||||
if (ch == zstring::max_char())
|
||||
if (ch == u().max_char())
|
||||
ranges.reset();
|
||||
else
|
||||
intersect(ch+1, zstring::max_char(), ranges);
|
||||
intersect(ch+1, u().max_char(), ranges);
|
||||
}
|
||||
else if (m().is_not(e, e1) && u().is_char_le(e1, lhs, rhs) && elem == rhs && u().is_const_char(lhs, ch)) {
|
||||
// not (ch <= e)
|
||||
|
|
|
@ -180,7 +180,7 @@ bool zstring::uses_unicode() const {
|
|||
|
||||
bool zstring::well_formed() const {
|
||||
for (unsigned ch : m_buffer) {
|
||||
if (ch > max_char())
|
||||
if (ch > unicode_max_char())
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -398,9 +398,8 @@ seq_decl_plugin::seq_decl_plugin(): m_init(false),
|
|||
}
|
||||
|
||||
void seq_decl_plugin::finalize() {
|
||||
for (psig* s : m_sigs) {
|
||||
for (psig* s : m_sigs)
|
||||
dealloc(s);
|
||||
}
|
||||
m_manager->dec_ref(m_string);
|
||||
m_manager->dec_ref(m_char);
|
||||
m_manager->dec_ref(m_reglan);
|
||||
|
@ -938,7 +937,7 @@ func_decl * seq_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters,
|
|||
if (!(num_parameters == 1 && arity == 0 &&
|
||||
parameters[0].is_int() &&
|
||||
0 <= parameters[0].get_int() &&
|
||||
parameters[0].get_int() < static_cast<int>(zstring::max_char()))) {
|
||||
parameters[0].get_int() < static_cast<int>(max_char()))) {
|
||||
m.raise_exception("invalid character declaration");
|
||||
}
|
||||
return m.mk_const_decl(m_charc_sym, m_char, func_decl_info(m_family_id, OP_CHAR_CONST, num_parameters, parameters));
|
||||
|
|
|
@ -118,8 +118,10 @@ private:
|
|||
bool uses_unicode() const;
|
||||
bool is_escape_char(char const *& s, unsigned& result);
|
||||
public:
|
||||
static unsigned max_char() { return 196607; }
|
||||
static unsigned num_bits() { return 16; }
|
||||
static unsigned unicode_max_char() { return 196607; }
|
||||
static unsigned unicode_num_bits() { return 18; }
|
||||
static unsigned ascii_max_char() { return 255; }
|
||||
static unsigned ascii_num_bits() { return 8; }
|
||||
zstring() {}
|
||||
zstring(char const* s);
|
||||
zstring(const std::string &str) : zstring(str.c_str()) {}
|
||||
|
@ -225,6 +227,9 @@ public:
|
|||
|
||||
bool is_char(ast* a) const { return a == m_char; }
|
||||
|
||||
unsigned max_char() const { return m_unicode ? zstring::unicode_max_char() : zstring::ascii_max_char(); }
|
||||
unsigned num_bits() const { return m_unicode ? zstring::unicode_num_bits() : zstring::ascii_num_bits(); }
|
||||
|
||||
app* mk_string(symbol const& s);
|
||||
app* mk_string(zstring const& s);
|
||||
app* mk_char(unsigned ch);
|
||||
|
@ -266,6 +271,8 @@ public:
|
|||
app* mk_char(unsigned ch) const;
|
||||
app* mk_le(expr* ch1, expr* ch2) const;
|
||||
app* mk_lt(expr* ch1, expr* ch2) const;
|
||||
unsigned max_char() const { return seq.max_char(); }
|
||||
unsigned num_bits() const { return seq.num_bits(); }
|
||||
|
||||
app* mk_skolem(symbol const& name, unsigned n, expr* const* args, sort* range);
|
||||
bool is_skolem(expr const* e) const { return is_app_of(e, m_fid, _OP_SEQ_SKOLEM); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue