CBMC
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
select_pointer_type.cpp
Go to the documentation of this file.
1/*******************************************************************\
2
3Module: Java Bytecode Language Conversion
4
5Author: Diffblue Ltd.
6
7\*******************************************************************/
8
12
13#include "select_pointer_type.h"
14
16#include "java_types.h"
17
18#include <util/std_types.h>
19
23 &generic_parameter_specialization_map,
24 const namespacet &) const
25{
27 pointer_type, generic_parameter_specialization_map);
28}
29
33 &generic_parameter_specialization_map) const
34{
36 if(parameter != nullptr)
37 {
38 irep_idt parameter_name = parameter->get_name();
39
40 // Make a local copy of the specialization map to unwind
42 generic_parameter_specialization_map;
43 while(true)
44 {
45 const std::optional<reference_typet> specialization =
48 {
49 // This means that the generic pointer_type has not been specialized
50 // in the current context (e.g., the method under test is generic);
51 // we return the pointer_type itself which is a pointer to its upper
52 // bound
53 return pointer_type;
54 }
55
57 return *specialization;
58 parameter_name = to_java_generic_parameter(*specialization).get_name();
59 }
60 }
61
62 auto base_type =
64 if(base_type != nullptr && is_java_array_tag(base_type->get_identifier()))
65 {
66 // if the pointer is an array, recursively specialize its element type
67 const auto *array_element_type =
69 if(array_element_type == nullptr)
70 return pointer_type;
71
73 *array_element_type, generic_parameter_specialization_map);
74
78 }
79
80 return pointer_type;
81}
82
83std::set<struct_tag_typet>
85 const irep_idt &,
86 const irep_idt &,
87 const namespacet &) const
88{
89 return {};
90}
pointer_typet pointer_type(const typet &subtype)
Definition c_types.cpp:235
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition dstring.h:38
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition namespace.h:91
The pointer type These are both 'bitvector_typet' (they have a width) and 'type_with_subtypet' (they ...
const typet & base_type() const
The type of the data what we point to.
virtual std::set< struct_tag_typet > get_parameter_alternative_types(const irep_idt &function_name, const irep_idt &parameter_name, const namespacet &ns) const
Get alternative types for a method parameter, e.g., based on the casts in the function body.
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.
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.
java_reference_typet java_array_type(const char subtype)
Construct an array pointer type.
bool is_java_array_tag(const irep_idt &tag)
See above.
const typet & java_array_element_type(const struct_tag_typet &array_symbol)
Return a const reference to the element type of a given java array type.
bool is_java_generic_parameter(const typet &type)
Checks whether the type is a java generic parameter/variable, e.g., T in List<T>.
Definition java_types.h:819
const java_generic_parametert & to_java_generic_parameter(const typet &type)
Definition java_types.h:826
Handle selection of correct pointer type (for example changing abstract classes to concrete versions)...
Pre-defined types.