Handle all automata through shared_ptr. (monstro patch)
A type such as 'const tgba_digraph*' and 'tgba_digraph*' are replaced by 'const_tgba_digraph_ptr' and 'tgba_digraph_ptr'. Additionally 'new tgba_digraph(...)' is replaced by 'make_tgba_digraph(...)'. This convention is followed by all automata types. Those smart pointers should normally be passed by const reference as input of function to avoid the atomic increments/decrements, but I probably missed a few, as this huge patch took me nearly 12h. * src/kripke/fwd.hh, src/tgba/fwd.hh: New files. * src/kripke/Makefile.am, src/tgba/Makefile.am: Adjust. * iface/dve2/dve2.cc, iface/dve2/dve2.hh, iface/dve2/dve2check.cc, src/bin/common_output.hh, src/bin/dstar2tgba.cc, src/bin/ltl2tgba.cc, src/bin/ltl2tgta.cc, src/bin/ltlcross.cc, src/bin/ltlfilt.cc, src/dstarparse/dra2ba.cc, src/dstarparse/dstar2tgba.cc, src/dstarparse/dstarparse.yy, src/dstarparse/nra2nba.cc, src/dstarparse/nsa2tgba.cc, src/dstarparse/public.hh, src/graphtest/tgbagraph.cc, src/kripke/fairkripke.hh, src/kripke/kripke.hh, src/kripke/kripkeexplicit.cc, src/kripke/kripkeexplicit.hh, src/kripke/kripkeprint.cc, src/kripke/kripkeprint.hh, src/kripkeparse/kripkeparse.yy, src/kripkeparse/public.hh, src/kripketest/parse_print_test.cc, src/ltlvisit/apcollect.cc, src/ltlvisit/apcollect.hh, src/ltlvisit/contain.cc, src/ltlvisit/contain.hh, src/neverparse/neverclaimparse.yy, src/neverparse/public.hh, src/priv/accmap.hh, src/priv/countstates.cc, src/priv/countstates.hh, src/saba/saba.hh, src/saba/sabacomplementtgba.cc, src/saba/sabacomplementtgba.hh, src/sabaalgos/sabadotty.cc, src/sabaalgos/sabadotty.hh, src/sabaalgos/sabareachiter.cc, src/sabaalgos/sabareachiter.hh, src/sabatest/sabacomplementtgba.cc, src/ta/ta.hh, src/ta/taexplicit.cc, src/ta/taexplicit.hh, src/ta/taproduct.cc, src/ta/taproduct.hh, src/ta/tgta.hh, src/ta/tgtaexplicit.cc, src/ta/tgtaexplicit.hh, src/ta/tgtaproduct.cc, src/ta/tgtaproduct.hh, src/taalgos/dotty.cc, src/taalgos/dotty.hh, src/taalgos/emptinessta.cc, src/taalgos/emptinessta.hh, src/taalgos/minimize.cc, src/taalgos/minimize.hh, src/taalgos/reachiter.cc, src/taalgos/reachiter.hh, src/taalgos/statessetbuilder.cc, src/taalgos/statessetbuilder.hh, src/taalgos/stats.cc, src/taalgos/stats.hh, src/taalgos/tgba2ta.cc, src/taalgos/tgba2ta.hh, src/tgba/bdddict.cc, src/tgba/bdddict.hh, src/tgba/formula2bdd.hh, src/tgba/futurecondcol.cc, src/tgba/futurecondcol.hh, src/tgba/taatgba.hh, src/tgba/tgba.cc, src/tgba/tgba.hh, src/tgba/tgbagraph.hh, src/tgba/tgbakvcomplement.cc, src/tgba/tgbakvcomplement.hh, src/tgba/tgbamask.cc, src/tgba/tgbamask.hh, src/tgba/tgbaproduct.cc, src/tgba/tgbaproduct.hh, src/tgba/tgbaproxy.cc, src/tgba/tgbaproxy.hh, src/tgba/tgbasafracomplement.cc, src/tgba/tgbasafracomplement.hh, src/tgba/tgbascc.cc, src/tgba/tgbascc.hh, src/tgba/tgbasgba.cc, src/tgba/tgbasgba.hh, src/tgba/wdbacomp.cc, src/tgba/wdbacomp.hh, src/tgbaalgos/bfssteps.cc, src/tgbaalgos/bfssteps.hh, src/tgbaalgos/complete.cc, src/tgbaalgos/complete.hh, src/tgbaalgos/compsusp.cc, src/tgbaalgos/compsusp.hh, src/tgbaalgos/cycles.hh, src/tgbaalgos/degen.cc, src/tgbaalgos/degen.hh, src/tgbaalgos/dotty.cc, src/tgbaalgos/dotty.hh, src/tgbaalgos/dottydec.cc, src/tgbaalgos/dottydec.hh, src/tgbaalgos/dtbasat.cc, src/tgbaalgos/dtbasat.hh, src/tgbaalgos/dtgbacomp.cc, src/tgbaalgos/dtgbacomp.hh, src/tgbaalgos/dtgbasat.cc, src/tgbaalgos/dtgbasat.hh, src/tgbaalgos/dupexp.cc, src/tgbaalgos/dupexp.hh, src/tgbaalgos/emptiness.cc, src/tgbaalgos/emptiness.hh, src/tgbaalgos/gtec/gtec.cc, src/tgbaalgos/gtec/gtec.hh, src/tgbaalgos/gtec/status.cc, src/tgbaalgos/gtec/status.hh, src/tgbaalgos/gv04.cc, src/tgbaalgos/gv04.hh, src/tgbaalgos/isdet.cc, src/tgbaalgos/isdet.hh, src/tgbaalgos/isweakscc.cc, src/tgbaalgos/lbtt.cc, src/tgbaalgos/lbtt.hh, src/tgbaalgos/ltl2taa.cc, src/tgbaalgos/ltl2taa.hh, src/tgbaalgos/ltl2tgba_fm.cc, src/tgbaalgos/ltl2tgba_fm.hh, src/tgbaalgos/magic.cc, src/tgbaalgos/magic.hh, src/tgbaalgos/minimize.cc, src/tgbaalgos/minimize.hh, src/tgbaalgos/ndfs_result.hxx, src/tgbaalgos/neverclaim.cc, src/tgbaalgos/neverclaim.hh, src/tgbaalgos/postproc.cc, src/tgbaalgos/postproc.hh, src/tgbaalgos/powerset.cc, src/tgbaalgos/powerset.hh, src/tgbaalgos/projrun.cc, src/tgbaalgos/projrun.hh, src/tgbaalgos/randomgraph.cc, src/tgbaalgos/randomgraph.hh, src/tgbaalgos/reachiter.cc, src/tgbaalgos/reachiter.hh, src/tgbaalgos/reducerun.cc, src/tgbaalgos/reducerun.hh, src/tgbaalgos/replayrun.cc, src/tgbaalgos/replayrun.hh, src/tgbaalgos/rundotdec.cc, src/tgbaalgos/rundotdec.hh, src/tgbaalgos/safety.cc, src/tgbaalgos/safety.hh, src/tgbaalgos/save.cc, src/tgbaalgos/save.hh, src/tgbaalgos/scc.cc, src/tgbaalgos/scc.hh, src/tgbaalgos/sccfilter.cc, src/tgbaalgos/sccfilter.hh, src/tgbaalgos/sccinfo.cc, src/tgbaalgos/sccinfo.hh, src/tgbaalgos/se05.cc, src/tgbaalgos/se05.hh, src/tgbaalgos/simulation.cc, src/tgbaalgos/simulation.hh, src/tgbaalgos/stats.cc, src/tgbaalgos/stats.hh, src/tgbaalgos/stripacc.cc, src/tgbaalgos/stripacc.hh, src/tgbaalgos/tau03.cc, src/tgbaalgos/tau03.hh, src/tgbaalgos/tau03opt.cc, src/tgbaalgos/tau03opt.hh, src/tgbaalgos/translate.cc, src/tgbaalgos/translate.hh, src/tgbaparse/public.hh, src/tgbaparse/tgbaparse.yy, src/tgbatest/complementation.cc, src/tgbatest/explprod.cc, src/tgbatest/ltl2tgba.cc, src/tgbatest/ltlprod.cc, src/tgbatest/maskacc.cc, src/tgbatest/powerset.cc, src/tgbatest/randtgba.cc, src/tgbatest/taatgba.cc, src/tgbatest/tgbaread.cc, src/tgbatest/tripprod.cc, wrap/python/ajax/spot.in, wrap/python/spot.i, wrap/python/tests/interdep.py: Use shared pointers for automata.
This commit is contained in:
parent
ca85d4184d
commit
51151ab271
195 changed files with 1792 additions and 1837 deletions
|
|
@ -1,5 +1,5 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2012, 2013 Laboratoire de Recherche et Développement
|
||||
// Copyright (C) 2012, 2013, 2014 Laboratoire de Recherche et Développement
|
||||
// de l'Epita (LRDE).
|
||||
//
|
||||
// This file is part of Spot, a model checking library.
|
||||
|
|
@ -73,7 +73,8 @@ public:
|
|||
}
|
||||
|
||||
std::ostream&
|
||||
print(const spot::tgba* aut, const spot::ltl::formula* f = 0,
|
||||
print(const spot::const_tgba_ptr& aut,
|
||||
const spot::ltl::formula* f = 0,
|
||||
double run_time = -1.)
|
||||
{
|
||||
formula_ = f;
|
||||
|
|
|
|||
|
|
@ -224,7 +224,8 @@ namespace
|
|||
/// The \a f argument is not needed if the Formula does not need
|
||||
/// to be output.
|
||||
std::ostream&
|
||||
print(const spot::dstar_aut* daut, const spot::tgba* aut,
|
||||
print(const spot::const_dstar_aut_ptr& daut,
|
||||
const spot::const_tgba_ptr& aut,
|
||||
const char* filename, double run_time)
|
||||
{
|
||||
filename_ = filename;
|
||||
|
|
@ -292,17 +293,11 @@ namespace
|
|||
process_file(const char* filename)
|
||||
{
|
||||
spot::dstar_parse_error_list pel;
|
||||
spot::dstar_aut* daut;
|
||||
daut = spot::dstar_parse(filename, pel, spot::make_bdd_dict());
|
||||
auto daut = spot::dstar_parse(filename, pel, spot::make_bdd_dict());
|
||||
if (spot::format_dstar_parse_errors(std::cerr, filename, pel))
|
||||
{
|
||||
delete daut;
|
||||
return 2;
|
||||
}
|
||||
return 2;
|
||||
if (!daut)
|
||||
{
|
||||
error(2, 0, "failed to read automaton from %s", filename);
|
||||
}
|
||||
error(2, 0, "failed to read automaton from %s", filename);
|
||||
|
||||
const xtime_t before = gethrxtime();
|
||||
|
||||
|
|
@ -336,8 +331,6 @@ namespace
|
|||
statistics.print(daut, aut, filename, conversion_time) << '\n';
|
||||
break;
|
||||
}
|
||||
delete aut;
|
||||
delete daut;
|
||||
flush_cout();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ namespace
|
|||
const char* filename = 0, int linenum = 0)
|
||||
{
|
||||
const xtime_t before = gethrxtime();
|
||||
const spot::tgba* aut = trans.run(&f);
|
||||
auto aut = trans.run(&f);
|
||||
const xtime_t after = gethrxtime();
|
||||
const double prec = XTIME_PRECISION;
|
||||
const double translation_time = (after - before) / prec;
|
||||
|
|
@ -254,7 +254,6 @@ namespace
|
|||
statistics.print(aut, f, translation_time) << '\n';
|
||||
break;
|
||||
}
|
||||
delete aut;
|
||||
f->destroy();
|
||||
flush_cout();
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ namespace
|
|||
process_formula(const spot::ltl::formula* f,
|
||||
const char* filename = 0, int linenum = 0)
|
||||
{
|
||||
const spot::tgba* aut = trans.run(&f);
|
||||
auto aut = trans.run(&f);
|
||||
|
||||
// This should not happen, because the parser we use can only
|
||||
// read PSL/LTL formula, but since our ltl::formula* type can
|
||||
|
|
@ -189,36 +189,22 @@ namespace
|
|||
|
||||
if (ta_type != TGTA)
|
||||
{
|
||||
spot::ta* testing_automaton =
|
||||
auto testing_automaton =
|
||||
tgba_to_ta(aut, ap_set, type == spot::postprocessor::BA,
|
||||
opt_with_artificial_initial_state,
|
||||
opt_single_pass_emptiness_check,
|
||||
opt_with_artificial_livelock);
|
||||
if (level != spot::postprocessor::Low)
|
||||
{
|
||||
spot::ta* testing_automaton_nm = testing_automaton;
|
||||
testing_automaton = spot::minimize_ta(testing_automaton);
|
||||
delete testing_automaton_nm;
|
||||
}
|
||||
testing_automaton = spot::minimize_ta(testing_automaton);
|
||||
spot::dotty_reachable(std::cout, testing_automaton);
|
||||
delete testing_automaton;
|
||||
}
|
||||
else
|
||||
{
|
||||
spot::tgta_explicit* tgta = tgba_to_tgta(aut, ap_set);
|
||||
auto tgta = tgba_to_tgta(aut, ap_set);
|
||||
if (level != spot::postprocessor::Low)
|
||||
{
|
||||
spot::tgta_explicit* a = spot::minimize_tgta(tgta);
|
||||
delete tgta;
|
||||
tgta = a;
|
||||
}
|
||||
spot::dotty_reachable(std::cout,
|
||||
dynamic_cast<spot::tgta_explicit*>(tgta)
|
||||
->get_ta());
|
||||
delete tgta;
|
||||
tgta = spot::minimize_tgta(tgta);
|
||||
spot::dotty_reachable(std::cout, tgta->get_ta());
|
||||
}
|
||||
|
||||
delete aut;
|
||||
f->destroy();
|
||||
flush_cout();
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -848,7 +848,7 @@ namespace
|
|||
string_to_tmp(string_ltl_wring, serial, filename_ltl_wring);
|
||||
}
|
||||
|
||||
const spot::tgba*
|
||||
spot::const_tgba_ptr
|
||||
translate(unsigned int translator_num, char l, statistics_formula* fstats)
|
||||
{
|
||||
output.reset(translator_num);
|
||||
|
|
@ -867,7 +867,7 @@ namespace
|
|||
|
||||
const char* status_str = 0;
|
||||
|
||||
const spot::tgba* res = 0;
|
||||
spot::const_tgba_ptr res = 0;
|
||||
if (timed_out)
|
||||
{
|
||||
// This is not considered to be a global error.
|
||||
|
|
@ -911,8 +911,7 @@ namespace
|
|||
err << "error: failed to parse the produced neverclaim.\n";
|
||||
spot::format_neverclaim_parse_errors(err, filename, pel);
|
||||
end_error();
|
||||
delete res;
|
||||
res = 0;
|
||||
res = nullptr;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -947,8 +946,7 @@ namespace
|
|||
{
|
||||
spot::dstar_parse_error_list pel;
|
||||
std::string filename = output.val()->name();
|
||||
spot::dstar_aut* aut;
|
||||
aut = spot::dstar_parse(filename, pel, dict);
|
||||
auto aut = spot::dstar_parse(filename, pel, dict);
|
||||
if (!pel.empty())
|
||||
{
|
||||
status_str = "parse error";
|
||||
|
|
@ -958,8 +956,7 @@ namespace
|
|||
" output.\n";
|
||||
spot::format_dstar_parse_errors(err, filename, pel);
|
||||
end_error();
|
||||
delete aut;
|
||||
res = 0;
|
||||
res = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -992,7 +989,6 @@ namespace
|
|||
}
|
||||
// convert it into TGBA for further processing
|
||||
res = dstar_to_tgba(aut);
|
||||
delete aut;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -1049,10 +1045,11 @@ namespace
|
|||
};
|
||||
|
||||
static void
|
||||
check_empty_prod(const spot::tgba* aut_i, const spot::tgba* aut_j,
|
||||
check_empty_prod(const spot::const_tgba_ptr& aut_i,
|
||||
const spot::const_tgba_ptr& aut_j,
|
||||
size_t i, size_t j, bool icomp, bool jcomp)
|
||||
{
|
||||
spot::tgba_product* prod = new spot::tgba_product(aut_i, aut_j);
|
||||
auto prod = spot::product(aut_i, aut_j);
|
||||
spot::emptiness_check* ec = spot::couvreur99(prod);
|
||||
spot::emptiness_check_result* res = ec->check();
|
||||
|
||||
|
|
@ -1090,7 +1087,6 @@ namespace
|
|||
}
|
||||
delete res;
|
||||
delete ec;
|
||||
delete prod;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1154,16 +1150,18 @@ namespace
|
|||
// Collect all the states of SSPACE that appear in the accepting SCCs
|
||||
// of PROD.
|
||||
static void
|
||||
states_in_acc(const spot::scc_map* m, const spot::tgba* sspace,
|
||||
states_in_acc(const spot::scc_map* m,
|
||||
const spot::const_tgba_ptr& sspace,
|
||||
state_set& s)
|
||||
{
|
||||
const spot::tgba* aut = m->get_aut();
|
||||
auto aut = m->get_aut();
|
||||
unsigned c = m->scc_count();
|
||||
for (unsigned n = 0; n < c; ++n)
|
||||
if (m->accepting(n))
|
||||
for (auto i: m->states_of(n))
|
||||
{
|
||||
spot::state* x = aut->project_state(i, sspace);
|
||||
assert(x);
|
||||
if (!s.insert(x).second)
|
||||
x->destroy();
|
||||
}
|
||||
|
|
@ -1171,7 +1169,7 @@ namespace
|
|||
|
||||
static bool
|
||||
consistency_check(const spot::scc_map* pos, const spot::scc_map* neg,
|
||||
const spot::tgba* sspace)
|
||||
const spot::const_tgba_ptr& sspace)
|
||||
{
|
||||
// the states of SSPACE should appear in the accepting SCC of at
|
||||
// least one of POS or NEG. Maybe both.
|
||||
|
|
@ -1266,12 +1264,12 @@ namespace
|
|||
// These store the result of the translation of the positive and
|
||||
// negative formulas.
|
||||
size_t m = translators.size();
|
||||
std::vector<const spot::tgba*> pos(m);
|
||||
std::vector<const spot::tgba*> neg(m);
|
||||
std::vector<spot::const_tgba_ptr> pos(m);
|
||||
std::vector<spot::const_tgba_ptr> neg(m);
|
||||
// These store the complement of the above results, when we can
|
||||
// compute it easily.
|
||||
std::vector<const spot::tgba*> comp_pos(m);
|
||||
std::vector<const spot::tgba*> comp_neg(m);
|
||||
std::vector<spot::const_tgba_ptr> comp_pos(m);
|
||||
std::vector<spot::const_tgba_ptr> comp_neg(m);
|
||||
|
||||
|
||||
unsigned n = vstats.size();
|
||||
|
|
@ -1400,20 +1398,19 @@ namespace
|
|||
{
|
||||
// build a random state-space.
|
||||
spot::srand(seed);
|
||||
spot::tgba* statespace = spot::random_graph(states, density,
|
||||
ap, dict);
|
||||
auto statespace = spot::random_graph(states, density, ap, dict);
|
||||
|
||||
// Products of the state space with the positive automata.
|
||||
std::vector<spot::tgba*> pos_prod(m);
|
||||
std::vector<spot::const_tgba_ptr> pos_prod(m);
|
||||
// Products of the state space with the negative automata.
|
||||
std::vector<spot::tgba*> neg_prod(m);
|
||||
std::vector<spot::const_tgba_ptr> neg_prod(m);
|
||||
// Associated SCC maps.
|
||||
std::vector<spot::scc_map*> pos_map(m);
|
||||
std::vector<spot::scc_map*> neg_map(m);
|
||||
for (size_t i = 0; i < m; ++i)
|
||||
if (pos[i])
|
||||
{
|
||||
spot::tgba* p = new spot::tgba_product(pos[i], statespace);
|
||||
auto p = spot::product(pos[i], statespace);
|
||||
pos_prod[i] = p;
|
||||
spot::scc_map* sm = new spot::scc_map(p);
|
||||
sm->build_map();
|
||||
|
|
@ -1433,7 +1430,7 @@ namespace
|
|||
for (size_t i = 0; i < m; ++i)
|
||||
if (neg[i])
|
||||
{
|
||||
spot::tgba* p = new spot::tgba_product(neg[i], statespace);
|
||||
auto p = spot::product(neg[i], statespace);
|
||||
neg_prod[i] = p;
|
||||
spot::scc_map* sm = new spot::scc_map(p);
|
||||
sm->build_map();
|
||||
|
|
@ -1475,31 +1472,14 @@ namespace
|
|||
// Cleanup.
|
||||
if (!no_checks)
|
||||
for (size_t i = 0; i < m; ++i)
|
||||
{
|
||||
delete neg_map[i];
|
||||
delete neg_prod[i];
|
||||
}
|
||||
delete neg_map[i];
|
||||
for (size_t i = 0; i < m; ++i)
|
||||
{
|
||||
delete pos_map[i];
|
||||
delete pos_prod[i];
|
||||
}
|
||||
delete statespace;
|
||||
delete pos_map[i];
|
||||
++seed;
|
||||
}
|
||||
std::cerr << std::endl;
|
||||
delete ap;
|
||||
|
||||
if (!no_checks)
|
||||
for (size_t i = 0; i < m; ++i)
|
||||
{
|
||||
delete neg[i];
|
||||
delete comp_neg[i];
|
||||
delete comp_pos[i];
|
||||
}
|
||||
for (size_t i = 0; i < m; ++i)
|
||||
delete pos[i];
|
||||
|
||||
// Shall we stop processing formulas now?
|
||||
abort_run = global_error_flag && stop_on_error;
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -560,9 +560,7 @@ namespace
|
|||
{
|
||||
matched &= !guarantee || is_guarantee_automaton(min);
|
||||
matched &= !safety || is_safety_mwdba(min);
|
||||
delete min;
|
||||
}
|
||||
delete aut;
|
||||
}
|
||||
|
||||
matched ^= invert;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue