@@ -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 convertion_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 |= convertion_result.new_method_seen ;
150
+ class_initializer_seen |= convertion_result.class_initializer_seen ;
168
151
}
169
152
}
170
153
@@ -272,6 +255,48 @@ bool ci_lazy_methodst::operator()(
272
255
return false ;
273
256
}
274
257
258
+ ci_lazy_methodst::convert_method_resultt
259
+ ci_lazy_methodst::convert_and_analyze_method (
260
+ const method_convertert &method_converter,
261
+ std::unordered_set<irep_idt> &methods_already_populated,
262
+ const bool class_initializer_seen,
263
+ const dstringt &mname,
264
+ symbol_tablet &symbol_table,
265
+ std::unordered_set<irep_idt> &methods_to_convert_later,
266
+ std::unordered_set<irep_idt> &instantiated_classes,
267
+ std::unordered_set<exprt, irep_hash> &virtual_function_calls)
268
+ {
269
+ convert_method_resultt result;
270
+ if (!methods_already_populated.insert (mname).second )
271
+ return result;
272
+
273
+ debug () << " CI lazy methods: elaborate " << mname << eom;
274
+
275
+ // Note this wraps *references* to methods_to_convert_later &
276
+ // instantiated_classes
277
+ ci_lazy_methods_neededt needed_methods (
278
+ methods_to_convert_later, instantiated_classes, symbol_table);
279
+
280
+ const bool could_not_convert_function =
281
+ method_converter (mname, needed_methods);
282
+ if (could_not_convert_function)
283
+ return result;
284
+
285
+ const exprt &method_body = symbol_table.lookup_ref (mname).value ;
286
+ gather_virtual_callsites (method_body, virtual_function_calls);
287
+
288
+ if (!class_initializer_seen && references_class_model (method_body))
289
+ {
290
+ result.class_initializer_seen = true ;
291
+ const irep_idt initializer_signature =
292
+ get_java_class_literal_initializer_signature ();
293
+ if (symbol_table.has_symbol (initializer_signature))
294
+ methods_to_convert_later.insert (initializer_signature);
295
+ }
296
+ result.new_method_seen = true ;
297
+ return result;
298
+ }
299
+
275
300
// / Entry point methods are either:
276
301
// / * the "main" function of the `main_class` if it exists
277
302
// / * all the methods of the main class if it is not empty
0 commit comments