1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-12 05:14:10 +02:00

Fix '_' in appended field dtors, fixed implicit-ctor static append

This commit is contained in:
Brian Fiete 2022-07-11 08:16:57 -04:00
parent d695434add
commit 627b0381f8

View file

@ -16896,14 +16896,13 @@ void BfModule::CreateStaticCtor()
{
for (auto fieldDef : typeDef->mFields)
{
if ((!fieldDef->mIsConst) && (fieldDef->mIsStatic) && (fieldDef->GetInitializer() != NULL))
if ((!fieldDef->mIsConst) && (fieldDef->mIsStatic))
{
// For extensions, only handle these fields in the appropriate extension
if ((fieldDef->mDeclaringType->mTypeDeclaration != methodDef->mDeclaringType->mTypeDeclaration))
continue;
UpdateSrcPos(fieldDef->GetInitializer());
auto initializer = fieldDef->GetInitializer();
auto fieldInst = &mCurTypeInstance->mFieldInstances[fieldDef->mIdx];
if (!fieldInst->mFieldIncluded)
continue;
@ -16911,12 +16910,18 @@ void BfModule::CreateStaticCtor()
{
continue;
}
if (fieldInst->IsAppendedObject())
{
AppendedObjectInit(fieldInst);
else
}
else if (initializer != NULL)
{
UpdateSrcPos(initializer);
GetFieldInitializerValue(fieldInst, NULL, NULL, NULL, true);
}
}
}
auto _CheckInitBlock = [&](BfAstNode* node)
{
@ -17106,8 +17111,14 @@ void BfModule::EmitDtorBody()
BfLocalVariable* localDef = new BfLocalVariable();
localDef->mName = "_";
localDef->mResolvedType = fieldInst->mResolvedType;
localDef->mAddr = value;
if (fieldInst->IsAppendedObject())
{
localDef->mValue = mBfIRBuilder->CreateBitCast(value, mBfIRBuilder->MapType(fieldInst->mResolvedType));
}
else
{
localDef->mAddr = value;
if ((mBfIRBuilder->DbgHasInfo()) && (!IsTargetingBeefBackend()))
{
// Create another pointer indirection, a ref to the gep
@ -17120,14 +17131,19 @@ void BfModule::EmitDtorBody()
localDef->mResolvedType = refFieldType;
localDef->mAddr = allocaInst;
}
}
mBfIRBuilder->RestoreDebugLocation();
auto defLocalVar = AddLocalVariableDef(localDef, true);
if (!fieldInst->IsAppendedObject())
{
// Put back so we actually modify the correct value*/
defLocalVar->mResolvedType = fieldInst->mResolvedType;
defLocalVar->mAddr = value;
}
}
while (fieldDtor != NULL)
{