Skip to content

Commit 3ac6d17

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 ce1f4d2 commit 3ac6d17

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/java_bytecode/java_types.h

+6
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ inline java_class_typet &to_java_class_type(typet &type)
146146
return static_cast<java_class_typet &>(type);
147147
}
148148

149+
template <>
150+
inline bool can_cast_type<java_class_typet>(const typet &type)
151+
{
152+
return can_cast_type<class_typet>(type);
153+
}
154+
149155
typet java_int_type();
150156
typet java_long_type();
151157
typet java_short_type();

src/util/std_types.h

+12
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)