bool Float ::toBool(void) const { return value != 0; }
bool Double ::toBool(void) const { return value != 0; }
bool String ::toBool(void) const { return true; }
-bool Enum ::toBool(void) const { return sig->value != 0; }
bool Struct ::toBool(void) const { return true; }
bool Array ::toBool(void) const { return true; }
bool Blob ::toBool(void) const { return true; }
signed long long UInt ::toSInt(void) const { assert(static_cast<signed long long>(value) >= 0); return static_cast<signed long long>(value); }
signed long long Float ::toSInt(void) const { return static_cast<signed long long>(value); }
signed long long Double ::toSInt(void) const { return static_cast<signed long long>(value); }
-signed long long Enum ::toSInt(void) const { return sig->value; }
// unsigned integer cast
unsigned long long UInt ::toUInt(void) const { return value; }
unsigned long long Float ::toUInt(void) const { return static_cast<unsigned long long>(value); }
unsigned long long Double ::toUInt(void) const { return static_cast<unsigned long long>(value); }
-unsigned long long Enum ::toUInt(void) const { assert(sig->value >= 0); return sig->value; }
// floating point cast
float UInt ::toFloat(void) const { return static_cast<float>(value); }
float Float ::toFloat(void) const { return value; }
float Double ::toFloat(void) const { return value; }
-float Enum ::toFloat(void) const { return static_cast<float>(sig->value); }
// floating point cast
double UInt ::toDouble(void) const { return static_cast<double>(value); }
double Float ::toDouble(void) const { return value; }
double Double ::toDouble(void) const { return value; }
-double Enum ::toDouble(void) const { return static_cast<double>(sig->value); }
// pointer cast
formatter::Attribute *normal;
formatter::Attribute *bold;
formatter::Attribute *italic;
+ formatter::Attribute *strike;
formatter::Attribute *red;
formatter::Attribute *pointer;
formatter::Attribute *literal;
normal = formatter->normal();
bold = formatter->bold();
italic = formatter->italic();
+ strike = formatter->strike();
red = formatter->color(formatter::RED);
pointer = formatter->color(formatter::GREEN);
literal = formatter->color(formatter::BLUE);
delete normal;
delete bold;
delete italic;
+ delete strike;
delete red;
delete pointer;
delete literal;
}
void visit(Enum *node) {
- os << literal << node->sig->name << normal;
+ 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;
+ }
+ }
+ os << literal << node->value << normal;
}
void visit(Bitmask *bitmask) {
}
void visit(Call *call) {
+ CallFlags flags = call->flags;
+
+ if (flags & CALL_FLAG_NON_REPRODUCIBLE) {
+ os << strike;
+ } else if (flags & (CALL_FLAG_FAKE | CALL_FLAG_NO_SIDE_EFFECTS)) {
+ os << normal;
+ } else {
+ os << bold;
+ }
+ os << call->sig->name << normal;
+
+ os << "(";
const char *sep = "";
- os << bold << call->sig->name << normal << "(";
for (unsigned i = 0; i < call->args.size(); ++i) {
os << sep << italic << call->sig->arg_names[i] << normal << " = ";
if (call->args[i]) {
sep = ", ";
}
os << ")";
+
if (call->ret) {
os << " = ";
_visit(call->ret);
}
+
+ if (flags & CALL_FLAG_INCOMPLETE) {
+ os << " // " << red << "incomplete" << normal;
+ }
+
os << "\n";
+
+ if (flags & CALL_FLAG_END_FRAME) {
+ os << "\n";
+ }
}
};