mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 03:52:19 +02:00
Fixed dtor lookup
This commit is contained in:
parent
eddbf7a984
commit
9268e3b25d
6 changed files with 73 additions and 37 deletions
|
@ -830,7 +830,6 @@ void BfContext::RebuildType(BfType* type, bool deleteOnDemandTypes, bool rebuild
|
|||
{
|
||||
BfTypeInstance* typeInst = type->ToTypeInstance();
|
||||
|
||||
|
||||
if (type->IsDeleting())
|
||||
{
|
||||
return;
|
||||
|
@ -2517,11 +2516,6 @@ void BfContext::QueueMethodSpecializations(BfTypeInstance* typeInst, bool checkS
|
|||
|
||||
BP_ZONE("BfContext::QueueMethodSpecializations");
|
||||
|
||||
if (typeInst->mTypeId == 578)
|
||||
{
|
||||
NOP;
|
||||
}
|
||||
|
||||
auto module = typeInst->mModule;
|
||||
if (module == NULL)
|
||||
return;
|
||||
|
|
|
@ -1916,13 +1916,7 @@ void BfModule::AddStackAlloc(BfTypedValue val, BfIRValue arraySize, BfAstNode* r
|
|||
bool hadDtorCall = false;
|
||||
while (checkBaseType != NULL)
|
||||
{
|
||||
checkBaseType->mTypeDef->PopulateMemberSets();
|
||||
BfMemberSetEntry* entry = NULL;
|
||||
BfMethodDef* dtorMethodDef = NULL;
|
||||
checkBaseType->mTypeDef->mMethodSet.TryGetWith(String("~this"), &entry);
|
||||
if (entry != NULL)
|
||||
dtorMethodDef = (BfMethodDef*)entry->mMemberDef;
|
||||
|
||||
BfMethodDef* dtorMethodDef = checkBaseType->mTypeDef->GetMethodByName("~this");
|
||||
if (dtorMethodDef != NULL)
|
||||
{
|
||||
auto dtorMethodInstance = GetMethodInstance(checkBaseType, dtorMethodDef, BfTypeVector());
|
||||
|
@ -15740,13 +15734,7 @@ void BfModule::EmitDtorBody()
|
|||
UpdateSrcPos(typeDef->mTypeDeclaration->mNameNode);
|
||||
}
|
||||
|
||||
checkBaseType->mTypeDef->PopulateMemberSets();
|
||||
BfMemberSetEntry* entry = NULL;
|
||||
BfMethodDef* dtorMethodDef = NULL;
|
||||
checkBaseType->mTypeDef->mMethodSet.TryGetWith(String("~this"), &entry);
|
||||
if (entry != NULL)
|
||||
dtorMethodDef = (BfMethodDef*)entry->mMemberDef;
|
||||
|
||||
BfMethodDef* dtorMethodDef = checkBaseType->mTypeDef->GetMethodByName("~this");
|
||||
if (dtorMethodDef != NULL)
|
||||
{
|
||||
auto dtorMethodInstance = GetMethodInstance(checkBaseType, dtorMethodDef, BfTypeVector());
|
||||
|
|
|
@ -2599,8 +2599,10 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
|||
SetAndRestoreValue<BfTypeInstance*> prevTypeInstance(mCurTypeInstance, typeInstance);
|
||||
SetAndRestoreValue<BfMethodInstance*> prevMethodInstance(mCurMethodInstance, NULL);
|
||||
SetAndRestoreValue<BfMethodState*> prevMethodState(mCurMethodState, NULL);
|
||||
SetAndRestoreValue<bool> prevHadError(mHadBuildError, false);
|
||||
SetAndRestoreValue<bool> prevHadWarning(mHadBuildWarning, false);
|
||||
|
||||
// WHY were we clearing these values?
|
||||
//SetAndRestoreValue<bool> prevHadError(mHadBuildError, false);
|
||||
//SetAndRestoreValue<bool> prevHadWarning(mHadBuildWarning, false);
|
||||
|
||||
BfTypeState typeState(mCurTypeInstance, mContext->mCurTypeState);
|
||||
typeState.mPopulateType = populateType;
|
||||
|
|
|
@ -3934,15 +3934,7 @@ void BfModule::Visit(BfDeleteStatement* deleteStmt)
|
|||
bool allowProtected = allowPrivate || TypeIsSubTypeOf(mCurTypeInstance, checkTypeInst);
|
||||
while (checkTypeInst != NULL)
|
||||
{
|
||||
auto checkTypeDef = checkTypeInst->mTypeDef;
|
||||
|
||||
checkTypeDef->PopulateMemberSets();
|
||||
BfMemberSetEntry* entry = NULL;
|
||||
BfMethodDef* dtorMethodDef = NULL;
|
||||
checkTypeDef->mMethodSet.TryGetWith(String("~this"), &entry);
|
||||
if (entry != NULL)
|
||||
dtorMethodDef = (BfMethodDef*)entry->mMemberDef;
|
||||
|
||||
auto dtorMethodDef = checkTypeInst->mTypeDef->GetMethodByName("~this");
|
||||
if (dtorMethodDef)
|
||||
{
|
||||
if (!CheckProtection(dtorMethodDef->mProtection, checkTypeInst->mTypeDef, allowProtected, allowPrivate))
|
||||
|
|
|
@ -833,12 +833,26 @@ int BfTypeDef::GetSelfGenericParamCount()
|
|||
|
||||
BfMethodDef* BfTypeDef::GetMethodByName(const StringImpl& name, int paramCount)
|
||||
{
|
||||
for (auto method : mMethods)
|
||||
{
|
||||
if ((name == method->mName) && ((paramCount == -1) || (paramCount == (int)method->mParams.size())))
|
||||
return method;
|
||||
}
|
||||
PopulateMemberSets();
|
||||
BfMemberSetEntry* entry = NULL;
|
||||
if (!mMethodSet.TryGetWith(name, &entry))
|
||||
return NULL;
|
||||
|
||||
BfMethodDef* bestMethodDef = NULL;
|
||||
auto methodDef = (BfMethodDef*)entry->mMemberDef;
|
||||
while (methodDef != NULL)
|
||||
{
|
||||
if ((name == methodDef->mName) && ((paramCount == -1) || (paramCount == (int)methodDef->mParams.size())))
|
||||
{
|
||||
if ((bestMethodDef == NULL) ||
|
||||
((bestMethodDef->mDeclaringType->IsExtension()) && (!methodDef->mDeclaringType->IsExtension())))
|
||||
bestMethodDef = methodDef;
|
||||
}
|
||||
|
||||
methodDef = methodDef->mNextWithSameName;
|
||||
}
|
||||
|
||||
return bestMethodDef;
|
||||
}
|
||||
|
||||
BfFieldDef* BfTypeDef::GetFieldByName(const StringImpl& name)
|
||||
|
|
|
@ -161,6 +161,32 @@ namespace Tests
|
|||
}
|
||||
}
|
||||
|
||||
class ClassF
|
||||
{
|
||||
public static int sVal = 3;
|
||||
|
||||
public int mF0 = 1 ~
|
||||
{
|
||||
sVal += 40;
|
||||
};
|
||||
}
|
||||
|
||||
extension ClassF
|
||||
{
|
||||
public int mF1 = 2 ~
|
||||
{
|
||||
sVal += 500;
|
||||
};
|
||||
}
|
||||
|
||||
class ClassG : ClassF
|
||||
{
|
||||
public int mG0 = 3 ~
|
||||
{
|
||||
sVal += 6000;
|
||||
};
|
||||
}
|
||||
|
||||
extension TClassA<T> where T : IGetExVal
|
||||
{
|
||||
public T mTVal;
|
||||
|
@ -226,6 +252,26 @@ namespace Tests
|
|||
ClassE ce = scope .();
|
||||
Test.Assert(ce.mD == 1);
|
||||
Test.Assert(ce.mE == 1);
|
||||
|
||||
///
|
||||
{
|
||||
ClassF cf = scope .();
|
||||
}
|
||||
Test.Assert(ClassF.sVal == 543);
|
||||
///
|
||||
{
|
||||
ClassF.sVal = 3;
|
||||
ClassG cg = scope .();
|
||||
}
|
||||
Test.Assert(ClassF.sVal == 6543);
|
||||
ClassF.sVal = 3;
|
||||
Object obj = new ClassF();
|
||||
delete obj;
|
||||
Test.Assert(ClassF.sVal == 543);
|
||||
ClassF.sVal = 3;
|
||||
obj = new ClassG();
|
||||
delete obj;
|
||||
Test.Assert(ClassF.sVal == 6543);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue