Skip to content

Commit 47bdb15

Browse files
authored
Merge pull request #4457 from antlechner/antonia/object-factory-allocate
Replace fresh_java_symbol in object factory
2 parents 14b15f6 + 1c57732 commit 47bdb15

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

jbmc/src/java_bytecode/java_object_factory.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,8 @@ class recursion_set_entryt
335335
/// \param symbol_table: the symbol table
336336
/// \param printable: if true, the nondet string must consist of printable
337337
/// characters only
338+
/// \param allocate_objects: manages memory allocation and keeps track of the
339+
/// newly created symbols
338340
///
339341
/// The code produced is of the form:
340342
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -366,7 +368,8 @@ void initialize_nondet_string_fields(
366368
const source_locationt &loc,
367369
const irep_idt &function_id,
368370
symbol_table_baset &symbol_table,
369-
bool printable)
371+
bool printable,
372+
allocate_objectst &allocate_objects)
370373
{
371374
PRECONDITION(
372375
java_string_library_preprocesst
@@ -402,11 +405,10 @@ void initialize_nondet_string_fields(
402405

403406
/// \todo Refactor with make_nondet_string_expr
404407
// 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");
408411
const side_effect_expr_nondett nondet_length(length_expr.type(), loc);
409-
code.add(code_declt(length_expr));
410412
code.add(code_assignt(length_expr, nondet_length));
411413

412414
// assume (length_expr >= min_nondet_string_length);
@@ -709,17 +711,14 @@ symbol_exprt java_object_factoryt::gen_nondet_subtype_pointer_init(
709711
size_t depth,
710712
const source_locationt &location)
711713
{
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");
718717

719718
// Generate a new object into this new symbol
720719
gen_nondet_init(
721720
assignments,
722-
new_symbol.symbol_expr(),
721+
new_symbol_expr,
723722
false, // is_sub
724723
"", // class_identifier
725724
false, // skip_classid
@@ -729,7 +728,7 @@ symbol_exprt java_object_factoryt::gen_nondet_subtype_pointer_init(
729728
update_in_placet::NO_UPDATE_IN_PLACE,
730729
location);
731730

732-
return new_symbol.symbol_expr();
731+
return new_symbol_expr;
733732
}
734733

735734
/// Creates an alternate_casest vector in which each item contains an
@@ -874,7 +873,8 @@ void java_object_factoryt::gen_nondet_struct_init(
874873
location,
875874
object_factory_parameters.function_id,
876875
symbol_table,
877-
object_factory_parameters.string_printable);
876+
object_factory_parameters.string_printable,
877+
allocate_objects);
878878
}
879879

880880
assignments.add(code_assignt(expr, *initial_object));

0 commit comments

Comments
 (0)