10
10
11
11
#include < string>
12
12
13
- #include < util/symbol_table.h>
14
- #include < util/suffix.h>
15
- #include < util/config.h>
16
13
#include < util/cmdline.h>
14
+ #include < util/config.h>
17
15
#include < util/expr_iterator.h>
16
+ #include < util/invariant.h>
18
17
#include < util/journalling_symbol_table.h>
18
+ #include < util/options.h>
19
19
#include < util/string2int.h>
20
- #include < util/invariant.h>
20
+ #include < util/suffix.h>
21
+ #include < util/symbol_table.h>
22
+
21
23
#include < json/json_parser.h>
22
24
23
25
#include < goto-programs/class_hierarchy.h>
39
41
#include " expr2java.h"
40
42
#include " load_method_by_regex.h"
41
43
42
- // / Consume options that are java bytecode specific.
43
- // / \param Command:line options
44
- // / \return None
45
- void java_bytecode_languaget::get_language_options (const cmdlinet &cmd)
44
+ // / Parse options that are java bytecode specific.
45
+ // / \param cmd Command line
46
+ // / \param [out] options The options object that will be updated.
47
+ void parse_java_language_options (const cmdlinet &cmd, optionst &options )
46
48
{
47
- assume_inputs_non_null=cmd.isset (" java-assume-inputs-non-null" );
48
- string_refinement_enabled = !cmd.isset (" no-refine-strings" );
49
- throw_runtime_exceptions =
50
- cmd.isset (" java-throw-runtime-exceptions" ) || // will go away
51
- cmd.isset (" throw-runtime-exceptions" );
52
- assert_uncaught_exceptions = !cmd.isset (" disable-uncaught-exception-check" );
53
- throw_assertion_error = cmd.isset (" throw-assertion-error" );
54
- threading_support = cmd.isset (" java-threading" );
49
+ options.set_option (
50
+ " java-assume-inputs-non-null" , cmd.isset (" java-assume-inputs-non-null" ));
51
+ options.set_option (
52
+ " throw-runtime-exceptions" , cmd.isset (" throw-runtime-exceptions" ));
53
+ options.set_option (
54
+ " uncaught-exception-check" , !cmd.isset (" disable-uncaught-exception-check" ));
55
+ options.set_option (
56
+ " throw-assertion-error" , cmd.isset (" throw-assertion-error" ));
57
+ options.set_option (" java-threading" , cmd.isset (" java-threading" ));
55
58
56
- if (cmd.isset (" java-max-input-array-length" )) // will go away
57
- {
58
- object_factory_parameters.max_nondet_array_length =
59
- safe_string2size_t (cmd.get_value (" java-max-input-array-length" ));
60
- }
61
- if (cmd.isset (" max-nondet-array-length" ))
59
+ if (cmd.isset (" java-max-vla-length" ))
62
60
{
63
- object_factory_parameters. max_nondet_array_length =
64
- safe_string2size_t ( cmd.get_value (" max-nondet-array -length" ));
61
+ options. set_option (
62
+ " java-max-vla-length " , cmd.get_value (" java- max-vla -length" ));
65
63
}
66
64
67
- if (cmd.isset (" java-max-input-tree-depth" )) // will go away
68
- {
69
- object_factory_parameters.max_nondet_tree_depth =
70
- safe_string2size_t (cmd.get_value (" java-max-input-tree-depth" ));
71
- }
72
- if (cmd.isset (" max-nondet-tree-depth" ))
65
+ options.set_option (
66
+ " symex-driven-lazy-loading" , cmd.isset (" symex-driven-lazy-loading" ));
67
+
68
+ if (cmd.isset (" java-load-class" ))
69
+ options.set_option (" java-load-class" , cmd.get_values (" java-load-class" ));
70
+
71
+ if (cmd.isset (" java-no-load-class" ))
73
72
{
74
- object_factory_parameters. max_nondet_tree_depth =
75
- safe_string2size_t ( cmd.get_value ( " max-nondet-tree-depth " ));
73
+ options. set_option (
74
+ " java-no-load-class " , cmd.get_values ( " java-no-load-class " ));
76
75
}
77
-
78
- if (cmd.isset (" string-max-input-length" )) // will go away
76
+ if (cmd.isset (" lazy-methods-extra-entry-point" ))
79
77
{
80
- object_factory_parameters.max_nondet_string_length =
81
- safe_string2size_t (cmd.get_value (" string-max-input-length" ));
78
+ options.set_option (
79
+ " lazy-methods-extra-entry-point" ,
80
+ cmd.get_values (" lazy-methods-extra-entry-point" ));
82
81
}
83
- if (cmd.isset (" max-nondet-string-length " ))
82
+ if (cmd.isset (" java-cp-include-files " ))
84
83
{
85
- object_factory_parameters. max_nondet_string_length =
86
- safe_string2size_t ( cmd.get_value (" max-nondet-string-length " ));
84
+ options. set_option (
85
+ " java-cp-include-files " , cmd.get_value (" java-cp-include-files " ));
87
86
}
87
+ }
88
88
89
- object_factory_parameters.string_printable = cmd.isset (" string-printable" );
90
- if (cmd.isset (" java-max-vla-length" ))
91
- max_user_array_length =
92
- safe_string2size_t (cmd.get_value (" java-max-vla-length" ));
93
- if (cmd.isset (" symex-driven-lazy-loading" ))
89
+ // / Consume options that are java bytecode specific.
90
+ void java_bytecode_languaget::set_language_options (const optionst &options)
91
+ {
92
+ object_factory_parameters.set (options);
93
+
94
+ assume_inputs_non_null =
95
+ options.get_bool_option (" java-assume-inputs-non-null" );
96
+ string_refinement_enabled = options.get_bool_option (" refine-strings" );
97
+ throw_runtime_exceptions =
98
+ options.get_bool_option (" throw-runtime-exceptions" );
99
+ assert_uncaught_exceptions =
100
+ options.get_bool_option (" uncaught-exception-check" );
101
+ throw_assertion_error = options.get_bool_option (" throw-assertion-error" );
102
+ threading_support = options.get_bool_option (" java-threading" );
103
+ max_user_array_length =
104
+ options.get_unsigned_int_option (" java-max-vla-length" );
105
+
106
+ if (options.get_bool_option (" symex-driven-lazy-loading" ))
94
107
lazy_methods_mode=LAZY_METHODS_MODE_EXTERNAL_DRIVER;
95
- else if (!cmd. isset ( " no- lazy-methods" ))
108
+ else if (options. get_bool_option ( " lazy-methods" ))
96
109
lazy_methods_mode=LAZY_METHODS_MODE_CONTEXT_INSENSITIVE;
97
110
else
98
111
lazy_methods_mode=LAZY_METHODS_MODE_EAGER;
99
112
100
113
if (throw_runtime_exceptions)
101
114
{
102
115
java_load_classes.insert (
103
- java_load_classes.end (),
104
- exception_needed_classes.begin (),
105
- exception_needed_classes.end ());
116
+ java_load_classes.end (),
117
+ exception_needed_classes.begin (),
118
+ exception_needed_classes.end ());
106
119
}
107
- if (cmd.isset (" java-load-class" ))
120
+
121
+ if (options.is_set (" java-load-class" ))
108
122
{
109
- const auto &values = cmd. get_values (" java-load-class" );
123
+ const auto &load_values = options. get_list_option (" java-load-class" );
110
124
java_load_classes.insert (
111
- java_load_classes.end (), values .begin (), values .end ());
125
+ java_load_classes.end (), load_values .begin (), load_values .end ());
112
126
}
113
- if (cmd. isset (" java-no-load-class" ))
127
+ if (options. is_set (" java-no-load-class" ))
114
128
{
115
- const auto &values = cmd. get_values (" java-no-load-class" );
116
- no_load_classes = {values .begin (), values .end ()};
129
+ const auto &no_load_values = options. get_list_option (" java-no-load-class" );
130
+ no_load_classes = {no_load_values .begin (), no_load_values .end ()};
117
131
}
118
-
119
- const std::list<std::string> &extra_entry_points=
120
- cmd.get_values (" lazy-methods-extra-entry-point" );
132
+ const std::list<std::string> &extra_entry_points =
133
+ options.get_list_option (" lazy-methods-extra-entry-point" );
121
134
std::transform (
122
135
extra_entry_points.begin (),
123
136
extra_entry_points.end (),
124
137
std::back_inserter (extra_methods),
125
138
build_load_method_by_regex);
126
- const auto &new_points = build_extra_entry_points (cmd );
139
+ const auto &new_points = build_extra_entry_points (options );
127
140
extra_methods.insert (
128
141
extra_methods.end (), new_points.begin (), new_points.end ());
129
142
130
- if (cmd.isset (" java-cp-include-files" ))
143
+ java_cp_include_files = options.get_option (" java-cp-include-files" );
144
+ if (!java_cp_include_files.empty ())
131
145
{
132
- java_cp_include_files=cmd.get_value (" java-cp-include-files" );
133
146
// load file list from JSON file
134
147
if (java_cp_include_files[0 ]==' @' )
135
148
{
@@ -144,7 +157,7 @@ void java_bytecode_languaget::get_language_options(const cmdlinet &cmd)
144
157
throw " the JSON file has a wrong format" ;
145
158
jsont include_files=json_cp_config[" jar" ];
146
159
if (!include_files.is_array ())
147
- throw " the JSON file has a wrong format" ;
160
+ throw " the JSON file has a wrong format" ;
148
161
149
162
// add jars from JSON config file to classpath
150
163
for (const jsont &file_entry : include_files.array )
@@ -160,7 +173,7 @@ void java_bytecode_languaget::get_language_options(const cmdlinet &cmd)
160
173
else
161
174
java_cp_include_files=" .*" ;
162
175
163
- nondet_static = cmd. isset (" nondet-static" );
176
+ nondet_static = options. get_bool_option (" nondet-static" );
164
177
165
178
language_options_initialized=true ;
166
179
}
@@ -1216,8 +1229,7 @@ java_bytecode_languaget::~java_bytecode_languaget()
1216
1229
// / specifying extra entry points. To provide a regex entry point, the command
1217
1230
// / line option `--lazy-methods-extra-entry-point` can be used directly.
1218
1231
std::vector<load_extra_methodst>
1219
- java_bytecode_languaget::build_extra_entry_points (
1220
- const cmdlinet &command_line) const
1232
+ java_bytecode_languaget::build_extra_entry_points (const optionst &options) const
1221
1233
{
1222
1234
return {};
1223
1235
}
0 commit comments