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
|
@ -829,8 +829,7 @@ void BfContext::ValidateDependencies()
|
||||||
void BfContext::RebuildType(BfType* type, bool deleteOnDemandTypes, bool rebuildModule, bool placeSpecializiedInPurgatory)
|
void BfContext::RebuildType(BfType* type, bool deleteOnDemandTypes, bool rebuildModule, bool placeSpecializiedInPurgatory)
|
||||||
{
|
{
|
||||||
BfTypeInstance* typeInst = type->ToTypeInstance();
|
BfTypeInstance* typeInst = type->ToTypeInstance();
|
||||||
|
|
||||||
|
|
||||||
if (type->IsDeleting())
|
if (type->IsDeleting())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -2517,11 +2516,6 @@ void BfContext::QueueMethodSpecializations(BfTypeInstance* typeInst, bool checkS
|
||||||
|
|
||||||
BP_ZONE("BfContext::QueueMethodSpecializations");
|
BP_ZONE("BfContext::QueueMethodSpecializations");
|
||||||
|
|
||||||
if (typeInst->mTypeId == 578)
|
|
||||||
{
|
|
||||||
NOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto module = typeInst->mModule;
|
auto module = typeInst->mModule;
|
||||||
if (module == NULL)
|
if (module == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1916,13 +1916,7 @@ void BfModule::AddStackAlloc(BfTypedValue val, BfIRValue arraySize, BfAstNode* r
|
||||||
bool hadDtorCall = false;
|
bool hadDtorCall = false;
|
||||||
while (checkBaseType != NULL)
|
while (checkBaseType != NULL)
|
||||||
{
|
{
|
||||||
checkBaseType->mTypeDef->PopulateMemberSets();
|
BfMethodDef* dtorMethodDef = checkBaseType->mTypeDef->GetMethodByName("~this");
|
||||||
BfMemberSetEntry* entry = NULL;
|
|
||||||
BfMethodDef* dtorMethodDef = NULL;
|
|
||||||
checkBaseType->mTypeDef->mMethodSet.TryGetWith(String("~this"), &entry);
|
|
||||||
if (entry != NULL)
|
|
||||||
dtorMethodDef = (BfMethodDef*)entry->mMemberDef;
|
|
||||||
|
|
||||||
if (dtorMethodDef != NULL)
|
if (dtorMethodDef != NULL)
|
||||||
{
|
{
|
||||||
auto dtorMethodInstance = GetMethodInstance(checkBaseType, dtorMethodDef, BfTypeVector());
|
auto dtorMethodInstance = GetMethodInstance(checkBaseType, dtorMethodDef, BfTypeVector());
|
||||||
|
@ -15740,13 +15734,7 @@ void BfModule::EmitDtorBody()
|
||||||
UpdateSrcPos(typeDef->mTypeDeclaration->mNameNode);
|
UpdateSrcPos(typeDef->mTypeDeclaration->mNameNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
checkBaseType->mTypeDef->PopulateMemberSets();
|
BfMethodDef* dtorMethodDef = checkBaseType->mTypeDef->GetMethodByName("~this");
|
||||||
BfMemberSetEntry* entry = NULL;
|
|
||||||
BfMethodDef* dtorMethodDef = NULL;
|
|
||||||
checkBaseType->mTypeDef->mMethodSet.TryGetWith(String("~this"), &entry);
|
|
||||||
if (entry != NULL)
|
|
||||||
dtorMethodDef = (BfMethodDef*)entry->mMemberDef;
|
|
||||||
|
|
||||||
if (dtorMethodDef != NULL)
|
if (dtorMethodDef != NULL)
|
||||||
{
|
{
|
||||||
auto dtorMethodInstance = GetMethodInstance(checkBaseType, dtorMethodDef, BfTypeVector());
|
auto dtorMethodInstance = GetMethodInstance(checkBaseType, dtorMethodDef, BfTypeVector());
|
||||||
|
|
|
@ -2599,8 +2599,10 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
||||||
SetAndRestoreValue<BfTypeInstance*> prevTypeInstance(mCurTypeInstance, typeInstance);
|
SetAndRestoreValue<BfTypeInstance*> prevTypeInstance(mCurTypeInstance, typeInstance);
|
||||||
SetAndRestoreValue<BfMethodInstance*> prevMethodInstance(mCurMethodInstance, NULL);
|
SetAndRestoreValue<BfMethodInstance*> prevMethodInstance(mCurMethodInstance, NULL);
|
||||||
SetAndRestoreValue<BfMethodState*> prevMethodState(mCurMethodState, 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);
|
BfTypeState typeState(mCurTypeInstance, mContext->mCurTypeState);
|
||||||
typeState.mPopulateType = populateType;
|
typeState.mPopulateType = populateType;
|
||||||
|
|
|
@ -3934,15 +3934,7 @@ void BfModule::Visit(BfDeleteStatement* deleteStmt)
|
||||||
bool allowProtected = allowPrivate || TypeIsSubTypeOf(mCurTypeInstance, checkTypeInst);
|
bool allowProtected = allowPrivate || TypeIsSubTypeOf(mCurTypeInstance, checkTypeInst);
|
||||||
while (checkTypeInst != NULL)
|
while (checkTypeInst != NULL)
|
||||||
{
|
{
|
||||||
auto checkTypeDef = checkTypeInst->mTypeDef;
|
auto dtorMethodDef = checkTypeInst->mTypeDef->GetMethodByName("~this");
|
||||||
|
|
||||||
checkTypeDef->PopulateMemberSets();
|
|
||||||
BfMemberSetEntry* entry = NULL;
|
|
||||||
BfMethodDef* dtorMethodDef = NULL;
|
|
||||||
checkTypeDef->mMethodSet.TryGetWith(String("~this"), &entry);
|
|
||||||
if (entry != NULL)
|
|
||||||
dtorMethodDef = (BfMethodDef*)entry->mMemberDef;
|
|
||||||
|
|
||||||
if (dtorMethodDef)
|
if (dtorMethodDef)
|
||||||
{
|
{
|
||||||
if (!CheckProtection(dtorMethodDef->mProtection, checkTypeInst->mTypeDef, allowProtected, allowPrivate))
|
if (!CheckProtection(dtorMethodDef->mProtection, checkTypeInst->mTypeDef, allowProtected, allowPrivate))
|
||||||
|
|
|
@ -833,12 +833,26 @@ int BfTypeDef::GetSelfGenericParamCount()
|
||||||
|
|
||||||
BfMethodDef* BfTypeDef::GetMethodByName(const StringImpl& name, int paramCount)
|
BfMethodDef* BfTypeDef::GetMethodByName(const StringImpl& name, int paramCount)
|
||||||
{
|
{
|
||||||
for (auto method : mMethods)
|
PopulateMemberSets();
|
||||||
{
|
BfMemberSetEntry* entry = NULL;
|
||||||
if ((name == method->mName) && ((paramCount == -1) || (paramCount == (int)method->mParams.size())))
|
if (!mMethodSet.TryGetWith(name, &entry))
|
||||||
return method;
|
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 NULL;
|
|
||||||
|
return bestMethodDef;
|
||||||
}
|
}
|
||||||
|
|
||||||
BfFieldDef* BfTypeDef::GetFieldByName(const StringImpl& name)
|
BfFieldDef* BfTypeDef::GetFieldByName(const StringImpl& name)
|
||||||
|
|
|
@ -160,6 +160,32 @@ namespace Tests
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
extension TClassA<T> where T : IGetExVal
|
||||||
{
|
{
|
||||||
|
@ -226,6 +252,26 @@ namespace Tests
|
||||||
ClassE ce = scope .();
|
ClassE ce = scope .();
|
||||||
Test.Assert(ce.mD == 1);
|
Test.Assert(ce.mD == 1);
|
||||||
Test.Assert(ce.mE == 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]
|
[Test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue