@@ -291,6 +291,50 @@ static bool needs_clinit_wrapper(
291
291
return false ;
292
292
}
293
293
294
+ static void create_function_symbol (
295
+ const irep_idt &class_name,
296
+ const irep_idt &function_name,
297
+ const irep_idt &function_base_name,
298
+ const synthetic_method_typet &synthetic_method_type,
299
+ symbol_tablet &symbol_table,
300
+ synthetic_methods_mapt &synthetic_methods)
301
+ {
302
+ symbolt function_symbol;
303
+ const java_method_typet function_type ({}, java_void_type ());
304
+ function_symbol.name = function_name;
305
+ function_symbol.pretty_name = function_symbol.name ;
306
+ function_symbol.base_name = function_base_name;
307
+ function_symbol.type = function_type;
308
+ // This provides a back-link from a method to its associated class, as is done
309
+ // for java_bytecode_convert_methodt::convert.
310
+ set_declaring_class (function_symbol, class_name);
311
+ function_symbol.mode = ID_java;
312
+ bool failed = symbol_table.add (function_symbol);
313
+ INVARIANT (!failed, id2string (function_base_name) + " symbol should be fresh" );
314
+
315
+ auto insert_result =
316
+ synthetic_methods.emplace (function_symbol.name , synthetic_method_type);
317
+ INVARIANT (
318
+ insert_result.second ,
319
+ " synthetic methods map should not already contain entry for " +
320
+ id2string (function_base_name));
321
+ }
322
+
323
+ // Create symbol for the "clinit_wrapper"
324
+ static void create_clinit_wrapper_function_symbol (
325
+ const irep_idt &class_name,
326
+ symbol_tablet &symbol_table,
327
+ synthetic_methods_mapt &synthetic_methods)
328
+ {
329
+ create_function_symbol (
330
+ class_name,
331
+ clinit_wrapper_name (class_name),
332
+ " clinit_wrapper" ,
333
+ synthetic_method_typet::STATIC_INITIALIZER_WRAPPER,
334
+ symbol_table,
335
+ synthetic_methods);
336
+ }
337
+
294
338
// / Creates a static initializer wrapper symbol for the given class, along with
295
339
// / a global boolean that tracks if it has been run already.
296
340
// / \param class_name: class symbol name
@@ -345,27 +389,8 @@ static void create_clinit_wrapper_symbols(
345
389
true );
346
390
}
347
391
348
- // Create symbol for the "clinit_wrapper"
349
- symbolt wrapper_method_symbol;
350
- const java_method_typet wrapper_method_type ({}, java_void_type ());
351
- wrapper_method_symbol.name = clinit_wrapper_name (class_name);
352
- wrapper_method_symbol.pretty_name = wrapper_method_symbol.name ;
353
- wrapper_method_symbol.base_name = " clinit_wrapper" ;
354
- wrapper_method_symbol.type = wrapper_method_type;
355
- // This provides a back-link from a method to its associated class, as is done
356
- // for java_bytecode_convert_methodt::convert.
357
- set_declaring_class (wrapper_method_symbol, class_name);
358
- wrapper_method_symbol.mode = ID_java;
359
- bool failed = symbol_table.add (wrapper_method_symbol);
360
- INVARIANT (!failed, " clinit-wrapper symbol should be fresh" );
361
-
362
- auto insert_result = synthetic_methods.emplace (
363
- wrapper_method_symbol.name ,
364
- synthetic_method_typet::STATIC_INITIALIZER_WRAPPER);
365
- INVARIANT (
366
- insert_result.second ,
367
- " synthetic methods map should not already contain entry for "
368
- " clinit wrapper" );
392
+ create_clinit_wrapper_function_symbol (
393
+ class_name, symbol_table, synthetic_methods);
369
394
}
370
395
371
396
// / Thread safe version of the static initializer.
0 commit comments