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 = cmd.isset (" throw-runtime-exceptions" );
50
- assert_uncaught_exceptions = !cmd.isset (" disable-uncaught-exception-check" );
51
- throw_assertion_error = cmd.isset (" throw-assertion-error" );
52
- threading_support = cmd.isset (" java-threading" );
53
-
54
- if (cmd.isset (" max-nondet-array-length" ))
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" ));
58
+
59
+ if (cmd.isset (" java-max-vla-length" ))
55
60
{
56
- object_factory_parameters. max_nondet_array_length =
57
- 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" ));
58
63
}
59
64
60
- 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" ))
61
72
{
62
- object_factory_parameters. max_nondet_tree_depth =
63
- 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 " ));
64
75
}
65
-
66
- if (cmd.isset (" max-nondet-string-length" ))
76
+ if (cmd.isset (" lazy-methods-extra-entry-point" ))
77
+ {
78
+ options.set_option (
79
+ " lazy-methods-extra-entry-point" ,
80
+ cmd.get_values (" lazy-methods-extra-entry-point" ));
81
+ }
82
+ if (cmd.isset (" java-cp-include-files" ))
67
83
{
68
- object_factory_parameters. max_nondet_string_length =
69
- 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 " ));
70
86
}
71
- if (cmd.isset (" string-non-empty" ))
72
- object_factory_parameters.min_nondet_string_length = 1 ;
87
+ }
73
88
74
- object_factory_parameters.string_printable = cmd.isset (" string-printable" );
75
- if (cmd.isset (" java-max-vla-length" ))
76
- max_user_array_length =
77
- safe_string2size_t (cmd.get_value (" java-max-vla-length" ));
78
- 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" ))
79
107
lazy_methods_mode=LAZY_METHODS_MODE_EXTERNAL_DRIVER;
80
- else if (!cmd. isset ( " no- lazy-methods" ))
108
+ else if (options. get_bool_option ( " lazy-methods" ))
81
109
lazy_methods_mode=LAZY_METHODS_MODE_CONTEXT_INSENSITIVE;
82
110
else
83
111
lazy_methods_mode=LAZY_METHODS_MODE_EAGER;
84
112
85
113
if (throw_runtime_exceptions)
86
114
{
87
115
java_load_classes.insert (
88
- java_load_classes.end (),
89
- exception_needed_classes.begin (),
90
- exception_needed_classes.end ());
116
+ java_load_classes.end (),
117
+ exception_needed_classes.begin (),
118
+ exception_needed_classes.end ());
91
119
}
92
- if (cmd.isset (" java-load-class" ))
120
+
121
+ if (options.is_set (" java-load-class" ))
93
122
{
94
- const auto &values = cmd. get_values (" java-load-class" );
123
+ const auto &load_values = options. get_list_option (" java-load-class" );
95
124
java_load_classes.insert (
96
- java_load_classes.end (), values .begin (), values .end ());
125
+ java_load_classes.end (), load_values .begin (), load_values .end ());
97
126
}
98
- if (cmd. isset (" java-no-load-class" ))
127
+ if (options. is_set (" java-no-load-class" ))
99
128
{
100
- const auto &values = cmd. get_values (" java-no-load-class" );
101
- 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 ()};
102
131
}
103
-
104
- const std::list<std::string> &extra_entry_points=
105
- 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" );
106
134
std::transform (
107
135
extra_entry_points.begin (),
108
136
extra_entry_points.end (),
109
137
std::back_inserter (extra_methods),
110
138
build_load_method_by_regex);
111
- const auto &new_points = build_extra_entry_points (cmd );
139
+ const auto &new_points = build_extra_entry_points (options );
112
140
extra_methods.insert (
113
141
extra_methods.end (), new_points.begin (), new_points.end ());
114
142
115
- 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 ())
116
145
{
117
- java_cp_include_files=cmd.get_value (" java-cp-include-files" );
118
146
// load file list from JSON file
119
147
if (java_cp_include_files[0 ]==' @' )
120
148
{
@@ -129,7 +157,7 @@ void java_bytecode_languaget::get_language_options(const cmdlinet &cmd)
129
157
throw " the JSON file has a wrong format" ;
130
158
jsont include_files=json_cp_config[" jar" ];
131
159
if (!include_files.is_array ())
132
- throw " the JSON file has a wrong format" ;
160
+ throw " the JSON file has a wrong format" ;
133
161
134
162
// add jars from JSON config file to classpath
135
163
for (const jsont &file_entry : include_files.array )
@@ -145,7 +173,7 @@ void java_bytecode_languaget::get_language_options(const cmdlinet &cmd)
145
173
else
146
174
java_cp_include_files=" .*" ;
147
175
148
- nondet_static = cmd. isset (" nondet-static" );
176
+ nondet_static = options. get_bool_option (" nondet-static" );
149
177
150
178
language_options_initialized=true ;
151
179
}
@@ -1219,8 +1247,7 @@ java_bytecode_languaget::~java_bytecode_languaget()
1219
1247
// / specifying extra entry points. To provide a regex entry point, the command
1220
1248
// / line option `--lazy-methods-extra-entry-point` can be used directly.
1221
1249
std::vector<load_extra_methodst>
1222
- java_bytecode_languaget::build_extra_entry_points (
1223
- const cmdlinet &command_line) const
1250
+ java_bytecode_languaget::build_extra_entry_points (const optionst &options) const
1224
1251
{
1225
1252
return {};
1226
1253
}
0 commit comments