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
- protected :
39
+ private :
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 &,
@@ -70,14 +58,41 @@ class remove_virtual_functionst
70
58
get_method (const irep_idt &class_id, const irep_idt &component_name) const ;
71
59
};
72
60
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)
61
+ class remove_virtual_functionst
79
62
{
80
- }
63
+ public:
64
+ remove_virtual_functionst (
65
+ symbol_table_baset &_symbol_table,
66
+ const class_hierarchyt &_class_hierarchy)
67
+ : class_hierarchy(_class_hierarchy),
68
+ symbol_table (_symbol_table),
69
+ ns(symbol_table)
70
+ {
71
+ }
72
+
73
+ void operator ()(goto_functionst &functions);
74
+
75
+ bool remove_virtual_functions (
76
+ const irep_idt &function_id,
77
+ goto_programt &goto_program);
78
+
79
+ goto_programt::targett remove_virtual_function (
80
+ const irep_idt &function_id,
81
+ goto_programt &goto_program,
82
+ goto_programt::targett target,
83
+ const dispatch_table_entriest &functions,
84
+ virtual_dispatch_fallback_actiont fallback_action);
85
+
86
+ private:
87
+ const class_hierarchyt &class_hierarchy;
88
+ symbol_table_baset &symbol_table;
89
+ namespacet ns;
90
+
91
+ goto_programt::targett remove_virtual_function (
92
+ const irep_idt &function_id,
93
+ goto_programt &goto_program,
94
+ goto_programt::targett target);
95
+ };
81
96
82
97
// / Replace specified virtual function call with a static call to its
83
98
// / most derived implementation
@@ -103,8 +118,9 @@ goto_programt::targett remove_virtual_functionst::remove_virtual_function(
103
118
!code.arguments ().empty (),
104
119
" virtual function calls must have at least a this-argument" );
105
120
121
+ get_virtual_calleest get_callees (symbol_table, class_hierarchy);
106
122
dispatch_table_entriest functions;
107
- get_functions (function, functions);
123
+ get_callees. get_functions (function, functions);
108
124
109
125
return remove_virtual_function (
110
126
function_id,
@@ -497,7 +513,7 @@ goto_programt::targett remove_virtual_functionst::remove_virtual_function(
497
513
// / -> [{"C", C.f}, {"B", C.f}, {"A", A.f}]
498
514
// / \param entry_map: map of class identifiers to dispatch table entries
499
515
// / \param resolve_function_call`: function to resolve abstract method call
500
- void remove_virtual_functionst ::get_child_functions_rec (
516
+ void get_virtual_calleest ::get_child_functions_rec (
501
517
const irep_idt &this_id,
502
518
const optionalt<symbol_exprt> &last_method_defn,
503
519
const irep_idt &component_name,
@@ -565,9 +581,9 @@ void remove_virtual_functionst::get_child_functions_rec(
565
581
// / \param function: function that should be called
566
582
// / \param [out] functions: is assigned a list of dispatch entries, i.e., pairs
567
583
// / of class names and function symbol to call when encountering the class.
568
- void remove_virtual_functionst ::get_functions (
584
+ void get_virtual_calleest ::get_functions (
569
585
const exprt &function,
570
- dispatch_table_entriest &functions)
586
+ dispatch_table_entriest &functions) const
571
587
{
572
588
// class part of function to call
573
589
const irep_idt class_id=function.get (ID_C_class);
@@ -650,7 +666,7 @@ void remove_virtual_functionst::get_functions(
650
666
// / \param component_name: Name of the function to look up
651
667
// / \return nil_exprt instance on error and a symbol_exprt pointing to
652
668
// / the method on success
653
- exprt remove_virtual_functionst ::get_method (
669
+ exprt get_virtual_calleest ::get_method (
654
670
const irep_idt &class_id,
655
671
const irep_idt &component_name) const
656
672
{
@@ -808,10 +824,10 @@ goto_programt::targett remove_virtual_function(
808
824
809
825
void collect_virtual_function_callees (
810
826
const exprt &function,
811
- symbol_table_baset &symbol_table,
827
+ const symbol_table_baset &symbol_table,
812
828
const class_hierarchyt &class_hierarchy,
813
829
dispatch_table_entriest &overridden_functions)
814
830
{
815
- remove_virtual_functionst instance (symbol_table, class_hierarchy);
816
- instance .get_functions (function, overridden_functions);
831
+ get_virtual_calleest get_callees (symbol_table, class_hierarchy);
832
+ get_callees .get_functions (function, overridden_functions);
817
833
}
0 commit comments