3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 17:15:31 +00:00

Reorganizing the code

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2012-10-20 19:54:08 -07:00
parent 8b70f0b833
commit d8cd3fc3ab
36 changed files with 261 additions and 429 deletions

66
src/util/plugin_manager.h Normal file
View file

@ -0,0 +1,66 @@
/*++
Copyright (c) 2006 Microsoft Corporation
Module Name:
plugin_manager.h
Abstract:
<abstract>
Author:
Leonardo de Moura (leonardo) 2007-09-18.
Revision History:
--*/
#ifndef _PLUGIN_MANAGER_H_
#define _PLUGIN_MANAGER_H_
#include"util.h"
template<typename Plugin>
class plugin_manager {
ptr_vector<Plugin> m_fid2plugins;
ptr_vector<Plugin> m_plugins;
public:
~plugin_manager() {
std::for_each(m_plugins.begin(), m_plugins.end(), delete_proc<Plugin>());
}
/**
\brief Release ownership of the plugins.
*/
void release() {
m_fid2plugins.reset();
m_plugins.reset();
}
void register_plugin(Plugin * p) {
SASSERT(p);
family_id fid = p->get_family_id();
SASSERT(m_fid2plugins.get(fid, 0) == 0);
m_fid2plugins.setx(fid, p, 0);
m_plugins.push_back(p);
}
Plugin * get_plugin(family_id fid) const {
if (fid == null_family_id) {
return 0;
}
return m_fid2plugins.get(fid, 0);
}
typename ptr_vector<Plugin>::const_iterator begin() const {
return m_plugins.begin();
}
typename ptr_vector<Plugin>::const_iterator end() const {
return m_plugins.end();
}
};
#endif /* _PLUGIN_MANAGER_H_ */

62
src/util/smt2_util.cpp Normal file
View file

@ -0,0 +1,62 @@
/*++
Copyright (c) 2011 Microsoft Corporation
Module Name:
smt2_util.cpp
Abstract:
Goodies for SMT2 standard
Author:
Leonardo (leonardo) 2012-10-20
Notes:
--*/
#include"smt2_util.h"
bool is_smt2_simple_symbol_char(char s) {
return
('0' <= s && s <= '9') ||
('a' <= s && s <= 'z') ||
('A' <= s && s <= 'Z') ||
s == '~' || s == '!' || s == '@' || s == '$' || s == '%' || s == '^' || s == '&' ||
s == '*' || s == '_' || s == '-' || s == '+' || s == '=' || s == '<' || s == '>' ||
s == '.' || s == '?' || s == '/';
}
bool is_smt2_quoted_symbol(char const * s) {
if (s == 0)
return false;
if ('0' <= s[0] && s[0] <= '9')
return true;
unsigned len = static_cast<unsigned>(strlen(s));
for (unsigned i = 0; i < len; i++)
if (!is_smt2_simple_symbol_char(s[i]))
return true;
return false;
}
bool is_smt2_quoted_symbol(symbol const & s) {
if (s.is_numerical())
return false;
return is_smt2_quoted_symbol(s.bare_str());
}
std::string mk_smt2_quoted_symbol(symbol const & s) {
SASSERT(is_smt2_quoted_symbol(s));
string_buffer<> buffer;
buffer.append('|');
char const * str = s.bare_str();
while (*str) {
if (*str == '|' || *str == '\\')
buffer.append('\\');
buffer.append(*str);
str++;
}
buffer.append('|');
return std::string(buffer.c_str());
}

29
src/util/smt2_util.h Normal file
View file

@ -0,0 +1,29 @@
/*++
Copyright (c) 2011 Microsoft Corporation
Module Name:
smt2_util.h
Abstract:
Goodies for SMT2 standard
Author:
Leonardo (leonardo) 2012-10-20
Notes:
--*/
#ifndef _SMT2_UTIL_H_
#define _SMT2_UTIL_H_
#include"symbol.h"
bool is_smt2_simple_symbol_char(char c);
bool is_smt2_quoted_symbol(char const * s);
bool is_smt2_quoted_symbol(symbol const & s);
std::string mk_smt2_quoted_symbol(symbol const & s);
#endif