mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Fixed detection of data cycles within unions
This commit is contained in:
parent
706153348a
commit
577cd2e270
3 changed files with 27 additions and 3 deletions
|
@ -114,7 +114,8 @@ public:
|
|||
{
|
||||
ResolveKind_None,
|
||||
ResolveKind_BuildingGenericParams,
|
||||
ResolveKind_ResolvingVarType
|
||||
ResolveKind_ResolvingVarType,
|
||||
ResolveKind_UnionInnerType,
|
||||
};
|
||||
|
||||
public:
|
||||
|
|
|
@ -704,6 +704,12 @@ bool BfModule::CheckCircularDataError()
|
|||
if (checkTypeState == NULL)
|
||||
return hadError;
|
||||
|
||||
if (checkTypeState->mResolveKind == BfTypeState::ResolveKind_UnionInnerType)
|
||||
{
|
||||
checkTypeState = checkTypeState->mPrevState;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isPreBaseCheck)
|
||||
{
|
||||
if (checkTypeState->mPopulateType != BfPopulateType_Declaration)
|
||||
|
@ -729,6 +735,14 @@ bool BfModule::CheckCircularDataError()
|
|||
{
|
||||
if (checkTypeState == NULL)
|
||||
return hadError;
|
||||
|
||||
if (checkTypeState->mResolveKind == BfTypeState::ResolveKind_UnionInnerType)
|
||||
{
|
||||
// Skip over this to actual data references
|
||||
checkTypeState = checkTypeState->mPrevState;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((checkTypeState->mCurAttributeTypeRef == NULL) && (checkTypeState->mCurBaseTypeRef == NULL) && (checkTypeState->mCurFieldDef == NULL) )
|
||||
return hadError;
|
||||
|
||||
|
@ -2762,7 +2776,10 @@ bool BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
|||
}
|
||||
}
|
||||
if (typeInstance->mIsUnion)
|
||||
{
|
||||
SetAndRestoreValue<BfTypeState::ResolveKind> prevResolveKind(typeState.mResolveKind, BfTypeState::ResolveKind_UnionInnerType);
|
||||
unionInnerType = typeInstance->GetUnionInnerType();
|
||||
}
|
||||
|
||||
if (!isOrdered)
|
||||
{
|
||||
|
|
|
@ -1283,6 +1283,10 @@ BfType* BfTypeInstance::GetUnionInnerType(bool* wantSplat)
|
|||
if (!mIsUnion)
|
||||
return NULL;
|
||||
|
||||
BfTypeState typeState(this, mContext->mCurTypeState);
|
||||
typeState.mPopulateType = BfPopulateType_Data;
|
||||
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
||||
|
||||
int unionSize = 0;
|
||||
BfType* unionInnerType = NULL;
|
||||
bool makeRaw = false;
|
||||
|
@ -1309,6 +1313,8 @@ BfType* BfTypeInstance::GetUnionInnerType(bool* wantSplat)
|
|||
|
||||
if (checkInnerType != NULL)
|
||||
{
|
||||
SetAndRestoreValue<BfFieldDef*> prevTypeRef(mContext->mCurTypeState->mCurFieldDef, fieldDef);
|
||||
|
||||
mModule->PopulateType(checkInnerType);
|
||||
if (checkInnerType->mSize > unionSize)
|
||||
unionSize = checkInnerType->mSize;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue