mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-16 09:11:17 +00:00
Add GetValueFloat() for numeric PTypes
This commit is contained in:
parent
feb5ab31cc
commit
299019ea15
2 changed files with 59 additions and 2 deletions
|
@ -412,6 +412,12 @@ int PType::GetValueInt(void *addr) const
|
|||
return 0;
|
||||
}
|
||||
|
||||
double PType::GetValueFloat(void *addr) const
|
||||
{
|
||||
assert(0 && "Cannot get value for this type");
|
||||
return 0;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// PType :: GetStoreOp
|
||||
|
@ -724,6 +730,17 @@ int PInt::GetValueInt(void *addr) const
|
|||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// PInt :: GetValueFloat
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
double PInt::GetValueFloat(void *addr) const
|
||||
{
|
||||
return GetValueInt(addr);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// PInt :: GetStoreOp
|
||||
|
@ -962,16 +979,27 @@ void PFloat::SetValue(void *addr, double val)
|
|||
//==========================================================================
|
||||
|
||||
int PFloat::GetValueInt(void *addr) const
|
||||
{
|
||||
return xs_ToInt(GetValueFloat(addr));
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// PFloat :: GetValueFloat
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
double PFloat::GetValueFloat(void *addr) const
|
||||
{
|
||||
assert(((intptr_t)addr & (Align - 1)) == 0 && "unaligned address");
|
||||
if (Size == 4)
|
||||
{
|
||||
return xs_ToInt(*(float *)addr);
|
||||
return *(float *)addr;
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(Size == 8);
|
||||
return xs_ToInt(*(double *)addr);
|
||||
return *(double *)addr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1145,6 +1173,18 @@ int PFixed::GetValueInt(void *addr) const
|
|||
return *(fixed_t *)addr >> FRACBITS;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// PFixed :: GetValueFloat
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
double PFixed::GetValueFloat(void *addr) const
|
||||
{
|
||||
assert(((intptr_t)addr & (Align - 1)) == 0 && "unaligned address");
|
||||
return FIXED2DBL(*(fixed_t *)addr);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// PFixed :: GetStoreOp
|
||||
|
@ -1212,6 +1252,18 @@ int PAngle::GetValueInt(void *addr) const
|
|||
return *(angle_t *)addr / ANGLE_1;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// PAngle :: GetValueFloat
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
double PAngle::GetValueFloat(void *addr) const
|
||||
{
|
||||
assert(((intptr_t)addr & (Align - 1)) == 0 && "unaligned address");
|
||||
return (double)(*(angle_t *)addr) / ANGLE_1;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// PAngle :: GetStoreOp
|
||||
|
|
|
@ -192,6 +192,7 @@ public:
|
|||
|
||||
// Gets the value of a variable of this type at (addr)
|
||||
virtual int GetValueInt(void *addr) const;
|
||||
virtual double GetValueFloat(void *addr) const;
|
||||
|
||||
// Gets the opcode to store from a register to memory
|
||||
virtual int GetStoreOp() const;
|
||||
|
@ -323,6 +324,7 @@ public:
|
|||
virtual void SetValue(void *addr, int val);
|
||||
virtual void SetValue(void *addr, double val);
|
||||
virtual int GetValueInt(void *addr) const;
|
||||
virtual double GetValueFloat(void *addr) const;
|
||||
virtual int GetStoreOp() const;
|
||||
virtual int GetLoadOp() const;
|
||||
virtual int GetRegType() const;
|
||||
|
@ -348,6 +350,7 @@ public:
|
|||
virtual void SetValue(void *addr, int val);
|
||||
virtual void SetValue(void *addr, double val);
|
||||
virtual int GetValueInt(void *addr) const;
|
||||
virtual double GetValueFloat(void *addr) const;
|
||||
virtual int GetStoreOp() const;
|
||||
virtual int GetLoadOp() const;
|
||||
virtual int GetRegType() const;
|
||||
|
@ -415,6 +418,7 @@ public:
|
|||
virtual void SetValue(void *addr, int val);
|
||||
virtual void SetValue(void *addr, double val);
|
||||
virtual int GetValueInt(void *addr) const;
|
||||
virtual double GetValueFloat(void *addr) const;
|
||||
virtual int GetStoreOp() const;
|
||||
virtual int GetLoadOp() const;
|
||||
};
|
||||
|
@ -428,6 +432,7 @@ public:
|
|||
virtual void SetValue(void *addr, int val);
|
||||
virtual void SetValue(void *addr, double val);
|
||||
virtual int GetValueInt(void *addr) const;
|
||||
virtual double GetValueFloat(void *addr) const;
|
||||
virtual int GetStoreOp() const;
|
||||
virtual int GetLoadOp() const;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue