Skip to content

Commit

Permalink
Add type_dynamic_cast and friends for java_class_typet
Browse files Browse the repository at this point in the history
Add type_dynamic_cast and friends for struct_typet, class_typet and java_class_typet
  • Loading branch information
NathanJPhillips committed Apr 12, 2018
1 parent ce1f4d2 commit 3ac6d17
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/java_bytecode/java_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ inline java_class_typet &to_java_class_type(typet &type)
return static_cast<java_class_typet &>(type);
}

template <>
inline bool can_cast_type<java_class_typet>(const typet &type)
{
return can_cast_type<class_typet>(type);
}

typet java_int_type();
typet java_long_type();
typet java_short_type();
Expand Down
12 changes: 12 additions & 0 deletions src/util/std_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,12 @@ inline struct_typet &to_struct_type(typet &type)
return static_cast<struct_typet &>(type);
}

template <>
inline bool can_cast_type<struct_typet>(const typet &type)
{
return type.id() == ID_struct;
}

/*! \brief C++ class type
*/
class class_typet:public struct_typet
Expand Down Expand Up @@ -432,6 +438,12 @@ inline class_typet &to_class_type(typet &type)
return static_cast<class_typet &>(type);
}

template <>
inline bool can_cast_type<class_typet>(const typet &type)
{
return can_cast_type<struct_typet>(type) && type.get_bool(ID_C_class);
}

/*! \brief The union type
*/
class union_typet:public struct_union_typet
Expand Down

0 comments on commit 3ac6d17

Please sign in to comment.