18
18
19
19
#include < goto-programs/lazy_goto_model.h>
20
20
21
- #include < langapi/mode.h>
22
-
23
21
#include < java_bytecode/java_bytecode_language.h>
24
22
#include < util/file_util.h>
25
23
@@ -38,42 +36,41 @@ symbol_tablet load_java_class_lazy(
38
36
const std::string &class_path,
39
37
const std::string &main)
40
38
{
41
- register_language ( new_java_bytecode_language);
39
+ std::unique_ptr<languaget> lang = new_java_bytecode_language ( );
42
40
43
- return load_java_class (
44
- java_class_name, class_path, main, get_language_from_mode (ID_java));
41
+ return load_java_class (java_class_name, class_path, main, std::move (lang));
45
42
}
46
43
47
- // / Go through the process of loading, type-checking and finalising loading a
48
- // / specific class file to build the symbol table.
49
- // / \param java_class_name: The name of the class file to load. It should not
50
- // / include the .class extension.
51
- // / \param class_path: The path to load the class from. Should be relative to
52
- // / the unit directory.
53
- // / \param main: The name of the main function or "" to use the default
54
- // / behaviour to find a main function.
55
- // / \return The symbol table that is generated by parsing this file.
44
+ // / Returns the symbol table from
45
+ // / \ref load_goto_model_from_java_class(const std::string &java_class_name, const std::string &class_path, const std::string &main) // NOLINT
56
46
symbol_tablet load_java_class (
57
47
const std::string &java_class_name,
58
48
const std::string &class_path,
59
49
const std::string &main)
60
50
{
61
- free_form_cmdlinet command_line;
62
- command_line.add_flag (" no-lazy-methods" );
63
- command_line.add_flag (" no-refine-strings" );
64
-
65
- register_language (new_java_bytecode_language);
51
+ return load_goto_model_from_java_class (java_class_name, class_path, main)
52
+ .get_symbol_table ();
53
+ }
66
54
67
- return load_java_class (
68
- java_class_name,
69
- class_path,
70
- main,
71
- get_language_from_mode (ID_java),
72
- command_line);
55
+ // / Returns the symbol table from \ref load_goto_model_from_java_class
56
+ symbol_tablet load_java_class (
57
+ const std::string &java_class_name,
58
+ const std::string &class_path,
59
+ const std::string &main,
60
+ std::unique_ptr<languaget> &&java_lang,
61
+ const cmdlinet &command_line)
62
+ {
63
+ return load_goto_model_from_java_class (
64
+ java_class_name,
65
+ class_path,
66
+ main,
67
+ std::move (java_lang),
68
+ command_line)
69
+ .get_symbol_table ();
73
70
}
74
71
75
- // / Go through the process of loading, type-checking and finalising loading a
76
- // / specific class file to build the symbol table .
72
+ // / Go through the process of loading, type-checking and finalising a
73
+ // / specific class file to build a goto model from it .
77
74
// / \param java_class_name: The name of the class file to load. It should not
78
75
// / include the .class extension.
79
76
// / \param class_path: The path to load the class from. Should be relative to
@@ -82,8 +79,11 @@ symbol_tablet load_java_class(
82
79
// / behaviour to find a main function.
83
80
// / \param java_lang: The language implementation to use for the loading,
84
81
// / which will be destroyed by this function.
85
- // / \return The symbol table that is generated by parsing this file.
86
- symbol_tablet load_java_class (
82
+ // / \param command_line: The command line used to configure the provided
83
+ // / language
84
+ // / \return The goto model containing both the functions and the symbol table
85
+ // / from loading this class.
86
+ goto_modelt load_goto_model_from_java_class (
87
87
const std::string &java_class_name,
88
88
const std::string &class_path,
89
89
const std::string &main,
@@ -153,9 +153,12 @@ symbol_tablet load_java_class(
153
153
// Check your working directory and the class path is correctly configured
154
154
// as this often indicates that one of these is wrong.
155
155
REQUIRE_FALSE (class_type.get_bool (ID_incomplete_class));
156
- return std::move (maybe_goto_model-> symbol_table );
156
+ return std::move (* maybe_goto_model);
157
157
}
158
158
159
+ // / Returns the symbol table from \ref load_goto_model_from_java_class
160
+ // / with the command line set to be disabling lazy loading and string
161
+ // / refinement
159
162
symbol_tablet load_java_class (
160
163
const std::string &java_class_name,
161
164
const std::string &class_path,
@@ -173,3 +176,21 @@ symbol_tablet load_java_class(
173
176
return load_java_class (
174
177
java_class_name, class_path, main, std::move (java_lang), command_line);
175
178
}
179
+
180
+ // / See \ref load_goto_model_from_java_class
181
+ // / With the command line configured to disable lazy loading and string
182
+ // / refinement and the language set to be the default java_bytecode language
183
+ goto_modelt load_goto_model_from_java_class (
184
+ const std::string &java_class_name,
185
+ const std::string &class_path,
186
+ const std::string &main)
187
+ {
188
+ free_form_cmdlinet command_line;
189
+ command_line.add_flag (" no-lazy-methods" );
190
+ command_line.add_flag (" no-refine-strings" );
191
+
192
+ std::unique_ptr<languaget> lang = new_java_bytecode_language ();
193
+
194
+ return load_goto_model_from_java_class (
195
+ java_class_name, class_path, main, std::move (lang), command_line);
196
+ }
0 commit comments