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, 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).
|
||||
// Copyright (C) 2004, 2005 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||
// et Marie Curie.
|
||||
|
|
@ -446,11 +446,11 @@ namespace spot
|
|||
auto res = std::make_shared<twa_run>(other);
|
||||
if (auto ps = aut->get_named_prop<const product_states>("product-states"))
|
||||
{
|
||||
auto a = std::dynamic_pointer_cast<const twa_graph>(aut);
|
||||
auto a = down_cast<const_twa_graph_ptr>(aut);
|
||||
if (!a)
|
||||
throw std::runtime_error("twa_run::project() confused: "
|
||||
"product-states found in a non-twa_graph");
|
||||
auto oth = std::dynamic_pointer_cast<const twa_graph>(other);
|
||||
auto oth = down_cast<const_twa_graph_ptr>(other);
|
||||
if (!oth)
|
||||
throw std::runtime_error("twa_run::project() confused: "
|
||||
"other ought to be a twa_graph");
|
||||
|
|
@ -709,8 +709,7 @@ namespace spot
|
|||
/// Note that this works only if the automaton is a twa_graph_ptr.
|
||||
void twa_run::highlight(unsigned color)
|
||||
{
|
||||
auto a = std::dynamic_pointer_cast<twa_graph>
|
||||
(std::const_pointer_cast<twa>(aut));
|
||||
auto a = down_cast<twa_graph_ptr>(std::const_pointer_cast<twa>(aut));
|
||||
if (!a)
|
||||
throw std::runtime_error("highlight() only work for twa_graph");
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2014, 2015, 2016 Laboratoire de Recherche et
|
||||
// Développement de l'Epita (LRDE).
|
||||
// Copyright (C) 2014-2017 Laboratoire de Recherche et Développement de
|
||||
// l'Epita (LRDE).
|
||||
//
|
||||
// This file is part of Spot, a model checking library.
|
||||
//
|
||||
|
|
@ -59,7 +59,6 @@ namespace spot
|
|||
{
|
||||
const state_tgbasl* o =
|
||||
down_cast<const state_tgbasl*>(other);
|
||||
assert(o);
|
||||
int res = s_->compare(o->real_state());
|
||||
if (res != 0)
|
||||
return res;
|
||||
|
|
@ -223,7 +222,6 @@ namespace spot
|
|||
virtual twa_succ_iterator* succ_iter(const state* state) const override
|
||||
{
|
||||
const state_tgbasl* s = down_cast<const state_tgbasl*>(state);
|
||||
assert(s);
|
||||
return new twasl_succ_iterator(a_->succ_iter(s->real_state()), s,
|
||||
a_->get_dict(), aps_);
|
||||
}
|
||||
|
|
@ -231,7 +229,6 @@ namespace spot
|
|||
virtual std::string format_state(const state* state) const override
|
||||
{
|
||||
const state_tgbasl* s = down_cast<const state_tgbasl*>(state);
|
||||
assert(s);
|
||||
return (a_->format_state(s->real_state())
|
||||
+ ", "
|
||||
+ bdd_format_formula(a_->get_dict(), s->cond()));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue