Skip to content

Commit 3ecac30

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 4badd8f commit 3ecac30

File tree

1 file changed

+30
-31
lines changed

1 file changed

+30
-31
lines changed

src/goto-programs/class_hierarchy.cpp

+30-31
Original file line numberDiff line numberDiff line change
@@ -20,37 +20,6 @@ Date: April 2016
2020
#include <util/std_types.h>
2121
#include <util/symbol_table.h>
2222

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

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+
173172
/// Get all the classes that class c inherits from (directly or indirectly). The
174173
/// first element(s) will be the immediate parents of c, though after this
175174
/// the order is all the parents of the first immediate parent

0 commit comments

Comments
 (0)