|
22 | 22 | #include "remove_skip.h"
|
23 | 23 | #include "resolve_inherited_component.h"
|
24 | 24 |
|
25 |
| -class remove_virtual_functionst |
| 25 | +class get_virtual_calleest |
26 | 26 | {
|
27 | 27 | public:
|
28 |
| - remove_virtual_functionst( |
29 |
| - symbol_table_baset &_symbol_table, |
30 |
| - const class_hierarchyt &_class_hierarchy); |
31 |
| - |
32 |
| - void operator()(goto_functionst &goto_functions); |
33 |
| - |
34 |
| - bool remove_virtual_functions( |
35 |
| - const irep_idt &function_id, |
36 |
| - goto_programt &goto_program); |
37 |
| - |
38 |
| - goto_programt::targett remove_virtual_function( |
39 |
| - const irep_idt &function_id, |
40 |
| - goto_programt &goto_program, |
41 |
| - goto_programt::targett target, |
42 |
| - const dispatch_table_entriest &functions, |
43 |
| - virtual_dispatch_fallback_actiont fallback_action); |
| 28 | + get_virtual_calleest( |
| 29 | + const symbol_table_baset &_symbol_table, |
| 30 | + const class_hierarchyt &_class_hierarchy) : |
| 31 | + ns(_symbol_table), |
| 32 | + symbol_table(_symbol_table), |
| 33 | + class_hierarchy(_class_hierarchy) |
| 34 | + { |
| 35 | + } |
44 | 36 |
|
45 |
| - void get_functions(const exprt &, dispatch_table_entriest &); |
| 37 | + void get_functions(const exprt &, dispatch_table_entriest &) const; |
46 | 38 |
|
47 | 39 | protected:
|
48 | 40 | const namespacet ns;
|
49 |
| - symbol_table_baset &symbol_table; |
| 41 | + const symbol_table_baset &symbol_table; |
50 | 42 |
|
51 | 43 | const class_hierarchyt &class_hierarchy;
|
52 | 44 |
|
53 |
| - goto_programt::targett remove_virtual_function( |
54 |
| - const irep_idt &function_id, |
55 |
| - goto_programt &goto_program, |
56 |
| - goto_programt::targett target); |
57 | 45 | typedef std::function<
|
58 | 46 | optionalt<resolve_inherited_componentt::inherited_componentt>(
|
59 | 47 | const irep_idt &,
|
60 | 48 | const irep_idt &)>
|
61 | 49 | function_call_resolvert;
|
| 50 | + |
62 | 51 | void get_child_functions_rec(
|
63 | 52 | const irep_idt &,
|
64 | 53 | const optionalt<symbol_exprt> &,
|
65 | 54 | const irep_idt &,
|
66 | 55 | dispatch_table_entriest &,
|
67 | 56 | dispatch_table_entries_mapt &,
|
68 | 57 | const function_call_resolvert &) const;
|
| 58 | + |
69 | 59 | exprt
|
70 | 60 | get_method(const irep_idt &class_id, const irep_idt &component_name) const;
|
71 | 61 | };
|
72 | 62 |
|
73 |
| -remove_virtual_functionst::remove_virtual_functionst( |
74 |
| - symbol_table_baset &_symbol_table, |
75 |
| - const class_hierarchyt &_class_hierarchy) |
76 |
| - : ns(_symbol_table), |
77 |
| - symbol_table(_symbol_table), |
78 |
| - class_hierarchy(_class_hierarchy) |
| 63 | +class remove_virtual_functionst : public get_virtual_calleest |
79 | 64 | {
|
80 |
| -} |
| 65 | +public: |
| 66 | + remove_virtual_functionst( |
| 67 | + symbol_table_baset &_symbol_table, |
| 68 | + const class_hierarchyt &_class_hierarchy) : |
| 69 | + get_virtual_calleest(_symbol_table, _class_hierarchy), |
| 70 | + symbol_table(_symbol_table) |
| 71 | + { |
| 72 | + } |
| 73 | + |
| 74 | + void operator()(goto_functionst &functions); |
| 75 | + |
| 76 | + bool remove_virtual_functions( |
| 77 | + const irep_idt &function_id, |
| 78 | + goto_programt &goto_program); |
| 79 | + |
| 80 | + goto_programt::targett remove_virtual_function( |
| 81 | + const irep_idt &function_id, |
| 82 | + goto_programt &goto_program, |
| 83 | + goto_programt::targett target, |
| 84 | + const dispatch_table_entriest &functions, |
| 85 | + virtual_dispatch_fallback_actiont fallback_action); |
| 86 | + |
| 87 | +protected: |
| 88 | + symbol_table_baset &symbol_table; |
| 89 | + |
| 90 | + goto_programt::targett remove_virtual_function( |
| 91 | + const irep_idt &function_id, |
| 92 | + goto_programt &goto_program, |
| 93 | + goto_programt::targett target); |
| 94 | +}; |
81 | 95 |
|
82 | 96 | /// Replace specified virtual function call with a static call to its
|
83 | 97 | /// most derived implementation
|
@@ -497,7 +511,7 @@ goto_programt::targett remove_virtual_functionst::remove_virtual_function(
|
497 | 511 | /// -> [{"C", C.f}, {"B", C.f}, {"A", A.f}]
|
498 | 512 | /// \param entry_map: map of class identifiers to dispatch table entries
|
499 | 513 | /// \param resolve_function_call`: function to resolve abstract method call
|
500 |
| -void remove_virtual_functionst::get_child_functions_rec( |
| 514 | +void get_virtual_calleest::get_child_functions_rec( |
501 | 515 | const irep_idt &this_id,
|
502 | 516 | const optionalt<symbol_exprt> &last_method_defn,
|
503 | 517 | const irep_idt &component_name,
|
@@ -565,9 +579,9 @@ void remove_virtual_functionst::get_child_functions_rec(
|
565 | 579 | /// \param function: function that should be called
|
566 | 580 | /// \param [out] functions: is assigned a list of dispatch entries, i.e., pairs
|
567 | 581 | /// of class names and function symbol to call when encountering the class.
|
568 |
| -void remove_virtual_functionst::get_functions( |
| 582 | +void get_virtual_calleest::get_functions( |
569 | 583 | const exprt &function,
|
570 |
| - dispatch_table_entriest &functions) |
| 584 | + dispatch_table_entriest &functions) const |
571 | 585 | {
|
572 | 586 | // class part of function to call
|
573 | 587 | const irep_idt class_id=function.get(ID_C_class);
|
@@ -650,7 +664,7 @@ void remove_virtual_functionst::get_functions(
|
650 | 664 | /// \param component_name: Name of the function to look up
|
651 | 665 | /// \return nil_exprt instance on error and a symbol_exprt pointing to
|
652 | 666 | /// the method on success
|
653 |
| -exprt remove_virtual_functionst::get_method( |
| 667 | +exprt get_virtual_calleest::get_method( |
654 | 668 | const irep_idt &class_id,
|
655 | 669 | const irep_idt &component_name) const
|
656 | 670 | {
|
@@ -808,10 +822,10 @@ goto_programt::targett remove_virtual_function(
|
808 | 822 |
|
809 | 823 | void collect_virtual_function_callees(
|
810 | 824 | const exprt &function,
|
811 |
| - symbol_table_baset &symbol_table, |
| 825 | + const symbol_table_baset &symbol_table, |
812 | 826 | const class_hierarchyt &class_hierarchy,
|
813 | 827 | dispatch_table_entriest &overridden_functions)
|
814 | 828 | {
|
815 |
| - remove_virtual_functionst instance(symbol_table, class_hierarchy); |
816 |
| - instance.get_functions(function, overridden_functions); |
| 829 | + get_virtual_calleest get_callees(symbol_table, class_hierarchy); |
| 830 | + get_callees.get_functions(function, overridden_functions); |
817 | 831 | }
|
0 commit comments