Debugger: Tweaks for float values.
FloatValue: - Store value as variant rather than double so as to be able to later differentiate between float vs double. PrimitiveValueNode: - Construct float nodes with variant value.
This commit is contained in:
@@ -77,7 +77,7 @@ PrimitiveValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader,
|
||||
else if (BVariant::TypeIsInteger(valueType))
|
||||
value = new(std::nothrow) IntegerValue(valueData);
|
||||
else if (BVariant::TypeIsFloat(valueType))
|
||||
value = new(std::nothrow) FloatValue(valueData.ToDouble());
|
||||
value = new(std::nothrow) FloatValue(valueData);
|
||||
else
|
||||
return B_UNSUPPORTED;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
FloatValue::FloatValue(double value)
|
||||
FloatValue::FloatValue(const BVariant& value)
|
||||
:
|
||||
fValue(value)
|
||||
{
|
||||
@@ -25,7 +25,21 @@ bool
|
||||
FloatValue::ToString(BString& _string) const
|
||||
{
|
||||
char buffer[128];
|
||||
snprintf(buffer, sizeof(buffer), "%g", fValue);
|
||||
|
||||
switch (fValue.Type()) {
|
||||
case B_FLOAT_TYPE:
|
||||
{
|
||||
snprintf(buffer, sizeof(buffer), "%f", fValue.ToFloat());
|
||||
break;
|
||||
}
|
||||
case B_DOUBLE_TYPE:
|
||||
{
|
||||
snprintf(buffer, sizeof(buffer), "%g", fValue.ToDouble());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
BString string(buffer);
|
||||
if (string.Length() == 0)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
@@ -11,10 +11,10 @@
|
||||
|
||||
class FloatValue : public Value {
|
||||
public:
|
||||
FloatValue(double value);
|
||||
FloatValue(const BVariant& value);
|
||||
virtual ~FloatValue();
|
||||
|
||||
double GetValue() const
|
||||
BVariant GetValue() const
|
||||
{ return fValue; }
|
||||
|
||||
virtual bool ToString(BString& _string) const;
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
virtual bool operator==(const Value& other) const;
|
||||
|
||||
private:
|
||||
double fValue;
|
||||
BVariant fValue;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user