mirror of
https://github.com/Z3Prover/z3
synced 2025-06-28 08:58:44 +00:00
integrate lambda expressions
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
bf4edef761
commit
520ce9a5ee
139 changed files with 2243 additions and 1506 deletions
|
@ -20,9 +20,10 @@ Revision History:
|
|||
|
||||
namespace smt {
|
||||
|
||||
fingerprint::fingerprint(region & r, void * d, unsigned d_h, unsigned n, enode * const * args):
|
||||
fingerprint::fingerprint(region & r, void * d, unsigned d_h, expr* def, unsigned n, enode * const * args):
|
||||
m_data(d),
|
||||
m_data_hash(d_h),
|
||||
m_def(def),
|
||||
m_num_args(n),
|
||||
m_args(nullptr) {
|
||||
m_args = new (r) enode*[n];
|
||||
|
@ -50,8 +51,18 @@ namespace smt {
|
|||
m_dummy.m_args = m_tmp.c_ptr();
|
||||
return &m_dummy;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, fingerprint const& f) {
|
||||
out << f.get_data_hash() << " " << " num_args " << f.get_num_args() << " ";
|
||||
for (enode const * arg : f) {
|
||||
out << " " << arg->get_owner_id();
|
||||
}
|
||||
out << "\n";
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
fingerprint * fingerprint_set::insert(void * data, unsigned data_hash, unsigned num_args, enode * const * args) {
|
||||
fingerprint * fingerprint_set::insert(void * data, unsigned data_hash, unsigned num_args, enode * const * args, expr* def) {
|
||||
fingerprint * d = mk_dummy(data, data_hash, num_args, args);
|
||||
if (m_set.contains(d))
|
||||
return nullptr;
|
||||
|
@ -66,11 +77,10 @@ namespace smt {
|
|||
tout << "\n";);
|
||||
return nullptr;
|
||||
}
|
||||
TRACE("fingerprint_bug", tout << "2) inserting: " << data_hash << " num_args: " << num_args;
|
||||
for (unsigned i = 0; i < num_args; i++) tout << " " << args[i]->get_owner_id();
|
||||
tout << "\n";);
|
||||
fingerprint * f = new (m_region) fingerprint(m_region, data, data_hash, num_args, d->m_args);
|
||||
TRACE("fingerprint_bug", tout << "2) inserting: " << *d;);
|
||||
fingerprint * f = new (m_region) fingerprint(m_region, data, data_hash, def, num_args, d->m_args);
|
||||
m_fingerprints.push_back(f);
|
||||
m_defs.push_back(def);
|
||||
m_set.insert(f);
|
||||
return f;
|
||||
}
|
||||
|
@ -89,6 +99,7 @@ namespace smt {
|
|||
void fingerprint_set::reset() {
|
||||
m_set.reset();
|
||||
m_fingerprints.reset();
|
||||
m_defs.reset();
|
||||
}
|
||||
|
||||
void fingerprint_set::push_scope() {
|
||||
|
@ -104,20 +115,15 @@ namespace smt {
|
|||
for (unsigned i = old_size; i < size; i++)
|
||||
m_set.erase(m_fingerprints[i]);
|
||||
m_fingerprints.shrink(old_size);
|
||||
m_defs.shrink(old_size);
|
||||
m_scopes.shrink(new_lvl);
|
||||
}
|
||||
|
||||
void fingerprint_set::display(std::ostream & out) const {
|
||||
out << "fingerprints:\n";
|
||||
SASSERT(m_set.size() == m_fingerprints.size());
|
||||
ptr_vector<fingerprint>::const_iterator it = m_fingerprints.begin();
|
||||
ptr_vector<fingerprint>::const_iterator end = m_fingerprints.end();
|
||||
for (; it != end; ++it) {
|
||||
fingerprint const * f = *it;
|
||||
out << f->get_data() << " #" << f->get_data_hash();
|
||||
for (unsigned i = 0; i < f->get_num_args(); i++)
|
||||
out << " #" << f->get_arg(i)->get_owner_id();
|
||||
out << "\n";
|
||||
for (fingerprint const * f : m_fingerprints) {
|
||||
out << f->get_data() << " " << *f;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,10 +132,7 @@ namespace smt {
|
|||
\brief Slow function for checking if there is a fingerprint congruent to (data args[0] ... args[num_args-1])
|
||||
*/
|
||||
bool fingerprint_set::slow_contains(void const * data, unsigned data_hash, unsigned num_args, enode * const * args) const {
|
||||
ptr_vector<fingerprint>::const_iterator it = m_fingerprints.begin();
|
||||
ptr_vector<fingerprint>::const_iterator end = m_fingerprints.end();
|
||||
for (; it != end; ++it) {
|
||||
fingerprint const * f = *it;
|
||||
for (fingerprint const* f : m_fingerprints) {
|
||||
if (f->get_data() != data)
|
||||
continue;
|
||||
if (f->get_num_args() != num_args)
|
||||
|
@ -139,12 +142,7 @@ namespace smt {
|
|||
if (f->get_arg(i)->get_root() != args[i]->get_root())
|
||||
break;
|
||||
if (i == num_args) {
|
||||
TRACE("missing_instance_detail", tout << "found instance data: " << data << "=" << f->get_data() << " hash: " << f->get_data_hash();
|
||||
for (unsigned i = 0; i < num_args; i++) {
|
||||
tout << " " << f->get_arg(i)->get_owner_id() << ":" << f->get_arg(i)->get_root()->get_owner_id() << "="
|
||||
<< args[i]->get_owner_id() << ":" << args[i]->get_root()->get_owner_id();
|
||||
}
|
||||
tout << "\n";);
|
||||
TRACE("missing_instance_detail", tout << "found instance data: " << data << "=" << *f;);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue