mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-29 07:12:36 +00:00
Add mDefFileNo to Fields
This commit is contained in:
parent
5ba1e96d29
commit
da06212134
5 changed files with 16 additions and 12 deletions
|
@ -591,13 +591,13 @@ PClass *PClass::CreateDerivedClass(FName name, unsigned int size, bool *newlycre
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
PField *PClass::AddField(FName name, PType *type, uint32_t flags)
|
PField *PClass::AddField(FName name, PType *type, uint32_t flags, int fileno)
|
||||||
{
|
{
|
||||||
PField *field;
|
PField *field;
|
||||||
if (!(flags & VARF_Meta))
|
if (!(flags & VARF_Meta))
|
||||||
{
|
{
|
||||||
unsigned oldsize = Size;
|
unsigned oldsize = Size;
|
||||||
field = VMType->Symbols.AddField(name, type, flags, Size);
|
field = VMType->Symbols.AddField(name, type, flags, Size, nullptr, fileno);
|
||||||
|
|
||||||
// Only initialize the defaults if they have already been created.
|
// Only initialize the defaults if they have already been created.
|
||||||
// For ZScript this is not the case, it will first define all fields before
|
// For ZScript this is not the case, it will first define all fields before
|
||||||
|
@ -612,7 +612,7 @@ PField *PClass::AddField(FName name, PType *type, uint32_t flags)
|
||||||
{
|
{
|
||||||
// Same as above, but a different data storage.
|
// Same as above, but a different data storage.
|
||||||
unsigned oldsize = MetaSize;
|
unsigned oldsize = MetaSize;
|
||||||
field = VMType->Symbols.AddField(name, type, flags, MetaSize);
|
field = VMType->Symbols.AddField(name, type, flags, MetaSize, nullptr, fileno);
|
||||||
|
|
||||||
if (field != nullptr && !(flags & VARF_Native) && Meta != nullptr)
|
if (field != nullptr && !(flags & VARF_Native) && Meta != nullptr)
|
||||||
{
|
{
|
||||||
|
|
|
@ -45,7 +45,7 @@ public:
|
||||||
bool ReadAllFields(FSerializer &ar, void *addr) const;
|
bool ReadAllFields(FSerializer &ar, void *addr) const;
|
||||||
int FindVirtualIndex(FName name, PFunction::Variant *variant, PFunction *parentfunc, bool exactReturnType);
|
int FindVirtualIndex(FName name, PFunction::Variant *variant, PFunction *parentfunc, bool exactReturnType);
|
||||||
PSymbol *FindSymbol(FName symname, bool searchparents) const;
|
PSymbol *FindSymbol(FName symname, bool searchparents) const;
|
||||||
PField *AddField(FName name, PType *type, uint32_t flags);
|
PField *AddField(FName name, PType *type, uint32_t flags, int fileno = 0);
|
||||||
void InitializeDefaults();
|
void InitializeDefaults();
|
||||||
|
|
||||||
static void StaticInit();
|
static void StaticInit();
|
||||||
|
|
|
@ -137,7 +137,6 @@ PField::PField()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PField::PField(FName name, PType *type, uint32_t flags, size_t offset, int bitvalue)
|
PField::PField(FName name, PType *type, uint32_t flags, size_t offset, int bitvalue)
|
||||||
: PSymbol(name), Offset(offset), Type(type), Flags(flags)
|
: PSymbol(name), Offset(offset), Type(type), Flags(flags)
|
||||||
{
|
{
|
||||||
|
@ -331,10 +330,12 @@ PSymbol *PSymbolTable::AddSymbol (PSymbol *sym)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
PField *PSymbolTable::AddField(FName name, PType *type, uint32_t flags, unsigned &Size, unsigned *Align)
|
PField *PSymbolTable::AddField(FName name, PType *type, uint32_t flags, unsigned &Size, unsigned *Align, int fileno)
|
||||||
{
|
{
|
||||||
PField *field = Create<PField>(name, type, flags);
|
PField *field = Create<PField>(name, type, flags);
|
||||||
|
|
||||||
|
field->mDefFileNo = fileno;
|
||||||
|
|
||||||
// The new field is added to the end of this struct, alignment permitting.
|
// The new field is added to the end of this struct, alignment permitting.
|
||||||
field->Offset = (Size + (type->Align - 1)) & ~(type->Align - 1);
|
field->Offset = (Size + (type->Align - 1)) & ~(type->Align - 1);
|
||||||
|
|
||||||
|
@ -365,10 +366,12 @@ PField *PSymbolTable::AddField(FName name, PType *type, uint32_t flags, unsigned
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
PField *PSymbolTable::AddNativeField(FName name, PType *type, size_t address, uint32_t flags, int bitvalue)
|
PField *PSymbolTable::AddNativeField(FName name, PType *type, size_t address, uint32_t flags, int bitvalue, int fileno)
|
||||||
{
|
{
|
||||||
PField *field = Create<PField>(name, type, flags | VARF_Native | VARF_Transient, address, bitvalue);
|
PField *field = Create<PField>(name, type, flags | VARF_Native | VARF_Transient, address, bitvalue);
|
||||||
|
|
||||||
|
field->mDefFileNo = fileno;
|
||||||
|
|
||||||
if (AddSymbol(field) == nullptr)
|
if (AddSymbol(field) == nullptr)
|
||||||
{ // name is already in use
|
{ // name is already in use
|
||||||
field->Destroy();
|
field->Destroy();
|
||||||
|
|
|
@ -78,6 +78,7 @@ public:
|
||||||
uint32_t Flags;
|
uint32_t Flags;
|
||||||
int BitValue;
|
int BitValue;
|
||||||
FString DeprecationMessage;
|
FString DeprecationMessage;
|
||||||
|
int mDefFileNo = 0;
|
||||||
protected:
|
protected:
|
||||||
PField();
|
PField();
|
||||||
};
|
};
|
||||||
|
@ -212,8 +213,8 @@ struct PSymbolTable
|
||||||
// a symbol with the same name is already in the table. This symbol is
|
// a symbol with the same name is already in the table. This symbol is
|
||||||
// not copied and will be freed when the symbol table is destroyed.
|
// not copied and will be freed when the symbol table is destroyed.
|
||||||
PSymbol *AddSymbol (PSymbol *sym);
|
PSymbol *AddSymbol (PSymbol *sym);
|
||||||
PField *AddField(FName name, PType *type, uint32_t flags, unsigned &Size, unsigned *Align = nullptr);
|
PField *AddField(FName name, PType *type, uint32_t flags, unsigned &Size, unsigned *Align = nullptr, int fileno = 0);
|
||||||
PField *AddNativeField(FName name, PType *type, size_t address, uint32_t flags, int bitvalue);
|
PField *AddNativeField(FName name, PType *type, size_t address, uint32_t flags, int bitvalue, int fileno = 0);
|
||||||
bool ReadFields(FSerializer &ar, void *addr, const char *TypeName) const;
|
bool ReadFields(FSerializer &ar, void *addr, const char *TypeName) const;
|
||||||
void WriteFields(FSerializer &ar, const void *addr, const void *def = nullptr) const;
|
void WriteFields(FSerializer &ar, const void *addr, const void *def = nullptr) const;
|
||||||
|
|
||||||
|
|
|
@ -3156,7 +3156,7 @@ PField *PStruct::AddField(FName name, PType *type, uint32_t flags)
|
||||||
|
|
||||||
PField *PStruct::AddNativeField(FName name, PType *type, size_t address, uint32_t flags, int bitvalue)
|
PField *PStruct::AddNativeField(FName name, PType *type, size_t address, uint32_t flags, int bitvalue)
|
||||||
{
|
{
|
||||||
return Symbols.AddNativeField(name, type, address, flags, bitvalue);
|
return Symbols.AddNativeField(name, type, address, flags, bitvalue, mDefFileNo);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -3297,7 +3297,7 @@ PClassType::PClassType(PClass *cls, int fileno)
|
||||||
|
|
||||||
PField *PClassType::AddField(FName name, PType *type, uint32_t flags)
|
PField *PClassType::AddField(FName name, PType *type, uint32_t flags)
|
||||||
{
|
{
|
||||||
return Descriptor->AddField(name, type, flags);
|
return Descriptor->AddField(name, type, flags, mDefFileNo);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -3308,7 +3308,7 @@ PField *PClassType::AddField(FName name, PType *type, uint32_t flags)
|
||||||
|
|
||||||
PField *PClassType::AddNativeField(FName name, PType *type, size_t address, uint32_t flags, int bitvalue)
|
PField *PClassType::AddNativeField(FName name, PType *type, size_t address, uint32_t flags, int bitvalue)
|
||||||
{
|
{
|
||||||
auto field = Symbols.AddNativeField(name, type, address, flags, bitvalue);
|
auto field = Symbols.AddNativeField(name, type, address, flags, bitvalue, mDefFileNo);
|
||||||
if (field != nullptr) Descriptor->Fields.Push(field);
|
if (field != nullptr) Descriptor->Fields.Push(field);
|
||||||
return field;
|
return field;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue