mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 03:52:19 +02:00
Removed mDtorDef, fixed MethodSpecializationRequest on emitted method
This commit is contained in:
parent
71d4dd0e90
commit
bc8758bbac
7 changed files with 71 additions and 51 deletions
|
@ -446,7 +446,20 @@ bool BfContext::ProcessWorkList(bool onlyReifiedTypes, bool onlyReifiedMethods)
|
||||||
workIdx = mMethodSpecializationWorkList.RemoveAt(workIdx);
|
workIdx = mMethodSpecializationWorkList.RemoveAt(workIdx);
|
||||||
|
|
||||||
auto typeInst = methodSpecializationRequest.mType->ToTypeInstance();
|
auto typeInst = methodSpecializationRequest.mType->ToTypeInstance();
|
||||||
module->GetMethodInstance(methodSpecializationRequest.mType->ToTypeInstance(), methodSpecializationRequest.mMethodDef, methodSpecializationRequest.mMethodGenericArguments,
|
|
||||||
|
BfMethodDef* methodDef = NULL;
|
||||||
|
if (methodSpecializationRequest.mForeignType != NULL)
|
||||||
|
{
|
||||||
|
module->PopulateType(methodSpecializationRequest.mForeignType);
|
||||||
|
methodDef = methodSpecializationRequest.mForeignType->mTypeDef->mMethods[methodSpecializationRequest.mMethodIdx];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
module->PopulateType(typeInst);
|
||||||
|
methodDef = typeInst->mTypeDef->mMethods[methodSpecializationRequest.mMethodIdx];
|
||||||
|
}
|
||||||
|
|
||||||
|
module->GetMethodInstance(typeInst, methodDef, methodSpecializationRequest.mMethodGenericArguments,
|
||||||
(BfGetMethodInstanceFlags)(methodSpecializationRequest.mFlags | BfGetMethodInstanceFlag_ResultNotUsed), methodSpecializationRequest.mForeignType);
|
(BfGetMethodInstanceFlags)(methodSpecializationRequest.mFlags | BfGetMethodInstanceFlag_ResultNotUsed), methodSpecializationRequest.mForeignType);
|
||||||
didWork = true;
|
didWork = true;
|
||||||
}
|
}
|
||||||
|
@ -2534,11 +2547,6 @@ void BfContext::QueueMethodSpecializations(BfTypeInstance* typeInst, bool checkS
|
||||||
|
|
||||||
auto methodDef = methodRef.mTypeInstance->mTypeDef->mMethods[methodRef.mMethodNum];
|
auto methodDef = methodRef.mTypeInstance->mTypeDef->mMethods[methodRef.mMethodNum];
|
||||||
|
|
||||||
if (methodDef->mName == "set__Capacity")
|
|
||||||
{
|
|
||||||
NOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto targetContext = methodRef.mTypeInstance->mContext;
|
auto targetContext = methodRef.mTypeInstance->mContext;
|
||||||
BfMethodSpecializationRequest* specializationRequest = targetContext->mMethodSpecializationWorkList.Alloc();
|
BfMethodSpecializationRequest* specializationRequest = targetContext->mMethodSpecializationWorkList.Alloc();
|
||||||
if (specializedMethodRefInfo.mHasReifiedRef)
|
if (specializedMethodRefInfo.mHasReifiedRef)
|
||||||
|
@ -2546,7 +2554,8 @@ void BfContext::QueueMethodSpecializations(BfTypeInstance* typeInst, bool checkS
|
||||||
else
|
else
|
||||||
specializationRequest->mFromModule = mUnreifiedModule;
|
specializationRequest->mFromModule = mUnreifiedModule;
|
||||||
specializationRequest->mFromModuleRevision = typeInst->mModule->mRevision;
|
specializationRequest->mFromModuleRevision = typeInst->mModule->mRevision;
|
||||||
specializationRequest->mMethodDef = methodRef.mTypeInstance->mTypeDef->mMethods[methodRef.mMethodNum];
|
specializationRequest->mMethodIdx = methodRef.mMethodNum;
|
||||||
|
//specializationRequest->mMethodDef = methodRef.mTypeInstance->mTypeDef->mMethods[methodRef.mMethodNum];
|
||||||
specializationRequest->mMethodGenericArguments = methodRef.mMethodGenericArguments;
|
specializationRequest->mMethodGenericArguments = methodRef.mMethodGenericArguments;
|
||||||
specializationRequest->mType = methodRef.mTypeInstance;
|
specializationRequest->mType = methodRef.mTypeInstance;
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ public:
|
||||||
class BfMethodSpecializationRequest : public BfWorkListEntry
|
class BfMethodSpecializationRequest : public BfWorkListEntry
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BfMethodDef* mMethodDef;
|
int32 mMethodIdx;
|
||||||
BfTypeVector mMethodGenericArguments;
|
BfTypeVector mMethodGenericArguments;
|
||||||
BfGetMethodInstanceFlags mFlags;
|
BfGetMethodInstanceFlags mFlags;
|
||||||
BfTypeInstance* mForeignType;
|
BfTypeInstance* mForeignType;
|
||||||
|
@ -52,10 +52,21 @@ public:
|
||||||
public:
|
public:
|
||||||
BfMethodSpecializationRequest()
|
BfMethodSpecializationRequest()
|
||||||
{
|
{
|
||||||
mMethodDef = NULL;
|
mMethodIdx = -1;
|
||||||
mFlags = BfGetMethodInstanceFlag_None;
|
mFlags = BfGetMethodInstanceFlag_None;
|
||||||
mForeignType = NULL;
|
mForeignType = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Init(BfTypeInstance* typeInstance, BfTypeInstance* foreignType, BfMethodDef* methodDef)
|
||||||
|
{
|
||||||
|
mType = typeInstance;
|
||||||
|
mMethodIdx = methodDef->mIdx;
|
||||||
|
mForeignType = foreignType;
|
||||||
|
if (foreignType != NULL)
|
||||||
|
BF_ASSERT(foreignType->mTypeDef->mMethods[mMethodIdx] == methodDef);
|
||||||
|
else
|
||||||
|
BF_ASSERT(typeInstance->mTypeDef->mMethods[mMethodIdx] == methodDef);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class BfMethodProcessRequest : public BfWorkListEntry
|
class BfMethodProcessRequest : public BfWorkListEntry
|
||||||
|
|
|
@ -521,7 +521,6 @@ BfMethodDef* BfDefBuilder::CreateMethodDef(BfMethodDeclaration* methodDeclaratio
|
||||||
methodDef->mName = "__BfStaticDtor";
|
methodDef->mName = "__BfStaticDtor";
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mCurTypeDef->mDtorDef = methodDef;
|
|
||||||
methodDef->mName = "~this";
|
methodDef->mName = "~this";
|
||||||
if (!methodDef->mIsVirtual)
|
if (!methodDef->mIsVirtual)
|
||||||
{
|
{
|
||||||
|
@ -1229,8 +1228,6 @@ BfMethodDef* BfDefBuilder::AddMethod(BfTypeDef* typeDef, BfMethodType methodType
|
||||||
methodDef->mName = "~this";
|
methodDef->mName = "~this";
|
||||||
methodDef->mIsVirtual = true;
|
methodDef->mIsVirtual = true;
|
||||||
methodDef->mIsOverride = true;
|
methodDef->mIsOverride = true;
|
||||||
BF_ASSERT(typeDef->mDtorDef == NULL);
|
|
||||||
typeDef->mDtorDef = methodDef;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1255,8 +1252,6 @@ BfMethodDef* BfDefBuilder::AddDtor(BfTypeDef* typeDef)
|
||||||
methodDef->mMethodType = BfMethodType_Dtor;
|
methodDef->mMethodType = BfMethodType_Dtor;
|
||||||
methodDef->mIsVirtual = true;
|
methodDef->mIsVirtual = true;
|
||||||
methodDef->mIsOverride = true;
|
methodDef->mIsOverride = true;
|
||||||
BF_ASSERT(typeDef->mDtorDef == NULL);
|
|
||||||
typeDef->mDtorDef = methodDef;
|
|
||||||
return methodDef;
|
return methodDef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2174,7 +2169,6 @@ void BfDefBuilder::FinishTypeDef(bool wantsToString)
|
||||||
if ((needsDtor) && (dtor == NULL))
|
if ((needsDtor) && (dtor == NULL))
|
||||||
{
|
{
|
||||||
auto methodDef = AddMethod(mCurTypeDef, BfMethodType_Dtor, BfProtection_Public, false, "", mIsComptime);
|
auto methodDef = AddMethod(mCurTypeDef, BfMethodType_Dtor, BfProtection_Public, false, "", mIsComptime);
|
||||||
BF_ASSERT(mCurTypeDef->mDtorDef == methodDef);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((needsStaticDtor) && (staticDtor == NULL))
|
if ((needsStaticDtor) && (staticDtor == NULL))
|
||||||
|
|
|
@ -1910,9 +1910,16 @@ void BfModule::AddStackAlloc(BfTypedValue val, BfIRValue arraySize, BfAstNode* r
|
||||||
bool hadDtorCall = false;
|
bool hadDtorCall = false;
|
||||||
while (checkBaseType != NULL)
|
while (checkBaseType != NULL)
|
||||||
{
|
{
|
||||||
if ((checkBaseType->mTypeDef->mDtorDef != NULL) /*&& (checkBaseType != mContext->mBfObjectType)*/)
|
checkBaseType->mTypeDef->PopulateMemberSets();
|
||||||
|
BfMemberSetEntry* entry = NULL;
|
||||||
|
BfMethodDef* dtorMethodDef = NULL;
|
||||||
|
checkBaseType->mTypeDef->mMethodSet.TryGetWith(String("~this"), &entry);
|
||||||
|
if (entry != NULL)
|
||||||
|
dtorMethodDef = (BfMethodDef*)entry->mMemberDef;
|
||||||
|
|
||||||
|
if (dtorMethodDef != NULL)
|
||||||
{
|
{
|
||||||
auto dtorMethodInstance = GetMethodInstance(checkBaseType, checkBaseType->mTypeDef->mDtorDef, BfTypeVector());
|
auto dtorMethodInstance = GetMethodInstance(checkBaseType, dtorMethodDef, BfTypeVector());
|
||||||
if (dtorMethodInstance)
|
if (dtorMethodInstance)
|
||||||
{
|
{
|
||||||
bool isDynAlloc = (scopeData != NULL) && (mCurMethodState->mCurScope->IsDyn(scopeData));
|
bool isDynAlloc = (scopeData != NULL) && (mCurMethodState->mCurScope->IsDyn(scopeData));
|
||||||
|
@ -12552,11 +12559,11 @@ BfModuleMethodInstance BfModule::GetMethodInstance(BfTypeInstance* typeInst, BfM
|
||||||
BfMethodSpecializationRequest* specializationRequest = mContext->mMethodSpecializationWorkList.Alloc();
|
BfMethodSpecializationRequest* specializationRequest = mContext->mMethodSpecializationWorkList.Alloc();
|
||||||
specializationRequest->mFromModule = typeInst->mModule;
|
specializationRequest->mFromModule = typeInst->mModule;
|
||||||
specializationRequest->mFromModuleRevision = typeInst->mModule->mRevision;
|
specializationRequest->mFromModuleRevision = typeInst->mModule->mRevision;
|
||||||
specializationRequest->mMethodDef = methodDef;
|
specializationRequest->Init(typeInst, foreignType, methodDef);
|
||||||
|
//specializationRequest->mMethodDef = methodDef;
|
||||||
specializationRequest->mMethodGenericArguments = methodGenericArguments;
|
specializationRequest->mMethodGenericArguments = methodGenericArguments;
|
||||||
specializationRequest->mType = typeInst;
|
specializationRequest->mType = typeInst;
|
||||||
specializationRequest->mFlags = flags;
|
specializationRequest->mFlags = flags;
|
||||||
specializationRequest->mForeignType = foreignType;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15524,9 +15531,16 @@ void BfModule::EmitDtorBody()
|
||||||
UpdateSrcPos(typeDef->mTypeDeclaration->mNameNode);
|
UpdateSrcPos(typeDef->mTypeDeclaration->mNameNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checkBaseType->mTypeDef->mDtorDef != NULL)
|
checkBaseType->mTypeDef->PopulateMemberSets();
|
||||||
|
BfMemberSetEntry* entry = NULL;
|
||||||
|
BfMethodDef* dtorMethodDef = NULL;
|
||||||
|
checkBaseType->mTypeDef->mMethodSet.TryGetWith(String("~this"), &entry);
|
||||||
|
if (entry != NULL)
|
||||||
|
dtorMethodDef = (BfMethodDef*)entry->mMemberDef;
|
||||||
|
|
||||||
|
if (dtorMethodDef != NULL)
|
||||||
{
|
{
|
||||||
auto dtorMethodInstance = GetMethodInstance(checkBaseType, checkBaseType->mTypeDef->mDtorDef, BfTypeVector());
|
auto dtorMethodInstance = GetMethodInstance(checkBaseType, dtorMethodDef, BfTypeVector());
|
||||||
if (IsSkippingExtraResolveChecks())
|
if (IsSkippingExtraResolveChecks())
|
||||||
{
|
{
|
||||||
// Nothing
|
// Nothing
|
||||||
|
|
|
@ -3933,9 +3933,17 @@ void BfModule::Visit(BfDeleteStatement* deleteStmt)
|
||||||
while (checkTypeInst != NULL)
|
while (checkTypeInst != NULL)
|
||||||
{
|
{
|
||||||
auto checkTypeDef = checkTypeInst->mTypeDef;
|
auto checkTypeDef = checkTypeInst->mTypeDef;
|
||||||
if (checkTypeDef->mDtorDef != NULL)
|
|
||||||
|
checkTypeDef->PopulateMemberSets();
|
||||||
|
BfMemberSetEntry* entry = NULL;
|
||||||
|
BfMethodDef* dtorMethodDef = NULL;
|
||||||
|
checkTypeDef->mMethodSet.TryGetWith(String("~this"), &entry);
|
||||||
|
if (entry != NULL)
|
||||||
|
dtorMethodDef = (BfMethodDef*)entry->mMemberDef;
|
||||||
|
|
||||||
|
if (dtorMethodDef)
|
||||||
{
|
{
|
||||||
if (!CheckProtection(checkTypeDef->mDtorDef->mProtection, checkTypeInst->mTypeDef, allowProtected, allowPrivate))
|
if (!CheckProtection(dtorMethodDef->mProtection, checkTypeInst->mTypeDef, allowProtected, allowPrivate))
|
||||||
{
|
{
|
||||||
auto error = Fail(StrFormat("'%s.~this()' is inaccessible due to its protection level", TypeToString(checkTypeInst).c_str()), deleteStmt->mExpression); // CS0122
|
auto error = Fail(StrFormat("'%s.~this()' is inaccessible due to its protection level", TypeToString(checkTypeInst).c_str()), deleteStmt->mExpression); // CS0122
|
||||||
}
|
}
|
||||||
|
|
|
@ -2670,7 +2670,6 @@ void BfSystem::InjectNewRevision(BfTypeDef* typeDef)
|
||||||
nextMethodDef->mParams.Clear();
|
nextMethodDef->mParams.Clear();
|
||||||
nextMethodDef->mGenericParams.Clear();
|
nextMethodDef->mGenericParams.Clear();
|
||||||
}
|
}
|
||||||
// Leave typeDef->mDtorDef
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2686,7 +2685,6 @@ void BfSystem::InjectNewRevision(BfTypeDef* typeDef)
|
||||||
for (auto method : typeDef->mMethods)
|
for (auto method : typeDef->mMethods)
|
||||||
method->mDeclaringType = typeDef;
|
method->mDeclaringType = typeDef;
|
||||||
nextTypeDef->mMethods.Clear();
|
nextTypeDef->mMethods.Clear();
|
||||||
typeDef->mDtorDef = nextTypeDef->mDtorDef;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto fieldDef : typeDef->mFields)
|
for (auto fieldDef : typeDef->mFields)
|
||||||
|
@ -2971,17 +2969,6 @@ void BfSystem::AddToCompositePartial(BfPassInstance* passInstance, BfTypeDef* co
|
||||||
}
|
}
|
||||||
typeDef->mPropertySet.Clear();
|
typeDef->mPropertySet.Clear();
|
||||||
|
|
||||||
if (partialTypeDef->mDtorDef != NULL)
|
|
||||||
{
|
|
||||||
if (typeDef->mDtorDef != NULL)
|
|
||||||
{
|
|
||||||
//passInstance->Fail("Destructor already defined", partialTypeDef->mDtorDef->mMethodDeclaration->mNameNode);
|
|
||||||
//TODO:
|
|
||||||
}
|
|
||||||
else
|
|
||||||
typeDef->mDtorDef = partialTypeDef->mDtorDef;
|
|
||||||
}
|
|
||||||
|
|
||||||
BF_ASSERT(partialTypeDef->mPartials.empty());
|
BF_ASSERT(partialTypeDef->mPartials.empty());
|
||||||
partialTypeDef->mPartialIdx = (int)typeDef->mPartials.size();
|
partialTypeDef->mPartialIdx = (int)typeDef->mPartials.size();
|
||||||
typeDef->mPartials.push_back(partialTypeDef);
|
typeDef->mPartials.push_back(partialTypeDef);
|
||||||
|
@ -3101,7 +3088,6 @@ void BfSystem::FinishCompositePartial(BfTypeDef* compositeTypeDef)
|
||||||
|
|
||||||
if ((allHasMethods[0][0].mDtor == 0) && (allHasMethods[1][0].mDtor > 1))
|
if ((allHasMethods[0][0].mDtor == 0) && (allHasMethods[1][0].mDtor > 1))
|
||||||
{
|
{
|
||||||
nextRevision->mDtorDef = NULL;
|
|
||||||
auto methodDef = BfDefBuilder::AddMethod(nextRevision, BfMethodType_Dtor, BfProtection_Public, false, "");
|
auto methodDef = BfDefBuilder::AddMethod(nextRevision, BfMethodType_Dtor, BfProtection_Public, false, "");
|
||||||
methodDef->mDeclaringType = primaryDef;
|
methodDef->mDeclaringType = primaryDef;
|
||||||
}
|
}
|
||||||
|
|
|
@ -960,7 +960,6 @@ public:
|
||||||
HashSet<BfMemberSetEntry> mFieldSet;
|
HashSet<BfMemberSetEntry> mFieldSet;
|
||||||
HashSet<BfMemberSetEntry> mPropertySet;
|
HashSet<BfMemberSetEntry> mPropertySet;
|
||||||
Array<BfOperatorDef*> mOperators;
|
Array<BfOperatorDef*> mOperators;
|
||||||
BfMethodDef* mDtorDef;
|
|
||||||
Array<BfGenericParamDef*> mGenericParamDefs;
|
Array<BfGenericParamDef*> mGenericParamDefs;
|
||||||
Array<BfExternalConstraintDef> mExternalConstraints;
|
Array<BfExternalConstraintDef> mExternalConstraints;
|
||||||
Array<BfTypeReference*> mBaseTypes;
|
Array<BfTypeReference*> mBaseTypes;
|
||||||
|
@ -1041,7 +1040,6 @@ public:
|
||||||
mNestDepth = 0;
|
mNestDepth = 0;
|
||||||
mOuterType = NULL;
|
mOuterType = NULL;
|
||||||
mTypeDeclaration = NULL;
|
mTypeDeclaration = NULL;
|
||||||
mDtorDef = NULL;
|
|
||||||
mNextRevision = NULL;
|
mNextRevision = NULL;
|
||||||
mProtection = BfProtection_Public;
|
mProtection = BfProtection_Public;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue