File tree 2 files changed +30
-0
lines changed
2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -507,6 +507,20 @@ class java_generic_symbol_typet : public symbol_typet
507
507
{
508
508
return (generic_typest &)(add (ID_generic_types).get_sub ());
509
509
}
510
+
511
+ // / Check if this symbol has the given generic type. If yes, return its index
512
+ // / in the vector of generic types.
513
+ // / \param type The type we are looking for.
514
+ // / \return The index of the type in the vector of generic types.
515
+ optionalt<size_t > generic_type (const reference_typet &type) const
516
+ {
517
+ const size_t &index =
518
+ std::find (generic_types ().begin (), generic_types ().end (), type) -
519
+ generic_types ().begin ();
520
+ if (index < generic_types ().size ())
521
+ return index ;
522
+ return {};
523
+ }
510
524
};
511
525
512
526
// / \param type: the type to check
Original file line number Diff line number Diff line change @@ -401,6 +401,22 @@ class class_typet:public struct_typet
401
401
return false ;
402
402
}
403
403
404
+ // / Return the base with the given name, if exists.
405
+ // / \param id The name of the base we are looking for.
406
+ // / \return The base if exists.
407
+ optionalt<baset> get_base (const irep_idt &id) const
408
+ {
409
+ if (has_base (id))
410
+ {
411
+ for (const auto &b : bases ())
412
+ {
413
+ if (to_symbol_type (b.type ()).get (ID_identifier) == id)
414
+ return b;
415
+ }
416
+ }
417
+ return {};
418
+ }
419
+
404
420
bool is_abstract () const
405
421
{
406
422
return get_bool (ID_abstract);
You can’t perform that action at this time.
0 commit comments