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_None,
|
||||||
ResolveKind_BuildingGenericParams,
|
ResolveKind_BuildingGenericParams,
|
||||||
ResolveKind_ResolvingVarType
|
ResolveKind_ResolvingVarType,
|
||||||
|
ResolveKind_UnionInnerType,
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -704,6 +704,12 @@ bool BfModule::CheckCircularDataError()
|
||||||
if (checkTypeState == NULL)
|
if (checkTypeState == NULL)
|
||||||
return hadError;
|
return hadError;
|
||||||
|
|
||||||
|
if (checkTypeState->mResolveKind == BfTypeState::ResolveKind_UnionInnerType)
|
||||||
|
{
|
||||||
|
checkTypeState = checkTypeState->mPrevState;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (isPreBaseCheck)
|
if (isPreBaseCheck)
|
||||||
{
|
{
|
||||||
if (checkTypeState->mPopulateType != BfPopulateType_Declaration)
|
if (checkTypeState->mPopulateType != BfPopulateType_Declaration)
|
||||||
|
@ -729,7 +735,15 @@ bool BfModule::CheckCircularDataError()
|
||||||
{
|
{
|
||||||
if (checkTypeState == NULL)
|
if (checkTypeState == NULL)
|
||||||
return hadError;
|
return hadError;
|
||||||
if ((checkTypeState->mCurAttributeTypeRef == NULL) && (checkTypeState->mCurBaseTypeRef == NULL) && (checkTypeState->mCurFieldDef == NULL))
|
|
||||||
|
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;
|
return hadError;
|
||||||
|
|
||||||
// We only get one chance to fire off these errors, they can't be ignored.
|
// We only get one chance to fire off these errors, they can't be ignored.
|
||||||
|
@ -2762,7 +2776,10 @@ bool BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (typeInstance->mIsUnion)
|
if (typeInstance->mIsUnion)
|
||||||
unionInnerType = typeInstance->GetUnionInnerType();
|
{
|
||||||
|
SetAndRestoreValue<BfTypeState::ResolveKind> prevResolveKind(typeState.mResolveKind, BfTypeState::ResolveKind_UnionInnerType);
|
||||||
|
unionInnerType = typeInstance->GetUnionInnerType();
|
||||||
|
}
|
||||||
|
|
||||||
if (!isOrdered)
|
if (!isOrdered)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1283,6 +1283,10 @@ BfType* BfTypeInstance::GetUnionInnerType(bool* wantSplat)
|
||||||
if (!mIsUnion)
|
if (!mIsUnion)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
BfTypeState typeState(this, mContext->mCurTypeState);
|
||||||
|
typeState.mPopulateType = BfPopulateType_Data;
|
||||||
|
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
||||||
|
|
||||||
int unionSize = 0;
|
int unionSize = 0;
|
||||||
BfType* unionInnerType = NULL;
|
BfType* unionInnerType = NULL;
|
||||||
bool makeRaw = false;
|
bool makeRaw = false;
|
||||||
|
@ -1309,6 +1313,8 @@ BfType* BfTypeInstance::GetUnionInnerType(bool* wantSplat)
|
||||||
|
|
||||||
if (checkInnerType != NULL)
|
if (checkInnerType != NULL)
|
||||||
{
|
{
|
||||||
|
SetAndRestoreValue<BfFieldDef*> prevTypeRef(mContext->mCurTypeState->mCurFieldDef, fieldDef);
|
||||||
|
|
||||||
mModule->PopulateType(checkInnerType);
|
mModule->PopulateType(checkInnerType);
|
||||||
if (checkInnerType->mSize > unionSize)
|
if (checkInnerType->mSize > unionSize)
|
||||||
unionSize = checkInnerType->mSize;
|
unionSize = checkInnerType->mSize;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue