@@ -34,13 +34,13 @@ class java_class_typet:public class_typet
34
34
35
35
inline const java_class_typet &to_java_class_type (const typet &type)
36
36
{
37
- assert (type.id ()==ID_struct);
37
+ PRECONDITION (type.id ()==ID_struct);
38
38
return static_cast <const java_class_typet &>(type);
39
39
}
40
40
41
41
inline java_class_typet &to_java_class_type (typet &type)
42
42
{
43
- assert (type.id ()==ID_struct);
43
+ PRECONDITION (type.id ()==ID_struct);
44
44
return static_cast <java_class_typet &>(type);
45
45
}
46
46
@@ -518,6 +518,71 @@ to_java_specialized_generic_class_type(typet &type)
518
518
return static_cast <const java_specialized_generic_class_typet &>(type);
519
519
}
520
520
521
+ // / Type for generic bases, extends typet with a
522
+ // / vector of java generic types.
523
+ // / This is used to store the type of generic superclasses and interfaces.
524
+ class java_generic_base_typet : public typet
525
+ {
526
+ public:
527
+ typedef std::vector<reference_typet> generic_typest;
528
+
529
+ java_generic_base_typet (
530
+ const irep_idt &identifier,
531
+ const generic_typest &gen_types)
532
+ : typet(ID_generic_base)
533
+ {
534
+ set (ID_identifier, identifier);
535
+ generic_types ().insert (generic_types ().end (), gen_types.begin (), gen_types
536
+ .end ());
537
+ }
538
+
539
+ static java_generic_base_typet build_from_ref (
540
+ const std::string &base_ref,
541
+ const std::string &class_name_prefix)
542
+ {
543
+ const typet &base_type = java_type_from_string (base_ref, class_name_prefix);
544
+ PRECONDITION (is_java_generic_type (base_type));
545
+ java_generic_typet gen_base_type = to_java_generic_type (base_type);
546
+ return java_generic_base_typet (
547
+ gen_base_type.subtype ().get (ID_identifier),
548
+ gen_base_type.generic_type_arguments ());
549
+ }
550
+
551
+ const generic_typest &generic_types () const
552
+ {
553
+ return (const generic_typest &)(find (ID_generic_types).get_sub ());
554
+ }
555
+
556
+ generic_typest &generic_types ()
557
+ {
558
+ return (generic_typest &)(add (ID_generic_types).get_sub ());
559
+ }
560
+ };
561
+
562
+ // / \param type: the type to check
563
+ // / \return true if type is a java class type with generics
564
+ inline bool is_java_generic_base_type (const typet &type)
565
+ {
566
+ return (type.id () == ID_generic_base);
567
+ }
568
+
569
+ // / \param type: the type to convert
570
+ // / \return the converted type
571
+ inline const java_generic_base_typet &
572
+ to_java_generic_base_type (const typet &type)
573
+ {
574
+ PRECONDITION (is_java_generic_base_type (type));
575
+ return static_cast <const java_generic_base_typet &>(type);
576
+ }
577
+
578
+ // / \param type: the type to convert
579
+ // / \return the converted type
580
+ inline java_generic_base_typet &to_java_generic_base_type (typet &type)
581
+ {
582
+ PRECONDITION (is_java_generic_base_type (type));
583
+ return static_cast <java_generic_base_typet &>(type);
584
+ }
585
+
521
586
// / Take a signature string and remove everything in angle brackets allowing for
522
587
// / the type to be parsed normally, for example
523
588
// / `java.util.HashSet<java.lang.Integer>` will be turned into
0 commit comments