mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-12-16 07:32:20 +00:00
Add void and error types; rejigger pointer types
- Added TypeVoid for statements, which produce no type. - Added TypeError for expressions whose arguments are incompatible. - Pointers now derive from PBasicType instead of PInt. Since they have their own register sets in the VM, this seems to make more sense than treating them as integers.
This commit is contained in:
parent
743b05189e
commit
0fb9f98a96
2 changed files with 38 additions and 16 deletions
|
@ -61,6 +61,8 @@ FTypeTable TypeTable;
|
||||||
TArray<PClass *> PClass::AllClasses;
|
TArray<PClass *> PClass::AllClasses;
|
||||||
bool PClass::bShutdown;
|
bool PClass::bShutdown;
|
||||||
|
|
||||||
|
PErrorType *TypeError;
|
||||||
|
PVoidType *TypeVoid;
|
||||||
PInt *TypeSInt8, *TypeUInt8;
|
PInt *TypeSInt8, *TypeUInt8;
|
||||||
PInt *TypeSInt16, *TypeUInt16;
|
PInt *TypeSInt16, *TypeUInt16;
|
||||||
PInt *TypeSInt32, *TypeUInt32;
|
PInt *TypeSInt32, *TypeUInt32;
|
||||||
|
@ -73,7 +75,6 @@ PStatePointer *TypeState;
|
||||||
PFixed *TypeFixed;
|
PFixed *TypeFixed;
|
||||||
PAngle *TypeAngle;
|
PAngle *TypeAngle;
|
||||||
|
|
||||||
|
|
||||||
// PRIVATE DATA DEFINITIONS ------------------------------------------------
|
// PRIVATE DATA DEFINITIONS ------------------------------------------------
|
||||||
|
|
||||||
// A harmless non-NULL FlatPointer for classes without pointers.
|
// A harmless non-NULL FlatPointer for classes without pointers.
|
||||||
|
@ -81,6 +82,9 @@ static const size_t TheEnd = ~(size_t)0;
|
||||||
|
|
||||||
// CODE --------------------------------------------------------------------
|
// CODE --------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMPLEMENT_CLASS(PErrorType)
|
||||||
|
IMPLEMENT_CLASS(PVoidType)
|
||||||
|
|
||||||
void DumpTypeTable()
|
void DumpTypeTable()
|
||||||
{
|
{
|
||||||
int used = 0;
|
int used = 0;
|
||||||
|
@ -300,6 +304,8 @@ void PType::GetTypeIDs(intptr_t &id1, intptr_t &id2) const
|
||||||
|
|
||||||
void PType::StaticInit()
|
void PType::StaticInit()
|
||||||
{
|
{
|
||||||
|
RUNTIME_CLASS(PErrorType)->TypeTableType = RUNTIME_CLASS(PErrorType);
|
||||||
|
RUNTIME_CLASS(PVoidType)->TypeTableType = RUNTIME_CLASS(PVoidType);
|
||||||
RUNTIME_CLASS(PInt)->TypeTableType = RUNTIME_CLASS(PInt);
|
RUNTIME_CLASS(PInt)->TypeTableType = RUNTIME_CLASS(PInt);
|
||||||
RUNTIME_CLASS(PFloat)->TypeTableType = RUNTIME_CLASS(PFloat);
|
RUNTIME_CLASS(PFloat)->TypeTableType = RUNTIME_CLASS(PFloat);
|
||||||
RUNTIME_CLASS(PString)->TypeTableType = RUNTIME_CLASS(PString);
|
RUNTIME_CLASS(PString)->TypeTableType = RUNTIME_CLASS(PString);
|
||||||
|
@ -320,6 +326,8 @@ void PType::StaticInit()
|
||||||
RUNTIME_CLASS(PFixed)->TypeTableType = RUNTIME_CLASS(PFixed);
|
RUNTIME_CLASS(PFixed)->TypeTableType = RUNTIME_CLASS(PFixed);
|
||||||
RUNTIME_CLASS(PAngle)->TypeTableType = RUNTIME_CLASS(PAngle);
|
RUNTIME_CLASS(PAngle)->TypeTableType = RUNTIME_CLASS(PAngle);
|
||||||
|
|
||||||
|
TypeTable.AddType(TypeError = new PErrorType);
|
||||||
|
TypeTable.AddType(TypeVoid = new PVoidType);
|
||||||
TypeTable.AddType(TypeSInt8 = new PInt(1, false));
|
TypeTable.AddType(TypeSInt8 = new PInt(1, false));
|
||||||
TypeTable.AddType(TypeUInt8 = new PInt(1, true));
|
TypeTable.AddType(TypeUInt8 = new PInt(1, true));
|
||||||
TypeTable.AddType(TypeSInt16 = new PInt(2, false));
|
TypeTable.AddType(TypeSInt16 = new PInt(2, false));
|
||||||
|
@ -877,9 +885,8 @@ IMPLEMENT_CLASS(PStatePointer)
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
PStatePointer::PStatePointer()
|
PStatePointer::PStatePointer()
|
||||||
: PInt(sizeof(FState *), true)
|
: PBasicType(sizeof(FState *), __alignof(FState *))
|
||||||
{
|
{
|
||||||
Align = __alignof(FState *);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -896,9 +903,8 @@ END_POINTERS
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
PPointer::PPointer()
|
PPointer::PPointer()
|
||||||
: PInt(sizeof(void *), true), PointedType(NULL)
|
: PBasicType(sizeof(void *), __alignof(void *)), PointedType(NULL)
|
||||||
{
|
{
|
||||||
Align = __alignof(void *);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -908,9 +914,8 @@ PPointer::PPointer()
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
PPointer::PPointer(PType *pointsat)
|
PPointer::PPointer(PType *pointsat)
|
||||||
: PInt(sizeof(void *), true), PointedType(pointsat)
|
: PBasicType(sizeof(void *), __alignof(void *)), PointedType(pointsat)
|
||||||
{
|
{
|
||||||
Align = __alignof(void *);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -165,6 +165,22 @@ public:
|
||||||
static void StaticInit();
|
static void StaticInit();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Not-really-a-type types --------------------------------------------------
|
||||||
|
|
||||||
|
class PErrorType : public PType
|
||||||
|
{
|
||||||
|
DECLARE_CLASS(PErrorType, PType);
|
||||||
|
public:
|
||||||
|
PErrorType() : PType(0, 1) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
class PVoidType : public PType
|
||||||
|
{
|
||||||
|
DECLARE_CLASS(PVoidType, PType);
|
||||||
|
public:
|
||||||
|
PVoidType() : PType(0, 1) {}
|
||||||
|
};
|
||||||
|
|
||||||
// Some categorization typing -----------------------------------------------
|
// Some categorization typing -----------------------------------------------
|
||||||
|
|
||||||
class PBasicType : public PType
|
class PBasicType : public PType
|
||||||
|
@ -290,16 +306,16 @@ public:
|
||||||
|
|
||||||
// Pointers -----------------------------------------------------------------
|
// Pointers -----------------------------------------------------------------
|
||||||
|
|
||||||
class PStatePointer : public PInt
|
class PStatePointer : public PBasicType
|
||||||
{
|
{
|
||||||
DECLARE_CLASS(PStatePointer, PInt);
|
DECLARE_CLASS(PStatePointer, PBasicType);
|
||||||
public:
|
public:
|
||||||
PStatePointer();
|
PStatePointer();
|
||||||
};
|
};
|
||||||
|
|
||||||
class PPointer : public PInt
|
class PPointer : public PBasicType
|
||||||
{
|
{
|
||||||
DECLARE_CLASS(PPointer, PInt);
|
DECLARE_CLASS(PPointer, PBasicType);
|
||||||
HAS_OBJECT_POINTERS;
|
HAS_OBJECT_POINTERS;
|
||||||
public:
|
public:
|
||||||
PPointer(PType *pointsat);
|
PPointer(PType *pointsat);
|
||||||
|
@ -316,17 +332,14 @@ protected:
|
||||||
PPointer();
|
PPointer();
|
||||||
};
|
};
|
||||||
|
|
||||||
class PClass;
|
|
||||||
class PClassPointer : public PPointer
|
class PClassPointer : public PPointer
|
||||||
{
|
{
|
||||||
DECLARE_CLASS(PClassPointer, PPointer);
|
DECLARE_CLASS(PClassPointer, PPointer);
|
||||||
HAS_OBJECT_POINTERS;
|
HAS_OBJECT_POINTERS;
|
||||||
public:
|
public:
|
||||||
PClassPointer(PClass *restrict);
|
PClassPointer(class PClass *restrict);
|
||||||
|
|
||||||
PClass *ClassRestriction;
|
class PClass *ClassRestriction;
|
||||||
|
|
||||||
typedef PClass *Type2;
|
|
||||||
|
|
||||||
virtual bool IsMatch(intptr_t id1, intptr_t id2) const;
|
virtual bool IsMatch(intptr_t id1, intptr_t id2) const;
|
||||||
virtual void GetTypeIDs(intptr_t &id1, intptr_t &id2) const;
|
virtual void GetTypeIDs(intptr_t &id1, intptr_t &id2) const;
|
||||||
|
@ -625,6 +638,8 @@ PPrototype *NewPrototype(const TArray<PType *> &rettypes, const TArray<PType *>
|
||||||
|
|
||||||
// Built-in types -----------------------------------------------------------
|
// Built-in types -----------------------------------------------------------
|
||||||
|
|
||||||
|
extern PErrorType *TypeError;
|
||||||
|
extern PVoidType *TypeVoid;
|
||||||
extern PInt *TypeSInt8, *TypeUInt8;
|
extern PInt *TypeSInt8, *TypeUInt8;
|
||||||
extern PInt *TypeSInt16, *TypeUInt16;
|
extern PInt *TypeSInt16, *TypeUInt16;
|
||||||
extern PInt *TypeSInt32, *TypeUInt32;
|
extern PInt *TypeSInt32, *TypeUInt32;
|
||||||
|
@ -662,6 +677,8 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
PSymbolConstNumeric(FName name, PType *type=NULL) : PSymbolConst(name, type) {}
|
PSymbolConstNumeric(FName name, PType *type=NULL) : PSymbolConst(name, type) {}
|
||||||
|
PSymbolConstNumeric(FName name, PType *type, int val) : PSymbolConst(name, type), Value(val) {}
|
||||||
|
PSymbolConstNumeric(FName name, PType *type, double val) : PSymbolConst(name, type), Float(val) {}
|
||||||
PSymbolConstNumeric() {}
|
PSymbolConstNumeric() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue