X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=common%2Ftrace_model.cpp;h=3f19bc6c60b27c43f82f66acd976fdee364871dc;hb=ee0fdfe385b70d95b3c3d590468fa6e329bf2cc7;hp=7e926ba46db70e65c5e8ee1a732f7ce9dcde784e;hpb=2ae3c962d308ceb866f7478866cdcc85f50a987d;p=apitrace diff --git a/common/trace_model.cpp b/common/trace_model.cpp index 7e926ba..3f19bc6 100644 --- a/common/trace_model.cpp +++ b/common/trace_model.cpp @@ -72,6 +72,18 @@ Blob::~Blob() { } } +StackFrame::~StackFrame() { + if (module != NULL) { + delete [] module; + } + if (function != NULL) { + delete [] function; + } + if (filename != NULL) { + delete [] filename; + } +} + // bool cast bool Null ::toBool(void) const { return false; } @@ -85,6 +97,7 @@ bool Struct ::toBool(void) const { return true; } bool Array ::toBool(void) const { return true; } bool Blob ::toBool(void) const { return true; } bool Pointer::toBool(void) const { return value != 0; } +bool Repr ::toBool(void) const { return static_cast(machineValue); } // signed integer cast @@ -95,6 +108,7 @@ signed long long SInt ::toSInt(void) const { return value; } signed long long UInt ::toSInt(void) const { assert(static_cast(value) >= 0); return static_cast(value); } signed long long Float ::toSInt(void) const { return static_cast(value); } signed long long Double ::toSInt(void) const { return static_cast(value); } +signed long long Repr ::toSInt(void) const { return machineValue->toSInt(); } // unsigned integer cast @@ -105,6 +119,7 @@ unsigned long long SInt ::toUInt(void) const { assert(value >= 0); return stat unsigned long long UInt ::toUInt(void) const { return value; } unsigned long long Float ::toUInt(void) const { return static_cast(value); } unsigned long long Double ::toUInt(void) const { return static_cast(value); } +unsigned long long Repr ::toUInt(void) const { return machineValue->toUInt(); } // floating point cast @@ -115,6 +130,7 @@ float SInt ::toFloat(void) const { return static_cast(value); } float UInt ::toFloat(void) const { return static_cast(value); } float Float ::toFloat(void) const { return value; } float Double ::toFloat(void) const { return value; } +float Repr ::toFloat(void) const { return machineValue->toFloat(); } // floating point cast @@ -125,6 +141,7 @@ double SInt ::toDouble(void) const { return static_cast(value); } double UInt ::toDouble(void) const { return static_cast(value); } double Float ::toDouble(void) const { return value; } double Double ::toDouble(void) const { return value; } +double Repr ::toDouble(void) const { return machineValue->toDouble(); } // pointer cast @@ -132,23 +149,27 @@ void * Value ::toPointer(void) const { assert(0); return NULL; } void * Null ::toPointer(void) const { return NULL; } void * Blob ::toPointer(void) const { return buf; } void * Pointer::toPointer(void) const { return (void *)value; } +void * Repr ::toPointer(void) const { return machineValue->toPointer(); } void * Value ::toPointer(bool bind) { assert(0); return NULL; } void * Null ::toPointer(bool bind) { return NULL; } void * Blob ::toPointer(bool bind) { if (bind) bound = true; return buf; } void * Pointer::toPointer(bool bind) { return (void *)value; } +void * Repr ::toPointer(bool bind) { return machineValue->toPointer(bind); } -// pointer cast +// unsigned int pointer cast unsigned long long Value ::toUIntPtr(void) const { assert(0); return 0; } unsigned long long Null ::toUIntPtr(void) const { return 0; } unsigned long long Pointer::toUIntPtr(void) const { return value; } +unsigned long long Repr ::toUIntPtr(void) const { return machineValue->toUIntPtr(); } // string cast const char * Value ::toString(void) const { assert(0); return NULL; } const char * Null ::toString(void) const { return NULL; } const char * String::toString(void) const { return value; } +const char * Repr ::toString(void) const { return machineValue->toString(); } // virtual Value::visit() @@ -165,6 +186,7 @@ void Struct ::visit(Visitor &visitor) { visitor.visit(this); } void Array ::visit(Visitor &visitor) { visitor.visit(this); } void Blob ::visit(Visitor &visitor) { visitor.visit(this); } void Pointer::visit(Visitor &visitor) { visitor.visit(this); } +void Repr ::visit(Visitor &visitor) { visitor.visit(this); } void Visitor::visit(Null *) { assert(0); } @@ -180,12 +202,15 @@ void Visitor::visit(Struct *) { assert(0); } void Visitor::visit(Array *) { assert(0); } void Visitor::visit(Blob *) { assert(0); } void Visitor::visit(Pointer *) { assert(0); } +void Visitor::visit(Repr *node) { node->machineValue->visit(*this); } +void Visitor::visit(Backtrace *) { assert(0); } +void Visitor::visit(StackFrame *) { assert(0); } static Null null; const Value & Value::operator[](size_t index) const { - const Array *array = dynamic_cast(this); + const Array *array = toArray(); if (array) { if (index < array->values.size()) { return *array->values[index];