Skip to content
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

Add functions to retrieve a reference to the element type of a java array [TG-3821] #2521

Merged
merged 1 commit into from
Jul 17, 2018
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
23 changes: 16 additions & 7 deletions jbmc/src/java_bytecode/java_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,24 @@ 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)
/// Return a const reference to the element type of a given java array type
/// \param array_symbol The java array type
const typet &java_array_element_type(const symbol_typet &array_symbol)
{
INVARIANT(
is_java_array_tag(array_type.get_identifier()),
DATA_INVARIANT(
is_java_array_tag(array_symbol.get_identifier()),
"Symbol should have array tag");
return array_symbol.find_type(ID_C_element_type);
}

/// Return a non-const reference to the element type of a given java array type
/// \param array_symbol The java array type
typet &java_array_element_type(symbol_typet &array_symbol)
{
DATA_INVARIANT(
is_java_array_tag(array_symbol.get_identifier()),
"Symbol should have array tag");
return array_type.find_type(ID_C_element_type);
return array_symbol.add_type(ID_C_element_type);
}

/// See above
Expand Down
3 changes: 2 additions & 1 deletion jbmc/src/java_bytecode/java_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ 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);
const typet &java_array_element_type(const symbol_typet &array_symbol);
typet &java_array_element_type(symbol_typet &array_symbol);

bool is_reference_type(char t);

Expand Down