@@ -10,14 +10,16 @@ Author: Daniel Kroening, kroening@kroening.com
1010
1111#include < string>
1212
13- #include < util/symbol_table.h>
14- #include < util/suffix.h>
15- #include < util/config.h>
1613#include < util/cmdline.h>
14+ #include < util/config.h>
1715#include < util/expr_iterator.h>
16+ #include < util/invariant.h>
1817#include < util/journalling_symbol_table.h>
18+ #include < util/options.h>
1919#include < util/string2int.h>
20- #include < util/invariant.h>
20+ #include < util/suffix.h>
21+ #include < util/symbol_table.h>
22+
2123#include < json/json_parser.h>
2224
2325#include < goto-programs/class_hierarchy.h>
@@ -39,82 +41,108 @@ Author: Daniel Kroening, kroening@kroening.com
3941#include " expr2java.h"
4042#include " load_method_by_regex.h"
4143
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 )
4648{
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" ))
5560 {
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" ));
5863 }
5964
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" ))
6172 {
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 " ));
6475 }
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" ))
6783 {
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 " ));
7086 }
71- if (cmd.isset (" string-non-empty" ))
72- object_factory_parameters.min_nondet_string_length = 1 ;
87+ }
7388
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" ))
79107 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" ))
81109 lazy_methods_mode=LAZY_METHODS_MODE_CONTEXT_INSENSITIVE;
82110 else
83111 lazy_methods_mode=LAZY_METHODS_MODE_EAGER;
84112
85113 if (throw_runtime_exceptions)
86114 {
87115 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 ());
91119 }
92- if (cmd.isset (" java-load-class" ))
120+
121+ if (options.is_set (" java-load-class" ))
93122 {
94- const auto &values = cmd. get_values (" java-load-class" );
123+ const auto &load_values = options. get_list_option (" java-load-class" );
95124 java_load_classes.insert (
96- java_load_classes.end (), values .begin (), values .end ());
125+ java_load_classes.end (), load_values .begin (), load_values .end ());
97126 }
98- if (cmd. isset (" java-no-load-class" ))
127+ if (options. is_set (" java-no-load-class" ))
99128 {
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 ()};
102131 }
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" );
106134 std::transform (
107135 extra_entry_points.begin (),
108136 extra_entry_points.end (),
109137 std::back_inserter (extra_methods),
110138 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 );
112140 extra_methods.insert (
113141 extra_methods.end (), new_points.begin (), new_points.end ());
114142
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 ())
116145 {
117- java_cp_include_files=cmd.get_value (" java-cp-include-files" );
118146 // load file list from JSON file
119147 if (java_cp_include_files[0 ]==' @' )
120148 {
@@ -129,7 +157,7 @@ void java_bytecode_languaget::get_language_options(const cmdlinet &cmd)
129157 throw " the JSON file has a wrong format" ;
130158 jsont include_files=json_cp_config[" jar" ];
131159 if (!include_files.is_array ())
132- throw " the JSON file has a wrong format" ;
160+ throw " the JSON file has a wrong format" ;
133161
134162 // add jars from JSON config file to classpath
135163 for (const jsont &file_entry : include_files.array )
@@ -145,7 +173,7 @@ void java_bytecode_languaget::get_language_options(const cmdlinet &cmd)
145173 else
146174 java_cp_include_files=" .*" ;
147175
148- nondet_static = cmd. isset (" nondet-static" );
176+ nondet_static = options. get_bool_option (" nondet-static" );
149177
150178 language_options_initialized=true ;
151179}
@@ -1219,8 +1247,7 @@ java_bytecode_languaget::~java_bytecode_languaget()
12191247// / specifying extra entry points. To provide a regex entry point, the command
12201248// / line option `--lazy-methods-extra-entry-point` can be used directly.
12211249std::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
12241251{
12251252 return {};
12261253}
0 commit comments