diff --git a/IDEHelper/Compiler/BfCompiler.cpp b/IDEHelper/Compiler/BfCompiler.cpp index efe5e42e..512f09e5 100644 --- a/IDEHelper/Compiler/BfCompiler.cpp +++ b/IDEHelper/Compiler/BfCompiler.cpp @@ -2080,11 +2080,6 @@ void BfCompiler::UpdateDependencyMap(bool deleteUnusued, bool& didWork) if (depType != NULL) { - if ((depType->mTypeId == 2574) && (!mIsResolveOnly) && (deleteUnusued)) - { - NOP; - } - extern BfModule* gLastCreatedModule; for (auto itr = depType->mDependencyMap.begin(); itr != depType->mDependencyMap.end(); ++itr) diff --git a/IDEHelper/Compiler/BfIRBuilder.cpp b/IDEHelper/Compiler/BfIRBuilder.cpp index b0de022a..f2359a49 100644 --- a/IDEHelper/Compiler/BfIRBuilder.cpp +++ b/IDEHelper/Compiler/BfIRBuilder.cpp @@ -2307,6 +2307,7 @@ void BfIRBuilder::CreateTypeDeclaration(BfType* type, bool forceDbgDefine) if (type->IsTypedPrimitive()) { + mModule->PopulateType(type); auto underlyingType = type->GetUnderlyingType(); irType = MapType(underlyingType); SetType(type, irType); @@ -2508,6 +2509,9 @@ void BfIRBuilder::CreateDbgTypeDefinition(BfType* type) bool wasMadeAddr = false; + StringT<128> staticVarName; + BfMangler::Mangle(staticVarName, mModule->mCompiler->GetMangleKind(), fieldInstance); + String fieldName = fieldDef->mName; BfIRValue intConstant; if (constant != NULL) @@ -2517,27 +2521,30 @@ void BfIRBuilder::CreateDbgTypeDefinition(BfType* type) continue; if ((constant->mConstType == BfConstType_Array) || - (constant->mConstType == BfConstType_AggZero)) + (constant->mConstType == BfConstType_AggZero) || + (constant->mTypeCode == BfTypeCode_NullPtr)) { staticValue = ConstToMemory(staticValue); wasMadeAddr = true; - } + } else if (resolvedFieldType->IsPointer()) { int stringId = constant->mInt32; const StringImpl& str = mModule->mContext->mStringObjectIdMap[stringId].mString; staticValue = mModule->GetStringCharPtr(str); - } - else + } + else if (constant->mTypeCode == BfTypeCode_StringId) { int stringId = constant->mInt32; const StringImpl& str = mModule->mContext->mStringObjectIdMap[stringId].mString; staticValue = mModule->GetStringObjectValue(str); } + else + { + mModule->FatalError(StrFormat("Invalid constant type for %s", staticVarName.c_str())); + } } - - StringT<128> staticVarName; - BfMangler::Mangle(staticVarName, mModule->mCompiler->GetMangleKind(), fieldInstance); + if (!useIntConstant) { auto useType = resolvedFieldType; @@ -3432,6 +3439,8 @@ BfIRValue BfIRBuilder::ConstToMemory(BfIRValue constVal) constType = ((BfConstantArray*)constant)->mType; else if (constant->mConstType == BfConstType_AggZero) constType = constant->mIRType; + else if (constant->mTypeCode == BfTypeCode_NullPtr) + constType = constant->mIRType; else BF_FATAL("Invalid const type for ConstToMemory"); auto memVal = CreateGlobalVariable(constType, true, BfIRLinkageType_Internal, constVal, StrFormat("__constMem%d", constVal.mId));