CBMC
|
Templated functions to cast to specific exprt-derived classes. More...
#include <typeinfo>
#include <type_traits>
#include <functional>
#include "invariant.h"
#include "expr.h"
Go to the source code of this file.
Classes | |
struct | detail::expr_try_dynamic_cast_return_typet< Ret, T > |
struct | detail::expr_dynamic_cast_return_typet< Ret, T > |
Namespaces | |
detail | |
Functions | |
template<typename T > | |
bool | can_cast_expr (const exprt &base) |
Check whether a reference to a generic exprt is of a specific derived class. More... | |
template<typename T > | |
bool | can_cast_type (const typet &base) |
Check whether a reference to a generic typet is of a specific derived class. More... | |
void | validate_expr (const exprt &) |
Called after casting. More... | |
template<typename T , typename TExpr > | |
auto | expr_try_dynamic_cast (TExpr &base) -> typename detail::expr_try_dynamic_cast_return_typet< T, TExpr >::type |
Try to cast a reference to a generic exprt to a specific derived class. More... | |
template<typename T , typename TExpr > | |
std::optional< T > | expr_try_dynamic_cast (TExpr &&base) |
Try to cast a generic exprt to a specific derived class. More... | |
template<typename T , typename TType > | |
auto | type_try_dynamic_cast (TType &base) -> typename detail::expr_try_dynamic_cast_return_typet< T, TType >::type |
Try to cast a reference to a generic typet to a specific derived class. More... | |
template<typename T , typename TType > | |
std::optional< T > | type_try_dynamic_cast (TType &&base) |
Try to cast a generic typet to a specific derived class. More... | |
template<typename T , typename TExpr > | |
auto | expr_dynamic_cast (TExpr &base) -> typename detail::expr_dynamic_cast_return_typet< T, TExpr >::type |
Cast a reference to a generic exprt to a specific derived class. More... | |
template<typename T , typename TExpr > | |
auto | expr_checked_cast (TExpr &base) -> typename detail::expr_dynamic_cast_return_typet< T, TExpr >::type |
Cast a reference to a generic exprt to a specific derived class. More... | |
template<typename T , typename TType > | |
auto | type_checked_cast (TType &base) -> typename detail::expr_dynamic_cast_return_typet< T, TType >::type |
Cast a reference to a generic typet to a specific derived class and checks that the type could be converted. More... | |
void | validate_operands (const exprt &value, exprt::operandst::size_type number, const char *message, bool allow_more=false) |
Templated functions to cast to specific exprt-derived classes.
Definition in file expr_cast.h.
|
inline |
|
inline |
auto expr_checked_cast | ( | TExpr & | base | ) | -> typename detail::expr_dynamic_cast_return_typet<T, TExpr>::type |
Cast a reference to a generic exprt to a specific derived class.
Also assert that the expression has the expected type.
T | The reference or const reference type to TUnderlying to cast to |
TExpr | The original type to cast from, either exprt or const exprt |
base | Reference to a generic exprt |
std::bad_cast | If base is not an instance of TUnderlying |
Definition at line 227 of file expr_cast.h.
auto expr_dynamic_cast | ( | TExpr & | base | ) | -> typename detail::expr_dynamic_cast_return_typet<T, TExpr>::type |
Cast a reference to a generic exprt to a specific derived class.
T | The reference or const reference type to TUnderlying to cast to |
TExpr | The original type to cast from, either exprt or const exprt |
base | Reference to a generic exprt |
std::bad_cast | If base is not an instance of TUnderlying |
Definition at line 207 of file expr_cast.h.
std::optional<T> expr_try_dynamic_cast | ( | TExpr && | base | ) |
Try to cast a generic exprt to a specific derived class.
T | The type to cast the base param to. |
TType | The original type to cast from, must be a exprt rvalue. |
base | A generic exprt rvalue. |
Definition at line 107 of file expr_cast.h.
auto expr_try_dynamic_cast | ( | TExpr & | base | ) | -> typename detail::expr_try_dynamic_cast_return_typet<T, TExpr>::type |
Try to cast a reference to a generic exprt to a specific derived class.
T | The reference or const reference type to TUnderlying to cast to |
TExpr | The original type to cast from, either exprt or const exprt |
base | Reference to a generic exprt |
Definition at line 81 of file expr_cast.h.
auto type_checked_cast | ( | TType & | base | ) | -> typename detail::expr_dynamic_cast_return_typet<T, TType>::type |
Cast a reference to a generic typet to a specific derived class and checks that the type could be converted.
T | The reference or const reference type to TUnderlying to cast to |
TType | The original type to cast from, either typet or const typet |
base | Reference to a generic typet |
Definition at line 242 of file expr_cast.h.
std::optional<T> type_try_dynamic_cast | ( | TType && | base | ) |
Try to cast a generic typet to a specific derived class.
T | The type to cast the base param to. |
TType | The original type to cast from, must be a typet rvalue. |
base | A generic typet rvalue. |
Definition at line 159 of file expr_cast.h.
auto type_try_dynamic_cast | ( | TType & | base | ) | -> typename detail::expr_try_dynamic_cast_return_typet<T, TType>::type |
Try to cast a reference to a generic typet to a specific derived class.
T | The reference or const reference type to TUnderlying to cast to |
TType | The original type to cast from, either typet or const typet |
base | Reference to a generic typet |
Definition at line 135 of file expr_cast.h.
|
inline |
Called after casting.
Provides a point to assert on the structure of the expr. By default, this is a no-op, but you can provide an overload to validate particular types. Should always succeed unless the program has entered an invalid state. We validate objects at cast time as that is when these checks have been used historically, but it would be reasonable to validate objects in this way at any time.
Definition at line 49 of file expr_cast.h.
|
inline |
Definition at line 250 of file expr_cast.h.