From 6cce0ffc25bb1b41109fc776ae2baabb315482bb Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Thu, 31 Mar 2022 10:47:23 -0700 Subject: [PATCH] Fixed comptime reflection reentrancy issue with StringView --- IDEHelper/Compiler/BfModule.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index b616cfb6..cb6c085a 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -1811,16 +1811,16 @@ BfIRValue BfModule::GetStringObjectValue(const StringImpl& str, bool define, boo } BfIRValue* irValuePtr = NULL; - if (!mStringObjectPool.TryAdd(strId, NULL, &irValuePtr)) - return *irValuePtr; + if (mStringObjectPool.TryGetValue(strId, &irValuePtr)) + return *irValuePtr; // If this wasn't in neither dictionary yet, add to mStringPoolRefs if (!mStringCharPtrPool.ContainsKey(strId)) mStringPoolRefs.Add(strId); BfIRValue strObject = CreateStringObjectValue(str, strId, define); - - *irValuePtr = strObject; + mStringObjectPool[strId] = strObject; + mStringPoolRefs.Add(strId); return strObject; @@ -5161,7 +5161,7 @@ BfIRValue BfModule::CreateClassVDataGlobal(BfTypeInstance* typeInstance, int* ou if (mBfIRBuilder->mIgnoreWrites) return mBfIRBuilder->GetFakeVal(); - PopulateType(typeInstance, BfPopulateType_DataAndMethods); + PopulateType(typeInstance, mIsComptimeModule ? BfPopulateType_Data : BfPopulateType_DataAndMethods); BfType* classVDataType = ResolveTypeDef(mCompiler->mClassVDataTypeDef); @@ -5706,7 +5706,7 @@ BfIRValue BfModule::CreateTypeData(BfType* type, Dictionary& usedStrin else typeDataSource = mContext->mBfTypeType; - if ((!mTypeDataRefs.ContainsKey(typeDataSource)) && (typeDataSource != type)) + if ((!mTypeDataRefs.ContainsKey(typeDataSource)) && (typeDataSource != type) && (!mIsComptimeModule)) { CreateTypeData(typeDataSource, usedStringIdMap, false, true, needsTypeNames, true); }