Avoid calling done(), as enabled by last patch.

* src/tgbaalgos/bfssteps.cc, src/tgbaalgos/complete.cc,
src/tgbaalgos/cycles.cc, src/tgbaalgos/dtgbacomp.cc,
src/tgbaalgos/gtec/gtec.cc, src/tgbaalgos/gv04.cc,
src/tgbaalgos/isweakscc.cc, src/tgbaalgos/lbtt.cc,
src/tgbaalgos/neverclaim.cc, src/tgbaalgos/reachiter.cc,
src/tgbaalgos/replayrun.cc, src/tgbaalgos/safety.cc,
src/tgbaalgos/save.cc: Avoid calls to done().
This commit is contained in:
Alexandre Duret-Lutz 2014-01-27 00:00:22 +01:00
parent 1a5c0cb1f3
commit b4c125c2b9
13 changed files with 143 additions and 137 deletions

View file

@ -72,8 +72,7 @@ namespace spot
{ {
const state* src = todo.front(); const state* src = todo.front();
todo.pop_front(); todo.pop_front();
tgba_succ_iterator* i = a_->succ_iter(src); for (auto i: a_->succ(src))
for (i->first(); !i->done(); i->next())
{ {
const state* dest = filter(i->current_state()); const state* dest = filter(i->current_state());
@ -88,7 +87,6 @@ namespace spot
{ {
// Found it! // Found it!
finalize(father, s, start, l); finalize(father, s, start, l);
a_->release_iter(i);
return dest; return dest;
} }
@ -100,7 +98,6 @@ namespace spot
father[dest] = s; father[dest] = s;
} }
} }
a_->release_iter(i);
} }
return 0; return 0;
} }

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*- // -*- coding: utf-8 -*-
// Copyright (C) 2013 Laboratoire de Recherche et Développement // Copyright (C) 2013, 2014 Laboratoire de Recherche et Développement
// de l'Epita. // de l'Epita.
// //
// This file is part of Spot, a model checking library. // This file is part of Spot, a model checking library.
@ -81,13 +81,16 @@ namespace spot
// add a transition to a sink state if the state is not complete. // add a transition to a sink state if the state is not complete.
bdd all = bddtrue; bdd all = bddtrue;
bdd acc = bddfalse; bdd acc = bddfalse;
i->first(); if (i->first())
{
// In case the automaton use state-based acceptance, propagate // In case the automaton use state-based acceptance, propagate
// the acceptance of the first transition to the one we add. // the acceptance of the first transition to the one we add.
if (!i->done())
acc = i->current_acceptance_conditions(); acc = i->current_acceptance_conditions();
for (; !i->done(); i->next())
do
all -= i->current_condition(); all -= i->current_condition();
while (i->next());
}
if (all != bddfalse) if (all != bddfalse)
{ {
trans* t = out_->create_transition(n, 0); trans* t = out_->create_transition(n, 0);

View file

@ -95,14 +95,15 @@ namespace spot
while (keep_going && !dfs_.empty()) while (keep_going && !dfs_.empty())
{ {
dfs_entry& cur = dfs_.back(); dfs_entry& cur = dfs_.back();
bool cont;
if (cur.succ == 0) if (cur.succ == 0)
{ {
cur.succ = aut_->succ_iter(cur.ts->first); cur.succ = aut_->succ_iter(cur.ts->first);
cur.succ->first(); cont = cur.succ->first();
} }
else else
cur.succ->next(); cont = cur.succ->next();
if (!cur.succ->done()) if (cont)
{ {
// Explore one successor. // Explore one successor.

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*- // -*- coding: utf-8 -*-
// Copyright (C) 2013 Laboratoire de Recherche et Développement // Copyright (C) 2013, 2014 Laboratoire de Recherche et Développement
// de l'Epita. // de l'Epita.
// //
// This file is part of Spot, a model checking library. // This file is part of Spot, a model checking library.
@ -78,8 +78,10 @@ namespace spot
{ {
// add a transition to a sink state if the state is not complete. // add a transition to a sink state if the state is not complete.
bdd all = bddtrue; bdd all = bddtrue;
for (i->first(); !i->done(); i->next()) if (i->first())
do
all -= i->current_condition(); all -= i->current_condition();
while (i->next());
if (all != bddfalse) if (all != bddfalse)
{ {
trans* t = out_->create_transition(n, 0); trans* t = out_->create_transition(n, 0);

View file

@ -115,7 +115,8 @@ namespace spot
for (;;) for (;;)
{ {
// Remove each destination of this iterator. // Remove each destination of this iterator.
for (i->first(); !i->done(); i->next()) if (i->first())
do
{ {
inc_transitions(); inc_transitions();
@ -136,6 +137,7 @@ namespace spot
to_remove.push(ecs_->aut->succ_iter(spi.first)); to_remove.push(ecs_->aut->succ_iter(spi.first));
} }
} }
while (i->next());
ecs_->aut->release_iter(i); ecs_->aut->release_iter(i);
if (to_remove.empty()) if (to_remove.empty())
break; break;

View file

@ -106,17 +106,18 @@ namespace spot
<< ")" << std::endl; << ")" << std::endl;
tgba_succ_iterator* iter = stack[dftop].lasttr; tgba_succ_iterator* iter = stack[dftop].lasttr;
bool cont;
if (!iter) if (!iter)
{ {
iter = stack[dftop].lasttr = a_->succ_iter(stack[dftop].s); iter = stack[dftop].lasttr = a_->succ_iter(stack[dftop].s);
iter->first(); cont = iter->first();
} }
else else
{ {
iter->next(); cont = iter->next();
} }
if (iter->done()) if (!cont)
{ {
trace << " No more successors" << std::endl; trace << " No more successors" << std::endl;
pop(); pop();

View file

@ -134,10 +134,9 @@ namespace spot
for (auto s: map.states_of(scc)) for (auto s: map.states_of(scc))
{ {
tgba_succ_iterator* it = a->succ_iter(s); tgba_succ_iterator* it = a->succ_iter(s);
it->first();
// If a state has no successors, the SCC is not complete. // If a state has no successors, the SCC is not complete.
if (it->done()) if (!it->first())
{ {
a->release_iter(it); a->release_iter(it);
return false; return false;
@ -154,9 +153,8 @@ namespace spot
next->destroy(); next->destroy();
if (sumall == bddtrue) if (sumall == bddtrue)
break; break;
it->next();
} }
while (!it->done()); while (it->next());
a->release_iter(it); a->release_iter(it);
if (sumall != bddtrue) if (sumall != bddtrue)

View file

@ -101,9 +101,8 @@ namespace spot
// is not terribly efficient since we have to create the // is not terribly efficient since we have to create the
// iterator. // iterator.
tgba_succ_iterator* it = aut_->succ_iter(s); tgba_succ_iterator* it = aut_->succ_iter(s);
it->first(); bool accepting = it->first()
bool accepting = && it->current_acceptance_conditions() == all_acc_conds_;
!it->done() && it->current_acceptance_conditions() == all_acc_conds_;
aut_->release_iter(it); aut_->release_iter(it);
return accepting; return accepting;
} }

View file

@ -86,9 +86,8 @@ namespace spot
// is not terribly efficient since we have to create the // is not terribly efficient since we have to create the
// iterator. // iterator.
tgba_succ_iterator* it = aut_->succ_iter(s); tgba_succ_iterator* it = aut_->succ_iter(s);
it->first();
bool accepting = bool accepting =
!it->done() && it->current_acceptance_conditions() == all_acc_conds_; it->first() && it->current_acceptance_conditions() == all_acc_conds_;
aut_->release_iter(it); aut_->release_iter(it);
return accepting; return accepting;
} }
@ -111,8 +110,7 @@ namespace spot
if (state_is_accepting(s)) if (state_is_accepting(s))
{ {
tgba_succ_iterator* it = aut_->succ_iter(s); tgba_succ_iterator* it = aut_->succ_iter(s);
it->first(); if (!it->first())
if (it->done())
label = "accept_S" + ns; label = "accept_S" + ns;
else else
{ {
@ -136,8 +134,7 @@ namespace spot
process_state(const state* s, int n, tgba_succ_iterator*) process_state(const state* s, int n, tgba_succ_iterator*)
{ {
tgba_succ_iterator* it = aut_->succ_iter(s); tgba_succ_iterator* it = aut_->succ_iter(s);
it->first(); if (!it->first())
if (it->done())
{ {
if (fi_needed_ != 0) if (fi_needed_ != 0)
os_ << " fi;\n"; os_ << " fi;\n";

View file

@ -61,7 +61,8 @@ namespace spot
int tn = seen[t]; int tn = seen[t];
tgba_succ_iterator* si = aut_->succ_iter(t); tgba_succ_iterator* si = aut_->succ_iter(t);
process_state(t, tn, si); process_state(t, tn, si);
for (si->first(); !si->done(); si->next()) if (si->first())
do
{ {
const state* current = si->current_state(); const state* current = si->current_state();
seen_map::const_iterator s = seen.find(current); seen_map::const_iterator s = seen.find(current);
@ -82,6 +83,7 @@ namespace spot
current->destroy(); current->destroy();
} }
} }
while (si->next());
aut_->release_iter(si); aut_->release_iter(si);
} }
end(); end();

View file

@ -62,14 +62,14 @@ namespace spot
l = &run->cycle; l = &run->cycle;
in = "cycle"; in = "cycle";
if (!debug) if (!debug)
os << "No prefix.\nCycle:" << std::endl; os << "No prefix.\nCycle:\n";
} }
else else
{ {
l = &run->prefix; l = &run->prefix;
in = "prefix"; in = "prefix";
if (!debug) if (!debug)
os << "Prefix:" << std::endl; os << "Prefix:\n";
} }
tgba_run::steps::const_iterator i = l->begin(); tgba_run::steps::const_iterator i = l->begin();
@ -78,9 +78,9 @@ namespace spot
{ {
if (debug) if (debug)
os << "ERROR: First state of run (in " << in << "): " os << "ERROR: First state of run (in " << in << "): "
<< a->format_state(i->s) << std::endl << a->format_state(i->s)
<< "does not match initial state of automata: " << "\ndoes not match initial state of automata: "
<< a->format_state(s) << std::endl; << a->format_state(s) << '\n';
s->destroy(); s->destroy();
return false; return false;
} }
@ -112,7 +112,7 @@ namespace spot
{ {
os << " "; os << " ";
} }
os << a->format_state(s) << std::endl; os << a->format_state(s) << '\n';
// expected outgoing transition // expected outgoing transition
bdd label = i->label; bdd label = i->label;
@ -133,7 +133,7 @@ namespace spot
in = "cycle"; in = "cycle";
i = l->begin(); i = l->begin();
if (!debug) if (!debug)
os << "Cycle:" << std::endl; os << "Cycle:\n";
} }
next = l->begin()->s; next = l->begin()->s;
} }
@ -144,7 +144,8 @@ namespace spot
// destroy it right now. // destroy it right now.
if (!debug) if (!debug)
s->destroy(); s->destroy();
for (j->first(); !j->done(); j->next()) if (j->first())
do
{ {
if (j->current_condition() != label if (j->current_condition() != label
|| j->current_acceptance_conditions() != acc) || j->current_acceptance_conditions() != acc)
@ -162,6 +163,7 @@ namespace spot
break; break;
} }
} }
while (j->next());
if (j->done()) if (j->done())
{ {
if (debug) if (debug)
@ -170,11 +172,11 @@ namespace spot
<< bdd_format_formula(a->get_dict(), label) << bdd_format_formula(a->get_dict(), label)
<< " and acc=" << bdd_format_accset(a->get_dict(), acc) << " and acc=" << bdd_format_accset(a->get_dict(), acc)
<< " leaving state " << serial << " leaving state " << serial
<< " for state " << a->format_state(next) << " for state " << a->format_state(next) << '\n'
<< std::endl
<< "The following transitions leave state " << serial << "The following transitions leave state " << serial
<< ":" << std::endl; << ":\n";
for (j->first(); !j->done(); j->next()) if (j->first())
do
{ {
const state* s2 = j->current_state(); const state* s2 = j->current_state();
os << " *"; os << " *";
@ -183,11 +185,13 @@ namespace spot
<< bdd_format_formula(a->get_dict(), << bdd_format_formula(a->get_dict(),
j->current_condition()) j->current_condition())
<< " and acc=" << " and acc="
<< bdd_format_accset(a->get_dict(), << (bdd_format_accset
j->current_acceptance_conditions()) (a->get_dict(),
<< " going to " << a->format_state(s2) << std::endl; j->current_acceptance_conditions()))
<< " going to " << a->format_state(s2) << '\n';
s2->destroy(); s2->destroy();
} }
while (j->next());
} }
a->release_iter(j); a->release_iter(j);
s->destroy(); s->destroy();
@ -228,8 +232,7 @@ namespace spot
if (debug) if (debug)
os << "all acceptance conditions (" os << "all acceptance conditions ("
<< bdd_format_accset(a->get_dict(), all_acc) << bdd_format_accset(a->get_dict(), all_acc)
<< ") have been seen" << ") have been seen\n";
<< std::endl;
} }
} }
} }
@ -238,11 +241,10 @@ namespace spot
{ {
if (debug) if (debug)
os << "ERROR: The cycle's acceptance conditions (" os << "ERROR: The cycle's acceptance conditions ("
<< bdd_format_accset(a->get_dict(), all_acc) << ") do not" << bdd_format_accset(a->get_dict(), all_acc)
<< std::endl << ") do not\nmatch those of the automaton ("
<< "match those of the automata ("
<< bdd_format_accset(a->get_dict(), expected_all_acc) << bdd_format_accset(a->get_dict(), expected_all_acc)
<< std::endl; << ")\n";
return false; return false;
} }

View file

@ -57,8 +57,7 @@ namespace spot
assert(!it->done()); assert(!it->done());
state* dest = it->current_state(); state* dest = it->current_state();
bdd cond = it->current_condition(); bdd cond = it->current_condition();
it->next(); result = (!it->next()) && (cond == bddtrue) && (!dest->compare(s));
result = (!dest->compare(s)) && it->done() && (cond == bddtrue);
dest->destroy(); dest->destroy();
aut->release_iter(it); aut->release_iter(it);
} }

View file

@ -1,8 +1,9 @@
// Copyright (C) 2011, 2012 Laboratoire de Recherche et Développement // -*- coding: utf-8 -*-
// de l'Epita (LRDE) // Copyright (C) 2011, 2012, 2014 Laboratoire de Recherche et
// Développement de l'Epita (LRDE)
// Copyright (C) 2003, 2004, 2005 Laboratoire d'Informatique de Paris // Copyright (C) 2003, 2004, 2005 Laboratoire d'Informatique de Paris
// 6 (LIP6), département Systèmes Répartis Coopératifs (SRC), // 6 (LIP6), département Systèmes Répartis Coopératifs (SRC),
// Université Pierre et Marie Curie. // Université Pierre et Marie Curie.
// //
// This file is part of Spot, a model checking library. // This file is part of Spot, a model checking library.
// //
@ -51,7 +52,8 @@ namespace spot
{ {
const bdd_dict* d = aut_->get_dict(); const bdd_dict* d = aut_->get_dict();
std::string cur = escape_str(aut_->format_state(s)); std::string cur = escape_str(aut_->format_state(s));
for (si->first(); !si->done(); si->next()) if (si->first())
do
{ {
state* dest = si->current_state(); state* dest = si->current_state();
os_ << "\"" << cur << "\", \""; os_ << "\"" << cur << "\", \"";
@ -62,6 +64,7 @@ namespace spot
print_acc(si->current_acceptance_conditions()) << ";\n"; print_acc(si->current_acceptance_conditions()) << ";\n";
dest->destroy(); dest->destroy();
} }
while (si->next());
} }
private: private: