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)
|
if (methodDef->mHasComptime)
|
||||||
name += "`COMPTIME";
|
name += "`COMPTIME";
|
||||||
|
|
||||||
if ((methodInst->mMethodDef->mDeclaringType->mPartialIdx != -1) && (methodInst->mMethodDef->mDeclaringType->IsExtension()) &&
|
if (((methodInst->GetOwner()->mTypeDef->IsGlobalsContainer()) &&
|
||||||
(!methodInst->mIsForeignMethodDef) && (!methodInst->mMethodDef->mIsExtern) &&
|
((methodDef->mMethodType == BfMethodType_Ctor) || (methodDef->mMethodType == BfMethodType_Dtor) || (methodDef->mName == BF_METHODNAME_MARKMEMBERS_STATIC))) ||
|
||||||
((!methodInst->mMethodDef->mIsOverride) || (methodDef->mName == BF_METHODNAME_MARKMEMBERS) || (methodDef->mMethodType == BfMethodType_Dtor)))
|
((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;
|
auto declType = methodInst->mMethodDef->mDeclaringType;
|
||||||
BF_ASSERT(methodInst->GetOwner()->mTypeDef->mIsCombinedPartial);
|
BF_ASSERT(methodInst->GetOwner()->mTypeDef->mIsCombinedPartial);
|
||||||
|
@ -2073,10 +2075,12 @@ void BfMSMangler::Mangle(StringImpl& name, bool is64Bit, BfMethodInstance* metho
|
||||||
else
|
else
|
||||||
AddStr(mangleContext, name, methodDef->mName);
|
AddStr(mangleContext, name, methodDef->mName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((methodInst->mMethodDef->mDeclaringType->mPartialIdx != -1) && (methodInst->mMethodDef->mDeclaringType->IsExtension()) &&
|
if (((methodInst->GetOwner()->mTypeDef->IsGlobalsContainer()) &&
|
||||||
(!methodInst->mIsForeignMethodDef) && (!methodInst->mMethodDef->mIsExtern) &&
|
((methodDef->mMethodType == BfMethodType_Ctor) || (methodDef->mMethodType == BfMethodType_Dtor) || (methodDef->mName == BF_METHODNAME_MARKMEMBERS_STATIC))) ||
|
||||||
((!methodInst->mMethodDef->mIsOverride) || (methodDef->mName == BF_METHODNAME_MARKMEMBERS) || (methodDef->mMethodType == BfMethodType_Dtor)))
|
((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;
|
auto declType = methodInst->mMethodDef->mDeclaringType;
|
||||||
BF_ASSERT(methodInst->GetOwner()->mTypeDef->mIsCombinedPartial);
|
BF_ASSERT(methodInst->GetOwner()->mTypeDef->mIsCombinedPartial);
|
||||||
|
|
|
@ -3139,7 +3139,7 @@ void BfSystem::FinishCompositePartial(BfTypeDef* compositeTypeDef)
|
||||||
|
|
||||||
_HasMethods allHasMethods[2][2] = { 0 };
|
_HasMethods allHasMethods[2][2] = { 0 };
|
||||||
auto primaryDef = nextRevision->mPartials[0];
|
auto primaryDef = nextRevision->mPartials[0];
|
||||||
|
|
||||||
//Dictionary<BfProject*, int> projectCount;
|
//Dictionary<BfProject*, int> projectCount;
|
||||||
|
|
||||||
bool hasCtorNoBody = false;
|
bool hasCtorNoBody = false;
|
||||||
|
@ -3151,6 +3151,8 @@ void BfSystem::FinishCompositePartial(BfTypeDef* compositeTypeDef)
|
||||||
for (auto partialTypeDef : nextRevision->mPartials)
|
for (auto partialTypeDef : nextRevision->mPartials)
|
||||||
{
|
{
|
||||||
bool isExtension = partialTypeDef->mTypeDeclaration != nextRevision->mTypeDeclaration;
|
bool isExtension = partialTypeDef->mTypeDeclaration != nextRevision->mTypeDeclaration;
|
||||||
|
if (!isExtension)
|
||||||
|
primaryDef = partialTypeDef;
|
||||||
|
|
||||||
bool hasInitializers = false;
|
bool hasInitializers = false;
|
||||||
for (auto methodDef : partialTypeDef->mMethods)
|
for (auto methodDef : partialTypeDef->mMethods)
|
||||||
|
@ -3218,37 +3220,40 @@ void BfSystem::FinishCompositePartial(BfTypeDef* compositeTypeDef)
|
||||||
// methodDef->mIsMutating = true;
|
// methodDef->mIsMutating = true;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// Static ctor
|
if (!primaryDef->IsGlobalsContainer())
|
||||||
if ((allHasMethods[0][1].mCtor == 0) && (allHasMethods[1][1].mCtor > 1))
|
|
||||||
{
|
{
|
||||||
auto methodDef = BfDefBuilder::AddMethod(nextRevision, BfMethodType_Ctor, BfProtection_Public, true, "");
|
// Static ctor
|
||||||
methodDef->mDeclaringType = primaryDef;
|
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))
|
if ((allHasMethods[0][0].mDtor == 0) && (allHasMethods[1][0].mDtor > 1))
|
||||||
{
|
{
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((allHasMethods[0][1].mDtor == 0) && (allHasMethods[1][1].mDtor > 1))
|
if ((allHasMethods[0][1].mDtor == 0) && (allHasMethods[1][1].mDtor > 1))
|
||||||
{
|
{
|
||||||
auto methodDef = BfDefBuilder::AddMethod(nextRevision, BfMethodType_Dtor, BfProtection_Public, true, "");
|
auto methodDef = BfDefBuilder::AddMethod(nextRevision, BfMethodType_Dtor, BfProtection_Public, true, "");
|
||||||
methodDef->mDeclaringType = primaryDef;
|
methodDef->mDeclaringType = primaryDef;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((allHasMethods[0][0].mMark == 0) && (allHasMethods[1][0].mMark > 1))
|
if ((allHasMethods[0][0].mMark == 0) && (allHasMethods[1][0].mMark > 1))
|
||||||
{
|
{
|
||||||
auto methodDef = BfDefBuilder::AddMethod(nextRevision, BfMethodType_Normal, BfProtection_Public, false, BF_METHODNAME_MARKMEMBERS);
|
auto methodDef = BfDefBuilder::AddMethod(nextRevision, BfMethodType_Normal, BfProtection_Public, false, BF_METHODNAME_MARKMEMBERS);
|
||||||
methodDef->mDeclaringType = primaryDef;
|
methodDef->mDeclaringType = primaryDef;
|
||||||
methodDef->mIsVirtual = true;
|
methodDef->mIsVirtual = true;
|
||||||
methodDef->mIsOverride = true;
|
methodDef->mIsOverride = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((allHasMethods[0][1].mMark == 0) && (allHasMethods[1][1].mMark > 1))
|
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);
|
auto methodDef = BfDefBuilder::AddMethod(nextRevision, BfMethodType_Normal, BfProtection_Public, true, BF_METHODNAME_MARKMEMBERS_STATIC);
|
||||||
methodDef->mDeclaringType = primaryDef;
|
methodDef->mDeclaringType = primaryDef;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this fails, it's probably because there were no actual composite pieces to put into it
|
// 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