@@ -87,6 +87,10 @@ reference_typet java_lang_object_type()
8787 return java_reference_type (symbol_typet (" java::java.lang.Object" ));
8888}
8989
90+ // / Construct an array pointer type. It is a pointer to a symbol with identifier
91+ // / java::array[]. Its ID_C_element_type is set to the corresponding primitive
92+ // / type, or void* for arrays of references.
93+ // / \param subtype Character indicating the type of array
9094reference_typet java_array_type (const char subtype)
9195{
9296 std::string subtype_str;
@@ -140,19 +144,48 @@ typet &java_array_element_type(symbol_typet &array_symbol)
140144 return array_symbol.add_type (ID_C_element_type);
141145}
142146
143- // / See above
144- // / \par parameters: Struct tag 'tag'
145- // / \return True if the given struct is a Java array
146- bool is_java_array_tag (const irep_idt& tag)
147+ // / Checks whether the given type is an array pointer type
148+ bool is_java_array_type (const typet &type)
147149{
148- return has_prefix (id2string (tag), " java::array[" );
150+ if (
151+ !can_cast_type<pointer_typet>(type) ||
152+ !can_cast_type<symbol_typet>(type.subtype ()))
153+ {
154+ return false ;
155+ }
156+ const auto &subtype_symbol = to_symbol_type (type.subtype ());
157+ return is_java_array_tag (subtype_symbol.get_identifier ());
149158}
150159
151- bool is_reference_type (const char t)
160+ // / Checks whether the given type is a multi-dimensional array pointer type,
161+ // i.e., a pointer to an array type with element type also being a pointer to an
162+ // / array type.
163+ bool is_multidim_java_array_type (const typet &type)
152164{
153- return ' a' ==t;
165+ return is_java_array_type (type) &&
166+ is_java_array_type (
167+ java_array_element_type (to_symbol_type (type.subtype ())));
168+ }
169+
170+ // / See above
171+ // / \param tag Tag of a struct
172+ // / \return True if the given string is a Java array tag, i.e., has a prefix
173+ // / of java::array[
174+ bool is_java_array_tag (const irep_idt& tag)
175+ {
176+ return has_prefix (id2string (tag), " java::array[" );
154177}
155178
179+ // / Constructs a type indicated by the given character:
180+ // / - i integer
181+ // / - l long
182+ // / - s short
183+ // / - b byte
184+ // / - c character
185+ // / - f float
186+ // / - d double
187+ // / - z boolean
188+ // / - a reference
156189typet java_type_from_char (char t)
157190{
158191 switch (t)
0 commit comments