diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index 121c0fb27..0a964917c 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -392,7 +392,12 @@ bool PType::VisitedNodeSet::Check(const PType *node) void PType::SetValue(void *addr, int val) { - assert(0 && "Cannot set value for this type"); + assert(0 && "Cannot set int value for this type"); +} + +void PType::SetValue(void *addr, double val) +{ + assert(0 && "Cannot set float value for this type"); } //========================================================================== @@ -682,6 +687,11 @@ void PInt::SetValue(void *addr, int val) } } +void PInt::SetValue(void *addr, double val) +{ + SetValue(addr, (int)val); +} + //========================================================================== // // PInt :: GetValueInt @@ -927,6 +937,11 @@ void PFloat::SetSymbols(const PFloat::SymbolInitI *sym, size_t count) //========================================================================== void PFloat::SetValue(void *addr, int val) +{ + return SetValue(addr, (double)val); +} + +void PFloat::SetValue(void *addr, double val) { assert(((intptr_t)addr & (Align - 1)) == 0 && "unaligned address"); if (Size == 4) @@ -1112,6 +1127,12 @@ void PFixed::SetValue(void *addr, int val) *(fixed_t *)addr = val << FRACBITS; } +void PFixed::SetValue(void *addr, double val) +{ + assert(((intptr_t)addr & (Align - 1)) == 0 && "unaligned address"); + *(fixed_t *)addr = FLOAT2FIXED(val); +} + //========================================================================== // // PFixed :: GetValueInt @@ -1173,6 +1194,12 @@ void PAngle::SetValue(void *addr, int val) *(angle_t *)addr = Scale(val, ANGLE_90, 90); } +void PAngle::SetValue(void *addr, double val) +{ + assert(((intptr_t)addr & (Align - 1)) == 0 && "unaligned address"); + *(angle_t *)addr = (angle_t)(val * ANGLE_90 / 90); +} + //========================================================================== // // PAngle :: GetValueInt diff --git a/src/dobjtype.h b/src/dobjtype.h index 05097795b..a5e2ab2a2 100644 --- a/src/dobjtype.h +++ b/src/dobjtype.h @@ -188,6 +188,7 @@ public: // Sets the value of a variable of this type at (addr) virtual void SetValue(void *addr, int val); + virtual void SetValue(void *addr, double val); // Gets the value of a variable of this type at (addr) virtual int GetValueInt(void *addr) const; @@ -320,6 +321,7 @@ public: PInt(unsigned int size, bool unsign); virtual void SetValue(void *addr, int val); + virtual void SetValue(void *addr, double val); virtual int GetValueInt(void *addr) const; virtual int GetStoreOp() const; virtual int GetLoadOp() const; @@ -344,6 +346,7 @@ public: PFloat(unsigned int size); virtual void SetValue(void *addr, int val); + virtual void SetValue(void *addr, double val); virtual int GetValueInt(void *addr) const; virtual int GetStoreOp() const; virtual int GetLoadOp() const; @@ -410,6 +413,7 @@ public: PFixed(); virtual void SetValue(void *addr, int val); + virtual void SetValue(void *addr, double val); virtual int GetValueInt(void *addr) const; virtual int GetStoreOp() const; virtual int GetLoadOp() const; @@ -422,6 +426,7 @@ public: PAngle(); virtual void SetValue(void *addr, int val); + virtual void SetValue(void *addr, double val); virtual int GetValueInt(void *addr) const; virtual int GetStoreOp() const; virtual int GetLoadOp() const;