From f2f365bfef4bc8ecfc1ee306a994af8766d03f60 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 28 Oct 2016 14:43:29 +0200 Subject: [PATCH] - fixed setup for PString which was missing the load/store/move instructions which caused me to overlook its register type. - properly set up the vector types. - fixed: a struct must start with a size of 0, not 1. This caused the layout of the vectors to be broken. --- src/dobjtype.cpp | 29 ++++++++++++++--------------- src/dobjtype.h | 8 +++++--- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index fd454896ed..7eb152ebdf 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -205,6 +205,7 @@ PType::PType(unsigned int size, unsigned int align) storeOp = OP_NOP; moveOp = OP_NOP; RegType = REGT_NIL; + RegCount = 1; } //========================================================================== @@ -570,7 +571,8 @@ void PType::StaticInit() TypeVector2->loadOp = OP_LV2; TypeVector2->storeOp = OP_SV2; TypeVector2->moveOp = OP_MOVEV2; - TypeVector2->RegType = REGT_FLOAT|REGT_MULTIREG; + TypeVector2->RegType = REGT_FLOAT; + TypeVector2->RegCount = 2; TypeVector3 = new PStruct(NAME_Vector3, nullptr); TypeVector3->AddField(NAME_X, TypeFloat64); @@ -579,10 +581,11 @@ void PType::StaticInit() // allow accessing xy as a vector2. This is marked native because it's not supposed to be serialized. TypeVector3->Symbols.AddSymbol(new PField(NAME_XY, TypeVector2, VARF_Native, 0)); TypeTable.AddType(TypeVector3); - TypeVector2->loadOp = OP_LV3; - TypeVector2->storeOp = OP_SV3; - TypeVector2->moveOp = OP_MOVEV3; - TypeVector2->RegType = REGT_FLOAT | REGT_MULTIREG; + TypeVector3->loadOp = OP_LV3; + TypeVector3->storeOp = OP_SV3; + TypeVector3->moveOp = OP_MOVEV3; + TypeVector3->RegType = REGT_FLOAT; + TypeVector3->RegCount = 3; @@ -1207,17 +1210,11 @@ PString::PString() : PBasicType(sizeof(FString), __alignof(FString)) { mDescriptiveName = "String"; -} + storeOp = OP_SS; + loadOp = OP_LS; + moveOp = OP_MOVES; + RegType = REGT_STRING; -//========================================================================== -// -// PString :: GetRegType -// -//========================================================================== - -int PString::GetRegType() const -{ - return REGT_STRING; } //========================================================================== @@ -2089,6 +2086,7 @@ IMPLEMENT_CLASS(PStruct) PStruct::PStruct() { mDescriptiveName = "Struct"; + Size = 0; } //========================================================================== @@ -2101,6 +2099,7 @@ PStruct::PStruct(FName name, PTypeBase *outer) : PNamedType(name, outer) { mDescriptiveName.Format("Struct<%s>", name.GetChars()); + Size = 0; } //========================================================================== diff --git a/src/dobjtype.h b/src/dobjtype.h index 984f5a379e..302352b21b 100644 --- a/src/dobjtype.h +++ b/src/dobjtype.h @@ -224,7 +224,7 @@ public: PSymbolTable Symbols; bool MemberOnly = false; // type may only be used as a struct/class member but not as a local variable or function argument. FString mDescriptiveName; - BYTE loadOp, storeOp, moveOp, RegType; + BYTE loadOp, storeOp, moveOp, RegType, RegCount; PType(unsigned int size = 1, unsigned int align = 1); virtual ~PType(); @@ -291,6 +291,10 @@ public: return RegType; } + int GetRegCount() const + { + return RegCount; + } // Returns true if this type matches the two identifiers. Referring to the // above table, any type is identified by at most two characteristics. Each // type that implements this function will cast these to the appropriate type. @@ -477,8 +481,6 @@ class PString : public PBasicType public: PString(); - virtual int GetRegType() const; - void WriteValue(FSerializer &ar, const char *key,const void *addr) const override; bool ReadValue(FSerializer &ar, const char *key,void *addr) const override; void SetDefaultValue(void *base, unsigned offset, TArray *special=NULL) const override;