28 for(
const auto &symbol_pair : symbol_table.
symbols)
30 if(symbol_pair.second.is_type && symbol_pair.second.type.id() == ID_struct)
34 class_map[symbol_pair.first].is_abstract =
40 for(
const auto &base : bases)
42 irep_idt parent=base.find(ID_type).get(ID_identifier);
46 class_map[parent].children.push_back(symbol_pair.first);
47 class_map[symbol_pair.first].parents.push_back(parent);
61 for(
const auto &symbol_pair : symbol_table.
symbols)
63 if(symbol_pair.second.is_type && symbol_pair.second.type.id() == ID_struct)
67 (*this)[new_node_index].class_identifier = symbol_pair.first;
72 for(
const auto &symbol_pair : symbol_table.
symbols)
74 if(symbol_pair.second.is_type && symbol_pair.second.type.id() == ID_struct)
78 for(
const auto &base : class_type.
bases())
95 class_mapt::const_iterator it=
class_map.find(c);
98 const entryt &entry=it->second;
100 for(
const auto &child : entry.
children)
101 dest.push_back(child);
104 for(
const auto &child : entry.
children)
117 class_mapt::const_iterator it=
class_map.find(c);
120 const entryt &entry=it->second;
122 for(
const auto &child : entry.
parents)
123 dest.push_back(child);
126 for(
const auto &child : entry.
parents)
137 out << c.first << (c.second.is_abstract ?
" (abstract)" :
"") <<
":\n";
140 out <<
" parents:\n";
141 for(
const auto &pa : c.second.parents)
142 out <<
" " << pa <<
'\n';
144 out <<
" children:\n";
145 for(
const auto &ch : c.second.children)
146 out <<
" " << ch <<
'\n';
154 ostr <<
"digraph class_hierarchy {\n" 156 <<
" node [fontsize=12 shape=box];\n";
159 for(
const auto &ch : c.second.parents)
161 ostr <<
" \"" << c.first <<
"\" -> " 162 <<
"\"" << ch <<
"\" " 163 <<
" [arrowhead=\"vee\"];" 175 bool children_only)
const 186 for(
const auto &pa : c.second.parents)
191 for(
const auto &ch : c.second.children)
void get_children_trans_rec(const irep_idt &, idst &) const
void operator()(const symbol_tablet &)
Looks for all the struct types in the symbol table and construct a map from class names to a data str...
void output(std::ostream &, bool children_only) const
Output the class hierarchy in plain text.
std::vector< irept > subt
Provides methods for streaming JSON objects.
void populate(const symbol_tablet &)
Populate the class hierarchy graph, such that there is a node for every struct type in the symbol tab...
nodes_by_namet nodes_by_name
Maps class identifiers onto node indices.
const symbol_typet & to_symbol_type(const typet &type)
Cast a generic typet to a symbol_typet.
json_stream_objectt & push_back_stream_object()
Add a JSON object child stream.
static jsont json_boolean(bool value)
const class_typet & to_class_type(const typet &type)
Cast a generic typet to a class_typet.
void get_parents_trans_rec(const irep_idt &, idst &) const
Get all the classes that inherit (directly or indirectly) from class c.
static mstreamt & eom(mstreamt &m)
bool get_bool(const irep_namet &name) const
Provides methods for streaming JSON arrays.
nodet::node_indext node_indext
void push_back(const jsont &json)
Push back a JSON element into the current array stream.
const struct_typet & to_struct_type(const typet &type)
Cast a generic typet to a struct_typet.
std::vector< irep_idt > idst
mstreamt & result() const
void add_edge(node_indext a, node_indext b)
void show_class_hierarchy(const class_hierarchyt &hierarchy, message_handlert &message_handler, ui_message_handlert::uit ui, bool children_only)
Output the class hierarchy.
const basest & bases() const
json_stream_arrayt & push_back_stream_array(const std::string &key)
Add a JSON array stream for a specific key.
goto_programt coverage_criteriont message_handlert & message_handler
json_stream_arrayt & json_stream()
Returns a reference to the top-level JSON array stream.
void output_dot(std::ostream &) const
Output class hierarchy in Graphviz DOT format.
const irept & find(const irep_namet &name) const