Skip to content

Commit b58813b

Browse files
author
Thomas Kiley
authored
Merge pull request diffblue#2479 from thk123/bugfix/TG-3908/give-string-objects-names
Given string types an appropriate name [TG-3908]
2 parents ffbb83f + fd2f21e commit b58813b

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

jbmc/src/java_bytecode/java_bytecode_convert_class.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ void java_bytecode_convert_classt::convert(
393393
new_symbol.base_name = base_name;
394394
new_symbol.pretty_name=c.name;
395395
new_symbol.name=qualified_classname;
396-
class_type.set(ID_name, new_symbol.name);
396+
class_type.set_name(new_symbol.name);
397397
new_symbol.type=class_type;
398398
new_symbol.mode=ID_java;
399399
new_symbol.is_type=true;
@@ -716,15 +716,15 @@ void java_bytecode_convert_classt::add_array_types(symbol_tablet &symbol_table)
716716
if(symbol_table.has_symbol(symbol_type_identifier))
717717
return;
718718

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

729729
class_type.components().reserve(3);
730730
class_typet::componentt base_class_component(

jbmc/src/java_bytecode/java_string_library_preprocess.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ void java_string_library_preprocesst::add_string_type(
222222
{
223223
java_class_typet string_type;
224224
string_type.set_tag(class_name);
225+
string_type.set_name("java::" + id2string(class_name));
225226
string_type.components().resize(3);
226227
string_type.components()[0].set_name("@java.lang.Object");
227228
string_type.components()[0].set_pretty_name("@java.lang.Object");

jbmc/src/java_bytecode/java_types.h

+14
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,20 @@ class java_class_typet:public class_typet
158158
return type_checked_cast<annotated_typet>(
159159
static_cast<typet &>(*this)).get_annotations();
160160
}
161+
162+
/// Get the name of the struct, which can be used to look up its symbol
163+
/// in the symbol table.
164+
const irep_idt &get_name() const
165+
{
166+
return get(ID_name);
167+
}
168+
169+
/// Set the name of the struct, which can be used to look up its symbol
170+
/// in the symbol table.
171+
void set_name(const irep_idt &name)
172+
{
173+
set(ID_name, name);
174+
}
161175
};
162176

163177
inline const java_class_typet &to_java_class_type(const typet &type)

jbmc/src/java_bytecode/java_utils.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void generate_class_stub(
6767
message_handlert &message_handler,
6868
const struct_union_typet::componentst &componentst)
6969
{
70-
class_typet class_type;
70+
java_class_typet class_type;
7171

7272
class_type.set_tag(class_name);
7373
class_type.set(ID_base_name, class_name);
@@ -79,7 +79,7 @@ void generate_class_stub(
7979
new_symbol.base_name=class_name;
8080
new_symbol.pretty_name=class_name;
8181
new_symbol.name="java::"+id2string(class_name);
82-
class_type.set(ID_name, new_symbol.name);
82+
class_type.set_name(new_symbol.name);
8383
new_symbol.type=class_type;
8484
new_symbol.mode=ID_java;
8585
new_symbol.is_type=true;

0 commit comments

Comments
 (0)