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;
+ }
};
void visit(Visitor &visitor);
std::vector<Value *> values;
+
+ inline size_t
+ size(void) const {
+ return values.size();
+ }
};
};
+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:
virtual void visit(Array *);
virtual void visit(Blob *);
virtual void visit(Pointer *);
+ virtual void visit(Repr *);
protected:
inline void _visit(Value *value) {
};
+struct Arg
+{
+ Value *value;
+};
+
class Call
{
unsigned thread_id;
unsigned no;
const FunctionSig *sig;
- std::vector<Value *> args;
+ std::vector<Arg> args;
Value *ret;
CallFlags flags;
inline Value & arg(unsigned index) {
assert(index < args.size());
- return *(args[index]);
+ return *(args[index].value);
}
};