Skip to content

Commit 3256f60

Browse files
author
svorenova
committed
Add functions to retrieve a reference to the java array element type
1 parent 6acabcb commit 3256f60

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

jbmc/src/java_bytecode/java_types.cpp

Lines changed: 15 additions & 6 deletions
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
{
128127
INVARIANT(
129-
is_java_array_tag(array_type.get_identifier()),
128+
is_java_array_tag(array_symbol.get_identifier()),
130129
"Symbol should have array tag");
131-
return array_type.find_type(ID_C_element_type);
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+
INVARIANT(
138+
is_java_array_tag(array_symbol.get_identifier()),
139+
"Symbol should have array tag");
140+
return const_cast<typet &>(array_symbol.find_type(ID_C_element_type));
132141
}
133142

134143
/// See above

jbmc/src/java_bytecode/java_types.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ reference_typet java_lang_object_type();
235235
symbol_typet java_classname(const std::string &);
236236

237237
reference_typet java_array_type(const char subtype);
238-
typet java_array_element_type(const symbol_typet &array_type);
238+
const typet &java_array_element_type(const symbol_typet &array_symbol);
239+
typet &java_array_element_type(symbol_typet &array_symbol);
239240

240241
bool is_reference_type(char t);
241242

0 commit comments

Comments
 (0)