Skip to content

Commit 5abbad4

Browse files
committed
Move non-graph function below graph functions
This way everything related to class_hierarchy_grapht appears first in the file, followed by everything related to class_hierarchyt. Ideally these parts should be split into different files in the future.
1 parent 55e5a3f commit 5abbad4

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

src/goto-programs/class_hierarchy.cpp

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,37 +19,6 @@ Date: April 2016
1919
#include <util/std_types.h>
2020
#include <util/symbol_table.h>
2121

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-
5322
/// Populate the class hierarchy graph, such that there is a node for every
5423
/// struct type in the symbol table and an edge representing each superclass
5524
/// <-> subclass relationship, pointing from parent to child.
@@ -162,6 +131,37 @@ void class_hierarchyt::get_children_trans_rec(
162131
get_children_trans_rec(child, dest);
163132
}
164133

134+
/// Looks for all the struct types in the symbol table and construct a map from
135+
/// class names to a data structure that contains lists of parent and child
136+
/// classes for each struct type (ie class).
137+
/// \param symbol_table: The symbol table to analyze
138+
void class_hierarchyt::operator()(const symbol_tablet &symbol_table)
139+
{
140+
for(const auto &symbol_pair : symbol_table.symbols)
141+
{
142+
if(symbol_pair.second.is_type && symbol_pair.second.type.id() == ID_struct)
143+
{
144+
const struct_typet &struct_type = to_struct_type(symbol_pair.second.type);
145+
146+
class_map[symbol_pair.first].is_abstract =
147+
struct_type.get_bool(ID_abstract);
148+
149+
const irept::subt &bases=
150+
struct_type.find(ID_bases).get_sub();
151+
152+
for(const auto &base : bases)
153+
{
154+
irep_idt parent=base.find(ID_type).get(ID_identifier);
155+
if(parent.empty())
156+
continue;
157+
158+
class_map[parent].children.push_back(symbol_pair.first);
159+
class_map[symbol_pair.first].parents.push_back(parent);
160+
}
161+
}
162+
}
163+
}
164+
165165
/// Get all the classes that class c inherits from (directly or indirectly). The
166166
/// first element(s) will be the immediate parents of c, though after this
167167
/// the order is all the parents of the first immediate parent

0 commit comments

Comments
 (0)