Skip to content

Commit d612d75

Browse files
Add type_dynamic_cast and friends for java_class_typet
Add type_dynamic_cast and friends for struct_typet, class_typet and java_class_typet
1 parent f90f7c4 commit d612d75

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/java_bytecode/java_types.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ inline java_class_typet &to_java_class_type(typet &type)
119119
return static_cast<java_class_typet &>(type);
120120
}
121121

122+
template <>
123+
inline bool can_cast_type<java_class_typet>(const typet &type)
124+
{
125+
return can_cast_type<class_typet>(type);
126+
}
127+
122128
typet java_int_type();
123129
typet java_long_type();
124130
typet java_short_type();

src/util/std_types.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,12 @@ inline struct_typet &to_struct_type(typet &type)
328328
return static_cast<struct_typet &>(type);
329329
}
330330

331+
template <>
332+
inline bool can_cast_type<struct_typet>(const typet &type)
333+
{
334+
return type.id() == ID_struct;
335+
}
336+
331337
/*! \brief C++ class type
332338
*/
333339
class class_typet:public struct_typet
@@ -432,6 +438,12 @@ inline class_typet &to_class_type(typet &type)
432438
return static_cast<class_typet &>(type);
433439
}
434440

441+
template <>
442+
inline bool can_cast_type<class_typet>(const typet &type)
443+
{
444+
return can_cast_type<struct_typet>(type) && type.get_bool(ID_C_class);
445+
}
446+
435447
/*! \brief The union type
436448
*/
437449
class union_typet:public struct_union_typet

0 commit comments

Comments
 (0)