1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-09 20:12:21 +02:00

Fixed dtor lookup

This commit is contained in:
Brian Fiete 2021-02-07 16:17:24 -08:00
parent eddbf7a984
commit 9268e3b25d
6 changed files with 73 additions and 37 deletions

View file

@ -829,8 +829,7 @@ void BfContext::ValidateDependencies()
void BfContext::RebuildType(BfType* type, bool deleteOnDemandTypes, bool rebuildModule, bool placeSpecializiedInPurgatory)
{
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;

View file

@ -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());

View file

@ -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;

View file

@ -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))

View file

@ -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 NULL;
return bestMethodDef;
}
BfFieldDef* BfTypeDef::GetFieldByName(const StringImpl& name)