#include <assert.h>
#include <map>
-#include <list>
#include <vector>
#include <iostream>
-#include "trace_writer.hpp"
-
namespace Trace {
+typedef unsigned Id;
+
+
+struct FunctionSig {
+ Id id;
+ const char *name;
+ unsigned num_args;
+ const char **arg_names;
+};
+
+
+struct StructSig {
+ Id id;
+ const char *name;
+ unsigned num_members;
+ const char **member_names;
+};
+
+
+struct EnumSig {
+ Id id;
+ const char *name;
+ signed long long value;
+};
+
+
+struct BitmaskFlag {
+ const char *name;
+ unsigned long long value;
+};
+
+
+struct BitmaskSig {
+ Id id;
+ unsigned num_flags;
+ const BitmaskFlag *flags;
+};
+
+
class Visitor;
virtual double toDouble(void) const;
virtual void *toPointer(void) const;
+ virtual void *toPointer(bool bind);
virtual unsigned long long toUIntPtr(void) const;
virtual const char *toString(void) const;
const Value & operator[](size_t index) const;
+
+ void dump(std::ostream &os, bool color=true);
};
virtual float toFloat(void) const;
virtual double toDouble(void) const;
void *toPointer(void) const;
+ void *toPointer(bool bind);
unsigned long long toUIntPtr(void) const;
const char *toString(void) const;
void visit(Visitor &visitor);
class Struct : public Value
{
public:
- struct Signature {
- const char *name;
- std::vector<const char *> member_names;
- };
-
- Struct(Signature *_sig) : sig(_sig), members(_sig->member_names.size()) { }
+ Struct(StructSig *_sig) : sig(_sig), members(_sig->num_members) { }
~Struct();
bool toBool(void) const;
void visit(Visitor &visitor);
- const Signature *sig;
+ const StructSig *sig;
std::vector<Value *> members;
};
Blob(size_t _size) {
size = _size;
buf = new char[_size];
+ bound = false;
}
~Blob();
bool toBool(void) const;
void *toPointer(void) const;
+ void *toPointer(bool bind);
void visit(Visitor &visitor);
size_t size;
char *buf;
+ bool bound;
};
bool toBool(void) const;
void *toPointer(void) const;
+ void *toPointer(bool bind);
unsigned long long toUIntPtr(void) const;
void visit(Visitor &visitor);
};
};
-std::ostream & operator <<(std::ostream &os, Value *value);
+inline std::ostream & operator <<(std::ostream &os, Value *value) {
+ if (value) {
+ value->dump(os);
+ }
+ return os;
+}
class Call
{
public:
- struct Signature {
- const char * name;
- std::vector<const char *> arg_names;
- };
-
unsigned no;
- const Signature *sig;
+ const FunctionSig *sig;
std::vector<Value *> args;
Value *ret;
- Call(Signature *_sig) : sig(_sig), args(_sig->arg_names.size()), ret(0) { }
+ Call(FunctionSig *_sig) : sig(_sig), args(_sig->num_args), ret(0) { }
~Call();
inline const char * name(void) const {
assert(index < args.size());
return *(args[index]);
}
+
+ void dump(std::ostream &os, bool color=true);
};
-std::ostream & operator <<(std::ostream &os, Call &call);
+inline std::ostream & operator <<(std::ostream &os, Call &call) {
+ call.dump(os);
+ return os;
+}
} /* namespace Trace */