Files
Pyarmor-Static-Unpack-1shot/pyc_numeric.h

123 lines
2.6 KiB
C
Raw Normal View History

2009-07-24 08:35:21 +00:00
#ifndef _PYC_NUMERIC_H
#define _PYC_NUMERIC_H
2011-10-23 17:48:10 -07:00
#include "pyc_object.h"
2009-07-24 08:35:21 +00:00
#include <list>
2011-09-23 21:46:05 -07:00
#include <string>
2009-07-24 08:35:21 +00:00
class PycInt : public PycObject {
public:
PycInt(int value = 0, int type = TYPE_INT)
: PycObject(type), m_value(value) { }
2009-07-24 21:15:51 +00:00
bool isEqual(PycRef<PycObject> obj) const
{
return (type() == obj->type()) &&
(m_value == obj.cast<PycInt>()->m_value);
}
2009-07-24 21:15:51 +00:00
2009-07-24 08:35:21 +00:00
void load(class PycData* stream, class PycModule* mod);
int value() const { return m_value; }
private:
int m_value;
};
class PycLong : public PycObject {
public:
PycLong(int type = TYPE_LONG)
: PycObject(type), m_size(0) { }
2009-07-24 21:15:51 +00:00
bool isEqual(PycRef<PycObject> obj) const;
2009-07-24 08:35:21 +00:00
void load(class PycData* stream, class PycModule* mod);
int size() const { return m_size; }
const std::list<int>& value() const { return m_value; }
2009-07-24 08:35:21 +00:00
2011-09-23 21:46:05 -07:00
std::string repr() const;
2009-07-24 08:35:21 +00:00
private:
int m_size;
std::list<int> m_value;
};
class PycFloat : public PycObject {
public:
PycFloat(int type = TYPE_FLOAT)
: PycObject(type), m_value(0) { }
~PycFloat() { if (m_value) delete[] m_value; }
2009-07-24 21:15:51 +00:00
bool isEqual(PycRef<PycObject> obj) const;
2009-07-24 08:35:21 +00:00
void load(class PycData* stream, class PycModule* mod);
const char* value() const { return m_value; }
private:
char* m_value; // Floats are stored as strings
};
class PycComplex : public PycFloat {
public:
PycComplex(int type = TYPE_COMPLEX)
: PycFloat(type), m_imag(0) { }
~PycComplex() { if (m_imag) delete[] m_imag; }
bool isEqual(PycRef<PycObject> obj) const;
void load(class PycData* stream, class PycModule* mod);
const char* imag() const { return m_imag; }
private:
char* m_imag;
};
class PycCFloat : public PycObject {
public:
PycCFloat(int type = TYPE_BINARY_FLOAT)
2014-06-05 12:12:46 +11:00
: PycObject(type), m_value.d(0.0) { }
bool isEqual(PycRef<PycObject> obj) const
{
return (type() == obj->type()) &&
2014-06-05 12:12:46 +11:00
(m_value.d == obj.cast<PycCFloat>()->m_value.d);
}
void load(class PycData* stream, class PycModule* mod);
2014-06-05 12:12:46 +11:00
double value() const { return m_value.d; }
private:
2014-06-05 12:12:46 +11:00
union
{
Pyc_INT64 i64;
double d;
} m_value;
};
class PycCComplex : public PycCFloat {
public:
PycCComplex(int type = TYPE_BINARY_COMPLEX)
: PycCFloat(type), m_imag(0.0) { }
bool isEqual(PycRef<PycObject> obj) const
{
return (PycCFloat::isEqual(obj)) &&
(m_imag == obj.cast<PycCComplex>()->m_imag);
}
void load(class PycData* stream, class PycModule* mod);
double imag() const { return m_imag; }
private:
double m_imag;
};
2009-07-24 08:35:21 +00:00
#endif