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:
parent
d695434add
commit
627b0381f8
1 changed files with 35 additions and 19 deletions
|
@ -16896,25 +16896,30 @@ void BfModule::CreateStaticCtor()
|
||||||
{
|
{
|
||||||
for (auto fieldDef : typeDef->mFields)
|
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
|
// For extensions, only handle these fields in the appropriate extension
|
||||||
if ((fieldDef->mDeclaringType->mTypeDeclaration != methodDef->mDeclaringType->mTypeDeclaration))
|
if ((fieldDef->mDeclaringType->mTypeDeclaration != methodDef->mDeclaringType->mTypeDeclaration))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
UpdateSrcPos(fieldDef->GetInitializer());
|
|
||||||
|
|
||||||
auto fieldInst = &mCurTypeInstance->mFieldInstances[fieldDef->mIdx];
|
auto initializer = fieldDef->GetInitializer();
|
||||||
|
auto fieldInst = &mCurTypeInstance->mFieldInstances[fieldDef->mIdx];
|
||||||
if (!fieldInst->mFieldIncluded)
|
if (!fieldInst->mFieldIncluded)
|
||||||
continue;
|
continue;
|
||||||
if (fieldInst->mResolvedType->IsVar())
|
if (fieldInst->mResolvedType->IsVar())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fieldInst->IsAppendedObject())
|
if (fieldInst->IsAppendedObject())
|
||||||
|
{
|
||||||
AppendedObjectInit(fieldInst);
|
AppendedObjectInit(fieldInst);
|
||||||
else
|
}
|
||||||
|
else if (initializer != NULL)
|
||||||
|
{
|
||||||
|
UpdateSrcPos(initializer);
|
||||||
GetFieldInitializerValue(fieldInst, NULL, NULL, NULL, true);
|
GetFieldInitializerValue(fieldInst, NULL, NULL, NULL, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17106,27 +17111,38 @@ void BfModule::EmitDtorBody()
|
||||||
BfLocalVariable* localDef = new BfLocalVariable();
|
BfLocalVariable* localDef = new BfLocalVariable();
|
||||||
localDef->mName = "_";
|
localDef->mName = "_";
|
||||||
localDef->mResolvedType = fieldInst->mResolvedType;
|
localDef->mResolvedType = fieldInst->mResolvedType;
|
||||||
localDef->mAddr = value;
|
|
||||||
|
if (fieldInst->IsAppendedObject())
|
||||||
if ((mBfIRBuilder->DbgHasInfo()) && (!IsTargetingBeefBackend()))
|
|
||||||
{
|
{
|
||||||
// Create another pointer indirection, a ref to the gep
|
localDef->mValue = mBfIRBuilder->CreateBitCast(value, mBfIRBuilder->MapType(fieldInst->mResolvedType));
|
||||||
auto refFieldType = CreateRefType(fieldInst->mResolvedType);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
localDef->mAddr = value;
|
||||||
|
if ((mBfIRBuilder->DbgHasInfo()) && (!IsTargetingBeefBackend()))
|
||||||
|
{
|
||||||
|
// Create another pointer indirection, a ref to the gep
|
||||||
|
auto refFieldType = CreateRefType(fieldInst->mResolvedType);
|
||||||
|
|
||||||
auto allocaInst = CreateAlloca(refFieldType);
|
auto allocaInst = CreateAlloca(refFieldType);
|
||||||
|
|
||||||
auto storeResult = mBfIRBuilder->CreateStore(value, allocaInst);
|
|
||||||
|
|
||||||
localDef->mResolvedType = refFieldType;
|
auto storeResult = mBfIRBuilder->CreateStore(value, allocaInst);
|
||||||
localDef->mAddr = allocaInst;
|
|
||||||
|
localDef->mResolvedType = refFieldType;
|
||||||
|
localDef->mAddr = allocaInst;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mBfIRBuilder->RestoreDebugLocation();
|
mBfIRBuilder->RestoreDebugLocation();
|
||||||
|
|
||||||
auto defLocalVar = AddLocalVariableDef(localDef, true);
|
auto defLocalVar = AddLocalVariableDef(localDef, true);
|
||||||
// Put back so we actually modify the correct value*/
|
|
||||||
defLocalVar->mResolvedType = fieldInst->mResolvedType;
|
if (!fieldInst->IsAppendedObject())
|
||||||
defLocalVar->mAddr = value;
|
{
|
||||||
|
// Put back so we actually modify the correct value*/
|
||||||
|
defLocalVar->mResolvedType = fieldInst->mResolvedType;
|
||||||
|
defLocalVar->mAddr = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (fieldDtor != NULL)
|
while (fieldDtor != NULL)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue