**************************************************************************/
+#include <limits>
+
#include "formatter.hpp"
#include "trace_dump.hpp"
}
void visit(Null *) {
- os << "NULL";
+ os << literal << "NULL" << normal;
}
void visit(Bool *node) {
}
void visit(Float *node) {
+ std::streamsize oldPrecision = os.precision(std::numeric_limits<float>::digits10 + 1);
os << literal << node->value << normal;
+ os.precision(oldPrecision);
}
void visit(Double *node) {
+ std::streamsize oldPrecision = os.precision(std::numeric_limits<double>::digits10 + 1);
os << literal << node->value << normal;
+ os.precision(oldPrecision);
}
void visit(String *node) {
}
void visit(Enum *node) {
- const EnumSig *sig = node->sig;
- for (const EnumValue *it = sig->values; it != sig->values + sig->num_values; ++it) {
- if (it->value == node->value) {
- os << literal << it->name << normal;
- return;
- }
+ const EnumValue *it = node->lookup();
+ if (it) {
+ os << literal << it->name << normal;
+ return;
}
os << literal << node->value << normal;
}
unsigned long long value = bitmask->value;
const BitmaskSig *sig = bitmask->sig;
bool first = true;
- for (const BitmaskFlag *it = sig->flags; value != 0 && it != sig->flags + sig->num_flags; ++it) {
+ for (const BitmaskFlag *it = sig->flags; it != sig->flags + sig->num_flags; ++it) {
+ assert(it->value || first);
if ((it->value && (value & it->value) == it->value) ||
(!it->value && value == 0)) {
if (!first) {
value &= ~it->value;
first = false;
}
+ if (value == 0) {
+ break;
+ }
}
if (value || first) {
if (!first) {
}
}
- 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 << "}";
}
os << pointer << "0x" << std::hex << p->value << std::dec << normal;
}
+ void visit(Repr *r) {
+ _visit(r->humanValue);
+ }
+
void visit(Call *call) {
CallFlags callFlags = call->flags;
+
+ if (!(dumpFlags & DUMP_FLAG_NO_CALL_NO)) {
+ os << call->no << " ";
+ }
if (callFlags & CALL_FLAG_NON_REPRODUCIBLE) {
os << strike;
void dump(Call &call, std::ostream &os, DumpFlags flags) {
Dumper d(os, flags);
- os << call.no << " ";
d.visit(&call);
}