Skip to content

Given string types an appropriate name [TG-3908] #2479

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
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
6 changes: 3 additions & 3 deletions jbmc/src/java_bytecode/java_bytecode_convert_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ void java_bytecode_convert_classt::convert(
new_symbol.base_name = base_name;
new_symbol.pretty_name=c.name;
new_symbol.name=qualified_classname;
class_type.set(ID_name, new_symbol.name);
class_type.set_name(new_symbol.name);
new_symbol.type=class_type;
new_symbol.mode=ID_java;
new_symbol.is_type=true;
Expand Down Expand Up @@ -716,15 +716,15 @@ void java_bytecode_convert_classt::add_array_types(symbol_tablet &symbol_table)
if(symbol_table.has_symbol(symbol_type_identifier))
return;

class_typet class_type;
java_class_typet class_type;
// we have the base class, java.lang.Object, length and data
// of appropriate type
class_type.set_tag(symbol_type_identifier);
// Note that non-array types don't have "java::" at the beginning of their
// tag, and their name is "java::" + their tag. Since arrays do have
// "java::" at the beginning of their tag we set the name to be the same as
// the tag.
class_type.set(ID_name, symbol_type_identifier);
class_type.set_name(symbol_type_identifier);

class_type.components().reserve(3);
class_typet::componentt base_class_component(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ void java_string_library_preprocesst::add_string_type(
{
java_class_typet string_type;
string_type.set_tag(class_name);
string_type.set_name("java::" + id2string(class_name));
string_type.components().resize(3);
string_type.components()[0].set_name("@java.lang.Object");
string_type.components()[0].set_pretty_name("@java.lang.Object");
Expand Down
14 changes: 14 additions & 0 deletions jbmc/src/java_bytecode/java_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,20 @@ class java_class_typet:public class_typet
return type_checked_cast<annotated_typet>(
static_cast<typet &>(*this)).get_annotations();
}

/// Get the name of the struct, which can be used to look up its symbol
/// in the symbol table.
const irep_idt &get_name() const
{
return get(ID_name);
}

/// Set the name of the struct, which can be used to look up its symbol
/// in the symbol table.
void set_name(const irep_idt &name)
{
set(ID_name, name);
}
};

inline const java_class_typet &to_java_class_type(const typet &type)
Expand Down
4 changes: 2 additions & 2 deletions jbmc/src/java_bytecode/java_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void generate_class_stub(
message_handlert &message_handler,
const struct_union_typet::componentst &componentst)
{
class_typet class_type;
java_class_typet class_type;

class_type.set_tag(class_name);
class_type.set(ID_base_name, class_name);
Expand All @@ -79,7 +79,7 @@ void generate_class_stub(
new_symbol.base_name=class_name;
new_symbol.pretty_name=class_name;
new_symbol.name="java::"+id2string(class_name);
class_type.set(ID_name, new_symbol.name);
class_type.set_name(new_symbol.name);
new_symbol.type=class_type;
new_symbol.mode=ID_java;
new_symbol.is_type=true;
Expand Down