mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-26 05:51:20 +00:00
- do not declare PNamedType::Outer as DObject.
Ultimately we may have to get a fully qualified name out of this, so Outer should be a type that can handle this feature. The new class for this is currently used as base for PType and PSymbol so that PNamedType inherits from it and maybe later a namespace symbol can, too.
This commit is contained in:
parent
ee66d22034
commit
06ca41f8b5
2 changed files with 46 additions and 14 deletions
|
@ -670,6 +670,20 @@ void PNamedType::GetTypeIDs(intptr_t &id1, intptr_t &id2) const
|
||||||
id2 = TypeName;
|
id2 = TypeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// PNamedType :: QualifiedName
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
FString PNamedType::QualifiedName() const
|
||||||
|
{
|
||||||
|
FString out;
|
||||||
|
if (Outer != nullptr) out = Outer->QualifiedName();
|
||||||
|
out << "::" << TypeName;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
/* PInt *******************************************************************/
|
/* PInt *******************************************************************/
|
||||||
|
|
||||||
IMPLEMENT_CLASS(PInt)
|
IMPLEMENT_CLASS(PInt)
|
||||||
|
@ -1752,7 +1766,7 @@ PEnum::PEnum()
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
PEnum::PEnum(FName name, DObject *outer)
|
PEnum::PEnum(FName name, PTypeBase *outer)
|
||||||
: PNamedType(name, outer), ValueType(NULL)
|
: PNamedType(name, outer), ValueType(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -1766,7 +1780,7 @@ PEnum::PEnum(FName name, DObject *outer)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
PEnum *NewEnum(FName name, DObject *outer)
|
PEnum *NewEnum(FName name, PTypeBase *outer)
|
||||||
{
|
{
|
||||||
size_t bucket;
|
size_t bucket;
|
||||||
PType *etype = TypeTable.FindType(RUNTIME_CLASS(PEnum), (intptr_t)outer, (intptr_t)name, &bucket);
|
PType *etype = TypeTable.FindType(RUNTIME_CLASS(PEnum), (intptr_t)outer, (intptr_t)name, &bucket);
|
||||||
|
@ -2149,7 +2163,7 @@ PStruct::PStruct()
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
PStruct::PStruct(FName name, DObject *outer)
|
PStruct::PStruct(FName name, PTypeBase *outer)
|
||||||
: PNamedType(name, outer)
|
: PNamedType(name, outer)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -2310,7 +2324,7 @@ size_t PStruct::PropagateMark()
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
PStruct *NewStruct(FName name, DObject *outer)
|
PStruct *NewStruct(FName name, PTypeBase *outer)
|
||||||
{
|
{
|
||||||
size_t bucket;
|
size_t bucket;
|
||||||
PType *stype = TypeTable.FindType(RUNTIME_CLASS(PStruct), (intptr_t)outer, (intptr_t)name, &bucket);
|
PType *stype = TypeTable.FindType(RUNTIME_CLASS(PStruct), (intptr_t)outer, (intptr_t)name, &bucket);
|
||||||
|
@ -3360,6 +3374,7 @@ CCMD(typetable)
|
||||||
|
|
||||||
// Symbol tables ------------------------------------------------------------
|
// Symbol tables ------------------------------------------------------------
|
||||||
|
|
||||||
|
IMPLEMENT_ABSTRACT_CLASS(PTypeBase);
|
||||||
IMPLEMENT_ABSTRACT_CLASS(PSymbol);
|
IMPLEMENT_ABSTRACT_CLASS(PSymbol);
|
||||||
IMPLEMENT_CLASS(PSymbolConst);
|
IMPLEMENT_CLASS(PSymbolConst);
|
||||||
IMPLEMENT_CLASS(PSymbolConstNumeric);
|
IMPLEMENT_CLASS(PSymbolConstNumeric);
|
||||||
|
|
|
@ -22,12 +22,28 @@ typedef std::pair<const class PType *, unsigned> FTypeAndOffset;
|
||||||
|
|
||||||
// Symbol information -------------------------------------------------------
|
// Symbol information -------------------------------------------------------
|
||||||
|
|
||||||
class PSymbol : public DObject
|
class PTypeBase : public DObject
|
||||||
{
|
{
|
||||||
DECLARE_ABSTRACT_CLASS(PSymbol, DObject);
|
DECLARE_ABSTRACT_CLASS(PTypeBase, DObject)
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual FString QualifiedName() const
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class PSymbol : public PTypeBase
|
||||||
|
{
|
||||||
|
DECLARE_ABSTRACT_CLASS(PSymbol, PTypeBase);
|
||||||
public:
|
public:
|
||||||
virtual ~PSymbol();
|
virtual ~PSymbol();
|
||||||
|
|
||||||
|
virtual FString QualifiedName() const
|
||||||
|
{
|
||||||
|
return SymbolName.GetChars();
|
||||||
|
}
|
||||||
|
|
||||||
FName SymbolName;
|
FName SymbolName;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -153,13 +169,13 @@ extern PSymbolTable GlobalSymbols;
|
||||||
|
|
||||||
struct ZCC_ExprConstant;
|
struct ZCC_ExprConstant;
|
||||||
class PClassType;
|
class PClassType;
|
||||||
class PType : public DObject
|
class PType : public PTypeBase
|
||||||
{
|
{
|
||||||
//DECLARE_ABSTRACT_CLASS_WITH_META(PType, DObject, PClassType);
|
//DECLARE_ABSTRACT_CLASS_WITH_META(PType, DObject, PClassType);
|
||||||
// We need to unravel the _WITH_META macro, since PClassType isn't defined yet,
|
// We need to unravel the _WITH_META macro, since PClassType isn't defined yet,
|
||||||
// and we can't define it until we've defined PClass. But we can't define that
|
// and we can't define it until we've defined PClass. But we can't define that
|
||||||
// without defining PType.
|
// without defining PType.
|
||||||
DECLARE_ABSTRACT_CLASS(PType, DObject)
|
DECLARE_ABSTRACT_CLASS(PType, PTypeBase)
|
||||||
HAS_OBJECT_POINTERS;
|
HAS_OBJECT_POINTERS;
|
||||||
protected:
|
protected:
|
||||||
enum { MetaClassNum = CLASSREG_PClassType };
|
enum { MetaClassNum = CLASSREG_PClassType };
|
||||||
|
@ -332,14 +348,15 @@ class PNamedType : public PCompoundType
|
||||||
DECLARE_ABSTRACT_CLASS(PNamedType, PCompoundType);
|
DECLARE_ABSTRACT_CLASS(PNamedType, PCompoundType);
|
||||||
HAS_OBJECT_POINTERS;
|
HAS_OBJECT_POINTERS;
|
||||||
public:
|
public:
|
||||||
DObject *Outer; // object this type is contained within
|
PTypeBase *Outer; // object this type is contained within
|
||||||
FName TypeName; // this type's name
|
FName TypeName; // this type's name
|
||||||
|
|
||||||
PNamedType() : Outer(NULL) {}
|
PNamedType() : Outer(NULL) {}
|
||||||
PNamedType(FName name, DObject *outer) : Outer(outer), TypeName(name) {}
|
PNamedType(FName name, PTypeBase *outer) : Outer(outer), TypeName(name) {}
|
||||||
|
|
||||||
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;
|
||||||
|
virtual FString QualifiedName() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Basic types --------------------------------------------------------------
|
// Basic types --------------------------------------------------------------
|
||||||
|
@ -533,7 +550,7 @@ class PEnum : public PNamedType
|
||||||
DECLARE_CLASS(PEnum, PNamedType);
|
DECLARE_CLASS(PEnum, PNamedType);
|
||||||
HAS_OBJECT_POINTERS;
|
HAS_OBJECT_POINTERS;
|
||||||
public:
|
public:
|
||||||
PEnum(FName name, DObject *outer);
|
PEnum(FName name, PTypeBase *outer);
|
||||||
|
|
||||||
PType *ValueType;
|
PType *ValueType;
|
||||||
TMap<FName, int> Values;
|
TMap<FName, int> Values;
|
||||||
|
@ -610,7 +627,7 @@ class PStruct : public PNamedType
|
||||||
{
|
{
|
||||||
DECLARE_CLASS(PStruct, PNamedType);
|
DECLARE_CLASS(PStruct, PNamedType);
|
||||||
public:
|
public:
|
||||||
PStruct(FName name, DObject *outer);
|
PStruct(FName name, PTypeBase *outer);
|
||||||
|
|
||||||
TArray<PField *> Fields;
|
TArray<PField *> Fields;
|
||||||
|
|
||||||
|
@ -822,8 +839,8 @@ PDynArray *NewDynArray(PType *type);
|
||||||
PPointer *NewPointer(PType *type);
|
PPointer *NewPointer(PType *type);
|
||||||
PClassPointer *NewClassPointer(PClass *restrict);
|
PClassPointer *NewClassPointer(PClass *restrict);
|
||||||
PClassWaitingForParent *NewUnknownClass(FName myname, FName parentname);
|
PClassWaitingForParent *NewUnknownClass(FName myname, FName parentname);
|
||||||
PEnum *NewEnum(FName name, DObject *outer);
|
PEnum *NewEnum(FName name, PTypeBase *outer);
|
||||||
PStruct *NewStruct(FName name, DObject *outer);
|
PStruct *NewStruct(FName name, PTypeBase *outer);
|
||||||
PPrototype *NewPrototype(const TArray<PType *> &rettypes, const TArray<PType *> &argtypes);
|
PPrototype *NewPrototype(const TArray<PType *> &rettypes, const TArray<PType *> &argtypes);
|
||||||
|
|
||||||
// Built-in types -----------------------------------------------------------
|
// Built-in types -----------------------------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue