@@ -24,10 +24,6 @@ Author: Daniel Kroening, kroening@kroening.com
24
24
25
25
class java_object_factoryt
26
26
{
27
- // / The source location for new statements emitted during the operation of the
28
- // / methods in this class.
29
- const source_locationt &loc;
30
-
31
27
const java_object_factory_parameterst object_factory_parameters;
32
28
33
29
// / This is employed in conjunction with the depth above. Every time the
@@ -49,9 +45,6 @@ class java_object_factoryt
49
45
// / The symbol table.
50
46
symbol_table_baset &symbol_table;
51
47
52
- // / A namespace built from exclusively one symbol table - the one above.
53
- namespacet ns;
54
-
55
48
// / Resolves pointer types potentially using some heuristics, for example
56
49
// / to replace pointers to interface types with pointers to concrete
57
50
// / implementations.
@@ -85,10 +78,8 @@ class java_object_factoryt
85
78
symbol_table_baset &_symbol_table,
86
79
const select_pointer_typet &pointer_type_selector,
87
80
message_handlert &log)
88
- : loc(loc),
89
- object_factory_parameters (_object_factory_parameters),
81
+ : object_factory_parameters(_object_factory_parameters),
90
82
symbol_table (_symbol_table),
91
- ns(_symbol_table),
92
83
pointer_type_selector(pointer_type_selector),
93
84
allocate_objects(
94
85
ID_java,
@@ -233,6 +224,7 @@ void java_object_factoryt::gen_pointer_target_init(
233
224
PRECONDITION (expr.type ().id () == ID_pointer);
234
225
PRECONDITION (update_in_place != update_in_placet::MAY_UPDATE_IN_PLACE);
235
226
227
+ const namespacet ns (symbol_table);
236
228
const typet &followed_target_type = ns.follow (target_type);
237
229
238
230
if (followed_target_type.id () == ID_struct)
@@ -495,6 +487,7 @@ void java_object_factoryt::gen_nondet_pointer_init(
495
487
const source_locationt &location)
496
488
{
497
489
PRECONDITION (expr.type ().id ()==ID_pointer);
490
+ const namespacet ns (symbol_table);
498
491
const pointer_typet &replacement_pointer_type =
499
492
pointer_type_selector.convert_pointer_type (
500
493
pointer_type, generic_parameter_specialization_map, ns);
@@ -555,7 +548,7 @@ void java_object_factoryt::gen_nondet_pointer_init(
555
548
if (update_in_place==update_in_placet::NO_UPDATE_IN_PLACE)
556
549
{
557
550
assignments.add (
558
- code_assignt{expr, null_pointer_exprt{pointer_type}, loc });
551
+ code_assignt{expr, null_pointer_exprt{pointer_type}, location });
559
552
}
560
553
// Otherwise leave it as it is.
561
554
return ;
@@ -634,7 +627,8 @@ void java_object_factoryt::gen_nondet_pointer_init(
634
627
update_in_placet::NO_UPDATE_IN_PLACE,
635
628
location);
636
629
637
- const code_assignt set_null_inst{expr, null_pointer_exprt{pointer_type}, loc};
630
+ const code_assignt set_null_inst{
631
+ expr, null_pointer_exprt{pointer_type}, location};
638
632
639
633
const bool allow_null = depth > object_factory_parameters.min_null_tree_depth ;
640
634
@@ -804,6 +798,7 @@ void java_object_factoryt::gen_nondet_struct_init(
804
798
const update_in_placet &update_in_place,
805
799
const source_locationt &location)
806
800
{
801
+ const namespacet ns (symbol_table);
807
802
PRECONDITION (ns.follow (expr.type ()).id ()==ID_struct);
808
803
PRECONDITION (struct_type.id ()==ID_struct);
809
804
@@ -852,7 +847,7 @@ void java_object_factoryt::gen_nondet_struct_init(
852
847
cases,
853
848
java_int_type (),
854
849
ID_java,
855
- loc ,
850
+ location ,
856
851
symbol_table));
857
852
}
858
853
else
@@ -880,7 +875,7 @@ void java_object_factoryt::gen_nondet_struct_init(
880
875
assignments,
881
876
object_factory_parameters.min_nondet_string_length ,
882
877
object_factory_parameters.max_nondet_string_length ,
883
- loc ,
878
+ location ,
884
879
object_factory_parameters.function_id ,
885
880
symbol_table,
886
881
object_factory_parameters.string_printable );
@@ -910,7 +905,7 @@ void java_object_factoryt::gen_nondet_struct_init(
910
905
if (update_in_place == update_in_placet::MUST_UPDATE_IN_PLACE)
911
906
continue ;
912
907
code_assignt code (me, from_integer (0 , me.type ()));
913
- code.add_source_location () = loc ;
908
+ code.add_source_location () = location ;
914
909
assignments.add (code);
915
910
}
916
911
else if (skip_special_string_fields && (name == " length" || name == " data" ))
@@ -1004,6 +999,7 @@ void java_object_factoryt::gen_nondet_init(
1004
999
const source_locationt &location)
1005
1000
{
1006
1001
const typet &type = override_type.has_value () ? *override_type : expr.type ();
1002
+ const namespacet ns (symbol_table);
1007
1003
const typet &followed_type = ns.follow (type);
1008
1004
1009
1005
if (type.id ()==ID_pointer)
@@ -1063,10 +1059,11 @@ void java_object_factoryt::gen_nondet_init(
1063
1059
{
1064
1060
// types different from pointer or structure:
1065
1061
// bool, int, float, byte, char, ...
1066
- exprt rhs = type.id () == ID_c_bool ? get_nondet_bool (type, loc)
1067
- : side_effect_expr_nondett (type, loc);
1062
+ exprt rhs = type.id () == ID_c_bool
1063
+ ? get_nondet_bool (type, location)
1064
+ : side_effect_expr_nondett (type, location);
1068
1065
code_assignt assign (expr, rhs);
1069
- assign.add_source_location ()=loc ;
1066
+ assign.add_source_location () = location ;
1070
1067
1071
1068
assignments.add (assign);
1072
1069
}
@@ -1112,12 +1109,12 @@ void java_object_factoryt::allocate_nondet_length_array(
1112
1109
allocate_objects,
1113
1110
assignments);
1114
1111
1115
- side_effect_exprt java_new_array (ID_java_new_array, lhs.type (), loc );
1112
+ side_effect_exprt java_new_array (ID_java_new_array, lhs.type (), location );
1116
1113
java_new_array.copy_to_operands (length_sym_expr);
1117
1114
java_new_array.set (ID_length_upper_bound, max_length_expr);
1118
1115
java_new_array.type ().subtype ().set (ID_element_type, element_type);
1119
1116
code_assignt assign (lhs, java_new_array);
1120
- assign.add_source_location () = loc ;
1117
+ assign.add_source_location () = location ;
1121
1118
assignments.add (assign);
1122
1119
}
1123
1120
@@ -1158,7 +1155,7 @@ void java_object_factoryt::array_primitive_init_code(
1158
1155
assignments.statements ().back ().add_source_location () = location;
1159
1156
1160
1157
// *array_data_init = NONDET(TYPE [max_length_expr]);
1161
- side_effect_expr_nondett nondet_data (array_type, loc );
1158
+ side_effect_expr_nondett nondet_data (array_type, location );
1162
1159
const dereference_exprt data_pointer_deref (
1163
1160
tmp_finite_array_pointer, array_type);
1164
1161
assignments.add (code_assignt (data_pointer_deref, std::move (nondet_data)));
@@ -1221,7 +1218,7 @@ void java_object_factoryt::array_loop_init_code(
1221
1218
init_array_expr.type (), " array_data_init" );
1222
1219
1223
1220
code_assignt data_assign (array_init_symexpr, init_array_expr);
1224
- data_assign.add_source_location ()=loc ;
1221
+ data_assign.add_source_location () = location ;
1225
1222
assignments.add (data_assign);
1226
1223
1227
1224
const symbol_exprt &counter_expr =
@@ -1307,6 +1304,7 @@ void java_object_factoryt::gen_nondet_array_init(
1307
1304
PRECONDITION (expr.type ().subtype ().id () == ID_struct_tag);
1308
1305
PRECONDITION (update_in_place != update_in_placet::MAY_UPDATE_IN_PLACE);
1309
1306
1307
+ const namespacet ns (symbol_table);
1310
1308
const typet &type = ns.follow (expr.type ().subtype ());
1311
1309
const struct_typet &struct_type = to_struct_type (type);
1312
1310
const typet &element_type =
@@ -1389,7 +1387,7 @@ bool java_object_factoryt::gen_nondet_enum_init(
1389
1387
{
1390
1388
const irep_idt &class_name = java_class_type.get_name ();
1391
1389
const irep_idt values_name = id2string (class_name) + " .$VALUES" ;
1392
- if (!ns. get_symbol_table () .has_symbol (values_name))
1390
+ if (!symbol_table .has_symbol (values_name))
1393
1391
{
1394
1392
log.warning () << values_name
1395
1393
<< " is missing, so the corresponding Enum "
@@ -1398,6 +1396,7 @@ bool java_object_factoryt::gen_nondet_enum_init(
1398
1396
return false ;
1399
1397
}
1400
1398
1399
+ const namespacet ns (symbol_table);
1401
1400
const symbolt &values = ns.lookup (values_name);
1402
1401
1403
1402
// Access members (length and data) of $VALUES array
0 commit comments