Use downcast when appropriate.
* src/taalgos/sba2ta.cc, src/ta/ta.cc, src/ta/taexplicit.cc, src/ta/taproduct.cc, src/taalgos/emptinessta.cc: Use downcast and cleanup whitespace.
This commit is contained in:
parent
bf01501e15
commit
c774ba141d
5 changed files with 684 additions and 678 deletions
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2010 Laboratoire de Recherche et Developpement
|
||||
// Copyright (C) 2010, 2011 Laboratoire de Recherche et Developpement
|
||||
// de l Epita (LRDE).
|
||||
//
|
||||
// This file is part of Spot, a model checking library.
|
||||
|
|
@ -78,5 +78,3 @@ namespace spot
|
|||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2010 Laboratoire de Recherche et Developpement
|
||||
// Copyright (C) 2010, 2011 Laboratoire de Recherche et Developpement
|
||||
// de l Epita (LRDE).
|
||||
//
|
||||
// This file is part of Spot, a model checking library.
|
||||
|
|
@ -103,15 +103,15 @@ namespace spot
|
|||
{
|
||||
|
||||
Sgi::hash_map<int, transitions*, Sgi::hash<int> >::const_iterator i =
|
||||
transitions_by_condition.find(condition.id());
|
||||
transitions_by_condition.find(condition.id());
|
||||
|
||||
if (i == transitions_by_condition.end())
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return i->second;
|
||||
return i->second;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -128,8 +128,8 @@ namespace spot
|
|||
|
||||
if (transitions_condition == 0)
|
||||
{
|
||||
transitions_condition = new transitions;
|
||||
transitions_by_condition[(t->condition).id()] = transitions_condition;
|
||||
transitions_condition = new transitions;
|
||||
transitions_by_condition[(t->condition).id()] = transitions_condition;
|
||||
}
|
||||
|
||||
transitions_condition->push_back(t);
|
||||
|
|
@ -188,7 +188,7 @@ namespace spot
|
|||
int
|
||||
state_ta_explicit::compare(const spot::state* other) const
|
||||
{
|
||||
const state_ta_explicit* o = dynamic_cast<const state_ta_explicit*> (other);
|
||||
const state_ta_explicit* o = down_cast<const state_ta_explicit*> (other);
|
||||
assert(o);
|
||||
|
||||
int compare_value = tgba_state_->compare(o->tgba_state_);
|
||||
|
|
@ -219,37 +219,37 @@ namespace spot
|
|||
|
||||
if (trans != 0)
|
||||
for (it_trans = trans->begin(); it_trans != trans->end();)
|
||||
{
|
||||
state_ta_explicit* dest = (*it_trans)->dest;
|
||||
bool is_stuttering_transition = (get_tgba_condition()
|
||||
== (dest)->get_tgba_condition());
|
||||
bool dest_is_livelock_accepting = dest->is_livelock_accepting_state();
|
||||
{
|
||||
state_ta_explicit* dest = (*it_trans)->dest;
|
||||
bool is_stuttering_transition = (get_tgba_condition()
|
||||
== (dest)->get_tgba_condition());
|
||||
bool dest_is_livelock_accepting = dest->is_livelock_accepting_state();
|
||||
|
||||
//Before deleting stuttering transitions, propaged back livelock and initial state's properties
|
||||
if (is_stuttering_transition)
|
||||
{
|
||||
if (dest_is_livelock_accepting)
|
||||
set_livelock_accepting_state(true);
|
||||
if (dest->is_initial_state())
|
||||
set_initial_state(true);
|
||||
}
|
||||
//Before deleting stuttering transitions, propaged back livelock and initial state's properties
|
||||
if (is_stuttering_transition)
|
||||
{
|
||||
if (dest_is_livelock_accepting)
|
||||
set_livelock_accepting_state(true);
|
||||
if (dest->is_initial_state())
|
||||
set_initial_state(true);
|
||||
}
|
||||
|
||||
//remove hole successors states
|
||||
state_ta_explicit::transitions* dest_trans =
|
||||
(dest)->get_transitions();
|
||||
bool dest_trans_empty = dest_trans == 0 || dest_trans->empty();
|
||||
if (is_stuttering_transition || (dest_trans_empty
|
||||
&& (!dest_is_livelock_accepting)))
|
||||
{
|
||||
get_transitions((*it_trans)->condition)->remove(*it_trans);
|
||||
delete (*it_trans);
|
||||
it_trans = trans->erase(it_trans);
|
||||
}
|
||||
else
|
||||
{
|
||||
it_trans++;
|
||||
}
|
||||
}
|
||||
//remove hole successors states
|
||||
state_ta_explicit::transitions* dest_trans =
|
||||
(dest)->get_transitions();
|
||||
bool dest_trans_empty = dest_trans == 0 || dest_trans->empty();
|
||||
if (is_stuttering_transition || (dest_trans_empty
|
||||
&& (!dest_is_livelock_accepting)))
|
||||
{
|
||||
get_transitions((*it_trans)->condition)->remove(*it_trans);
|
||||
delete (*it_trans);
|
||||
it_trans = trans->erase(it_trans);
|
||||
}
|
||||
else
|
||||
{
|
||||
it_trans++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -262,18 +262,18 @@ namespace spot
|
|||
// they are not cloned.
|
||||
if (trans != 0)
|
||||
for (it_trans = trans->begin(); it_trans != trans->end(); it_trans++)
|
||||
{
|
||||
delete *it_trans;
|
||||
}
|
||||
{
|
||||
delete *it_trans;
|
||||
}
|
||||
delete trans;
|
||||
get_tgba_state()->destroy();
|
||||
|
||||
Sgi::hash_map<int, transitions*, Sgi::hash<int> >::iterator i =
|
||||
transitions_by_condition.begin();
|
||||
transitions_by_condition.begin();
|
||||
while (i != transitions_by_condition.end())
|
||||
{
|
||||
delete i->second;
|
||||
++i;
|
||||
delete i->second;
|
||||
++i;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -293,10 +293,10 @@ namespace spot
|
|||
ta::states_set_t::iterator it;
|
||||
for (it = states_set_.begin(); it != states_set_.end(); it++)
|
||||
{
|
||||
state_ta_explicit* s = dynamic_cast<state_ta_explicit*> (*it);
|
||||
state_ta_explicit* s = down_cast<state_ta_explicit*> (*it);
|
||||
|
||||
s->free_transitions();
|
||||
delete s;
|
||||
s->free_transitions();
|
||||
delete s;
|
||||
}
|
||||
get_dict()->unregister_all_my_variables(this);
|
||||
delete tgba_;
|
||||
|
|
@ -306,17 +306,17 @@ namespace spot
|
|||
ta_explicit::add_state(state_ta_explicit* s)
|
||||
{
|
||||
std::pair<ta::states_set_t::iterator, bool> add_state_to_ta =
|
||||
states_set_.insert(s);
|
||||
states_set_.insert(s);
|
||||
|
||||
return dynamic_cast<state_ta_explicit*> (*add_state_to_ta.first);
|
||||
return static_cast<state_ta_explicit*> (*add_state_to_ta.first);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
ta_explicit::add_to_initial_states_set(state* state)
|
||||
{
|
||||
state_ta_explicit * s = dynamic_cast<state_ta_explicit*> (state);
|
||||
|
||||
state_ta_explicit * s = down_cast<state_ta_explicit*> (state);
|
||||
assert(s);
|
||||
s->set_initial_state(true);
|
||||
|
||||
initial_states_set_.insert(s);
|
||||
|
|
@ -326,7 +326,8 @@ namespace spot
|
|||
void
|
||||
ta_explicit::delete_stuttering_and_hole_successors(spot::state* s)
|
||||
{
|
||||
state_ta_explicit * state = dynamic_cast<state_ta_explicit*> (s);
|
||||
state_ta_explicit * state = down_cast<state_ta_explicit*> (s);
|
||||
assert(state);
|
||||
state->delete_stuttering_and_hole_successors();
|
||||
if (state->is_initial_state()) add_to_initial_states_set(state);
|
||||
|
||||
|
|
@ -354,35 +355,39 @@ namespace spot
|
|||
ta_explicit::get_state_condition(const spot::state* initial_state) const
|
||||
{
|
||||
const state_ta_explicit* sta =
|
||||
dynamic_cast<const state_ta_explicit*> (initial_state);
|
||||
down_cast<const state_ta_explicit*> (initial_state);
|
||||
assert(sta);
|
||||
return sta->get_tgba_condition();
|
||||
}
|
||||
|
||||
bool
|
||||
ta_explicit::is_accepting_state(const spot::state* s) const
|
||||
{
|
||||
const state_ta_explicit* sta = dynamic_cast<const state_ta_explicit*> (s);
|
||||
const state_ta_explicit* sta = down_cast<const state_ta_explicit*> (s);
|
||||
assert(sta);
|
||||
return sta->is_accepting_state();
|
||||
}
|
||||
|
||||
bool
|
||||
ta_explicit::is_initial_state(const spot::state* s) const
|
||||
{
|
||||
const state_ta_explicit* sta = dynamic_cast<const state_ta_explicit*> (s);
|
||||
const state_ta_explicit* sta = down_cast<const state_ta_explicit*> (s);
|
||||
assert(sta);
|
||||
return sta->is_initial_state();
|
||||
}
|
||||
|
||||
bool
|
||||
ta_explicit::is_livelock_accepting_state(const spot::state* s) const
|
||||
{
|
||||
const state_ta_explicit* sta = dynamic_cast<const state_ta_explicit*> (s);
|
||||
const state_ta_explicit* sta = down_cast<const state_ta_explicit*> (s);
|
||||
assert(sta);
|
||||
return sta->is_livelock_accepting_state();
|
||||
}
|
||||
|
||||
ta_succ_iterator*
|
||||
ta_explicit::succ_iter(const spot::state* state) const
|
||||
{
|
||||
const state_ta_explicit* s = dynamic_cast<const state_ta_explicit*> (state);
|
||||
const state_ta_explicit* s = down_cast<const state_ta_explicit*> (state);
|
||||
assert(s);
|
||||
return new ta_explicit_succ_iterator(s);
|
||||
}
|
||||
|
|
@ -390,7 +395,7 @@ namespace spot
|
|||
ta_succ_iterator*
|
||||
ta_explicit::succ_iter(const spot::state* state, bdd condition) const
|
||||
{
|
||||
const state_ta_explicit* s = dynamic_cast<const state_ta_explicit*> (state);
|
||||
const state_ta_explicit* s = down_cast<const state_ta_explicit*> (state);
|
||||
assert(s);
|
||||
return new ta_explicit_succ_iterator(s, condition);
|
||||
}
|
||||
|
|
@ -410,14 +415,14 @@ namespace spot
|
|||
std::string
|
||||
ta_explicit::format_state(const spot::state* s) const
|
||||
{
|
||||
const state_ta_explicit* sta = dynamic_cast<const state_ta_explicit*> (s);
|
||||
const state_ta_explicit* sta = down_cast<const state_ta_explicit*> (s);
|
||||
assert(sta);
|
||||
|
||||
if (sta->get_tgba_condition() == bddtrue)
|
||||
return tgba_->format_state(sta->get_tgba_state());
|
||||
|
||||
return tgba_->format_state(sta->get_tgba_state()) + "\n"
|
||||
+ bdd_format_formula(get_dict(), sta->get_tgba_condition());
|
||||
+ bdd_format_formula(get_dict(), sta->get_tgba_condition());
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -428,26 +433,26 @@ namespace spot
|
|||
for (it = states_set_.begin(); it != states_set_.end(); it++)
|
||||
{
|
||||
|
||||
const state_ta_explicit* source =
|
||||
dynamic_cast<const state_ta_explicit*> (*it);
|
||||
const state_ta_explicit* source =
|
||||
static_cast<const state_ta_explicit*> (*it);
|
||||
|
||||
state_ta_explicit::transitions* trans = source->get_transitions();
|
||||
state_ta_explicit::transitions::iterator it_trans;
|
||||
state_ta_explicit::transitions* trans = source->get_transitions();
|
||||
state_ta_explicit::transitions::iterator it_trans;
|
||||
|
||||
if (trans != 0)
|
||||
for (it_trans = trans->begin(); it_trans != trans->end();)
|
||||
{
|
||||
if (source->get_tgba_condition()
|
||||
== ((*it_trans)->dest)->get_tgba_condition())
|
||||
{
|
||||
delete *it_trans;
|
||||
it_trans = trans->erase(it_trans);
|
||||
}
|
||||
else
|
||||
{
|
||||
it_trans++;
|
||||
}
|
||||
}
|
||||
if (trans != 0)
|
||||
for (it_trans = trans->begin(); it_trans != trans->end();)
|
||||
{
|
||||
if (source->get_tgba_condition()
|
||||
== ((*it_trans)->dest)->get_tgba_condition())
|
||||
{
|
||||
delete *it_trans;
|
||||
it_trans = trans->erase(it_trans);
|
||||
}
|
||||
else
|
||||
{
|
||||
it_trans++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace spot
|
|||
|
||||
state_ta_product::state_ta_product(const state_ta_product& o) :
|
||||
state(), ta_state_(o.get_ta_state()), kripke_state_(
|
||||
o.get_kripke_state()->clone())
|
||||
o.get_kripke_state()->clone())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ namespace spot
|
|||
int
|
||||
state_ta_product::compare(const state* other) const
|
||||
{
|
||||
const state_ta_product* o = dynamic_cast<const state_ta_product*> (other);
|
||||
const state_ta_product* o = down_cast<const state_ta_product*> (other);
|
||||
assert(o);
|
||||
int res = ta_state_->compare(o->get_ta_state());
|
||||
if (res != 0)
|
||||
|
|
@ -91,9 +91,9 @@ namespace spot
|
|||
ta_succ_it_->next();
|
||||
if (ta_succ_it_->done())
|
||||
{
|
||||
delete ta_succ_it_;
|
||||
ta_succ_it_ = 0;
|
||||
kripke_succ_it_->next();
|
||||
delete ta_succ_it_;
|
||||
ta_succ_it_ = 0;
|
||||
kripke_succ_it_->next();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -111,9 +111,9 @@ namespace spot
|
|||
// done().)
|
||||
if (kripke_succ_it_->done())
|
||||
{
|
||||
delete kripke_succ_it_;
|
||||
kripke_succ_it_ = 0;
|
||||
return;
|
||||
delete kripke_succ_it_;
|
||||
kripke_succ_it_ = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
next_non_stuttering_();
|
||||
|
|
@ -126,8 +126,8 @@ namespace spot
|
|||
current_state_ = 0;
|
||||
if (is_stuttering_transition())
|
||||
{
|
||||
ta_succ_it_ = 0;
|
||||
kripke_succ_it_->next();
|
||||
ta_succ_it_ = 0;
|
||||
kripke_succ_it_->next();
|
||||
}
|
||||
else
|
||||
step_();
|
||||
|
|
@ -144,34 +144,34 @@ namespace spot
|
|||
|
||||
while (!done())
|
||||
{
|
||||
state * kripke_succ_it_current_state = kripke_succ_it_->current_state();
|
||||
bdd dc = kripke_->state_condition(kripke_succ_it_current_state);
|
||||
state * kripke_succ_it_current_state = kripke_succ_it_->current_state();
|
||||
bdd dc = kripke_->state_condition(kripke_succ_it_current_state);
|
||||
|
||||
is_stuttering_transition_ = (sc == dc);
|
||||
if (is_stuttering_transition_)
|
||||
{
|
||||
//if stuttering transition, the TA automata stays in the same state
|
||||
current_state_ = new state_ta_product(source_->get_ta_state(),
|
||||
kripke_succ_it_current_state);
|
||||
current_condition_ = bddtrue;
|
||||
return;
|
||||
}
|
||||
is_stuttering_transition_ = (sc == dc);
|
||||
if (is_stuttering_transition_)
|
||||
{
|
||||
//if stuttering transition, the TA automata stays in the same state
|
||||
current_state_ = new state_ta_product(source_->get_ta_state(),
|
||||
kripke_succ_it_current_state);
|
||||
current_condition_ = bddtrue;
|
||||
return;
|
||||
}
|
||||
|
||||
if (ta_succ_it_ == 0){
|
||||
current_condition_ = bdd_setxor(sc, dc);
|
||||
ta_succ_it_ = ta_->succ_iter(source_->get_ta_state(), current_condition_);
|
||||
ta_succ_it_->first();
|
||||
}
|
||||
if (ta_succ_it_ == 0){
|
||||
current_condition_ = bdd_setxor(sc, dc);
|
||||
ta_succ_it_ = ta_->succ_iter(source_->get_ta_state(), current_condition_);
|
||||
ta_succ_it_->first();
|
||||
}
|
||||
|
||||
if (!ta_succ_it_->done())
|
||||
{
|
||||
current_state_ = new state_ta_product(ta_succ_it_->current_state(),
|
||||
kripke_succ_it_current_state);
|
||||
return;
|
||||
}
|
||||
if (!ta_succ_it_->done())
|
||||
{
|
||||
current_state_ = new state_ta_product(ta_succ_it_->current_state(),
|
||||
kripke_succ_it_current_state);
|
||||
return;
|
||||
}
|
||||
|
||||
kripke_succ_it_current_state->destroy();
|
||||
step_();
|
||||
kripke_succ_it_current_state->destroy();
|
||||
step_();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -227,7 +227,7 @@ namespace spot
|
|||
ta_product::ta_product(const ta* testing_automata,
|
||||
const kripke* kripke_structure) :
|
||||
dict_(testing_automata->get_dict()), ta_(testing_automata), kripke_(
|
||||
kripke_structure)
|
||||
kripke_structure)
|
||||
{
|
||||
assert(dict_ == kripke_structure->get_dict());
|
||||
dict_->register_all_variables_of(&ta_, this);
|
||||
|
|
@ -252,19 +252,19 @@ namespace spot
|
|||
|
||||
for (it = ta_init_states_set.begin(); it != ta_init_states_set.end(); it++)
|
||||
{
|
||||
state* kripke_init_state = kripke_->get_init_state();
|
||||
if ((kripke_->state_condition(kripke_init_state))
|
||||
== (ta_->get_state_condition(*it)))
|
||||
{
|
||||
state_ta_product* stp = new state_ta_product((*it),
|
||||
kripke_init_state);
|
||||
state* kripke_init_state = kripke_->get_init_state();
|
||||
if ((kripke_->state_condition(kripke_init_state))
|
||||
== (ta_->get_state_condition(*it)))
|
||||
{
|
||||
state_ta_product* stp = new state_ta_product((*it),
|
||||
kripke_init_state);
|
||||
|
||||
initial_states_set.insert(stp);
|
||||
}
|
||||
else
|
||||
{
|
||||
kripke_init_state->destroy();
|
||||
}
|
||||
initial_states_set.insert(stp);
|
||||
}
|
||||
else
|
||||
{
|
||||
kripke_init_state->destroy();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -274,7 +274,7 @@ namespace spot
|
|||
ta_succ_iterator_product*
|
||||
ta_product::succ_iter(const state* s) const
|
||||
{
|
||||
const state_ta_product* stp = dynamic_cast<const state_ta_product*> (s);
|
||||
const state_ta_product* stp = down_cast<const state_ta_product*> (s);
|
||||
assert(s);
|
||||
|
||||
return new ta_succ_iterator_product(stp, ta_, kripke_);
|
||||
|
|
@ -289,16 +289,17 @@ namespace spot
|
|||
std::string
|
||||
ta_product::format_state(const state* state) const
|
||||
{
|
||||
const state_ta_product* s = dynamic_cast<const state_ta_product*> (state);
|
||||
const state_ta_product* s = down_cast<const state_ta_product*> (state);
|
||||
assert(s);
|
||||
return kripke_->format_state(s->get_kripke_state()) + " * \n"
|
||||
+ ta_->format_state(s->get_ta_state());
|
||||
+ ta_->format_state(s->get_ta_state());
|
||||
}
|
||||
|
||||
bool
|
||||
ta_product::is_accepting_state(const spot::state* s) const
|
||||
{
|
||||
const state_ta_product* stp = dynamic_cast<const state_ta_product*> (s);
|
||||
const state_ta_product* stp = down_cast<const state_ta_product*> (s);
|
||||
assert(stp);
|
||||
|
||||
return ta_->is_accepting_state(stp->get_ta_state());
|
||||
}
|
||||
|
|
@ -306,7 +307,8 @@ namespace spot
|
|||
bool
|
||||
ta_product::is_livelock_accepting_state(const spot::state* s) const
|
||||
{
|
||||
const state_ta_product* stp = dynamic_cast<const state_ta_product*> (s);
|
||||
const state_ta_product* stp = down_cast<const state_ta_product*> (s);
|
||||
assert(stp);
|
||||
|
||||
return ta_->is_livelock_accepting_state(stp->get_ta_state());
|
||||
}
|
||||
|
|
@ -314,21 +316,23 @@ namespace spot
|
|||
bool
|
||||
ta_product::is_initial_state(const spot::state* s) const
|
||||
{
|
||||
const state_ta_product* stp = dynamic_cast<const state_ta_product*> (s);
|
||||
const state_ta_product* stp = down_cast<const state_ta_product*> (s);
|
||||
assert(stp);
|
||||
|
||||
state* ta_s = stp->get_ta_state();
|
||||
state* kr_s = stp->get_kripke_state();
|
||||
|
||||
return (ta_->is_initial_state(ta_s))
|
||||
&& ((kripke_->get_init_state())->compare(kr_s) == 0)
|
||||
&& ((kripke_->state_condition(kr_s))
|
||||
== (ta_->get_state_condition(ta_s)));
|
||||
&& ((kripke_->get_init_state())->compare(kr_s) == 0)
|
||||
&& ((kripke_->state_condition(kr_s))
|
||||
== (ta_->get_state_condition(ta_s)));
|
||||
}
|
||||
|
||||
bdd
|
||||
ta_product::get_state_condition(const spot::state* s) const
|
||||
{
|
||||
const state_ta_product* stp = dynamic_cast<const state_ta_product*> (s);
|
||||
const state_ta_product* stp = down_cast<const state_ta_product*> (s);
|
||||
assert(stp);
|
||||
state* ta_s = stp->get_ta_state();
|
||||
return ta_->get_state_condition(ta_s);
|
||||
}
|
||||
|
|
@ -337,7 +341,8 @@ namespace spot
|
|||
ta_product::free_state(const spot::state* s) const
|
||||
{
|
||||
|
||||
const state_ta_product* stp = dynamic_cast<const state_ta_product*> (s);
|
||||
const state_ta_product* stp = down_cast<const state_ta_product*> (s);
|
||||
assert(stp);
|
||||
ta_->free_state(stp->get_ta_state());
|
||||
delete stp;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue