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

View file

@ -1,5 +1,5 @@
// -*- 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.
//
// 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.
bdd all = bddtrue;
bdd acc = bddfalse;
i->first();
if (i->first())
{
// In case the automaton use state-based acceptance, propagate
// the acceptance of the first transition to the one we add.
if (!i->done())
acc = i->current_acceptance_conditions();
for (; !i->done(); i->next())
do
all -= i->current_condition();
while (i->next());
}
if (all != bddfalse)
{
trans* t = out_->create_transition(n, 0);

View file

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

View file

@ -1,5 +1,5 @@
// -*- 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.
//
// 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.
bdd all = bddtrue;
for (i->first(); !i->done(); i->next())
if (i->first())
do
all -= i->current_condition();
while (i->next());
if (all != bddfalse)
{
trans* t = out_->create_transition(n, 0);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,8 +1,9 @@
// Copyright (C) 2011, 2012 Laboratoire de Recherche et Développement
// de l'Epita (LRDE)
// -*- coding: utf-8 -*-
// 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
// 6 (LIP6), département Systèmes Répartis Coopératifs (SRC),
// Université Pierre et Marie Curie.
// 6 (LIP6), département Systèmes Répartis Coopératifs (SRC),
// Université Pierre et Marie Curie.
//
// This file is part of Spot, a model checking library.
//
@ -51,7 +52,8 @@ namespace spot
{
const bdd_dict* d = aut_->get_dict();
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();
os_ << "\"" << cur << "\", \"";
@ -62,6 +64,7 @@ namespace spot
print_acc(si->current_acceptance_conditions()) << ";\n";
dest->destroy();
}
while (si->next());
}
private: