@@ -522,6 +522,65 @@ to_java_specialized_generic_class_type(typet &type)
522522 return static_cast <const java_specialized_generic_class_typet &>(type);
523523}
524524
525+ // / Type for a generic symbol, extends symbol_typet with a
526+ // / vector of java generic types.
527+ // / This is used to store the type of generic superclasses and interfaces.
528+ class java_generic_symbol_typet : public symbol_typet
529+ {
530+ public:
531+ typedef std::vector<reference_typet> generic_typest;
532+
533+ java_generic_symbol_typet (
534+ const symbol_typet &type,
535+ const std::string &base_ref,
536+ const std::string &class_name_prefix)
537+ : symbol_typet(type)
538+ {
539+ set (ID_C_java_generic_symbol, true );
540+ const typet &base_type = java_type_from_string (base_ref, class_name_prefix);
541+ PRECONDITION (is_java_generic_type (base_type));
542+ const java_generic_typet gen_base_type = to_java_generic_type (base_type);
543+ generic_types ().insert (
544+ generic_types ().end (),
545+ gen_base_type.generic_type_arguments ().begin (),
546+ gen_base_type.generic_type_arguments ().end ());
547+ }
548+
549+ const generic_typest &generic_types () const
550+ {
551+ return (const generic_typest &)(find (ID_generic_types).get_sub ());
552+ }
553+
554+ generic_typest &generic_types ()
555+ {
556+ return (generic_typest &)(add (ID_generic_types).get_sub ());
557+ }
558+ };
559+
560+ // / \param type: the type to check
561+ // / \return true if the type is a symbol type with generics
562+ inline bool is_java_generic_symbol_type (const typet &type)
563+ {
564+ return type.get_bool (ID_C_java_generic_symbol);
565+ }
566+
567+ // / \param type: the type to convert
568+ // / \return the converted type
569+ inline const java_generic_symbol_typet &
570+ to_java_generic_symbol_type (const typet &type)
571+ {
572+ PRECONDITION (is_java_generic_symbol_type (type));
573+ return static_cast <const java_generic_symbol_typet &>(type);
574+ }
575+
576+ // / \param type: the type to convert
577+ // / \return the converted type
578+ inline java_generic_symbol_typet &to_java_generic_symbol_type (typet &type)
579+ {
580+ PRECONDITION (is_java_generic_symbol_type (type));
581+ return static_cast <java_generic_symbol_typet &>(type);
582+ }
583+
525584// / Take a signature string and remove everything in angle brackets allowing for
526585// / the type to be parsed normally, for example
527586// / `java.util.HashSet<java.lang.Integer>` will be turned into
0 commit comments