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

Hardening against errors during build fails

This commit is contained in:
Brian Fiete 2025-01-24 12:54:58 -08:00
parent ac7f66c1f1
commit 9444a0d936
2 changed files with 28 additions and 12 deletions

View file

@ -4235,19 +4235,22 @@ void BfModule::CreateStaticField(BfFieldInstance* fieldInstance, bool isThreadLo
else
irType = mBfIRBuilder->MapType(fieldType, BfIRPopulateType_Eventually_Full);
BfIRValue globalVar = mBfIRBuilder->CreateGlobalVariable(
irType,
false,
BfIRLinkageType_External,
initValue,
staticVarName,
isThreadLocal);
mBfIRBuilder->GlobalVar_SetAlignment(globalVar, fieldType->mAlign);
if (storageKind != BfIRStorageKind_Normal)
mBfIRBuilder->GlobalVar_SetStorageKind(globalVar, storageKind);
if (fieldType->mSize > 0)
{
BfIRValue globalVar = mBfIRBuilder->CreateGlobalVariable(
irType,
false,
BfIRLinkageType_External,
initValue,
staticVarName,
isThreadLocal);
mBfIRBuilder->GlobalVar_SetAlignment(globalVar, fieldType->mAlign);
if (storageKind != BfIRStorageKind_Normal)
mBfIRBuilder->GlobalVar_SetStorageKind(globalVar, storageKind);
BF_ASSERT(globalVar);
mStaticFieldRefs[fieldInstance] = globalVar;
BF_ASSERT(globalVar);
mStaticFieldRefs[fieldInstance] = globalVar;
}
}
}
}
@ -14755,6 +14758,15 @@ BfModuleMethodInstance BfModule::GetMethodInstance(BfTypeInstance* typeInst, BfM
}
else
{
if (methodDef->mIdx >= typeInst->mMethodInstanceGroups.mSize)
PopulateType(typeInst, BfPopulateType_DataAndMethods);
if (methodDef->mIdx >= typeInst->mMethodInstanceGroups.mSize)
{
InternalError("GetMethodInstance OOB error", methodDef->GetRefNode());
return BfModuleMethodInstance();
}
methodInstGroup = &typeInst->mMethodInstanceGroups[methodDef->mIdx];
}