X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=common%2Ftrace_model.hpp;h=bb8936e32946bc78763edb025802ce1f6adfccc4;hb=be6b2e76b2a5c529eec85cab10732444143c87d5;hp=076ff098d61f9fa25edf72a80aef7c4796663d9f;hpb=0af9670e1d6fe6e9dc6d38c7b28e18a5fea7d009;p=apitrace diff --git a/common/trace_model.hpp b/common/trace_model.hpp index 076ff09..bb8936e 100644 --- a/common/trace_model.hpp +++ b/common/trace_model.hpp @@ -228,6 +228,17 @@ public: void visit(Visitor &visitor); const EnumSig *sig; + + const EnumValue * + lookup() { + // TODO: use a std::map + for (const EnumValue *it = sig->values; it != sig->values + sig->num_values; ++it) { + if (it->value == value) { + return it; + } + } + return NULL; + } }; @@ -266,6 +277,11 @@ public: void visit(Visitor &visitor); std::vector values; + + inline size_t + size(void) const { + return values.size(); + } }; @@ -304,6 +320,35 @@ public: }; +class Repr : public Value +{ +public: + Repr(Value *human, Value *machine) : + humanValue(human), + machineValue(machine) + {} + + /** Human-readible value */ + Value *humanValue; + + /** Machine-readible value */ + Value *machineValue; + + virtual bool toBool(void) const; + virtual signed long long toSInt(void) const; + virtual unsigned long long toUInt(void) const; + virtual float toFloat(void) const; + 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; + + void visit(Visitor &visitor); +}; + + class Visitor { public: @@ -320,6 +365,7 @@ public: virtual void visit(Array *); virtual void visit(Blob *); virtual void visit(Pointer *); + virtual void visit(Repr *); protected: inline void _visit(Value *value) { @@ -406,6 +452,11 @@ enum { }; +struct Arg +{ + Value *value; +}; + class Call { @@ -413,7 +464,7 @@ public: unsigned thread_id; unsigned no; const FunctionSig *sig; - std::vector args; + std::vector args; Value *ret; CallFlags flags; @@ -434,7 +485,7 @@ public: inline Value & arg(unsigned index) { assert(index < args.size()); - return *(args[index]); + return *(args[index].value); } };