mirror of
https://github.com/Z3Prover/z3
synced 2025-04-12 20:18:18 +00:00
factored out is_variable_proc to a header file
This commit is contained in:
parent
42e7d29df3
commit
ac6ca4d334
|
@ -36,44 +36,7 @@ Revision History:
|
||||||
#include "cooperate.h"
|
#include "cooperate.h"
|
||||||
#include "datatype_decl_plugin.h"
|
#include "datatype_decl_plugin.h"
|
||||||
|
|
||||||
class is_variable_proc {
|
#include "qe_vartest.h"
|
||||||
public:
|
|
||||||
virtual bool operator()(expr* e) const = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
class is_variable_test : public is_variable_proc {
|
|
||||||
enum is_var_kind { BY_VAR_SET, BY_VAR_SET_COMPLEMENT, BY_NUM_DECLS };
|
|
||||||
uint_set m_var_set;
|
|
||||||
unsigned m_num_decls;
|
|
||||||
is_var_kind m_var_kind;
|
|
||||||
public:
|
|
||||||
is_variable_test(uint_set const& vars, bool index_of_bound) :
|
|
||||||
m_var_set(vars),
|
|
||||||
m_num_decls(0),
|
|
||||||
m_var_kind(index_of_bound?BY_VAR_SET:BY_VAR_SET_COMPLEMENT) {}
|
|
||||||
|
|
||||||
is_variable_test(unsigned num_decls) :
|
|
||||||
m_num_decls(num_decls),
|
|
||||||
m_var_kind(BY_NUM_DECLS) {}
|
|
||||||
|
|
||||||
virtual bool operator()(expr* e) const {
|
|
||||||
if (!is_var(e)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
unsigned idx = to_var(e)->get_idx();
|
|
||||||
switch(m_var_kind) {
|
|
||||||
case BY_VAR_SET:
|
|
||||||
return m_var_set.contains(idx);
|
|
||||||
case BY_VAR_SET_COMPLEMENT:
|
|
||||||
return !m_var_set.contains(idx);
|
|
||||||
case BY_NUM_DECLS:
|
|
||||||
return idx < m_num_decls;
|
|
||||||
}
|
|
||||||
UNREACHABLE();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
namespace eq {
|
namespace eq {
|
||||||
class der {
|
class der {
|
||||||
|
|
63
src/qe/qe_vartest.h
Normal file
63
src/qe/qe_vartest.h
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
/*++
|
||||||
|
Copyright (c) 2013 Microsoft Corporation
|
||||||
|
|
||||||
|
Module Name:
|
||||||
|
|
||||||
|
qe_vartest.h
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
Utilities for quantifiers.
|
||||||
|
|
||||||
|
Author:
|
||||||
|
|
||||||
|
Nikolaj Bjorner (nbjorner) 2013-08-28
|
||||||
|
|
||||||
|
Revision History:
|
||||||
|
|
||||||
|
--*/
|
||||||
|
#ifndef QE_VARTEST_H_
|
||||||
|
#define QE_VARTEST_H_
|
||||||
|
|
||||||
|
#include "ast.h"
|
||||||
|
#include "uint_set.h"
|
||||||
|
|
||||||
|
class is_variable_proc {
|
||||||
|
public:
|
||||||
|
virtual bool operator()(expr* e) const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class is_variable_test : public is_variable_proc {
|
||||||
|
enum is_var_kind { BY_VAR_SET, BY_VAR_SET_COMPLEMENT, BY_NUM_DECLS };
|
||||||
|
uint_set m_var_set;
|
||||||
|
unsigned m_num_decls;
|
||||||
|
is_var_kind m_var_kind;
|
||||||
|
public:
|
||||||
|
is_variable_test(uint_set const& vars, bool index_of_bound) :
|
||||||
|
m_var_set(vars),
|
||||||
|
m_num_decls(0),
|
||||||
|
m_var_kind(index_of_bound?BY_VAR_SET:BY_VAR_SET_COMPLEMENT) {}
|
||||||
|
|
||||||
|
is_variable_test(unsigned num_decls) :
|
||||||
|
m_num_decls(num_decls),
|
||||||
|
m_var_kind(BY_NUM_DECLS) {}
|
||||||
|
|
||||||
|
virtual bool operator()(expr* e) const {
|
||||||
|
if (!is_var(e)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
unsigned idx = to_var(e)->get_idx();
|
||||||
|
switch(m_var_kind) {
|
||||||
|
case BY_VAR_SET:
|
||||||
|
return m_var_set.contains(idx);
|
||||||
|
case BY_VAR_SET_COMPLEMENT:
|
||||||
|
return !m_var_set.contains(idx);
|
||||||
|
case BY_NUM_DECLS:
|
||||||
|
return idx < m_num_decls;
|
||||||
|
}
|
||||||
|
UNREACHABLE();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in a new issue