@@ -113,7 +113,7 @@ bool ci_lazy_methodst::operator()(
113
113
{
114
114
std::unordered_set<irep_idt> initial_callable_methods;
115
115
ci_lazy_methods_neededt initial_lazy_methods (
116
- initial_callable_methods, instantiated_classes, symbol_table);
116
+ initial_callable_methods, instantiated_classes, symbol_table, pointer_type_selector );
117
117
initialize_instantiated_classes (
118
118
methods_to_convert_later, namespacet (symbol_table), initial_lazy_methods);
119
119
methods_to_convert_later.insert (
@@ -278,7 +278,7 @@ ci_lazy_methodst::convert_and_analyze_method(
278
278
// Note this wraps *references* to methods_to_convert_later &
279
279
// instantiated_classes
280
280
ci_lazy_methods_neededt needed_methods (
281
- methods_to_convert_later, instantiated_classes, symbol_table);
281
+ methods_to_convert_later, instantiated_classes, symbol_table, pointer_type_selector );
282
282
283
283
const bool could_not_convert_function =
284
284
method_converter (mname, needed_methods);
@@ -410,8 +410,7 @@ void ci_lazy_methodst::initialize_instantiated_classes(
410
410
if (param.type ().id ()==ID_pointer)
411
411
{
412
412
const pointer_typet &original_pointer=to_pointer_type (param.type ());
413
- initialize_all_instantiated_classes_from_pointer (
414
- original_pointer, ns, needed_lazy_methods);
413
+ needed_lazy_methods.add_all_needed_classes (original_pointer);
415
414
}
416
415
}
417
416
}
@@ -428,75 +427,6 @@ void ci_lazy_methodst::initialize_instantiated_classes(
428
427
needed_lazy_methods.add_needed_class (" java::" + id2string (id));
429
428
}
430
429
431
- // / Build up list of methods for types for a pointer and any types it
432
- // / might be subsituted for. See
433
- // / `initialize_instantiated_classes` for more details.
434
- // / \param pointer_type: The type to gather methods for.
435
- // / \param ns: global namespace
436
- // / \param [out] needed_lazy_methods: Populated with all Java reference types
437
- // / whose references may be passed, directly or indirectly, to any of the
438
- // / functions in `entry_points`
439
- void ci_lazy_methodst::initialize_all_instantiated_classes_from_pointer (
440
- const pointer_typet &pointer_type,
441
- const namespacet &ns,
442
- ci_lazy_methods_neededt &needed_lazy_methods)
443
- {
444
- initialize_instantiated_classes_from_pointer (
445
- pointer_type,
446
- ns,
447
- needed_lazy_methods);
448
-
449
- // TODO we should be passing here a map that maps generic parameters
450
- // to concrete types in the current context TG-2664
451
- const pointer_typet &subbed_pointer_type =
452
- pointer_type_selector.convert_pointer_type (pointer_type, {}, ns);
453
-
454
- if (subbed_pointer_type!=pointer_type)
455
- {
456
- initialize_instantiated_classes_from_pointer (
457
- subbed_pointer_type, ns, needed_lazy_methods);
458
- }
459
- }
460
-
461
- // / Build up list of methods for types for a specific pointer type. See
462
- // / `initialize_instantiated_classes` for more details.
463
- // / \param pointer_type: The type to gather methods for.
464
- // / \param ns: global namespace
465
- // / \param [out] needed_lazy_methods: Populated with all Java reference types
466
- // / whose references may be passed, directly or indirectly, to any of the
467
- // / functions in `entry_points`
468
- void ci_lazy_methodst::initialize_instantiated_classes_from_pointer (
469
- const pointer_typet &pointer_type,
470
- const namespacet &ns,
471
- ci_lazy_methods_neededt &needed_lazy_methods)
472
- {
473
- const symbol_typet &class_type=to_symbol_type (pointer_type.subtype ());
474
- const auto ¶m_classid=class_type.get_identifier ();
475
-
476
- // Note here: different arrays may have different element types, so we should
477
- // explore again even if we've seen this classid before in the array case.
478
- if (needed_lazy_methods.add_needed_class (param_classid) ||
479
- is_java_array_tag (param_classid))
480
- {
481
- gather_field_types (pointer_type.subtype (), ns, needed_lazy_methods);
482
- }
483
-
484
- if (is_java_generic_type (pointer_type))
485
- {
486
- // Assume if this is a generic like X<A, B, C>, then any concrete parameters
487
- // will at some point be instantiated.
488
- const auto &generic_args =
489
- to_java_generic_type (pointer_type).generic_type_arguments ();
490
- for (const auto &generic_arg : generic_args)
491
- {
492
- if (!is_java_generic_parameter (generic_arg))
493
- {
494
- initialize_instantiated_classes_from_pointer (
495
- generic_arg, ns, needed_lazy_methods);
496
- }
497
- }
498
- }
499
- }
500
430
501
431
// / Get places where virtual functions are called.
502
432
// / \param e: expression tree to search
@@ -591,64 +521,6 @@ void ci_lazy_methodst::gather_needed_globals(
591
521
gather_needed_globals (*opit, symbol_table, needed);
592
522
}
593
523
594
- // / See param needed_lazy_methods
595
- // / \param class_type: root of class tree to search
596
- // / \param ns: global namespace
597
- // / \param [out] needed_lazy_methods: Popualted with all Java reference types
598
- // / reachable starting at `class_type`. For example if `class_type` is
599
- // / `symbol_typet("java::A")` and A has a B field, then `B` (but not `A`) will
600
- // / noted as a needed class.
601
- void ci_lazy_methodst::gather_field_types (
602
- const typet &class_type,
603
- const namespacet &ns,
604
- ci_lazy_methods_neededt &needed_lazy_methods)
605
- {
606
- const auto &underlying_type=to_struct_type (ns.follow (class_type));
607
- if (is_java_array_tag (underlying_type.get_tag ()))
608
- {
609
- // If class_type is not a symbol this may be a reference array,
610
- // but we can't tell what type.
611
- if (class_type.id () == ID_symbol)
612
- {
613
- const typet &element_type =
614
- java_array_element_type (to_symbol_type (class_type));
615
- if (element_type.id () == ID_pointer)
616
- {
617
- // This is a reference array -- mark its element type available.
618
- initialize_all_instantiated_classes_from_pointer (
619
- to_pointer_type (element_type), ns, needed_lazy_methods);
620
- }
621
- }
622
- }
623
- else
624
- {
625
- for (const auto &field : underlying_type.components ())
626
- {
627
- if (field.type ().id () == ID_struct || field.type ().id () == ID_symbol)
628
- gather_field_types (field.type (), ns, needed_lazy_methods);
629
- else if (field.type ().id () == ID_pointer)
630
- {
631
- if (field.type ().subtype ().id () == ID_symbol)
632
- {
633
- initialize_all_instantiated_classes_from_pointer (
634
- to_pointer_type (field.type ()), ns, needed_lazy_methods);
635
- }
636
- else
637
- {
638
- // If raw structs were possible this would lead to missed
639
- // dependencies, as both array element and specialised generic type
640
- // information cannot be obtained in this case.
641
- // We should therefore only be skipping pointers such as the uint16t*
642
- // in our internal String representation.
643
- INVARIANT (
644
- field.type ().subtype ().id () != ID_struct,
645
- " struct types should be referred to by symbol at this stage" );
646
- }
647
- }
648
- }
649
- }
650
- }
651
-
652
524
// / Find a virtual callee, if one is defined and the callee type is known to
653
525
// / exist.
654
526
// / \param instantiated_classes: set of classes that can be instantiated.
0 commit comments