mirror of
https://github.com/Z3Prover/z3
synced 2025-08-21 18:50:26 +00:00
adding unit tests for doc
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
4eadaabe64
commit
2a00f2b38c
5 changed files with 153 additions and 24 deletions
|
@ -22,49 +22,81 @@ Revision History:
|
|||
|
||||
#include "doc.h"
|
||||
void doc_manager::reset() {
|
||||
// m.reset(); - not until docs are in small object allocator.
|
||||
}
|
||||
doc* doc_manager::allocate() {
|
||||
return 0;
|
||||
return alloc(doc, m.allocate());
|
||||
}
|
||||
doc* doc_manager::allocate1() {
|
||||
return 0;
|
||||
return alloc(doc, m.allocate1());
|
||||
}
|
||||
doc* doc_manager::allocate0() {
|
||||
return 0;
|
||||
return alloc(doc, m.allocate0());
|
||||
}
|
||||
doc* doc_manager::allocateX() {
|
||||
return 0;
|
||||
return alloc(doc, m.allocateX());
|
||||
}
|
||||
doc* doc_manager::allocate(doc const& src) {
|
||||
return 0;
|
||||
doc* r = alloc(doc, m.allocate(src.pos()));
|
||||
for (unsigned i = 0; i < src.neg().size(); ++i) {
|
||||
r->neg().push_back(m.allocate(src.neg()[i]));
|
||||
}
|
||||
return r;
|
||||
}
|
||||
doc* doc_manager::allocate(uint64 n) {
|
||||
return 0;
|
||||
return alloc(doc, m.allocate(n));
|
||||
}
|
||||
doc* doc_manager::allocate(rational const& r) {
|
||||
return 0;
|
||||
return alloc(doc, m.allocate(r));
|
||||
}
|
||||
doc* doc_manager::allocate(uint64 n, unsigned hi, unsigned lo) {
|
||||
return 0;
|
||||
return alloc(doc, m.allocate(n, hi, lo));
|
||||
}
|
||||
doc* doc_manager::allocate(doc, unsigned const* permutation) {
|
||||
return 0;
|
||||
doc* doc_manager::allocate(doc const& src, unsigned const* permutation) {
|
||||
doc* r = alloc(doc, m.allocate(src.pos(), permutation));
|
||||
for (unsigned i = 0; i < src.neg().size(); ++i) {
|
||||
r->neg().push_back(m.allocate(src.neg()[i], permutation));
|
||||
}
|
||||
return r;
|
||||
}
|
||||
void doc_manager::deallocate(doc* src) {
|
||||
dealloc(src);
|
||||
}
|
||||
void doc_manager::copy(doc& dst, doc const& src) const {
|
||||
void doc_manager::copy(doc& dst, doc const& src) {
|
||||
m.copy(dst.pos(), src.pos());
|
||||
unsigned n = std::min(src.neg().size(), dst.neg().size());
|
||||
for (unsigned i = 0; i < n; ++i) {
|
||||
m.copy(dst.neg()[i], src.neg()[i]);
|
||||
}
|
||||
for (unsigned i = n; i < dst.neg().size(); ++i) {
|
||||
dst.neg().erase(m, dst.neg().size()-1);
|
||||
}
|
||||
for (unsigned i = n; i < src.neg().size(); ++i) {
|
||||
dst.neg().push_back(m.allocate(src.neg()[i]));
|
||||
}
|
||||
}
|
||||
doc& doc_manager::fill0(doc& src) const {
|
||||
doc& doc_manager::fill0(doc& src) {
|
||||
src.neg().reset(m);
|
||||
m.fill0(src.pos());
|
||||
return src;
|
||||
}
|
||||
doc& doc_manager::fill1(doc& src) const {
|
||||
doc& doc_manager::fill1(doc& src) {
|
||||
src.neg().reset(m);
|
||||
m.fill1(src.pos());
|
||||
return src;
|
||||
}
|
||||
doc& doc_manager::fillX(doc& src) const {
|
||||
doc& doc_manager::fillX(doc& src) {
|
||||
src.neg().reset(m);
|
||||
m.fillX(src.pos());
|
||||
return src;
|
||||
}
|
||||
bool doc_manager::set_and(doc& dst, doc const& src) const {
|
||||
return false;
|
||||
bool doc_manager::set_and(doc& dst, doc const& src) {
|
||||
// (A \ B) & (C \ D) = (A & C) \ (B u D)
|
||||
if (!m.set_and(dst.pos(), src.pos())) return false;
|
||||
for (unsigned i = 0; i < src.neg().size(); ++i) {
|
||||
dst.neg().insert(m, m.allocate(src.neg()[i]));
|
||||
}
|
||||
return (src.neg().is_empty() || fold_neg(dst));
|
||||
}
|
||||
bool doc_manager::fold_neg(doc& dst) {
|
||||
start_over:
|
||||
|
|
|
@ -44,15 +44,15 @@ public:
|
|||
doc* allocate(uint64 n);
|
||||
doc* allocate(rational const& r);
|
||||
doc* allocate(uint64 n, unsigned hi, unsigned lo);
|
||||
doc* allocate(doc, unsigned const* permutation);
|
||||
doc* allocate(doc const& src, unsigned const* permutation);
|
||||
void deallocate(doc* src);
|
||||
void copy(doc& dst, doc const& src) const;
|
||||
doc& reset(doc& src) const { return fill0(src); }
|
||||
doc& fill0(doc& src) const;
|
||||
doc& fill1(doc& src) const;
|
||||
doc& fillX(doc& src) const;
|
||||
void copy(doc& dst, doc const& src);
|
||||
doc& reset(doc& src) { return fill0(src); }
|
||||
doc& fill0(doc& src);
|
||||
doc& fill1(doc& src);
|
||||
doc& fillX(doc& src);
|
||||
bool is_full(doc const& src) const;
|
||||
bool set_and(doc& dst, doc const& src) const;
|
||||
bool set_and(doc& dst, doc const& src);
|
||||
bool fold_neg(doc& dst);
|
||||
bool intersect(doc const& A, doc const& B, doc& result) const;
|
||||
void complement(doc const& src, ptr_vector<doc>& result);
|
||||
|
@ -328,6 +328,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
doc(tbv* t): m_pos(t) {}
|
||||
tbv& pos() { return *m_pos; }
|
||||
utbv& neg() { return m_neg; }
|
||||
tbv const& pos() const { return *m_pos; }
|
||||
|
@ -349,6 +350,7 @@ public:
|
|||
doc_ref& operator=(doc* d2) {
|
||||
if (d) dm.deallocate(d);
|
||||
d = d2;
|
||||
return *this;
|
||||
}
|
||||
doc& operator*() { return *d; }
|
||||
doc* operator->() { return d; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue