1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-09 03:52:19 +02:00

Fixed population of typed primitives, fixed null constants

This commit is contained in:
Brian Fiete 2020-06-05 11:23:24 -07:00
parent 053e36a62a
commit 71bc9c5d61
2 changed files with 16 additions and 12 deletions

View file

@ -2080,11 +2080,6 @@ void BfCompiler::UpdateDependencyMap(bool deleteUnusued, bool& didWork)
if (depType != NULL) if (depType != NULL)
{ {
if ((depType->mTypeId == 2574) && (!mIsResolveOnly) && (deleteUnusued))
{
NOP;
}
extern BfModule* gLastCreatedModule; extern BfModule* gLastCreatedModule;
for (auto itr = depType->mDependencyMap.begin(); itr != depType->mDependencyMap.end(); ++itr) for (auto itr = depType->mDependencyMap.begin(); itr != depType->mDependencyMap.end(); ++itr)

View file

@ -2307,6 +2307,7 @@ void BfIRBuilder::CreateTypeDeclaration(BfType* type, bool forceDbgDefine)
if (type->IsTypedPrimitive()) if (type->IsTypedPrimitive())
{ {
mModule->PopulateType(type);
auto underlyingType = type->GetUnderlyingType(); auto underlyingType = type->GetUnderlyingType();
irType = MapType(underlyingType); irType = MapType(underlyingType);
SetType(type, irType); SetType(type, irType);
@ -2508,6 +2509,9 @@ void BfIRBuilder::CreateDbgTypeDefinition(BfType* type)
bool wasMadeAddr = false; bool wasMadeAddr = false;
StringT<128> staticVarName;
BfMangler::Mangle(staticVarName, mModule->mCompiler->GetMangleKind(), fieldInstance);
String fieldName = fieldDef->mName; String fieldName = fieldDef->mName;
BfIRValue intConstant; BfIRValue intConstant;
if (constant != NULL) if (constant != NULL)
@ -2517,7 +2521,8 @@ void BfIRBuilder::CreateDbgTypeDefinition(BfType* type)
continue; continue;
if ((constant->mConstType == BfConstType_Array) || if ((constant->mConstType == BfConstType_Array) ||
(constant->mConstType == BfConstType_AggZero)) (constant->mConstType == BfConstType_AggZero) ||
(constant->mTypeCode == BfTypeCode_NullPtr))
{ {
staticValue = ConstToMemory(staticValue); staticValue = ConstToMemory(staticValue);
wasMadeAddr = true; wasMadeAddr = true;
@ -2528,16 +2533,18 @@ void BfIRBuilder::CreateDbgTypeDefinition(BfType* type)
const StringImpl& str = mModule->mContext->mStringObjectIdMap[stringId].mString; const StringImpl& str = mModule->mContext->mStringObjectIdMap[stringId].mString;
staticValue = mModule->GetStringCharPtr(str); staticValue = mModule->GetStringCharPtr(str);
} }
else else if (constant->mTypeCode == BfTypeCode_StringId)
{ {
int stringId = constant->mInt32; int stringId = constant->mInt32;
const StringImpl& str = mModule->mContext->mStringObjectIdMap[stringId].mString; const StringImpl& str = mModule->mContext->mStringObjectIdMap[stringId].mString;
staticValue = mModule->GetStringObjectValue(str); 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) if (!useIntConstant)
{ {
auto useType = resolvedFieldType; auto useType = resolvedFieldType;
@ -3432,6 +3439,8 @@ BfIRValue BfIRBuilder::ConstToMemory(BfIRValue constVal)
constType = ((BfConstantArray*)constant)->mType; constType = ((BfConstantArray*)constant)->mType;
else if (constant->mConstType == BfConstType_AggZero) else if (constant->mConstType == BfConstType_AggZero)
constType = constant->mIRType; constType = constant->mIRType;
else if (constant->mTypeCode == BfTypeCode_NullPtr)
constType = constant->mIRType;
else else
BF_FATAL("Invalid const type for ConstToMemory"); BF_FATAL("Invalid const type for ConstToMemory");
auto memVal = CreateGlobalVariable(constType, true, BfIRLinkageType_Internal, constVal, StrFormat("__constMem%d", constVal.mId)); auto memVal = CreateGlobalVariable(constType, true, BfIRLinkageType_Internal, constVal, StrFormat("__constMem%d", constVal.mId));