@@ -19,37 +19,6 @@ Date: April 2016
19
19
#include < util/std_types.h>
20
20
#include < util/symbol_table.h>
21
21
22
- // / Looks for all the struct types in the symbol table and construct a map from
23
- // / class names to a data structure that contains lists of parent and child
24
- // / classes for each struct type (ie class).
25
- // / \param symbol_table: The symbol table to analyze
26
- void class_hierarchyt::operator ()(const symbol_tablet &symbol_table)
27
- {
28
- for (const auto &symbol_pair : symbol_table.symbols )
29
- {
30
- if (symbol_pair.second .is_type && symbol_pair.second .type .id () == ID_struct)
31
- {
32
- const struct_typet &struct_type = to_struct_type (symbol_pair.second .type );
33
-
34
- class_map[symbol_pair.first ].is_abstract =
35
- struct_type.get_bool (ID_abstract);
36
-
37
- const irept::subt &bases=
38
- struct_type.find (ID_bases).get_sub ();
39
-
40
- for (const auto &base : bases)
41
- {
42
- irep_idt parent=base.find (ID_type).get (ID_identifier);
43
- if (parent.empty ())
44
- continue ;
45
-
46
- class_map[parent].children .push_back (symbol_pair.first );
47
- class_map[symbol_pair.first ].parents .push_back (parent);
48
- }
49
- }
50
- }
51
- }
52
-
53
22
// / Populate the class hierarchy graph, such that there is a node for every
54
23
// / struct type in the symbol table and an edge representing each superclass
55
24
// / <-> subclass relationship, pointing from parent to child.
@@ -164,6 +133,37 @@ void class_hierarchyt::get_children_trans_rec(
164
133
get_children_trans_rec (child, dest);
165
134
}
166
135
136
+ // / Looks for all the struct types in the symbol table and construct a map from
137
+ // / class names to a data structure that contains lists of parent and child
138
+ // / classes for each struct type (ie class).
139
+ // / \param symbol_table: The symbol table to analyze
140
+ void class_hierarchyt::operator ()(const symbol_tablet &symbol_table)
141
+ {
142
+ for (const auto &symbol_pair : symbol_table.symbols )
143
+ {
144
+ if (symbol_pair.second .is_type && symbol_pair.second .type .id () == ID_struct)
145
+ {
146
+ const struct_typet &struct_type = to_struct_type (symbol_pair.second .type );
147
+
148
+ class_map[symbol_pair.first ].is_abstract =
149
+ struct_type.get_bool (ID_abstract);
150
+
151
+ const irept::subt &bases=
152
+ struct_type.find (ID_bases).get_sub ();
153
+
154
+ for (const auto &base : bases)
155
+ {
156
+ irep_idt parent=base.find (ID_type).get (ID_identifier);
157
+ if (parent.empty ())
158
+ continue ;
159
+
160
+ class_map[parent].children .push_back (symbol_pair.first );
161
+ class_map[symbol_pair.first ].parents .push_back (parent);
162
+ }
163
+ }
164
+ }
165
+ }
166
+
167
167
// / Get all the classes that class c inherits from (directly or indirectly). The
168
168
// / first element(s) will be the immediate parents of c, though after this
169
169
// / the order is all the parents of the first immediate parent
0 commit comments