@@ -98,34 +98,8 @@ bool ci_lazy_methodst::operator()(
9898 method_bytecodet &method_bytecode,
9999 const method_convertert &method_converter)
100100{
101- std::unordered_set<irep_idt> methods_to_convert_later;
102-
103- main_function_resultt main_function =
104- get_main_symbol (symbol_table, main_class, get_message_handler ());
105- if (!main_function.is_success ())
106- {
107- // Failed, mark all functions in the given main class(es)
108- // reachable.
109- std::vector<irep_idt> reachable_classes;
110- if (!main_class.empty ())
111- reachable_classes.push_back (main_class);
112- else
113- reachable_classes = main_jar_classes;
114- for (const irep_idt &class_name : reachable_classes)
115- {
116- const auto &methods =
117- java_class_loader.get_original_class (class_name).parsed_class .methods ;
118- for (const auto &method : methods)
119- {
120- const irep_idt methodid =
121- " java::" + id2string (class_name) + " ." + id2string (method.name )
122- + " :" + id2string (method.descriptor );
123- methods_to_convert_later.insert (methodid);
124- }
125- }
126- }
127- else
128- methods_to_convert_later.insert (main_function.main_function .name );
101+ std::unordered_set<irep_idt> methods_to_convert_later =
102+ entry_point_methods (symbol_table);
129103
130104 // Add any extra entry points specified; we should elaborate these in the
131105 // same way as the main function.
@@ -297,6 +271,46 @@ bool ci_lazy_methodst::operator()(
297271 return false ;
298272}
299273
274+ // / Entry point methods are either:
275+ // / * the "main" function of the `main_class` if it exists
276+ // / * all the methods of the main class if it is not empty
277+ // / * all the methods of the main jar file
278+ // / \return set of identifiers of entry point methods
279+ std::unordered_set<irep_idt>
280+ ci_lazy_methodst::entry_point_methods (const symbol_tablet &symbol_table)
281+ {
282+ std::unordered_set<irep_idt> methods_to_convert_later;
283+
284+ const main_function_resultt main_function = get_main_symbol (
285+ symbol_table, this ->main_class , this ->get_message_handler ());
286+ if (!main_function.is_success ())
287+ {
288+ // Failed, mark all functions in the given main class(es)
289+ // reachable.
290+ std::vector<irep_idt> reachable_classes;
291+ if (!this ->main_class .empty ())
292+ reachable_classes.push_back (this ->main_class );
293+ else
294+ reachable_classes = this ->main_jar_classes ;
295+ for (const irep_idt &class_name : reachable_classes)
296+ {
297+ const auto &methods =
298+ this ->java_class_loader .get_original_class (class_name)
299+ .parsed_class .methods ;
300+ for (const auto &method : methods)
301+ {
302+ const irep_idt methodid = " java::" + id2string (class_name) + " ." +
303+ id2string (method.name ) + " :" +
304+ id2string (method.descriptor );
305+ methods_to_convert_later.insert (methodid);
306+ }
307+ }
308+ }
309+ else
310+ methods_to_convert_later.insert (main_function.main_function .name );
311+ return methods_to_convert_later;
312+ }
313+
300314// / Translates the given list of method names from human-readable to
301315// / internal syntax.
302316// / Expands any wildcards (entries ending in '.*') in the given method
0 commit comments