@@ -32,6 +32,26 @@ static std::ostream &format_rec(std::ostream &os, const struct_typet &src)
32
32
return os << " }" ;
33
33
}
34
34
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
+
35
55
// The below generates a string in a generic syntax
36
56
// that is inspired by C/C++/Java, and is meant for debugging
37
57
// purposes.
@@ -51,8 +71,24 @@ std::ostream &format_rec(std::ostream &os, const typet &type)
51
71
}
52
72
else if (id == ID_struct)
53
73
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 ();
54
82
else if (id == ID_symbol_type)
55
83
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 () << ' ]' ;
56
92
else
57
93
return os << id;
58
94
}
0 commit comments