Skip to content

Commit f887a99

Browse files
author
Joel Allred
committed
Move make_allocate_code to java_object_factory
Will also be used in java_object_factory
1 parent 5d354a5 commit f887a99

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

jbmc/src/java_bytecode/java_object_factory.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,6 +1198,18 @@ void java_object_factoryt::allocate_nondet_length_array(
11981198
assignments.add(assign);
11991199
}
12001200

1201+
/// Create code allocating object of size `size` and assigning it to `lhs`
1202+
/// \param lhs : pointer which will be allocated
1203+
/// \param size : size of the object
1204+
/// \return code allocation object and assigning `lhs`
1205+
codet make_allocate_code(const symbol_exprt &lhs, const exprt &size)
1206+
{
1207+
side_effect_exprt alloc(ID_allocate, lhs.type(), lhs.source_location());
1208+
alloc.add_to_operands(size);
1209+
alloc.add_to_operands(false_exprt());
1210+
return code_assignt(lhs, alloc);
1211+
}
1212+
12011213
/// Create code to initialize a Java array whose size will be at most
12021214
/// `max_nondet_array_length`. The code is emitted to \p assignments does as
12031215
/// follows:

jbmc/src/java_bytecode/java_object_factory.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,6 @@ void gen_nondet_init(
126126
const java_object_factory_parameterst &object_factory_parameters,
127127
update_in_placet update_in_place);
128128

129+
codet make_allocate_code(const symbol_exprt &lhs, const exprt &size);
130+
129131
#endif // CPROVER_JAVA_BYTECODE_JAVA_OBJECT_FACTORY_H

jbmc/src/java_bytecode/java_string_library_preprocess.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -627,18 +627,6 @@ codet java_string_library_preprocesst::code_return_function_application(
627627
return code_returnt(fun_app);
628628
}
629629

630-
/// Create code allocating object of size `size` and assigning it to `lhs`
631-
/// \param lhs : pointer which will be allocated
632-
/// \param size : size of the object
633-
/// \return code allocation object and assigning `lhs`
634-
static codet make_allocate_code(const symbol_exprt &lhs, const exprt &size)
635-
{
636-
side_effect_exprt alloc(ID_allocate, lhs.type(), lhs.source_location());
637-
alloc.add_to_operands(size);
638-
alloc.add_to_operands(false_exprt());
639-
return code_assignt(lhs, alloc);
640-
}
641-
642630
/// Declare a fresh symbol of type array of character with infinite size.
643631
/// \param symbol_table: the symbol table
644632
/// \param loc: source location

0 commit comments

Comments
 (0)