mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Fixes for global ctor/dtor/mark
This commit is contained in:
parent
8c6de21bf8
commit
2fdf87c7a2
2 changed files with 43 additions and 34 deletions
|
@ -916,9 +916,11 @@ String BfGNUMangler::Mangle(BfMethodInstance* methodInst)
|
|||
if (methodDef->mHasComptime)
|
||||
name += "`COMPTIME";
|
||||
|
||||
if ((methodInst->mMethodDef->mDeclaringType->mPartialIdx != -1) && (methodInst->mMethodDef->mDeclaringType->IsExtension()) &&
|
||||
(!methodInst->mIsForeignMethodDef) && (!methodInst->mMethodDef->mIsExtern) &&
|
||||
((!methodInst->mMethodDef->mIsOverride) || (methodDef->mName == BF_METHODNAME_MARKMEMBERS) || (methodDef->mMethodType == BfMethodType_Dtor)))
|
||||
if (((methodInst->GetOwner()->mTypeDef->IsGlobalsContainer()) &&
|
||||
((methodDef->mMethodType == BfMethodType_Ctor) || (methodDef->mMethodType == BfMethodType_Dtor) || (methodDef->mName == BF_METHODNAME_MARKMEMBERS_STATIC))) ||
|
||||
((methodInst->mMethodDef->mDeclaringType->mPartialIdx != -1) && (methodInst->mMethodDef->mDeclaringType->IsExtension()) &&
|
||||
(!methodInst->mIsForeignMethodDef) && (!methodInst->mMethodDef->mIsExtern) &&
|
||||
((!methodInst->mMethodDef->mIsOverride) || (methodDef->mName == BF_METHODNAME_MARKMEMBERS) || (methodDef->mMethodType == BfMethodType_Dtor))))
|
||||
{
|
||||
auto declType = methodInst->mMethodDef->mDeclaringType;
|
||||
BF_ASSERT(methodInst->GetOwner()->mTypeDef->mIsCombinedPartial);
|
||||
|
@ -2073,10 +2075,12 @@ void BfMSMangler::Mangle(StringImpl& name, bool is64Bit, BfMethodInstance* metho
|
|||
else
|
||||
AddStr(mangleContext, name, methodDef->mName);
|
||||
}
|
||||
|
||||
if ((methodInst->mMethodDef->mDeclaringType->mPartialIdx != -1) && (methodInst->mMethodDef->mDeclaringType->IsExtension()) &&
|
||||
(!methodInst->mIsForeignMethodDef) && (!methodInst->mMethodDef->mIsExtern) &&
|
||||
((!methodInst->mMethodDef->mIsOverride) || (methodDef->mName == BF_METHODNAME_MARKMEMBERS) || (methodDef->mMethodType == BfMethodType_Dtor)))
|
||||
|
||||
if (((methodInst->GetOwner()->mTypeDef->IsGlobalsContainer()) &&
|
||||
((methodDef->mMethodType == BfMethodType_Ctor) || (methodDef->mMethodType == BfMethodType_Dtor) || (methodDef->mName == BF_METHODNAME_MARKMEMBERS_STATIC))) ||
|
||||
((methodInst->mMethodDef->mDeclaringType->mPartialIdx != -1) && (methodInst->mMethodDef->mDeclaringType->IsExtension()) &&
|
||||
(!methodInst->mIsForeignMethodDef) && (!methodInst->mMethodDef->mIsExtern) &&
|
||||
((!methodInst->mMethodDef->mIsOverride) || (methodDef->mName == BF_METHODNAME_MARKMEMBERS) || (methodDef->mMethodType == BfMethodType_Dtor))))
|
||||
{
|
||||
auto declType = methodInst->mMethodDef->mDeclaringType;
|
||||
BF_ASSERT(methodInst->GetOwner()->mTypeDef->mIsCombinedPartial);
|
||||
|
|
|
@ -3139,7 +3139,7 @@ void BfSystem::FinishCompositePartial(BfTypeDef* compositeTypeDef)
|
|||
|
||||
_HasMethods allHasMethods[2][2] = { 0 };
|
||||
auto primaryDef = nextRevision->mPartials[0];
|
||||
|
||||
|
||||
//Dictionary<BfProject*, int> projectCount;
|
||||
|
||||
bool hasCtorNoBody = false;
|
||||
|
@ -3151,6 +3151,8 @@ void BfSystem::FinishCompositePartial(BfTypeDef* compositeTypeDef)
|
|||
for (auto partialTypeDef : nextRevision->mPartials)
|
||||
{
|
||||
bool isExtension = partialTypeDef->mTypeDeclaration != nextRevision->mTypeDeclaration;
|
||||
if (!isExtension)
|
||||
primaryDef = partialTypeDef;
|
||||
|
||||
bool hasInitializers = false;
|
||||
for (auto methodDef : partialTypeDef->mMethods)
|
||||
|
@ -3218,37 +3220,40 @@ void BfSystem::FinishCompositePartial(BfTypeDef* compositeTypeDef)
|
|||
// methodDef->mIsMutating = true;
|
||||
// }
|
||||
|
||||
// Static ctor
|
||||
if ((allHasMethods[0][1].mCtor == 0) && (allHasMethods[1][1].mCtor > 1))
|
||||
if (!primaryDef->IsGlobalsContainer())
|
||||
{
|
||||
auto methodDef = BfDefBuilder::AddMethod(nextRevision, BfMethodType_Ctor, BfProtection_Public, true, "");
|
||||
methodDef->mDeclaringType = primaryDef;
|
||||
}
|
||||
// Static ctor
|
||||
if ((allHasMethods[0][1].mCtor == 0) && (allHasMethods[1][1].mCtor > 1))
|
||||
{
|
||||
auto methodDef = BfDefBuilder::AddMethod(nextRevision, BfMethodType_Ctor, BfProtection_Public, true, "");
|
||||
methodDef->mDeclaringType = primaryDef;
|
||||
}
|
||||
|
||||
if ((allHasMethods[0][0].mDtor == 0) && (allHasMethods[1][0].mDtor > 1))
|
||||
{
|
||||
auto methodDef = BfDefBuilder::AddMethod(nextRevision, BfMethodType_Dtor, BfProtection_Public, false, "");
|
||||
methodDef->mDeclaringType = primaryDef;
|
||||
}
|
||||
if ((allHasMethods[0][0].mDtor == 0) && (allHasMethods[1][0].mDtor > 1))
|
||||
{
|
||||
auto methodDef = BfDefBuilder::AddMethod(nextRevision, BfMethodType_Dtor, BfProtection_Public, false, "");
|
||||
methodDef->mDeclaringType = primaryDef;
|
||||
}
|
||||
|
||||
if ((allHasMethods[0][1].mDtor == 0) && (allHasMethods[1][1].mDtor > 1))
|
||||
{
|
||||
auto methodDef = BfDefBuilder::AddMethod(nextRevision, BfMethodType_Dtor, BfProtection_Public, true, "");
|
||||
methodDef->mDeclaringType = primaryDef;
|
||||
}
|
||||
if ((allHasMethods[0][1].mDtor == 0) && (allHasMethods[1][1].mDtor > 1))
|
||||
{
|
||||
auto methodDef = BfDefBuilder::AddMethod(nextRevision, BfMethodType_Dtor, BfProtection_Public, true, "");
|
||||
methodDef->mDeclaringType = primaryDef;
|
||||
}
|
||||
|
||||
if ((allHasMethods[0][0].mMark == 0) && (allHasMethods[1][0].mMark > 1))
|
||||
{
|
||||
auto methodDef = BfDefBuilder::AddMethod(nextRevision, BfMethodType_Normal, BfProtection_Public, false, BF_METHODNAME_MARKMEMBERS);
|
||||
methodDef->mDeclaringType = primaryDef;
|
||||
methodDef->mIsVirtual = true;
|
||||
methodDef->mIsOverride = true;
|
||||
}
|
||||
if ((allHasMethods[0][0].mMark == 0) && (allHasMethods[1][0].mMark > 1))
|
||||
{
|
||||
auto methodDef = BfDefBuilder::AddMethod(nextRevision, BfMethodType_Normal, BfProtection_Public, false, BF_METHODNAME_MARKMEMBERS);
|
||||
methodDef->mDeclaringType = primaryDef;
|
||||
methodDef->mIsVirtual = true;
|
||||
methodDef->mIsOverride = true;
|
||||
}
|
||||
|
||||
if ((allHasMethods[0][1].mMark == 0) && (allHasMethods[1][1].mMark > 1))
|
||||
{
|
||||
auto methodDef = BfDefBuilder::AddMethod(nextRevision, BfMethodType_Normal, BfProtection_Public, true, BF_METHODNAME_MARKMEMBERS_STATIC);
|
||||
methodDef->mDeclaringType = primaryDef;
|
||||
if ((allHasMethods[0][1].mMark == 0) && (allHasMethods[1][1].mMark > 1))
|
||||
{
|
||||
auto methodDef = BfDefBuilder::AddMethod(nextRevision, BfMethodType_Normal, BfProtection_Public, true, BF_METHODNAME_MARKMEMBERS_STATIC);
|
||||
methodDef->mDeclaringType = primaryDef;
|
||||
}
|
||||
}
|
||||
|
||||
// If this fails, it's probably because there were no actual composite pieces to put into it
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue