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

Fixed issues with chained dtors in extensions

This commit is contained in:
Brian Fiete 2020-10-15 12:05:50 -07:00
parent 3bb94764d2
commit fe7d3d80e7

View file

@ -1878,10 +1878,10 @@ void BfModule::AddStackAlloc(BfTypedValue val, BfIRValue arraySize, BfAstNode* r
{ {
if ((checkBaseType->mTypeDef->mDtorDef != NULL) /*&& (checkBaseType != mContext->mBfObjectType)*/) if ((checkBaseType->mTypeDef->mDtorDef != NULL) /*&& (checkBaseType != mContext->mBfObjectType)*/)
{ {
bool isDynAlloc = (scopeData != NULL) && (mCurMethodState->mCurScope->IsDyn(scopeData));
auto dtorMethodInstance = GetMethodInstance(checkBaseType, checkBaseType->mTypeDef->mDtorDef, BfTypeVector()); auto dtorMethodInstance = GetMethodInstance(checkBaseType, checkBaseType->mTypeDef->mDtorDef, BfTypeVector());
if (dtorMethodInstance)
{
bool isDynAlloc = (scopeData != NULL) && (mCurMethodState->mCurScope->IsDyn(scopeData));
BfIRValue useVal = val.mValue; BfIRValue useVal = val.mValue;
useVal = mBfIRBuilder->CreateBitCast(val.mValue, mBfIRBuilder->MapTypeInstPtr(checkBaseType)); useVal = mBfIRBuilder->CreateBitCast(val.mValue, mBfIRBuilder->MapTypeInstPtr(checkBaseType));
@ -1911,6 +1911,7 @@ void BfModule::AddStackAlloc(BfTypedValue val, BfIRValue arraySize, BfAstNode* r
break; break;
} }
}
checkBaseType = checkBaseType->mBaseType; checkBaseType = checkBaseType->mBaseType;
} }
@ -14872,6 +14873,12 @@ void BfModule::EmitDtorBody()
auto fieldDef = fieldInst->GetFieldDef(); auto fieldDef = fieldInst->GetFieldDef();
if ((fieldDef != NULL) && (fieldDef->mIsStatic == methodDef->mIsStatic) && (fieldDef->mFieldDeclaration != NULL) && (fieldDef->mFieldDeclaration->mFieldDtor != NULL)) if ((fieldDef != NULL) && (fieldDef->mIsStatic == methodDef->mIsStatic) && (fieldDef->mFieldDeclaration != NULL) && (fieldDef->mFieldDeclaration->mFieldDtor != NULL))
{ {
if (fieldDef->mDeclaringType != mCurMethodInstance->mMethodDef->mDeclaringType)
{
BF_ASSERT(mCurTypeInstance->mTypeDef->mIsCombinedPartial);
continue;
}
if ((!methodDef->mIsStatic) && (mCurTypeInstance->IsValueType())) if ((!methodDef->mIsStatic) && (mCurTypeInstance->IsValueType()))
{ {
Fail("Structs cannot have field destructors", fieldDef->mFieldDeclaration->mFieldDtor->mTildeToken, true); Fail("Structs cannot have field destructors", fieldDef->mFieldDeclaration->mFieldDtor->mTildeToken, true);
@ -14967,7 +14974,7 @@ void BfModule::EmitDtorBody()
} }
} }
if (!methodDef->mIsStatic) if ((!methodDef->mIsStatic) && (mCurMethodInstance->mChainType != BfMethodChainType_ChainMember))
{ {
auto checkBaseType = mCurTypeInstance->mBaseType; auto checkBaseType = mCurTypeInstance->mBaseType;
while (checkBaseType != NULL) while (checkBaseType != NULL)