Skip to content

Commit 64bfc03

Browse files
author
Daniel Kroening
committed
java frontend: symbol_type -> struct_tag
1 parent 12b70f7 commit 64bfc03

File tree

57 files changed

+482
-474
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+482
-474
lines changed

jbmc/src/java_bytecode/ci_lazy_methods.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ ci_lazy_methodst::ci_lazy_methodst(
6161
/// class
6262
static bool references_class_model(const exprt &expr)
6363
{
64-
static const symbol_typet class_type("java::java.lang.Class");
64+
static const struct_tag_typet class_type("java::java.lang.Class");
6565

6666
for(auto it = expr.depth_begin(); it != expr.depth_end(); ++it)
6767
{

jbmc/src/java_bytecode/ci_lazy_methods_needed.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void ci_lazy_methods_neededt::initialize_instantiated_classes_from_pointer(
7474
const pointer_typet &pointer_type,
7575
const namespacet &ns)
7676
{
77-
const symbol_typet &class_type = to_symbol_type(pointer_type.subtype());
77+
const auto &class_type = to_struct_tag_type(pointer_type.subtype());
7878
const auto &param_classid = class_type.get_identifier();
7979

8080
// Note here: different arrays may have different element types, so we should
@@ -112,10 +112,10 @@ void ci_lazy_methods_neededt::gather_field_types(
112112
{
113113
// If class_type is not a symbol this may be a reference array,
114114
// but we can't tell what type.
115-
if(class_type.id() == ID_symbol_type)
115+
if(class_type.id() == ID_struct_tag)
116116
{
117117
const typet &element_type =
118-
java_array_element_type(to_symbol_type(class_type));
118+
java_array_element_type(to_struct_tag_type(class_type));
119119
if(element_type.id() == ID_pointer)
120120
{
121121
// This is a reference array -- mark its element type available.
@@ -127,11 +127,11 @@ void ci_lazy_methods_neededt::gather_field_types(
127127
{
128128
for(const auto &field : underlying_type.components())
129129
{
130-
if(field.type().id() == ID_struct || field.type().id() == ID_symbol_type)
130+
if(field.type().id() == ID_struct || field.type().id() == ID_struct_tag)
131131
gather_field_types(field.type(), ns);
132132
else if(field.type().id() == ID_pointer)
133133
{
134-
if(field.type().subtype().id() == ID_symbol_type)
134+
if(field.type().subtype().id() == ID_struct_tag)
135135
{
136136
add_all_needed_classes(to_pointer_type(field.type()));
137137
}

jbmc/src/java_bytecode/generic_parameter_specialization_map_keys.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,29 +136,29 @@ const void generic_parameter_specialization_map_keyst::insert_pairs_for_pointer(
136136
/// in the form of a symbol rather than a pointer (as opposed to the function
137137
/// insert_pairs_for_pointer). Own the keys and pop from their stack
138138
/// on destruction; otherwise do nothing.
139-
/// \param symbol_type symbol type to get the specialized generic types from
139+
/// \param struct_tag_type symbol type to get the specialized generic types from
140140
/// \param symbol_struct struct type of the symbol type, must be generic if
141141
/// the symbol is generic
142142
const void generic_parameter_specialization_map_keyst::insert_pairs_for_symbol(
143-
const symbol_typet &symbol_type,
143+
const struct_tag_typet &struct_tag_type,
144144
const typet &symbol_struct)
145145
{
146146
// If the struct is:
147147
// - an incomplete class or
148148
// - a class that is neither generic nor implicitly generic (this
149149
// may be due to unsupported class signature)
150-
// then ignore the generic types in the symbol_type and do not add any pairs.
150+
// then ignore the generic types in the struct_tag_type and do not add any pairs.
151151
// TODO TG-1996 should decide how mocking and generics should work
152152
// together. Currently an incomplete class is never marked as generic. If
153153
// this changes in TG-1996 then the condition below should be updated.
154154
if(
155-
is_java_generic_symbol_type(symbol_type) &&
155+
is_java_generic_struct_tag_type(struct_tag_type) &&
156156
!symbol_struct.get_bool(ID_incomplete_class) &&
157157
(is_java_generic_class_type(symbol_struct) ||
158158
is_java_implicitly_generic_class_type(symbol_struct)))
159159
{
160-
const java_generic_symbol_typet &generic_symbol =
161-
to_java_generic_symbol_type(symbol_type);
160+
const java_generic_struct_tag_typet &generic_symbol =
161+
to_java_generic_struct_tag_type(struct_tag_type);
162162

163163
const std::vector<java_generic_parametert> &generic_parameters =
164164
get_all_generic_parameters(symbol_struct);

jbmc/src/java_bytecode/generic_parameter_specialization_map_keys.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,8 @@ class generic_parameter_specialization_map_keyst
5050
const void insert_pairs_for_pointer(
5151
const pointer_typet &pointer_type,
5252
const typet &pointer_subtype_struct);
53-
const void insert_pairs_for_symbol(
54-
const symbol_typet &symbol_type,
55-
const typet &symbol_struct);
53+
const void
54+
insert_pairs_for_symbol(const struct_tag_typet &, const typet &symbol_struct);
5655

5756
private:
5857
/// Generic parameter specialization map to modify

jbmc/src/java_bytecode/java_bytecode_concurrency_instrumentation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ static void instrument_synchronized_code(
237237

238238
// Create the finally block with the same label targeted in the catch-push
239239
const symbolt &tmp_symbol = get_fresh_aux_symbol(
240-
java_reference_type(symbol_typet("java::java.lang.Throwable")),
240+
java_reference_type(struct_tag_typet("java::java.lang.Throwable")),
241241
id2string(symbol.name),
242242
"caught-synchronized-exception",
243243
code.source_location(),

jbmc/src/java_bytecode/java_bytecode_convert_class.cpp

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ void java_bytecode_convert_classt::convert(
338338

339339
if(!c.super_class.empty())
340340
{
341-
const symbol_typet base("java::" + id2string(c.super_class));
341+
const struct_tag_typet base("java::" + id2string(c.super_class));
342342

343343
// if the superclass is generic then the class has the superclass reference
344344
// including the generic info in its signature
@@ -350,7 +350,7 @@ void java_bytecode_convert_classt::convert(
350350
{
351351
try
352352
{
353-
const java_generic_symbol_typet generic_base(
353+
const java_generic_struct_tag_typet generic_base(
354354
base, superclass_ref.value(), qualified_classname);
355355
class_type.add_base(generic_base);
356356
}
@@ -378,7 +378,7 @@ void java_bytecode_convert_classt::convert(
378378
// interfaces are recorded as bases
379379
for(const auto &interface : c.implements)
380380
{
381-
const symbol_typet base("java::" + id2string(interface));
381+
const struct_tag_typet base("java::" + id2string(interface));
382382

383383
// if the interface is generic then the class has the interface reference
384384
// including the generic info in its signature
@@ -390,7 +390,7 @@ void java_bytecode_convert_classt::convert(
390390
{
391391
try
392392
{
393-
const java_generic_symbol_typet generic_base(
393+
const java_generic_struct_tag_typet generic_base(
394394
base, interface_ref.value(), qualified_classname);
395395
class_type.add_base(generic_base);
396396
}
@@ -772,26 +772,27 @@ void java_bytecode_convert_classt::add_array_types(symbol_tablet &symbol_table)
772772

773773
for(const char l : letters)
774774
{
775-
symbol_typet symbol_type=
776-
to_symbol_type(java_array_type(l).subtype());
775+
struct_tag_typet struct_tag_type =
776+
to_struct_tag_type(java_array_type(l).subtype());
777777

778-
const irep_idt &symbol_type_identifier=symbol_type.get_identifier();
779-
if(symbol_table.has_symbol(symbol_type_identifier))
778+
const irep_idt &struct_tag_type_identifier =
779+
struct_tag_type.get_identifier();
780+
if(symbol_table.has_symbol(struct_tag_type_identifier))
780781
return;
781782

782783
java_class_typet class_type;
783784
// we have the base class, java.lang.Object, length and data
784785
// of appropriate type
785-
class_type.set_tag(symbol_type_identifier);
786+
class_type.set_tag(struct_tag_type_identifier);
786787
// Note that non-array types don't have "java::" at the beginning of their
787788
// tag, and their name is "java::" + their tag. Since arrays do have
788789
// "java::" at the beginning of their tag we set the name to be the same as
789790
// the tag.
790-
class_type.set_name(symbol_type_identifier);
791+
class_type.set_name(struct_tag_type_identifier);
791792

792793
class_type.components().reserve(3);
793794
class_typet::componentt base_class_component(
794-
"@java.lang.Object", symbol_typet("java::java.lang.Object"));
795+
"@java.lang.Object", struct_tag_typet("java::java.lang.Object"));
795796
base_class_component.set_pretty_name("@java.lang.Object");
796797
base_class_component.set_base_name("@java.lang.Object");
797798
class_type.components().push_back(base_class_component);
@@ -807,16 +808,16 @@ void java_bytecode_convert_classt::add_array_types(symbol_tablet &symbol_table)
807808
data_component.set_base_name("data");
808809
class_type.components().push_back(data_component);
809810

810-
class_type.add_base(symbol_typet("java::java.lang.Object"));
811+
class_type.add_base(struct_tag_typet("java::java.lang.Object"));
811812

812813
INVARIANT(
813814
is_valid_java_array(class_type),
814815
"Constructed a new type representing a Java Array "
815816
"object that doesn't match expectations");
816817

817818
symbolt symbol;
818-
symbol.name=symbol_type_identifier;
819-
symbol.base_name=symbol_type.get(ID_C_base_name);
819+
symbol.name = struct_tag_type_identifier;
820+
symbol.base_name = struct_tag_type.get(ID_C_base_name);
820821
symbol.is_type=true;
821822
symbol.type = class_type;
822823
symbol.mode = ID_java;
@@ -825,13 +826,13 @@ void java_bytecode_convert_classt::add_array_types(symbol_tablet &symbol_table)
825826
// Also provide a clone method:
826827
// ----------------------------
827828

828-
const irep_idt clone_name=
829-
id2string(symbol_type_identifier)+".clone:()Ljava/lang/Object;";
829+
const irep_idt clone_name =
830+
id2string(struct_tag_type_identifier) + ".clone:()Ljava/lang/Object;";
830831
java_method_typet::parametert this_param;
831832
this_param.set_identifier(id2string(clone_name)+"::this");
832833
this_param.set_base_name("this");
833834
this_param.set_this();
834-
this_param.type()=java_reference_type(symbol_type);
835+
this_param.type() = java_reference_type(struct_tag_type);
835836
const java_method_typet clone_type({this_param}, java_lang_object_type());
836837

837838
parameter_symbolt this_symbol;
@@ -848,7 +849,7 @@ void java_bytecode_convert_classt::add_array_types(symbol_tablet &symbol_table)
848849
local_symbol.name=local_name;
849850
local_symbol.base_name="cloned_array";
850851
local_symbol.pretty_name=local_symbol.base_name;
851-
local_symbol.type=java_reference_type(symbol_type);
852+
local_symbol.type = java_reference_type(struct_tag_type);
852853
local_symbol.mode=ID_java;
853854
symbol_table.add(local_symbol);
854855
const auto &local_symexpr=local_symbol.symbol_expr();
@@ -861,9 +862,9 @@ void java_bytecode_convert_classt::add_array_types(symbol_tablet &symbol_table)
861862
source_locationt location;
862863
location.set_function(local_name);
863864
side_effect_exprt java_new_array(
864-
ID_java_new_array, java_reference_type(symbol_type), location);
865-
dereference_exprt old_array(this_symbol.symbol_expr(), symbol_type);
866-
dereference_exprt new_array(local_symexpr, symbol_type);
865+
ID_java_new_array, java_reference_type(struct_tag_type), location);
866+
dereference_exprt old_array(this_symbol.symbol_expr(), struct_tag_type);
867+
dereference_exprt new_array(local_symexpr, struct_tag_type);
867868
member_exprt old_length(
868869
old_array, length_component.get_name(), length_component.type());
869870
java_new_array.copy_to_operands(old_length);
@@ -931,8 +932,8 @@ void java_bytecode_convert_classt::add_array_types(symbol_tablet &symbol_table)
931932

932933
symbolt clone_symbol;
933934
clone_symbol.name=clone_name;
934-
clone_symbol.pretty_name=
935-
id2string(symbol_type_identifier)+".clone:()";
935+
clone_symbol.pretty_name =
936+
id2string(struct_tag_type_identifier) + ".clone:()";
936937
clone_symbol.base_name="clone";
937938
clone_symbol.type=clone_type;
938939
clone_symbol.value=clone_body;
@@ -1061,9 +1062,10 @@ static void find_and_replace_parameters(
10611062
find_and_replace_parameters(argument, replacement_parameters);
10621063
}
10631064
}
1064-
else if(is_java_generic_symbol_type(type))
1065+
else if(is_java_generic_struct_tag_type(type))
10651066
{
1066-
java_generic_symbol_typet &generic_base = to_java_generic_symbol_type(type);
1067+
java_generic_struct_tag_typet &generic_base =
1068+
to_java_generic_struct_tag_type(type);
10671069
std::vector<reference_typet> &gen_types = generic_base.generic_types();
10681070
for(auto &gen_type : gen_types)
10691071
{

jbmc/src/java_bytecode/java_bytecode_convert_method.cpp

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,8 @@ void java_bytecode_convert_method_lazy(
383383
{
384384
java_method_typet::parameterst &parameters = member_type.parameters();
385385
java_method_typet::parametert this_p;
386-
const reference_typet object_ref_type=
387-
java_reference_type(symbol_typet(class_symbol.name));
386+
const reference_typet object_ref_type =
387+
java_reference_type(struct_tag_typet(class_symbol.name));
388388
this_p.type()=object_ref_type;
389389
this_p.set_this();
390390
parameters.insert(parameters.begin(), this_p);
@@ -658,7 +658,7 @@ static irep_idt get_if_cmp_operator(const irep_idt &stmt)
658658

659659
static member_exprt to_member(const exprt &pointer, const exprt &fieldref)
660660
{
661-
symbol_typet class_type(fieldref.get(ID_class));
661+
struct_tag_typet class_type(fieldref.get(ID_class));
662662

663663
const typecast_exprt pointer2(pointer, java_reference_type(class_type));
664664

@@ -1185,9 +1185,11 @@ codet java_bytecode_convert_methodt::convert_instructions(
11851185
{
11861186
if(cur_pc==it->handler_pc)
11871187
{
1188-
if(catch_type != typet() || it->catch_type == symbol_typet(irep_idt()))
1188+
if(
1189+
catch_type != typet() ||
1190+
it->catch_type == struct_tag_typet(irep_idt()))
11891191
{
1190-
catch_type=symbol_typet("java::java.lang.Throwable");
1192+
catch_type = struct_tag_typet("java::java.lang.Throwable");
11911193
break;
11921194
}
11931195
else
@@ -1637,7 +1639,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
16371639
const typecast_exprt pointer(op[0], java_array_type(statement[0]));
16381640

16391641
dereference_exprt array(pointer, pointer.type().subtype());
1640-
PRECONDITION(pointer.type().subtype().id() == ID_symbol_type);
1642+
PRECONDITION(pointer.type().subtype().id() == ID_struct_tag);
16411643
array.set(ID_java_member_access, true);
16421644

16431645
const member_exprt length(array, "length", java_int_type());
@@ -2119,7 +2121,7 @@ void java_bytecode_convert_methodt::convert_invoke(
21192121
if(parameters.empty() || !parameters[0].get_this())
21202122
{
21212123
irep_idt classname = arg0.get(ID_C_class);
2122-
typet thistype = symbol_typet(classname);
2124+
typet thistype = struct_tag_typet(classname);
21232125
// Note invokespecial is used for super-method calls as well as
21242126
// constructors.
21252127
if(statement == "invokespecial")
@@ -2548,7 +2550,7 @@ void java_bytecode_convert_methodt::convert_new(
25482550
c = code_assignt(tmp, java_new_expr);
25492551
c.add_source_location() = location;
25502552
codet clinit_call =
2551-
get_clinit_call(to_symbol_type(arg0.type()).get_identifier());
2553+
get_clinit_call(to_struct_tag_type(arg0.type()).get_identifier());
25522554
if(clinit_call.get_statement() != ID_skip)
25532555
{
25542556
code_blockt ret_block;
@@ -2565,10 +2567,10 @@ codet java_bytecode_convert_methodt::convert_putstatic(
25652567
const exprt::operandst &op,
25662568
const symbol_exprt &symbol_expr)
25672569
{
2568-
if(needed_lazy_methods && arg0.type().id() == ID_symbol_type)
2570+
if(needed_lazy_methods && arg0.type().id() == ID_struct_tag)
25692571
{
25702572
needed_lazy_methods->add_needed_class(
2571-
to_symbol_type(arg0.type()).get_identifier());
2573+
to_struct_tag_type(arg0.type()).get_identifier());
25722574
}
25732575

25742576
code_blockt block;
@@ -2615,18 +2617,18 @@ void java_bytecode_convert_methodt::convert_getstatic(
26152617
{
26162618
if(needed_lazy_methods)
26172619
{
2618-
if(arg0.type().id() == ID_symbol_type)
2620+
if(arg0.type().id() == ID_struct_tag)
26192621
{
26202622
needed_lazy_methods->add_needed_class(
2621-
to_symbol_type(arg0.type()).get_identifier());
2623+
to_struct_tag_type(arg0.type()).get_identifier());
26222624
}
26232625
else if(arg0.type().id() == ID_pointer)
26242626
{
26252627
const auto &pointer_type = to_pointer_type(arg0.type());
2626-
if(pointer_type.subtype().id() == ID_symbol_type)
2628+
if(pointer_type.subtype().id() == ID_struct_tag)
26272629
{
26282630
needed_lazy_methods->add_needed_class(
2629-
to_symbol_type(pointer_type.subtype()).get_identifier());
2631+
to_struct_tag_type(pointer_type.subtype()).get_identifier());
26302632
}
26312633
}
26322634
else if(is_assertions_disabled_field)

jbmc/src/java_bytecode/java_bytecode_instrument.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@ codet java_bytecode_instrumentt::throw_exception(
108108
struct_union_typet::componentst{});
109109
}
110110

111-
pointer_typet exc_ptr_type=
112-
pointer_type(symbol_typet(exc_class_name));
111+
pointer_typet exc_ptr_type = pointer_type(struct_tag_typet(exc_class_name));
113112

114113
// Allocate and throw an instance of the exception class:
115114

jbmc/src/java_bytecode/java_bytecode_language.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ static void infer_opaque_type_fields(
332332
static symbol_exprt get_or_create_class_literal_symbol(
333333
const irep_idt &class_id, symbol_tablet &symbol_table)
334334
{
335-
symbol_typet java_lang_Class("java::java.lang.Class");
335+
struct_tag_typet java_lang_Class("java::java.lang.Class");
336336
symbol_exprt symbol_expr(
337337
id2string(class_id) + JAVA_CLASS_MODEL_SUFFIX,
338338
java_lang_Class);

jbmc/src/java_bytecode/java_bytecode_parse_tree.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ java_bytecode_parse_treet::find_annotation(
117117
if(annotation.type.id() != ID_pointer)
118118
return false;
119119
const typet &type = annotation.type.subtype();
120-
return type.id() == ID_symbol_type &&
121-
to_symbol_type(type).get_identifier() == annotation_type_name;
120+
return type.id() == ID_struct_tag &&
121+
to_struct_tag_type(type).get_identifier() == annotation_type_name;
122122
});
123123
if(annotation_it == annotations.end())
124124
return {};

jbmc/src/java_bytecode/java_bytecode_parse_tree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ struct java_bytecode_parse_treet
116116
std::size_t start_pc;
117117
std::size_t end_pc;
118118
std::size_t handler_pc;
119-
symbol_typet catch_type;
119+
struct_tag_typet catch_type;
120120
};
121121

122122
typedef std::vector<exceptiont> exception_tablet;

0 commit comments

Comments
 (0)