@@ -335,6 +335,8 @@ class recursion_set_entryt
335
335
// / \param symbol_table: the symbol table
336
336
// / \param printable: if true, the nondet string must consist of printable
337
337
// / characters only
338
+ // / \param allocate_objects: manages memory allocation and keeps track of the
339
+ // / newly created symbols
338
340
// /
339
341
// / The code produced is of the form:
340
342
// / ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -366,7 +368,8 @@ void initialize_nondet_string_fields(
366
368
const source_locationt &loc,
367
369
const irep_idt &function_id,
368
370
symbol_table_baset &symbol_table,
369
- bool printable)
371
+ bool printable,
372
+ allocate_objectst &allocate_objects)
370
373
{
371
374
PRECONDITION (
372
375
java_string_library_preprocesst
@@ -402,11 +405,10 @@ void initialize_nondet_string_fields(
402
405
403
406
// / \todo Refactor with make_nondet_string_expr
404
407
// length_expr = nondet(int);
405
- const symbolt length_sym = fresh_java_symbol (
406
- java_int_type (), " tmp_object_factory " , loc, function_id, symbol_table);
407
- const symbol_exprt length_expr = length_sym. symbol_expr ( );
408
+ const symbol_exprt length_expr =
409
+ allocate_objects. allocate_automatic_local_object (
410
+ java_int_type (), " tmp_object_factory " );
408
411
const side_effect_expr_nondett nondet_length (length_expr.type (), loc);
409
- code.add (code_declt (length_expr));
410
412
code.add (code_assignt (length_expr, nondet_length));
411
413
412
414
// assume (length_expr >= min_nondet_string_length);
@@ -709,17 +711,14 @@ symbol_exprt java_object_factoryt::gen_nondet_subtype_pointer_init(
709
711
size_t depth,
710
712
const source_locationt &location)
711
713
{
712
- symbolt new_symbol = fresh_java_symbol (
713
- replacement_pointer,
714
- " tmp_object_factory" ,
715
- location,
716
- object_factory_parameters.function_id ,
717
- symbol_table);
714
+ const symbol_exprt new_symbol_expr =
715
+ allocate_objects.allocate_automatic_local_object (
716
+ replacement_pointer, " tmp_object_factory" );
718
717
719
718
// Generate a new object into this new symbol
720
719
gen_nondet_init (
721
720
assignments,
722
- new_symbol. symbol_expr () ,
721
+ new_symbol_expr ,
723
722
false , // is_sub
724
723
" " , // class_identifier
725
724
false , // skip_classid
@@ -729,7 +728,7 @@ symbol_exprt java_object_factoryt::gen_nondet_subtype_pointer_init(
729
728
update_in_placet::NO_UPDATE_IN_PLACE,
730
729
location);
731
730
732
- return new_symbol. symbol_expr () ;
731
+ return new_symbol_expr ;
733
732
}
734
733
735
734
// / Creates an alternate_casest vector in which each item contains an
@@ -874,7 +873,8 @@ void java_object_factoryt::gen_nondet_struct_init(
874
873
location,
875
874
object_factory_parameters.function_id ,
876
875
symbol_table,
877
- object_factory_parameters.string_printable );
876
+ object_factory_parameters.string_printable ,
877
+ allocate_objects);
878
878
}
879
879
880
880
assignments.add (code_assignt (expr, *initial_object));
0 commit comments