@@ -199,10 +199,8 @@ void java_object_factoryt::gen_pointer_target_init(
199
199
PRECONDITION (update_in_place != update_in_placet::MAY_UPDATE_IN_PLACE);
200
200
201
201
const namespacet ns (symbol_table);
202
- const typet &followed_target_type = ns.follow (target_type);
203
- PRECONDITION (followed_target_type.id () == ID_struct);
204
-
205
- const auto &target_class_type = to_java_class_type (followed_target_type);
202
+ const auto &target_class_type =
203
+ to_java_class_type (ns.follow_tag (to_struct_tag_type (target_type)));
206
204
if (target_class_type.get_tag ().starts_with (" java::array[" ))
207
205
{
208
206
assignments.append (gen_nondet_array_init (
@@ -374,7 +372,7 @@ void initialize_nondet_string_fields(
374
372
{
375
373
namespacet ns (symbol_table);
376
374
const struct_typet &struct_type =
377
- to_struct_type ( ns.follow (struct_expr.type ()));
375
+ ns.follow_tag ( to_struct_tag_type (struct_expr.type ()));
378
376
PRECONDITION (is_java_string_type (struct_type));
379
377
380
378
// We allow type StringBuffer and StringBuilder to be initialized
@@ -481,9 +479,6 @@ void java_object_factoryt::gen_nondet_pointer_init(
481
479
{
482
480
PRECONDITION (expr.type ().id ()==ID_pointer);
483
481
const namespacet ns (symbol_table);
484
- const typet &subtype = pointer_type.base_type ();
485
- const typet &followed_subtype = ns.follow (subtype);
486
- PRECONDITION (followed_subtype.id () == ID_struct);
487
482
const pointer_typet &replacement_pointer_type =
488
483
pointer_type_selector.convert_pointer_type (
489
484
pointer_type, generic_parameter_specialization_map, ns);
@@ -501,7 +496,7 @@ void java_object_factoryt::gen_nondet_pointer_init(
501
496
generic_parameter_specialization_map);
502
497
generic_parameter_specialization_map_keys.insert (
503
498
replacement_pointer_type,
504
- ns.follow ( replacement_pointer_type.base_type ()));
499
+ ns.follow_tag ( to_struct_tag_type ( replacement_pointer_type.base_type () )));
505
500
506
501
const symbol_exprt real_pointer_symbol = gen_nondet_subtype_pointer_init (
507
502
assignments, lifetime, replacement_pointer_type, depth, location);
@@ -529,7 +524,9 @@ void java_object_factoryt::gen_nondet_pointer_init(
529
524
// When we visit for 2nd time a type AND the maximum depth is exceeded, we set
530
525
// the pointer to NULL instead of recursively initializing the struct to which
531
526
// it points.
532
- const struct_typet &struct_type = to_struct_type (followed_subtype);
527
+ const struct_tag_typet &tag_type =
528
+ to_struct_tag_type (pointer_type.base_type ());
529
+ const struct_typet &struct_type = ns.follow_tag (tag_type);
533
530
const irep_idt &struct_tag = struct_type.get_tag ();
534
531
535
532
// If this is a recursive type of some kind AND the depth is exceeded, set
@@ -564,7 +561,7 @@ void java_object_factoryt::gen_nondet_pointer_init(
564
561
// ci_lazy_methodst::initialize_instantiated_classes.
565
562
if (
566
563
const auto class_type =
567
- type_try_dynamic_cast<java_class_typet>(followed_subtype ))
564
+ type_try_dynamic_cast<java_class_typet>(struct_type ))
568
565
{
569
566
if (class_type->get_base (" java::java.lang.Enum" ))
570
567
{
@@ -581,13 +578,13 @@ void java_object_factoryt::gen_nondet_pointer_init(
581
578
// if the initialization mode is MAY_UPDATE or MUST_UPDATE in place, then we
582
579
// emit to `update_in_place_assignments` code for in-place initialization of
583
580
// the object pointed by `expr`, assuming that such object is of type
584
- // `subtype `
581
+ // `tag_type `
585
582
if (update_in_place!=update_in_placet::NO_UPDATE_IN_PLACE)
586
583
{
587
584
gen_pointer_target_init (
588
585
update_in_place_assignments,
589
586
expr,
590
- subtype ,
587
+ tag_type ,
591
588
lifetime,
592
589
depth,
593
590
update_in_placet::MUST_UPDATE_IN_PLACE,
@@ -610,7 +607,7 @@ void java_object_factoryt::gen_nondet_pointer_init(
610
607
gen_pointer_target_init (
611
608
non_null_inst,
612
609
expr,
613
- subtype ,
610
+ tag_type ,
614
611
lifetime,
615
612
depth,
616
613
update_in_placet::NO_UPDATE_IN_PLACE,
@@ -773,7 +770,7 @@ void java_object_factoryt::gen_nondet_struct_init(
773
770
const source_locationt &location)
774
771
{
775
772
const namespacet ns (symbol_table);
776
- PRECONDITION (ns. follow ( expr.type ()) .id ()==ID_struct );
773
+ PRECONDITION (expr.type ().id () == ID_struct_tag );
777
774
778
775
typedef struct_typet::componentst componentst;
779
776
const irep_idt &struct_tag=struct_type.get_tag ();
@@ -1008,7 +1005,6 @@ void java_object_factoryt::gen_nondet_init(
1008
1005
{
1009
1006
const typet &type = override_type.has_value () ? *override_type : expr.type ();
1010
1007
const namespacet ns (symbol_table);
1011
- const typet &followed_type = ns.follow (type);
1012
1008
1013
1009
if (type.id ()==ID_pointer)
1014
1010
{
@@ -1021,7 +1017,8 @@ void java_object_factoryt::gen_nondet_init(
1021
1017
generic_parameter_specialization_map_keys (
1022
1018
generic_parameter_specialization_map);
1023
1019
generic_parameter_specialization_map_keys.insert (
1024
- pointer_type, ns.follow (pointer_type.base_type ()));
1020
+ pointer_type,
1021
+ ns.follow_tag (to_struct_tag_type (pointer_type.base_type ())));
1025
1022
1026
1023
gen_nondet_pointer_init (
1027
1024
assignments,
@@ -1032,9 +1029,9 @@ void java_object_factoryt::gen_nondet_init(
1032
1029
update_in_place,
1033
1030
location);
1034
1031
}
1035
- else if (followed_type .id () == ID_struct )
1032
+ else if (type .id () == ID_struct_tag )
1036
1033
{
1037
- const struct_typet struct_type = to_struct_type (followed_type );
1034
+ const struct_typet struct_type = ns. follow_tag ( to_struct_tag_type (type) );
1038
1035
1039
1036
// If we are about to initialize a generic class (as a superclass object
1040
1037
// for a different object), add its concrete types to the map and delete
@@ -1388,8 +1385,8 @@ code_blockt gen_nondet_array_init(
1388
1385
code_blockt statements;
1389
1386
1390
1387
const namespacet ns (symbol_table);
1391
- const typet &type = ns. follow ( to_pointer_type (expr. type ()). base_type ());
1392
- const struct_typet &struct_type = to_struct_type ( type);
1388
+ const struct_typet &struct_type =
1389
+ ns. follow_tag ( to_struct_tag_type ( to_pointer_type (expr. type ()). base_type ()) );
1393
1390
const typet &element_type = static_cast <const typet &>(
1394
1391
to_pointer_type (expr.type ()).base_type ().find (ID_element_type));
1395
1392
@@ -1492,7 +1489,8 @@ bool java_object_factoryt::gen_nondet_enum_init(
1492
1489
1493
1490
// Access members (length and data) of $VALUES array
1494
1491
dereference_exprt deref_expr (values.symbol_expr ());
1495
- const auto &deref_struct_type = to_struct_type (ns.follow (deref_expr.type ()));
1492
+ const auto &deref_struct_type =
1493
+ ns.follow_tag (to_struct_tag_type (deref_expr.type ()));
1496
1494
PRECONDITION (is_valid_java_array (deref_struct_type));
1497
1495
const auto &comps = deref_struct_type.components ();
1498
1496
const member_exprt length_expr (deref_expr, " length" , comps[1 ].type ());
0 commit comments