Skip to content

Commit 78cf3b9

Browse files
Make class hierarchy output with parents optional
1 parent e5e0897 commit 78cf3b9

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

jbmc/unit/java_bytecode/goto-programs/class_hierarchy_output.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ SCENARIO(
4747
std::stringstream output_dot_stream;
4848

4949
hierarchy(symbol_table);
50-
hierarchy.output(output_stream);
50+
hierarchy.output(output_stream, false);
5151
hierarchy.output_dot(output_dot_stream);
5252

5353
std::string output = output_stream.str();

src/goto-instrument/goto_instrument_parse_options.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ int goto_instrument_parse_optionst::doit()
659659
if(cmdline.isset("dot"))
660660
hierarchy.output_dot(std::cout);
661661
else
662-
hierarchy.output(std::cout);
662+
hierarchy.output(std::cout, false);
663663

664664
return 0;
665665
}

src/goto-programs/class_hierarchy.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ void class_hierarchyt::operator()(const symbol_tablet &symbol_table)
3030
{
3131
const struct_typet &struct_type = to_struct_type(symbol_pair.second.type);
3232

33+
class_map[symbol_pair.first].is_abstract =
34+
struct_type.get_bool(ID_abstract);
35+
3336
const irept::subt &bases=
3437
struct_type.find(ID_bases).get_sub();
3538

@@ -123,17 +126,20 @@ void class_hierarchyt::get_parents_trans_rec(
123126
get_parents_trans_rec(child, dest);
124127
}
125128

126-
void class_hierarchyt::output(std::ostream &out) const
129+
/// Output the class hierarchy in plain text
130+
/// \param out: the output stream
131+
/// \param children_only: print the children only and do not print the parents
132+
void class_hierarchyt::output(std::ostream &out, bool children_only) const
127133
{
128134
for(const auto &c : class_map)
129135
{
130-
for(const auto &pa : c.second.parents)
131-
out << "Parent of " << c.first << ": "
132-
<< pa << '\n';
133-
136+
if(!children_only)
137+
{
138+
for(const auto &pa : c.second.parents)
139+
out << "Parent of " << c.first << ": " << pa << '\n';
140+
}
134141
for(const auto &ch : c.second.children)
135-
out << "Child of " << c.first << ": "
136-
<< ch << '\n';
142+
out << "Child of " << c.first << ": " << ch << '\n';
137143
}
138144
}
139145

src/goto-programs/class_hierarchy.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class class_hierarchyt
3232
{
3333
public:
3434
idst parents, children;
35+
bool is_abstract;
3536
};
3637

3738
typedef std::map<irep_idt, entryt> class_mapt;
@@ -55,7 +56,7 @@ class class_hierarchyt
5556
return result;
5657
}
5758

58-
void output(std::ostream &) const;
59+
void output(std::ostream &, bool children_only) const;
5960
void output_dot(std::ostream &) const;
6061

6162
protected:

0 commit comments

Comments
 (0)