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