Skip to content

Commit e66f76f

Browse files
author
svorenova
committed
Add a check functions for (multi-dimensional) array types
1 parent 78b7119 commit e66f76f

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

jbmc/src/java_bytecode/java_types.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,25 @@ typet &java_array_element_type(symbol_typet &array_symbol)
140140
return array_symbol.add_type(ID_C_element_type);
141141
}
142142

143+
/// Checks whether the given type is an array pointer type
144+
bool is_java_array_type(const typet &type)
145+
{
146+
if(!(type.id() == ID_pointer && type.subtype().id() == ID_symbol))
147+
return false;
148+
const auto &subtype_symbol = to_symbol_type(type.subtype());
149+
return is_java_array_tag(subtype_symbol.get_identifier());
150+
}
151+
152+
/// Checks whether the given type is a multi-dimensional array pointer type,
153+
// i.e., a pointer to an array type with element type also being a pointer to an
154+
/// array type.
155+
bool is_multidim_java_array_type(const typet &type)
156+
{
157+
return is_java_array_type(type) &&
158+
is_java_array_type(
159+
java_array_element_type(to_symbol_type(type.subtype())));
160+
}
161+
143162
/// See above
144163
/// \par parameters: Struct tag 'tag'
145164
/// \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
@@ -247,6 +247,8 @@ symbol_typet java_classname(const std::string &);
247247
reference_typet java_array_type(const char subtype);
248248
const typet &java_array_element_type(const symbol_typet &array_symbol);
249249
typet &java_array_element_type(symbol_typet &array_symbol);
250+
bool is_java_array_type(const typet &type);
251+
bool is_multidim_java_array_type(const typet &type);
250252

251253
bool is_reference_type(char t);
252254

0 commit comments

Comments
 (0)