Rework the 'down_cast' macro, closing #196.
* spot/misc/casts.hh: New inline functions and compile-time checks. * spot/kripke/kripkegraph.hh, spot/ta/taexplicit.cc, spot/ta/taproduct.cc, spot/ta/tgtaproduct.cc, spot/taalgos/tgba2ta.cc, spot/twa/taatgba.hh, spot/twa/taatgba.cc, spot/twa/twagraph.hh, spot/twa/twaproduct.cc, spot/twaalgos/emptiness.cc, spot/twaalgos/stutter.cc, spot/ltsmin/ltsmin.cc, tests/core/ikwiad.cc, tests/core/ngraph.cc: Remove downcast checks from code.
This commit is contained in:
parent
07a76e4d93
commit
3f5470898d
15 changed files with 143 additions and 89 deletions
|
|
@ -1,6 +1,6 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016
|
||||
// Laboratoire de Recherche et Développement de l'Epita (LRDE)
|
||||
// Copyright (C) 2009-2017 Laboratoire de Recherche et Développement de
|
||||
// l'Epita (LRDE)
|
||||
//
|
||||
// This file is part of Spot, a model checking library.
|
||||
//
|
||||
|
|
@ -62,7 +62,6 @@ namespace spot
|
|||
taa_tgba::succ_iter(const spot::state* state) const
|
||||
{
|
||||
const spot::set_state* s = down_cast<const spot::set_state*>(state);
|
||||
assert(s);
|
||||
return new taa_succ_iterator(s->get_state(), acc());
|
||||
}
|
||||
|
||||
|
|
@ -80,7 +79,6 @@ namespace spot
|
|||
set_state::compare(const spot::state* other) const
|
||||
{
|
||||
const set_state* o = down_cast<const set_state*>(other);
|
||||
assert(o);
|
||||
|
||||
const taa_tgba::state_set* s1 = get_state();
|
||||
const taa_tgba::state_set* s2 = o->get_state();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2009, 2011, 2012, 2013, 2014, 2015, 2016 Laboratoire de
|
||||
// Recherche et Développement de l'Epita (LRDE).
|
||||
// Copyright (C) 2009, 2011-2017 Laboratoire de Recherche et Développement de
|
||||
// l'Epita (LRDE).
|
||||
//
|
||||
// This file is part of Spot, a model checking library.
|
||||
//
|
||||
|
|
@ -209,7 +209,6 @@ namespace spot
|
|||
virtual std::string format_state(const spot::state* s) const override
|
||||
{
|
||||
const spot::set_state* se = down_cast<const spot::set_state*>(s);
|
||||
SPOT_ASSERT(se);
|
||||
const state_set* ss = se->get_state();
|
||||
return format_state_set(ss);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2014, 2015, 2016 Laboratoire de Recherche et Développement
|
||||
// de l'Epita.
|
||||
// Copyright (C) 2014-2017 Laboratoire de Recherche et Développement de l'Epita.
|
||||
//
|
||||
// This file is part of Spot, a model checking library.
|
||||
//
|
||||
|
|
@ -45,7 +44,6 @@ namespace spot
|
|||
virtual int compare(const spot::state* other) const override
|
||||
{
|
||||
auto o = down_cast<const twa_graph_state*>(other);
|
||||
SPOT_ASSERT(o);
|
||||
|
||||
// Do not simply return "other - this", it might not fit in an int.
|
||||
if (o < this)
|
||||
|
|
@ -306,7 +304,6 @@ namespace spot
|
|||
succ_iter(const state* st) const override
|
||||
{
|
||||
auto s = down_cast<const typename graph_t::state_storage_t*>(st);
|
||||
SPOT_ASSERT(s);
|
||||
SPOT_ASSERT(!s->succ || g_.is_valid_edge(s->succ));
|
||||
|
||||
if (this->iter_cache_)
|
||||
|
|
@ -336,7 +333,6 @@ namespace spot
|
|||
state_number(const state* st) const
|
||||
{
|
||||
auto s = down_cast<const typename graph_t::state_storage_t*>(st);
|
||||
SPOT_ASSERT(s);
|
||||
return s - &g_.state_storage(0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@ namespace spot
|
|||
state_product::compare(const state* other) const
|
||||
{
|
||||
const state_product* o = down_cast<const state_product*>(other);
|
||||
assert(o);
|
||||
int res = left_->compare(o->left());
|
||||
if (res != 0)
|
||||
return res;
|
||||
|
|
@ -336,7 +335,6 @@ namespace spot
|
|||
twa_product::succ_iter(const state* state) const
|
||||
{
|
||||
const state_product* s = down_cast<const state_product*>(state);
|
||||
assert(s);
|
||||
twa_succ_iterator* li = left_->succ_iter(s->left());
|
||||
twa_succ_iterator* ri = right_->succ_iter(s->right());
|
||||
|
||||
|
|
@ -370,7 +368,6 @@ namespace spot
|
|||
twa_product::format_state(const state* state) const
|
||||
{
|
||||
const state_product* s = down_cast<const state_product*>(state);
|
||||
assert(s);
|
||||
return (left_->format_state(s->left())
|
||||
+ " * "
|
||||
+ right_->format_state(s->right()));
|
||||
|
|
@ -380,7 +377,6 @@ namespace spot
|
|||
twa_product::project_state(const state* s, const const_twa_ptr& t) const
|
||||
{
|
||||
const state_product* s2 = down_cast<const state_product*>(s);
|
||||
assert(s2);
|
||||
if (t.get() == this)
|
||||
return s2->clone();
|
||||
state* res = left_->project_state(s2->left(), t);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue