}
void EndBitmask(void) {
- WriteByte(Trace::TYPE_VOID);
+ WriteByte(Trace::TYPE_NULL);
}
void BeginPointer(const char *type, const void *addr)
void EndPointer(void) { }
void LiteralBool(bool value) {
- WriteByte(Trace::TYPE_BOOL);
- WriteByte(value ? 0 : 1);
+ WriteByte(value ? Trace::TYPE_TRUE : Trace::TYPE_FALSE);
}
void LiteralSInt(signed long long value) {
}
void LiteralNull(void) {
- WriteByte(Trace::TYPE_POINTER);
- WriteUInt(0);
- WriteByte(Trace::TYPE_OPAQUE);
+ WriteByte(Trace::TYPE_NULL);
}
void LiteralOpaque(void) {
};
enum Type {
- TYPE_VOID = 0,
- TYPE_BOOL,
+ TYPE_NULL = 0,
+ TYPE_FALSE,
+ TYPE_TRUE,
TYPE_SINT,
TYPE_UINT,
TYPE_FLOAT,
namespace Trace {
-void Void::visit(Visitor &visitor) {
+void Null::visit(Visitor &visitor) {
visitor.visit(this);
}
Dumper(std::ostream &_os) : os(_os) {}
- void visit(Void *node) {
+ void visit(Null *node) {
+ os << "NULL";
}
void visit(Bool *node) {
return fl->value;
}
-static Void void_;
+static Null null;
const Value & Value::operator[](size_t index) const {
const Array *array = dynamic_cast<const Array *>(unwrap(this));
return *array->values[index];
}
}
- return void_;
+ return null;
}
Value::operator void *(void) const {
const Blob *blob = dynamic_cast<const Blob *>(unwrap(this));
- assert(blob);
- return blob->buf;
+ if (blob)
+ return blob->buf;
+ const Null *null = dynamic_cast<const Null *>(unwrap(this));
+ if (null);
+ return NULL;
+ assert(0);
+ return NULL;
}
Value & Call::arg(const char *name) {
return *it->second;
}
}
- return void_;
+ return null;
}
std::ostream & operator <<(std::ostream &os, Call &call) {
};
-class Void : public Value
+class Null : public Value
{
public:
void visit(Visitor &visitor);
class Visitor
{
public:
- virtual void visit(Void *) {assert(0);}
+ virtual void visit(Null *) {assert(0);}
virtual void visit(Bool *) {assert(0);}
virtual void visit(SInt *) {assert(0);}
virtual void visit(UInt *) {assert(0);}
int c;
c = gzgetc(file);
switch(c) {
- case Trace::TYPE_BOOL:
- return parse_bool();
+ case Trace::TYPE_FALSE:
+ return new Bool(false);
+ case Trace::TYPE_TRUE:
+ return new Bool(true);
case Trace::TYPE_SINT:
return parse_sint();
case Trace::TYPE_UINT:
return parse_blob();
case Trace::TYPE_POINTER:
return parse_pointer();
- case Trace::TYPE_VOID:
- return NULL;
+ case Trace::TYPE_NULL:
+ return new Null;
default:
std::cerr << "error: unknown type " << c << "\n";
assert(0);
case Trace::TYPE_CONST:
read_string();
break;
- case Trace::TYPE_VOID:
+ case Trace::TYPE_NULL:
goto done;
default:
std::cerr << "error: uexpected type " << c << "\n";