Skip to content

Commit f611794

Browse files
author
Daniel Kroening
authored
Merge pull request #2998 from diffblue/format-type
format(type) additions
2 parents 204437e + e2d9556 commit f611794

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/util/format_type.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,26 @@ static std::ostream &format_rec(std::ostream &os, const struct_typet &src)
3232
return os << " }";
3333
}
3434

35+
/// format a \ref union_typet
36+
static std::ostream &format_rec(std::ostream &os, const union_typet &src)
37+
{
38+
os << "union"
39+
<< " {";
40+
bool first = true;
41+
42+
for(const auto &c : src.components())
43+
{
44+
if(first)
45+
first = false;
46+
else
47+
os << ',';
48+
49+
os << ' ' << format(c.type()) << ' ' << c.get_name();
50+
}
51+
52+
return os << " }";
53+
}
54+
3555
// The below generates a string in a generic syntax
3656
// that is inspired by C/C++/Java, and is meant for debugging
3757
// purposes.
@@ -51,8 +71,24 @@ std::ostream &format_rec(std::ostream &os, const typet &type)
5171
}
5272
else if(id == ID_struct)
5373
return format_rec(os, to_struct_type(type));
74+
else if(id == ID_union)
75+
return format_rec(os, to_union_type(type));
76+
else if(id == ID_union_tag)
77+
return os << "union " << to_union_tag_type(type).get_identifier();
78+
else if(id == ID_struct_tag)
79+
return os << "struct " << to_struct_tag_type(type).get_identifier();
80+
else if(id == ID_c_enum_tag)
81+
return os << "c_enum " << to_c_enum_tag_type(type).get_identifier();
5482
else if(id == ID_symbol_type)
5583
return os << "symbol_type " << to_symbol_type(type).get_identifier();
84+
else if(id == ID_signedbv)
85+
return os << "signedbv[" << to_signedbv_type(type).get_width() << ']';
86+
else if(id == ID_unsignedbv)
87+
return os << "unsignedbv[" << to_unsignedbv_type(type).get_width() << ']';
88+
else if(id == ID_floatbv)
89+
return os << "floatbv[" << to_floatbv_type(type).get_width() << ']';
90+
else if(id == ID_c_bool)
91+
return os << "c_bool[" << to_c_bool_type(type).get_width() << ']';
5692
else
5793
return os << id;
5894
}

0 commit comments

Comments
 (0)