Move helper functions from simplify.cc to the AST files.

* src/ltlvisit/simplify.cc (spot::ltl::is_And, spot::ltl::is_F,
spot::ltl::is_FG, spot::ltl::is_G, spot::ltl::is_GF, spot::ltl::is_M,
spot::ltl::is_Or, spot::ltl::is_R, spot::ltl::is_U, spot::ltl::is_W,
spot::ltl::is_X, spot::ltl::is_binop, spot::ltl::is_constant,
spot::ltl::is_multop, spot::ltl::is_unop): Move ...
* src/ltlast/binop.hh, src/ltlast/constant.hh, src/ltlast/multop.hh
src/ltlast/unop.hh: ... here, as appropriate.
This commit is contained in:
Alexandre Duret-Lutz 2012-02-16 19:05:20 +01:00
parent aa4b68fcfc
commit 5e7c0add49
5 changed files with 254 additions and 147 deletions

View file

@ -165,6 +165,71 @@ namespace spot
vec* children_;
};
/// \brief Cast \a f into a multop.
///
/// Cast \a f into a multop iff it is a multop instance. Return 0
/// otherwise. This is faster than \c dynamic_cast.
inline
multop*
is_multop(formula* f)
{
if (f->kind() != formula::MultOp)
return 0;
return static_cast<multop*>(f);
}
/// \brief Cast \a f into a multop if it has type \a op.
///
/// Cast \a f into a multop iff it is a multop instance with operator \a op.
/// Returns 0 otherwise.
inline
multop*
is_multop(formula* f, multop::type op)
{
if (f->kind() != formula::MultOp)
return 0;
multop* mo = static_cast<multop*>(f);
if (mo->op() != op)
return 0;
return mo;
}
/// \brief Cast \a f into a multop if it has type \a op1 or \a op2.
///
/// Cast \a f into a multop iff it is a multop instance with operator \a op1
/// or \a op2. Returns 0 otherwise.
inline
multop*
is_multop(const formula* f, multop::type op1, multop::type op2)
{
if (f->kind() != formula::MultOp)
return 0;
multop* mo = static_cast<multop*>(const_cast<formula*>(f));
if (mo->op() != op1 && mo->op() != op2)
return 0;
return mo;
}
/// \brief Cast \a f into a multop if it is an And.
///
/// Return 0 otherwise.
inline
multop*
is_And(formula* f)
{
return is_multop(f, multop::And);
}
/// \brief Cast \a f into a multop if it is an Or.
///
/// Return 0 otherwise.
inline
multop*
is_Or(formula* f)
{
return is_multop(f, multop::Or);
}
}
}