@@ -29,7 +29,6 @@ Author: Diffblue Ltd.
29
29
// / removed via `lazy-methods`. Example of use: `ArrayList` as general
30
30
// / implementation for `List` interface.
31
31
// / \param pointer_type_selector: selector to handle correct pointer types
32
- // / \param message_handler: the message handler to use for output
33
32
// / \param synthetic_methods: map from synthetic method names to the type of
34
33
// / synthetic method (e.g. stub class static initialiser). Indicates that
35
34
// / these method bodies are produced internally, rather than generated from
@@ -42,10 +41,8 @@ ci_lazy_methodst::ci_lazy_methodst(
42
41
java_class_loadert &java_class_loader,
43
42
const std::vector<irep_idt> &extra_instantiated_classes,
44
43
const select_pointer_typet &pointer_type_selector,
45
- message_handlert &message_handler,
46
44
const synthetic_methods_mapt &synthetic_methods)
47
- : messaget(message_handler),
48
- main_class(main_class),
45
+ : main_class(main_class),
49
46
main_jar_classes(main_jar_classes),
50
47
lazy_methods_extra_entry_points(lazy_methods_extra_entry_points),
51
48
java_class_loader(java_class_loader),
@@ -96,14 +93,16 @@ static bool references_class_model(const exprt &expr)
96
93
// / \param [out] method_bytecode: map from method names to relevant symbol and
97
94
// / parsed-method objects.
98
95
// / \param method_converter: Function for converting methods on demand.
96
+ // / \param message_handler: the message handler to use for output
99
97
// / \return Returns false on success
100
98
bool ci_lazy_methodst::operator ()(
101
99
symbol_tablet &symbol_table,
102
100
method_bytecodet &method_bytecode,
103
- const method_convertert &method_converter)
101
+ const method_convertert &method_converter,
102
+ message_handlert &message_handler)
104
103
{
105
104
std::unordered_set<irep_idt> methods_to_convert_later =
106
- entry_point_methods (symbol_table);
105
+ entry_point_methods (symbol_table, message_handler );
107
106
108
107
// Add any extra entry points specified; we should elaborate these in the
109
108
// same way as the main function.
@@ -134,6 +133,8 @@ bool ci_lazy_methodst::operator()(
134
133
called_virtual_functions;
135
134
bool class_initializer_seen = false ;
136
135
136
+ messaget log{message_handler};
137
+
137
138
bool any_new_classes = true ;
138
139
while (any_new_classes)
139
140
{
@@ -155,7 +156,8 @@ bool ci_lazy_methodst::operator()(
155
156
symbol_table,
156
157
methods_to_convert_later,
157
158
instantiated_classes,
158
- called_virtual_functions);
159
+ called_virtual_functions,
160
+ message_handler);
159
161
any_new_methods |= conversion_result.new_method_seen ;
160
162
class_initializer_seen |= conversion_result.class_initializer_seen ;
161
163
}
@@ -164,8 +166,9 @@ bool ci_lazy_methodst::operator()(
164
166
// Given the object types we now know may be created, populate more
165
167
// possible virtual function call targets:
166
168
167
- debug () << " CI lazy methods: add virtual method targets ("
168
- << called_virtual_functions.size () << " callsites)" << eom;
169
+ log.debug () << " CI lazy methods: add virtual method targets ("
170
+ << called_virtual_functions.size () << " callsites)"
171
+ << messaget::eom;
169
172
170
173
for (const class_method_descriptor_exprt &called_virtual_function :
171
174
called_virtual_functions)
@@ -214,9 +217,9 @@ bool ci_lazy_methodst::operator()(
214
217
keep_symbols.add (sym.second );
215
218
}
216
219
217
- debug () << " CI lazy methods: removed "
218
- << symbol_table.symbols .size () - keep_symbols.symbols .size ()
219
- << " unreachable methods and globals" << eom;
220
+ log. debug () << " CI lazy methods: removed "
221
+ << symbol_table.symbols .size () - keep_symbols.symbols .size ()
222
+ << " unreachable methods and globals" << messaget:: eom;
220
223
221
224
symbol_table.swap (keep_symbols);
222
225
@@ -322,13 +325,15 @@ ci_lazy_methodst::convert_and_analyze_method(
322
325
std::unordered_set<irep_idt> &methods_to_convert_later,
323
326
std::unordered_set<irep_idt> &instantiated_classes,
324
327
std::unordered_set<class_method_descriptor_exprt, irep_hash>
325
- &called_virtual_functions)
328
+ &called_virtual_functions,
329
+ message_handlert &message_handler)
326
330
{
327
331
convert_method_resultt result;
328
332
if (!methods_already_populated.insert (method_name).second )
329
333
return result;
330
334
331
- debug () << " CI lazy methods: elaborate " << method_name << eom;
335
+ messaget log{message_handler};
336
+ log.debug () << " CI lazy methods: elaborate " << method_name << messaget::eom;
332
337
333
338
// Note this wraps *references* to methods_to_convert_later &
334
339
// instantiated_classes
@@ -361,13 +366,14 @@ ci_lazy_methodst::convert_and_analyze_method(
361
366
// / * all the methods of the main class if it is not empty
362
367
// / * all the methods of the main jar file
363
368
// / \return set of identifiers of entry point methods
364
- std::unordered_set<irep_idt>
365
- ci_lazy_methodst::entry_point_methods (const symbol_tablet &symbol_table)
369
+ std::unordered_set<irep_idt> ci_lazy_methodst::entry_point_methods (
370
+ const symbol_tablet &symbol_table,
371
+ message_handlert &message_handler)
366
372
{
367
373
std::unordered_set<irep_idt> methods_to_convert_later;
368
374
369
- const main_function_resultt main_function = get_main_symbol (
370
- symbol_table, this ->main_class , this -> get_message_handler () );
375
+ const main_function_resultt main_function =
376
+ get_main_symbol ( symbol_table, this ->main_class , message_handler );
371
377
if (!main_function.is_success ())
372
378
{
373
379
// Failed, mark all functions in the given main class(es)
0 commit comments