25
25
#include " java_types.h"
26
26
#include " java_utils.h"
27
27
28
- /* ******************************************************************\
29
-
30
- Function: gen_nondet_init
31
-
32
- Inputs:
33
-
34
- Outputs:
35
-
36
- Purpose:
37
-
38
- \*******************************************************************/
39
-
40
28
class java_object_factoryt :public messaget
41
29
{
42
30
code_blockt &init_code;
@@ -75,25 +63,20 @@ class java_object_factoryt:public messaget
75
63
bool is_sub,
76
64
irep_idt class_identifier,
77
65
const source_locationt &loc,
78
- bool skip_classid,
79
66
bool create_dynamic_objects,
80
67
bool override =false ,
81
68
const typet &override_type=empty_typet());
82
69
};
83
70
84
-
85
71
/* ******************************************************************\
86
72
87
- Function: gen_nondet_array_init
73
+ Function: java_object_factoryt::allocate_object
88
74
89
- Inputs: the target expression, desired object type, source location
90
- and Boolean whether to create a dynamic object
75
+ Inputs:
91
76
92
- Outputs: the allocated object
77
+ Outputs:
93
78
94
- Purpose: Returns false if we can't figure out the size of allocate_type.
95
- allocate_type may differ from target_expr, e.g. for target_expr
96
- having type int* and allocate_type being an int[10].
79
+ Purpose:
97
80
98
81
\*******************************************************************/
99
82
@@ -165,16 +148,33 @@ exprt java_object_factoryt::allocate_object(
165
148
}
166
149
}
167
150
168
- // Override type says to ignore the LHS' real type, and init it with the given
169
- // type regardless. Used at the moment for reference arrays, which are
170
- // implemented as void* arrays but should be init'd as their true type with
171
- // appropriate casts.
151
+ /* ******************************************************************\
152
+
153
+ Function: java_object_factoryt::gen_nondet_init
154
+
155
+ Inputs:
156
+ expr -
157
+ is_sub -
158
+ class_identifier -
159
+ loc -
160
+ create_dynamic_objects -
161
+ override - Ignore the LHS' real type. Used at the moment for
162
+ reference arrays, which are implemented as void*
163
+ arrays but should be init'd as their true type with
164
+ appropriate casts.
165
+ override_type - Type to use if ignoring the LHS' real type
166
+
167
+ Outputs:
168
+
169
+ Purpose:
170
+
171
+ \*******************************************************************/
172
+
172
173
void java_object_factoryt::gen_nondet_init (
173
174
const exprt &expr,
174
175
bool is_sub,
175
176
irep_idt class_identifier,
176
177
const source_locationt &loc,
177
- bool skip_classid,
178
178
bool create_dynamic_objects,
179
179
bool override ,
180
180
const typet &override_type)
@@ -250,20 +250,17 @@ void java_object_factoryt::gen_nondet_init(
250
250
{
251
251
exprt allocated=
252
252
allocate_object (expr, subtype, loc, create_dynamic_objects);
253
- {
254
- exprt init_expr;
255
- if (allocated.id ()==ID_address_of)
256
- init_expr=allocated.op0 ();
257
- else
258
- init_expr=dereference_exprt (allocated, allocated.type ().subtype ());
259
- gen_nondet_init (
260
- init_expr,
261
- false ,
262
- " " ,
263
- loc,
264
- false ,
265
- create_dynamic_objects);
266
- }
253
+ exprt init_expr;
254
+ if (allocated.id ()==ID_address_of)
255
+ init_expr=allocated.op0 ();
256
+ else
257
+ init_expr=dereference_exprt (allocated, allocated.type ().subtype ());
258
+ gen_nondet_init (
259
+ init_expr,
260
+ false ,
261
+ " " ,
262
+ loc,
263
+ create_dynamic_objects);
267
264
}
268
265
269
266
if (!assume_non_null)
@@ -297,9 +294,6 @@ void java_object_factoryt::gen_nondet_init(
297
294
298
295
if (name==" @class_identifier" )
299
296
{
300
- if (skip_classid)
301
- continue ;
302
-
303
297
irep_idt qualified_clsid=" java::" +as_string (class_identifier);
304
298
constant_exprt ci (qualified_clsid, string_typet ());
305
299
code_assignt code (me, ci);
@@ -327,7 +321,6 @@ void java_object_factoryt::gen_nondet_init(
327
321
_is_sub,
328
322
class_identifier,
329
323
loc,
330
- false ,
331
324
create_dynamic_objects);
332
325
}
333
326
}
@@ -345,7 +338,7 @@ void java_object_factoryt::gen_nondet_init(
345
338
346
339
/* ******************************************************************\
347
340
348
- Function: gen_nondet_array_init
341
+ Function: java_object_factoryt:: gen_nondet_array_init
349
342
350
343
Inputs:
351
344
@@ -379,7 +372,7 @@ void java_object_factoryt::gen_nondet_array_init(
379
372
const auto &length_sym_expr=length_sym.symbol_expr ();
380
373
381
374
// Initialize array with some undetermined length:
382
- gen_nondet_init (length_sym_expr, false , irep_idt (), loc, false , false );
375
+ gen_nondet_init (length_sym_expr, false , irep_idt (), loc, false );
383
376
384
377
// Insert assumptions to bound its length:
385
378
binary_relation_exprt
@@ -464,7 +457,6 @@ void java_object_factoryt::gen_nondet_array_init(
464
457
false ,
465
458
irep_idt (),
466
459
loc,
467
- false ,
468
460
true ,
469
461
true ,
470
462
element_type);
@@ -479,44 +471,6 @@ void java_object_factoryt::gen_nondet_array_init(
479
471
480
472
/* ******************************************************************\
481
473
482
- Function: gen_nondet_init
483
-
484
- Inputs:
485
-
486
- Outputs:
487
-
488
- Purpose:
489
-
490
- \*******************************************************************/
491
-
492
- void gen_nondet_init (
493
- const exprt &expr,
494
- code_blockt &init_code,
495
- symbol_tablet &symbol_table,
496
- const source_locationt &loc,
497
- bool skip_classid,
498
- bool create_dyn_objs,
499
- bool assume_non_null,
500
- message_handlert &message_handler,
501
- size_t max_nondet_array_length)
502
- {
503
- java_object_factoryt state (
504
- init_code,
505
- assume_non_null,
506
- max_nondet_array_length,
507
- symbol_table,
508
- message_handler);
509
- state.gen_nondet_init (
510
- expr,
511
- false ,
512
- " " ,
513
- loc,
514
- skip_classid,
515
- create_dyn_objs);
516
- }
517
-
518
- /* ******************************************************************\
519
-
520
474
Function: new_tmp_symbol
521
475
522
476
Inputs:
@@ -592,17 +546,18 @@ exprt object_factory(
592
546
593
547
exprt object=aux_symbol.symbol_expr ();
594
548
595
- const namespacet ns (symbol_table);
596
- gen_nondet_init (
597
- object,
549
+ java_object_factoryt state (
598
550
init_code,
551
+ !allow_null,
552
+ max_nondet_array_length,
599
553
symbol_table,
600
- loc,
601
- false ,
554
+ message_handler);
555
+ state.gen_nondet_init (
556
+ object,
602
557
false ,
603
- !allow_null ,
604
- message_handler ,
605
- max_nondet_array_length );
558
+ " " ,
559
+ loc ,
560
+ false );
606
561
607
562
return object;
608
563
}
0 commit comments