mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-12-12 13:12:14 +00:00
Added PStruct::AddField()
This commit is contained in:
parent
476a98652c
commit
6c1f3a1396
2 changed files with 32 additions and 0 deletions
|
@ -920,6 +920,34 @@ PStruct::PStruct(FName name, DObject *outer)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// PStruct :: AddField
|
||||||
|
//
|
||||||
|
// Appends a new field to the end of a struct.
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
PField *PStruct::AddField(FName name, PType *type)
|
||||||
|
{
|
||||||
|
PField *field = new PField(name, type);
|
||||||
|
|
||||||
|
// The new field is added to the end of this struct, alignment permitting.
|
||||||
|
field->FieldOffset = (Size + (type->Align - 1)) & ~(type->Align - 1);
|
||||||
|
|
||||||
|
// Enlarge this struct to enclose the new field.
|
||||||
|
Size = field->FieldOffset + type->Size;
|
||||||
|
|
||||||
|
// This struct's alignment is the same as the largest alignment of any of
|
||||||
|
// its fields.
|
||||||
|
Align = MAX(Align, type->Align);
|
||||||
|
|
||||||
|
Fields.Push(field);
|
||||||
|
Symbols.AddSymbol(field);
|
||||||
|
|
||||||
|
return field;
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// PStruct :: PropagateMark
|
// PStruct :: PropagateMark
|
||||||
|
|
|
@ -325,6 +325,8 @@ class PField : public PSymbol
|
||||||
DECLARE_CLASS(PField, PSymbol);
|
DECLARE_CLASS(PField, PSymbol);
|
||||||
HAS_OBJECT_POINTERS
|
HAS_OBJECT_POINTERS
|
||||||
public:
|
public:
|
||||||
|
PField(FName name, PType *type) : PSymbol(name), FieldOffset(0), FieldType(type) {}
|
||||||
|
|
||||||
unsigned int FieldOffset;
|
unsigned int FieldOffset;
|
||||||
PType *FieldType;
|
PType *FieldType;
|
||||||
};
|
};
|
||||||
|
@ -411,6 +413,8 @@ public:
|
||||||
TArray<PField *> Fields;
|
TArray<PField *> Fields;
|
||||||
PSymbolTable Symbols;
|
PSymbolTable Symbols;
|
||||||
|
|
||||||
|
PField *AddField(FName name, PType *type);
|
||||||
|
|
||||||
size_t PropagateMark();
|
size_t PropagateMark();
|
||||||
protected:
|
protected:
|
||||||
PStruct();
|
PStruct();
|
||||||
|
|
Loading…
Reference in a new issue