Skip to content

Commit 4e313ed

Browse files
author
svorenova
committed
Add functions to retrieve a reference to the element type of a java array
1 parent d1a4169 commit 4e313ed

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

jbmc/src/java_bytecode/java_types.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,26 @@ typet java_array_element_type(const symbol_typet &array_type)
131131
return array_type.find_type(ID_C_element_type);
132132
}
133133

134+
/// Return a const reference to the element type of a given java array type
135+
/// \param array_type The java array type
136+
const typet &java_array_element_type_ref(const symbol_typet &array_type)
137+
{
138+
INVARIANT(
139+
is_java_array_tag(array_type.get_identifier()),
140+
"Symbol should have array tag");
141+
return array_type.find_type(ID_C_element_type);
142+
}
143+
144+
/// Return a non-const reference to the element type of a given java array type
145+
/// \param array_type The java array type
146+
typet &java_array_element_type_ref(symbol_typet &array_type)
147+
{
148+
INVARIANT(
149+
is_java_array_tag(array_type.get_identifier()),
150+
"Symbol should have array tag");
151+
return const_cast<typet &>(array_type.find_type(ID_C_element_type));
152+
}
153+
134154
/// See above
135155
/// \par parameters: Struct tag 'tag'
136156
/// \return True if the given struct is a Java array

jbmc/src/java_bytecode/java_types.h

+2
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ symbol_typet java_classname(const std::string &);
236236

237237
reference_typet java_array_type(const char subtype);
238238
typet java_array_element_type(const symbol_typet &array_type);
239+
const typet &java_array_element_type_ref(const symbol_typet &array_type);
240+
typet &java_array_element_type_ref(symbol_typet &array_type);
239241

240242
bool is_reference_type(char t);
241243

0 commit comments

Comments
 (0)