summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorJosé Fonseca <jose.r.fonseca@gmail.com>2012-11-20 17:04:24 +0000
committerJosé Fonseca <jose.r.fonseca@gmail.com>2012-11-20 17:04:24 +0000
commitbf8d87f389a361fd1acf47fcd7dad5a7c4e14a6b (patch)
treeacd080b95f18309320028babc8f170bebd1d7ab3 /common
parentdbf714bb5a9bd14e08defced32871f6a0ecf5e72 (diff)
dump: Pretty print anonymous structure members.
Diffstat (limited to 'common')
-rw-r--r--common/trace_dump.cpp28
1 files changed, 23 insertions, 5 deletions
diff --git a/common/trace_dump.cpp b/common/trace_dump.cpp
index 2b8c27a3..e6810b6a 100644
--- a/common/trace_dump.cpp
+++ b/common/trace_dump.cpp
@@ -170,14 +170,32 @@ public:
}
}
- void visit(Struct *s) {
- const char *sep = "";
- os << "{";
+ const char *
+ visitMembers(Struct *s, const char *sep = "") {
for (unsigned i = 0; i < s->members.size(); ++i) {
- os << sep << italic << s->sig->member_names[i] << normal << " = ";
- _visit(s->members[i]);
+ const char *memberName = s->sig->member_names[i];
+ Value *memberValue = s->members[i];
+
+ if (!memberName || !*memberName) {
+ // Anonymous structure
+ Struct *memberStruct = dynamic_cast<Struct *>(memberValue);
+ assert(memberStruct);
+ if (memberStruct) {
+ sep = visitMembers(memberStruct, sep);
+ continue;
+ }
+ }
+
+ os << sep << italic << memberName << normal << " = ",
+ _visit(memberValue);
sep = ", ";
}
+ return sep;
+ }
+
+ void visit(Struct *s) {
+ os << "{";
+ visitMembers(s);
os << "}";
}