mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 17:15:31 +00:00
Add get_sort(expr * n) function that does not depend on ast_manager. Move power_of_two to rational class. Add arith_recognizers and bv_recognizers classes. The two new classes contain the 'read-only' methods from arith_util and bv_util.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
4f0d5a5756
commit
cec328cfdc
17 changed files with 314 additions and 282 deletions
|
@ -27,6 +27,31 @@ synch_mpq_manager * rational::g_mpq_manager = 0;
|
|||
rational rational::m_zero(0);
|
||||
rational rational::m_one(1);
|
||||
rational rational::m_minus_one(-1);
|
||||
vector<rational> rational::m_powers_of_two;
|
||||
|
||||
void mk_power_up_to(vector<rational> & pws, unsigned n) {
|
||||
if (pws.empty()) {
|
||||
pws.push_back(rational(1));
|
||||
}
|
||||
unsigned sz = pws.size();
|
||||
rational curr = pws[sz - 1];
|
||||
rational two(2);
|
||||
for (unsigned i = sz; i <= n; i++) {
|
||||
curr *= two;
|
||||
pws.push_back(curr);
|
||||
}
|
||||
}
|
||||
|
||||
rational rational::power_of_two(unsigned k) {
|
||||
rational result;
|
||||
#pragma omp critical (powers_of_two)
|
||||
{
|
||||
if (k >= m_powers_of_two.size())
|
||||
mk_power_up_to(m_powers_of_two, k+1);
|
||||
result = m_powers_of_two[k];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void rational::initialize() {
|
||||
if (!g_mpq_manager) {
|
||||
|
@ -35,6 +60,7 @@ void rational::initialize() {
|
|||
}
|
||||
|
||||
void rational::finalize() {
|
||||
m_powers_of_two.finalize();
|
||||
dealloc(g_mpq_manager);
|
||||
g_mpq_manager = 0;
|
||||
}
|
||||
|
|
|
@ -26,14 +26,13 @@ class rational {
|
|||
static rational m_zero;
|
||||
static rational m_one;
|
||||
static rational m_minus_one;
|
||||
|
||||
static vector<rational> m_powers_of_two;
|
||||
static synch_mpq_manager * g_mpq_manager;
|
||||
|
||||
|
||||
static synch_mpq_manager & m() { return *g_mpq_manager; }
|
||||
|
||||
public:
|
||||
static void initialize();
|
||||
|
||||
static void finalize();
|
||||
/*
|
||||
ADD_INITIALIZER('rational::initialize();')
|
||||
|
@ -272,6 +271,8 @@ public:
|
|||
return result;
|
||||
}
|
||||
|
||||
static rational power_of_two(unsigned k);
|
||||
|
||||
bool is_power_of_two(unsigned & shift) {
|
||||
return m().is_power_of_two(m_val, shift);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue