Skip to content

Commit c4412e9

Browse files
Merge pull request #871 from smowton/refactor-java-object-factory
Refactor java object factory
2 parents f038ac1 + 405ce62 commit c4412e9

File tree

3 files changed

+290
-139
lines changed

3 files changed

+290
-139
lines changed

src/java_bytecode/java_entry_point.cpp

+16-21
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ Author: Daniel Kroening, [email protected]
2525
#include <ansi-c/c_types.h>
2626
#include <ansi-c/string_constant.h>
2727

28-
#include <goto-programs/goto_functions.h>
2928
#include <goto-programs/remove_exceptions.h>
3029

3130
#include "java_entry_point.h"
@@ -98,10 +97,9 @@ Function: java_static_lifetime_init
9897
9998
\*******************************************************************/
10099

101-
bool java_static_lifetime_init(
100+
void java_static_lifetime_init(
102101
symbol_tablet &symbol_table,
103102
const source_locationt &source_location,
104-
message_handlert &message_handler,
105103
bool assume_init_pointers_not_null,
106104
unsigned max_nondet_array_length)
107105
{
@@ -138,6 +136,7 @@ bool java_static_lifetime_init(
138136
}
139137
auto newsym=object_factory(
140138
sym.type,
139+
symname,
141140
code_block,
142141
allow_null,
143142
symbol_table,
@@ -173,8 +172,6 @@ bool java_static_lifetime_init(
173172
code_block.add(function_call);
174173
}
175174
}
176-
177-
return false;
178175
}
179176

180177
/*******************************************************************\
@@ -194,8 +191,7 @@ exprt::operandst java_build_arguments(
194191
code_blockt &init_code,
195192
symbol_tablet &symbol_table,
196193
bool assume_init_pointers_not_null,
197-
unsigned max_nondet_array_length,
198-
message_handlert &message_handler)
194+
unsigned max_nondet_array_length)
199195
{
200196
const code_typet::parameterst &parameters=
201197
to_code_type(function.type).parameters();
@@ -224,27 +220,29 @@ exprt::operandst java_build_arguments(
224220
is_main=(named_main && has_correct_type);
225221
}
226222

223+
const code_typet::parametert &p=parameters[param_number];
224+
const irep_idt base_name=p.get_base_name().empty()?
225+
("argument#"+std::to_string(param_number)):p.get_base_name();
226+
227227
bool allow_null=(!is_main) && (!is_this) && !assume_init_pointers_not_null;
228228

229229
main_arguments[param_number]=
230230
object_factory(
231-
parameters[param_number].type(),
231+
p.type(),
232+
base_name,
232233
init_code,
233234
allow_null,
234235
symbol_table,
235236
max_nondet_array_length,
236237
function.location);
237238

238-
const symbolt &p_symbol=
239-
symbol_table.lookup(parameters[param_number].get_identifier());
240-
241239
// record as an input
242240
codet input(ID_input);
243241
input.operands().resize(2);
244242
input.op0()=
245243
address_of_exprt(
246244
index_exprt(
247-
string_constantt(p_symbol.base_name),
245+
string_constantt(base_name),
248246
from_integer(0, index_type())));
249247
input.op1()=main_arguments[param_number];
250248
input.add_source_location()=function.location;
@@ -556,13 +554,11 @@ bool java_entry_point(
556554

557555
create_initialize(symbol_table);
558556

559-
if(java_static_lifetime_init(
560-
symbol_table,
561-
symbol.location,
562-
message_handler,
563-
assume_init_pointers_not_null,
564-
max_nondet_array_length))
565-
return true;
557+
java_static_lifetime_init(
558+
symbol_table,
559+
symbol.location,
560+
assume_init_pointers_not_null,
561+
max_nondet_array_length);
566562

567563
code_blockt init_code;
568564

@@ -626,8 +622,7 @@ bool java_entry_point(
626622
init_code,
627623
symbol_table,
628624
assume_init_pointers_not_null,
629-
max_nondet_array_length,
630-
message_handler);
625+
max_nondet_array_length);
631626
call_main.arguments()=main_arguments;
632627

633628
init_code.move_to_operands(call_main);

0 commit comments

Comments
 (0)