Get rid of all dynamic_cast<>s while working on LTL formulae.

They are too slow.

* src/ltlast/formula.hh (opkind, kind, kind_): Use an enum
to indicate the actual kind of the formula.  This way we can
check the kind of a formula without relying on dynamic_cast.
* src/ltlast/atomic_prop.cc, src/ltlast/automatop.cc,
src/ltlast/binop.cc, src/ltlast/bunop.cc, src/ltlast/constant.cc,
src/ltlast/multop.cc, src/ltlast/refformula.cc,
src/ltlast/refformula.hh, src/ltlast/unop.cc: Adjust constructors.
* src/ltlvisit/basicreduce.cc, src/ltlvisit/mark.cc,
src/ltlvisit/reduce.cc, src/ltlvisit/syntimpl.cc,
src/ltlvisit/tostring.cc: Replace all dynamic_cast by a
call to kind() followed by a static_cast.
This commit is contained in:
Alexandre Duret-Lutz 2010-12-09 13:19:44 +01:00
parent 48cde88b9b
commit 957ba664b7
15 changed files with 743 additions and 609 deletions

View file

@ -188,7 +188,7 @@ namespace spot
// a[*] is OK, no need to print {a}[*].
// However want braces for {!a}[*], the only unary
// operator that can be nested with [*].
bool need_parent = !!dynamic_cast<const unop*>(bo->child());
bool need_parent = (bo->child()->kind() == formula::UnOp);
if (need_parent || full_parent_)
openp();
@ -206,7 +206,7 @@ namespace spot
top_level_ = false;
// The parser treats F0, F1, G0, G1, X0, and X1 as atomic
// propositions. So make sure we output F(0), G(1), etc.
bool need_parent = !!dynamic_cast<const constant*>(uo->child());
bool need_parent = (uo->child()->kind() == formula::Constant);
bool top_level = top_level_;
if (full_parent_)
@ -456,7 +456,7 @@ namespace spot
case unop::X:
// The parser treats X0, and X1 as atomic
// propositions. So make sure we output X(0) and X(1).
need_parent = !!dynamic_cast<const constant*>(uo->child());
need_parent = (uo->child()->kind() == formula::Constant);
if (full_parent_)
need_parent = false;
os_ << "X";