CBMC
|
#include <select_pointer_type.h>
Public Member Functions | |
virtual | ~select_pointer_typet ()=default |
virtual pointer_typet | convert_pointer_type (const pointer_typet &pointer_type, const generic_parameter_specialization_mapt &generic_parameter_specialization_map, const namespacet &ns) const |
Select what type should be used for a given pointer type. More... | |
virtual std::set< struct_tag_typet > | get_parameter_alternative_types (const irep_idt &function_name, const irep_idt ¶meter_name, const namespacet &ns) const |
Get alternative types for a method parameter, e.g., based on the casts in the function body. More... | |
pointer_typet | specialize_generics (const pointer_typet &pointer_type, const generic_parameter_specialization_mapt &generic_parameter_specialization_map) const |
Specialize generic parameters in a pointer type based on the current map of parameters -> types. More... | |
Definition at line 22 of file select_pointer_type.h.
|
virtualdefault |
|
virtual |
Select what type should be used for a given pointer type.
In the base class we just use the supplied type. Derived classes can override this behavior to provide more sophisticated type selection. Generic parameters are replaced with their specialized type.
pointer_type | The pointer type to convert |
generic_parameter_specialization_map | Map of types for all generic parameters in the current scope |
ns | Namespace for type lookups |
Definition at line 20 of file select_pointer_type.cpp.
|
virtual |
Get alternative types for a method parameter, e.g., based on the casts in the function body.
In the base class we just return an empty set. Derived classes can override this behaviour to provide more sophisticated alternative type identification.
Definition at line 84 of file select_pointer_type.cpp.
pointer_typet select_pointer_typet::specialize_generics | ( | const pointer_typet & | pointer_type, |
const generic_parameter_specialization_mapt & | generic_parameter_specialization_map | ||
) | const |
Specialize generic parameters in a pointer type based on the current map of parameters -> types.
We specialize generics only if the pointer is a java generic parameter or an array with generic parameters. More general generic types such as MyGeneric<T>
are specialized indirectly in java_object_factoryt, their concrete types are already stored in the map and will be retrieved when needed e.g., to initialize fields. Example:
class MyGeneric<T,U> { MyGeneric<U,T> gen; T t;}
When instantiating MyGeneric<Integer,String> my
we need to resolve the type of my.gen.t
. The map would in this context containNote that the top of the stacks for T and U create a recursion T -> U, U-> T. We break it and specialize T my.gen.t
to String my.gen.t
.
pointer_type | The pointer to be specialized |
generic_parameter_specialization_map | Map of types for all generic parameters in the current scope |
Definition at line 30 of file select_pointer_type.cpp.