Skip to content

Add a helper function for accessing the element type of a Java array type #1543

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/java_bytecode/java_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,17 @@ reference_typet java_array_type(const char subtype)
return java_reference_type(symbol_type);
}

/// Return the type of the elements of a given java array type
/// \param array_type The java array type
/// \return The type of the elements of the array
typet java_array_element_type(const symbol_typet &array_type)
{
INVARIANT(
is_java_array_tag(array_type.get_identifier()),
"Symbol should have array tag");
return array_type.find_type(ID_C_element_type);
}

/// See above
/// \par parameters: Struct tag 'tag'
/// \return True if the given struct is a Java array
Expand Down
1 change: 1 addition & 0 deletions src/java_bytecode/java_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ reference_typet java_lang_object_type();
symbol_typet java_classname(const std::string &);

reference_typet java_array_type(const char subtype);
typet java_array_element_type(const symbol_typet &array_type);

bool is_reference_type(char t);

Expand Down