From 1bb6a2c0e5b52a3ea67075ad4ffec96b98a90b9a Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Wed, 13 May 2020 15:07:26 -0700 Subject: [PATCH] Fixed ability to add data members to string --- IDEHelper/Compiler/BfModule.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index 8797e426..f05aaacd 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -1495,6 +1495,16 @@ BfIRValue BfModule::CreateStringObjectValue(const StringImpl& str, int stringId, } typeValueParams.push_back(stringCharsVal); // mPtr + for (int fieldIdx = 0; fieldIdx < (int)stringTypeInst->mFieldInstances.size(); fieldIdx++) + { + auto fieldInstance = &stringTypeInst->mFieldInstances[fieldIdx]; + if (fieldInstance->mDataIdx < 4) + continue; + while (fieldInstance->mDataIdx >= typeValueParams.size()) + typeValueParams.Add(BfIRValue()); + typeValueParams[fieldInstance->mDataIdx] = GetDefaultValue(fieldInstance->mResolvedType); + } + stringValData = mBfIRBuilder->CreateConstStruct(mBfIRBuilder->MapTypeInst(stringTypeInst, BfIRPopulateType_Full), typeValueParams); }