1
1
/* ******************************************************************\
2
2
3
- Module: Non-deterministic object init and choice for JBMC
3
+ Module: Non-deterministic object init and choice for CBMC
4
4
5
5
Author: Diffblue Ltd.
6
6
7
7
\*******************************************************************/
8
8
9
9
#include " nondet.h"
10
10
11
- #include < java_bytecode/java_types.h>
12
11
#include < util/arith_tools.h>
13
12
#include < util/c_types.h>
14
13
#include < util/fresh_symbol.h>
@@ -23,7 +22,8 @@ Module: Non-deterministic object init and choice for JBMC
23
22
// / ```
24
23
// / \param min_value: Minimum value (inclusive) of returned int.
25
24
// / \param max_value: Maximum value (inclusive) of returned int.
26
- // / \param name_prefix: Prefix for the fresh symbol name generated.
25
+ // / \param name_prefix: Prefix for the fresh symbol name generated (should be
26
+ // / function id)
27
27
// / \param int_type: The type of the int used to non-deterministically choose
28
28
// / one of the switch cases.
29
29
// / \param source_location: The location to mark the generated int with.
@@ -37,21 +37,18 @@ symbol_exprt generate_nondet_int(
37
37
const int64_t max_value,
38
38
const std::string &name_prefix,
39
39
const typet &int_type,
40
+ const irep_idt &mode,
40
41
const source_locationt &source_location,
41
42
symbol_table_baset &symbol_table,
42
43
code_blockt &instructions)
43
44
{
44
45
PRECONDITION (min_value < max_value);
45
46
46
47
// Declare a symbol for the non deterministic integer.
47
- const symbol_exprt &nondet_symbol = get_fresh_aux_symbol (
48
- int_type,
49
- name_prefix,
50
- " nondet_int" ,
51
- source_location,
52
- ID_java,
53
- symbol_table)
54
- .symbol_expr ();
48
+ const symbol_exprt &nondet_symbol =
49
+ get_fresh_aux_symbol (
50
+ int_type, name_prefix, " nondet_int" , source_location, mode, symbol_table)
51
+ .symbol_expr ();
55
52
instructions.add (code_declt (nondet_symbol));
56
53
57
54
// Assign the symbol any non deterministic integer value.
@@ -77,7 +74,7 @@ symbol_exprt generate_nondet_int(
77
74
}
78
75
79
76
// / Pick nondeterministically between imperative actions 'switch_cases'.
80
- // / \param name_prefix: Name prefix for fresh symbols
77
+ // / \param name_prefix: Name prefix for fresh symbols (should be function id)
81
78
// / \param switch_cases: List of codet objects to execute in each switch case.
82
79
// / \param int_type: The type of the int used to non-deterministically choose
83
80
// / one of the switch cases.
@@ -89,6 +86,7 @@ code_blockt generate_nondet_switch(
89
86
const irep_idt &name_prefix,
90
87
const alternate_casest &switch_cases,
91
88
const typet &int_type,
89
+ const irep_idt &mode,
92
90
const source_locationt &source_location,
93
91
symbol_table_baset &symbol_table)
94
92
{
@@ -105,14 +103,15 @@ code_blockt generate_nondet_switch(
105
103
switch_cases.size () - 1 ,
106
104
id2string (name_prefix),
107
105
int_type,
106
+ mode,
108
107
source_location,
109
108
symbol_table,
110
109
result_block);
111
110
112
111
result_switch.value () = switch_value;
113
112
114
113
code_blockt switch_block;
115
- int64_t case_number = 0 ;
114
+ size_t case_number = 0 ;
116
115
for (const auto &switch_case : switch_cases)
117
116
{
118
117
code_blockt this_block;
0 commit comments