Skip to content

Commit f10badb

Browse files
author
svorenova
committed
Add functions to retrieve a reference to the java array element type
1 parent a18b32d commit f10badb

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

jbmc/src/java_bytecode/java_types.cpp

+16-7
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,24 @@ reference_typet java_array_type(const char subtype)
120120
return java_reference_type(symbol_type);
121121
}
122122

123-
/// Return the type of the elements of a given java array type
124-
/// \param array_type The java array type
125-
/// \return The type of the elements of the array
126-
typet java_array_element_type(const symbol_typet &array_type)
123+
/// Return a const reference to the element type of a given java array type
124+
/// \param array_symbol The java array type
125+
const typet &java_array_element_type(const symbol_typet &array_symbol)
127126
{
128-
INVARIANT(
129-
is_java_array_tag(array_type.get_identifier()),
127+
DATA_INVARIANT(
128+
is_java_array_tag(array_symbol.get_identifier()),
129+
"Symbol should have array tag");
130+
return array_symbol.find_type(ID_C_element_type);
131+
}
132+
133+
/// Return a non-const reference to the element type of a given java array type
134+
/// \param array_symbol The java array type
135+
typet &java_array_element_type(symbol_typet &array_symbol)
136+
{
137+
DATA_INVARIANT(
138+
is_java_array_tag(array_symbol.get_identifier()),
130139
"Symbol should have array tag");
131-
return array_type.find_type(ID_C_element_type);
140+
return array_symbol.add_type(ID_C_element_type);
132141
}
133142

134143
/// See above

jbmc/src/java_bytecode/java_types.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,8 @@ reference_typet java_lang_object_type();
245245
symbol_typet java_classname(const std::string &);
246246

247247
reference_typet java_array_type(const char subtype);
248-
typet java_array_element_type(const symbol_typet &array_type);
248+
const typet &java_array_element_type(const symbol_typet &array_symbol);
249+
typet &java_array_element_type(symbol_typet &array_symbol);
249250

250251
bool is_reference_type(char t);
251252

0 commit comments

Comments
 (0)