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:
Maximilien Colange 2017-02-01 17:50:01 +01:00
parent 07a76e4d93
commit 3f5470898d
15 changed files with 143 additions and 89 deletions

View file

@ -1,6 +1,6 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016 Laboratoire de
// Recherche et Développement de l'Epita (LRDE)
// Copyright (C) 2011-2017 Laboratoire de Recherche et Développement de
// l'Epita (LRDE)
//
// This file is part of Spot, a model checking library.
//
@ -42,7 +42,6 @@ namespace spot
virtual int compare(const spot::state* other) const override
{
auto o = down_cast<const kripke_graph_state*>(other);
SPOT_ASSERT(o);
// Do not simply return "other - this", it might not fit in an int.
if (o < this)
@ -194,7 +193,6 @@ namespace spot
succ_iter(const spot::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_)
@ -213,7 +211,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);
}
@ -245,7 +242,6 @@ namespace spot
virtual bdd state_condition(const state* s) const override
{
auto gs = down_cast<const kripke_graph_state*>(s);
SPOT_ASSERT(gs);
return gs->cond();
}