@@ -137,34 +137,17 @@ bool ci_lazy_methodst::operator()(
137
137
std::swap (methods_to_convert, methods_to_convert_later);
138
138
for (const auto &mname : methods_to_convert)
139
139
{
140
- if (!methods_already_populated.insert (mname).second )
141
- continue ;
142
- debug () << " CI lazy methods: elaborate " << mname << eom;
143
- if (
144
- method_converter (
145
- mname,
146
- // Note this wraps *references* to methods_to_convert_later &
147
- // instantiated_classes
148
- ci_lazy_methods_neededt (
149
- methods_to_convert_later, instantiated_classes, symbol_table)))
150
- {
151
- // Couldn't convert this function
152
- continue ;
153
- }
154
- const exprt &method_body = symbol_table.lookup_ref (mname).value ;
155
-
156
- gather_virtual_callsites (method_body, virtual_function_calls);
157
-
158
- if (!class_initializer_seen && references_class_model (method_body))
159
- {
160
- class_initializer_seen = true ;
161
- irep_idt initializer_signature =
162
- get_java_class_literal_initializer_signature ();
163
- if (symbol_table.has_symbol (initializer_signature))
164
- methods_to_convert_later.insert (initializer_signature);
165
- }
166
-
167
- any_new_methods = true ;
140
+ const auto conversion_result = convert_and_analyze_method (
141
+ method_converter,
142
+ methods_already_populated,
143
+ class_initializer_seen,
144
+ mname,
145
+ symbol_table,
146
+ methods_to_convert_later,
147
+ instantiated_classes,
148
+ virtual_function_calls);
149
+ any_new_methods |= conversion_result.new_method_seen ;
150
+ class_initializer_seen |= conversion_result.class_initializer_seen ;
168
151
}
169
152
}
170
153
@@ -272,6 +255,57 @@ bool ci_lazy_methodst::operator()(
272
255
return false ;
273
256
}
274
257
258
+ // / Convert a method, add it to the populated set, add needed methods to
259
+ // / methods_to_convert_later and add virtual calls from the method to
260
+ // / virtual_function_calls
261
+ // / \return structure containing two Booleans:
262
+ // / * class_initializer_seen which is true if the class_initializer_seen
263
+ // / argument was false and the class_model is referenced in
264
+ // / the body of the method
265
+ // / * new_method_seen if the method was not converted before and was
266
+ // / converted successfully here
267
+ ci_lazy_methodst::convert_method_resultt
268
+ ci_lazy_methodst::convert_and_analyze_method (
269
+ const method_convertert &method_converter,
270
+ std::unordered_set<irep_idt> &methods_already_populated,
271
+ const bool class_initializer_already_seen,
272
+ const irep_idt &method_name,
273
+ symbol_tablet &symbol_table,
274
+ std::unordered_set<irep_idt> &methods_to_convert_later,
275
+ std::unordered_set<irep_idt> &instantiated_classes,
276
+ std::unordered_set<exprt, irep_hash> &virtual_function_calls)
277
+ {
278
+ convert_method_resultt result;
279
+ if (!methods_already_populated.insert (method_name).second )
280
+ return result;
281
+
282
+ debug () << " CI lazy methods: elaborate " << method_name << eom;
283
+
284
+ // Note this wraps *references* to methods_to_convert_later &
285
+ // instantiated_classes
286
+ ci_lazy_methods_neededt needed_methods (
287
+ methods_to_convert_later, instantiated_classes, symbol_table);
288
+
289
+ const bool could_not_convert_function =
290
+ method_converter (method_name, needed_methods);
291
+ if (could_not_convert_function)
292
+ return result;
293
+
294
+ const exprt &method_body = symbol_table.lookup_ref (method_name).value ;
295
+ gather_virtual_callsites (method_body, virtual_function_calls);
296
+
297
+ if (!class_initializer_already_seen && references_class_model (method_body))
298
+ {
299
+ result.class_initializer_seen = true ;
300
+ const irep_idt initializer_signature =
301
+ get_java_class_literal_initializer_signature ();
302
+ if (symbol_table.has_symbol (initializer_signature))
303
+ methods_to_convert_later.insert (initializer_signature);
304
+ }
305
+ result.new_method_seen = true ;
306
+ return result;
307
+ }
308
+
275
309
// / Entry point methods are either:
276
310
// / * the "main" function of the `main_class` if it exists
277
311
// / * all the methods of the main class if it is not empty
0 commit comments