Skip to content

Commit ef6b4af

Browse files
author
Matthias Güdemann
committed
Post-fix arrays as generic types with their element type
1 parent 4db6fc6 commit ef6b4af

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

src/java_bytecode/generate_java_generic_type.cpp

+18-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,24 @@ irep_idt generate_java_generic_typet::build_generic_tag(
119119
INVARIANT(
120120
is_java_generic_inst_parameter(param),
121121
"Only create full concretized generic types");
122-
new_tag_buffer << param.subtype().get(ID_identifier);
122+
const irep_idt &id(id2string(param.subtype().get(ID_identifier)));
123+
new_tag_buffer << id2string(id);
124+
if(is_java_array_tag(id))
125+
{
126+
const typet &element_type =
127+
java_array_element_type(to_symbol_type(param.subtype()));
128+
129+
// If this is an array of references then we will specialize its
130+
// identifier using the type of the objects in the array. Else, there can
131+
// be a problem with the same symbols for different instantiations using
132+
// arrays with different types.
133+
if(element_type.id() == ID_pointer)
134+
{
135+
const symbol_typet element_symbol =
136+
to_symbol_type(element_type.subtype());
137+
new_tag_buffer << "of_" << id2string(element_symbol.get_identifier());
138+
}
139+
}
123140
}
124141

125142
new_tag_buffer << ">";

src/java_bytecode/java_utils.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@ Author: Daniel Kroening, [email protected]
2121

2222
bool java_is_array_type(const typet &type)
2323
{
24-
if(type.id()!=ID_struct)
24+
if(type.id() != ID_struct)
2525
return false;
26-
return has_prefix(id2string(
27-
to_struct_type(type).get_tag()),
28-
"java::array[");
26+
return is_java_array_tag(to_struct_type(type).get_tag());
2927
}
3028

3129
unsigned java_local_variable_slots(const typet &t)

0 commit comments

Comments
 (0)