* src/tgba/bddprint.cc (dict): Make this variable static.

(want_prom): New global static variable.
(print_handle): Honor want_prom.
(print_sat_handler, bdd_print_sat, bdd_format_sat): New functions.
(bdd_print_set, bdd_print_dot, bdd_print_table): Set want_prom.
* src/tgba/bddprint.hh (bdd_print_sat, bdd_format_sat): New functions.
* src/tgbaalgos/save.cc, src/tgbaalgos/save.hh,
src/tgbatest/readsave.cc, src/tgbatest/readsave.test: New files.
* src/tgbaalgos/Makefile.am (libtgbaalgos_la_SOURCES): Add
save.cc and save.hh.
* src/tgbatest/Makefile.am (check_PROGRAMS): Add readsave.
(readsave_SOURCES): New variable.
(TESTS): Add readsave.test.
This commit is contained in:
Alexandre Duret-Lutz 2003-06-05 16:22:30 +00:00
parent 6884a7f985
commit 19e47ee6e4
10 changed files with 237 additions and 8 deletions

View file

@ -5,7 +5,10 @@
namespace spot
{
/// Global dictionary used by print_handler() to lookup variables.
const tgba_bdd_dict* dict;
static const tgba_bdd_dict* dict;
/// Global flag to enable Prom[x] output (instead of `x').
static bool want_prom;
/// Stream handler used by Buddy to display BDD variables.
static void
@ -20,7 +23,11 @@ namespace spot
isi = dict->prom_formula_map.find(var);
if (isi != dict->prom_formula_map.end())
{
o << "Prom["; to_string(isi->second, o) << "]";
if (want_prom)
o << "Prom[";
to_string(isi->second, o);
if (want_prom)
o << "]";
}
else
{
@ -46,10 +53,49 @@ namespace spot
}
static std::ostream* where;
static void
print_sat_handler(char* varset, int size)
{
bool not_first = false;
for (int v = 0; v < size; ++v)
{
if (varset[v] < 0)
continue;
if (not_first)
*where << " ";
else
not_first = true;
if (varset[v] == 0)
*where << "!";
print_handler(*where, v);
}
}
std::ostream&
bdd_print_sat(std::ostream& os, const tgba_bdd_dict& d, bdd b)
{
dict = &d;
where = &os;
want_prom = false;
assert (bdd_satone(b) == b);
bdd_allsat (b, print_sat_handler);
return os;
}
std::string
bdd_format_sat(const tgba_bdd_dict& d, bdd b)
{
std::ostringstream os;
bdd_print_sat(os, d, b);
return os.str();
}
std::ostream&
bdd_print_set(std::ostream& os, const tgba_bdd_dict& d, bdd b)
{
dict = &d;
want_prom = true;
bdd_strm_hook(print_handler);
os << bddset << b;
bdd_strm_hook(0);
@ -68,6 +114,7 @@ namespace spot
bdd_print_dot(std::ostream& os, const tgba_bdd_dict& d, bdd b)
{
dict = &d;
want_prom = true;
bdd_strm_hook(print_handler);
os << bdddot << b;
bdd_strm_hook(0);
@ -78,6 +125,7 @@ namespace spot
bdd_print_table(std::ostream& os, const tgba_bdd_dict& d, bdd b)
{
dict = &d;
want_prom = true;
bdd_strm_hook(print_handler);
os << bddtable << b;
bdd_strm_hook(0);

View file

@ -9,29 +9,46 @@
namespace spot
{
/// \brief Print a BDD as a list of literals.
///
/// This assumes that \a b is a conjunction of literals.
/// \param os The output stream.
/// \param dict The dictionary to use, to lookup variables.
/// \param b The BDD to print.
std::ostream& bdd_print_sat(std::ostream& os,
const tgba_bdd_dict& dict, bdd b);
/// \brief Format a BDD as a list of literals.
///
/// This assumes that \a b is a conjunction of literals.
/// \param dict The dictionary to use, to lookup variables.
/// \param b The BDD to print.
/// \return The BDD formated as a string.
std::string bdd_format_sat(const tgba_bdd_dict& dict, bdd b);
/// \brief Print a BDD as a set.
/// \param os The output stream.
/// \param dict The dictionary to use, to lookup variables.
/// \param b The BDD to print.
/// \param b The BDD to print.
std::ostream& bdd_print_set(std::ostream& os,
const tgba_bdd_dict& dict, bdd b);
/// \brief Format a BDD as a set.
/// \param dict The dictionary to use, to lookup variables.
/// \param b The BDD to print.
/// \param b The BDD to print.
/// \return The BDD formated as a string.
std::string bdd_format_set(const tgba_bdd_dict& dict, bdd b);
/// \brief Print a BDD as a diagram in dotty format.
/// \param os The output stream.
/// \param dict The dictionary to use, to lookup variables.
/// \param b The BDD to print.
/// \param b The BDD to print.
std::ostream& bdd_print_dot(std::ostream& os,
const tgba_bdd_dict& dict, bdd b);
/// \brief Print a BDD as a table.
/// \param os The output stream.
/// \param dict The dictionary to use, to lookup variables.
/// \param b The BDD to print.
/// \param b The BDD to print.
std::ostream& bdd_print_table(std::ostream& os,
const tgba_bdd_dict& dict, bdd b);