mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Fixed data cycle detection for sized arrays
This commit is contained in:
parent
d593488591
commit
9697c2a682
6 changed files with 56 additions and 46 deletions
|
@ -1424,9 +1424,9 @@ void BfAutoComplete::CheckIdentifier(BfAstNode* identifierNode, bool isInExpress
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((mModule->mContext->mCurTypeState != NULL) && (mModule->mContext->mCurTypeState->mTypeInstance != NULL))
|
if ((mModule->mContext->mCurTypeState != NULL) && (mModule->mContext->mCurTypeState->mType != NULL))
|
||||||
{
|
{
|
||||||
BF_ASSERT(mModule->mCurTypeInstance == mModule->mContext->mCurTypeState->mTypeInstance);
|
BF_ASSERT(mModule->mCurTypeInstance == mModule->mContext->mCurTypeState->mType);
|
||||||
|
|
||||||
BfGlobalLookup globalLookup;
|
BfGlobalLookup globalLookup;
|
||||||
globalLookup.mKind = BfGlobalLookup::Kind_All;
|
globalLookup.mKind = BfGlobalLookup::Kind_All;
|
||||||
|
@ -1790,9 +1790,9 @@ bool BfAutoComplete::CheckMemberReference(BfAstNode* target, BfAstNode* dotToken
|
||||||
checkTypeInst = mModule->GetOuterType(checkTypeInst);
|
checkTypeInst = mModule->GetOuterType(checkTypeInst);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((mModule->mContext->mCurTypeState != NULL) && (mModule->mContext->mCurTypeState->mTypeInstance != NULL))
|
if ((mModule->mContext->mCurTypeState != NULL) && (mModule->mContext->mCurTypeState->mType != NULL))
|
||||||
{
|
{
|
||||||
BF_ASSERT(mModule->mCurTypeInstance == mModule->mContext->mCurTypeState->mTypeInstance);
|
BF_ASSERT(mModule->mCurTypeInstance == mModule->mContext->mCurTypeState->mType);
|
||||||
|
|
||||||
BfGlobalLookup globalLookup;
|
BfGlobalLookup globalLookup;
|
||||||
globalLookup.mKind = BfGlobalLookup::Kind_All;
|
globalLookup.mKind = BfGlobalLookup::Kind_All;
|
||||||
|
|
|
@ -4268,7 +4268,7 @@ void BfCompiler::ProcessAutocompleteTempType()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SetAndRestoreValue<BfTypeInstance*> prevType(module->mCurTypeInstance, typeInst);
|
SetAndRestoreValue<BfTypeInstance*> prevType(module->mCurTypeInstance, typeInst);
|
||||||
typeState.mTypeInstance = typeInst;
|
typeState.mType = typeInst;
|
||||||
|
|
||||||
BfGenericExtensionEntry* genericExEntry = NULL;
|
BfGenericExtensionEntry* genericExEntry = NULL;
|
||||||
bool hadTempExtensionInfo = false;
|
bool hadTempExtensionInfo = false;
|
||||||
|
|
|
@ -138,7 +138,7 @@ public:
|
||||||
public:
|
public:
|
||||||
BfTypeState* mPrevState;
|
BfTypeState* mPrevState;
|
||||||
|
|
||||||
BfTypeInstance* mTypeInstance;
|
BfType* mType;
|
||||||
BfTypeDef* mGlobalContainerCurUserTypeDef;
|
BfTypeDef* mGlobalContainerCurUserTypeDef;
|
||||||
Array<BfGlobalContainerEntry> mGlobalContainers; // All global containers that are visible
|
Array<BfGlobalContainerEntry> mGlobalContainers; // All global containers that are visible
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ public:
|
||||||
BfTypeState()
|
BfTypeState()
|
||||||
{
|
{
|
||||||
mPrevState = NULL;
|
mPrevState = NULL;
|
||||||
mTypeInstance = NULL;
|
mType = NULL;
|
||||||
mGlobalContainerCurUserTypeDef = NULL;
|
mGlobalContainerCurUserTypeDef = NULL;
|
||||||
|
|
||||||
mPopulateType = BfPopulateType_Identity;
|
mPopulateType = BfPopulateType_Identity;
|
||||||
|
@ -172,14 +172,15 @@ public:
|
||||||
mResolveKind = ResolveKind_None;
|
mResolveKind = ResolveKind_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
BfTypeState(BfTypeInstance* typeInstance, BfTypeState* prevState = NULL)
|
BfTypeState(BfType* type, BfTypeState* prevState = NULL)
|
||||||
{
|
{
|
||||||
mPrevState = prevState;
|
mPrevState = prevState;
|
||||||
mTypeInstance = typeInstance;
|
mType = type;
|
||||||
mGlobalContainerCurUserTypeDef = NULL;
|
mGlobalContainerCurUserTypeDef = NULL;
|
||||||
|
|
||||||
mPopulateType = BfPopulateType_Declaration;
|
mPopulateType = BfPopulateType_Declaration;
|
||||||
mCurBaseTypeRef = NULL;
|
mCurBaseTypeRef = NULL;
|
||||||
|
mCurBaseType = NULL;
|
||||||
mCurFieldDef = NULL;
|
mCurFieldDef = NULL;
|
||||||
mCurAttributeTypeRef = NULL;
|
mCurAttributeTypeRef = NULL;
|
||||||
mCurTypeDef = NULL;
|
mCurTypeDef = NULL;
|
||||||
|
|
|
@ -2483,7 +2483,7 @@ bool BfMethodMatcher::CheckType(BfTypeInstance* typeInstance, BfTypedValue targe
|
||||||
while (checkTypeState != NULL)
|
while (checkTypeState != NULL)
|
||||||
{
|
{
|
||||||
if ((checkTypeState->mResolveKind == BfTypeState::ResolveKind_ResolvingVarType) &&
|
if ((checkTypeState->mResolveKind == BfTypeState::ResolveKind_ResolvingVarType) &&
|
||||||
(checkTypeState->mTypeInstance == typeInstance))
|
(checkTypeState->mType == typeInstance))
|
||||||
isResolvingVarField = true;
|
isResolvingVarField = true;
|
||||||
checkTypeState = checkTypeState->mPrevState;
|
checkTypeState = checkTypeState->mPrevState;
|
||||||
}
|
}
|
||||||
|
@ -3979,7 +3979,7 @@ BfTypedValue BfExprEvaluator::LookupIdentifier(BfAstNode* refNode, const StringI
|
||||||
{
|
{
|
||||||
if (checkTypeState->mCurFieldDef != NULL)
|
if (checkTypeState->mCurFieldDef != NULL)
|
||||||
{
|
{
|
||||||
if (checkTypeState->mTypeInstance == mModule->mCurTypeInstance)
|
if (checkTypeState->mType == mModule->mCurTypeInstance)
|
||||||
resolvingFieldDef = checkTypeState->mCurFieldDef;
|
resolvingFieldDef = checkTypeState->mCurFieldDef;
|
||||||
}
|
}
|
||||||
checkTypeState = checkTypeState->mPrevState;
|
checkTypeState = checkTypeState->mPrevState;
|
||||||
|
@ -4046,7 +4046,7 @@ BfTypedValue BfExprEvaluator::LookupIdentifier(BfAstNode* refNode, const StringI
|
||||||
|
|
||||||
if (!thisValue.HasType())
|
if (!thisValue.HasType())
|
||||||
{
|
{
|
||||||
if ((mModule->mContext->mCurTypeState != NULL) && (mModule->mContext->mCurTypeState->mTypeInstance == mModule->mCurTypeInstance) &&
|
if ((mModule->mContext->mCurTypeState != NULL) && (mModule->mContext->mCurTypeState->mType == mModule->mCurTypeInstance) &&
|
||||||
(mModule->mContext->mCurTypeState->mResolveKind == BfTypeState::ResolveKind_Attributes))
|
(mModule->mContext->mCurTypeState->mResolveKind == BfTypeState::ResolveKind_Attributes))
|
||||||
{
|
{
|
||||||
// Can't do static lookups yet
|
// Can't do static lookups yet
|
||||||
|
@ -4311,7 +4311,7 @@ BfTypedValue BfExprEvaluator::LookupField(BfAstNode* targetSrc, BfTypedValue tar
|
||||||
{
|
{
|
||||||
// Don't allow lookups yet
|
// Don't allow lookups yet
|
||||||
if ((mModule->mContext->mCurTypeState->mResolveKind == BfTypeState::ResolveKind_Attributes) &&
|
if ((mModule->mContext->mCurTypeState->mResolveKind == BfTypeState::ResolveKind_Attributes) &&
|
||||||
(startCheckType == mModule->mContext->mCurTypeState->mTypeInstance))
|
(startCheckType == mModule->mContext->mCurTypeState->mType))
|
||||||
return BfTypedValue();
|
return BfTypedValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4479,7 +4479,7 @@ BfTypedValue BfExprEvaluator::LookupField(BfAstNode* targetSrc, BfTypedValue tar
|
||||||
if ((mModule->mContext->mCurTypeState != NULL) && (mModule->mContext->mCurTypeState->mCurFieldDef != NULL))
|
if ((mModule->mContext->mCurTypeState != NULL) && (mModule->mContext->mCurTypeState->mCurFieldDef != NULL))
|
||||||
{
|
{
|
||||||
// If we're initializing another const field then also set it as having const eval
|
// If we're initializing another const field then also set it as having const eval
|
||||||
auto resolvingFieldInstance = &mModule->mContext->mCurTypeState->mTypeInstance->mFieldInstances[mModule->mContext->mCurTypeState->mCurFieldDef->mIdx];
|
auto resolvingFieldInstance = &mModule->mContext->mCurTypeState->mType->ToTypeInstance()->mFieldInstances[mModule->mContext->mCurTypeState->mCurFieldDef->mIdx];
|
||||||
if (resolvingFieldInstance->GetFieldDef()->mIsConst)
|
if (resolvingFieldInstance->GetFieldDef()->mIsConst)
|
||||||
resolvingFieldInstance->mHadConstEval = true;
|
resolvingFieldInstance->mHadConstEval = true;
|
||||||
}
|
}
|
||||||
|
@ -15319,7 +15319,7 @@ void BfExprEvaluator::InjectMixin(BfAstNode* targetSrc, BfTypedValue target, boo
|
||||||
|
|
||||||
if ((methodMatcher.mBestMethodDef == NULL) && (target.mType == NULL) && (mModule->mContext->mCurTypeState != NULL))
|
if ((methodMatcher.mBestMethodDef == NULL) && (target.mType == NULL) && (mModule->mContext->mCurTypeState != NULL))
|
||||||
{
|
{
|
||||||
BF_ASSERT(mModule->mCurTypeInstance == mModule->mContext->mCurTypeState->mTypeInstance);
|
BF_ASSERT(mModule->mCurTypeInstance == mModule->mContext->mCurTypeState->mType);
|
||||||
BfGlobalLookup globalLookup;
|
BfGlobalLookup globalLookup;
|
||||||
globalLookup.mKind = BfGlobalLookup::Kind_Method;
|
globalLookup.mKind = BfGlobalLookup::Kind_Method;
|
||||||
globalLookup.mName = name;
|
globalLookup.mName = name;
|
||||||
|
|
|
@ -2998,7 +2998,7 @@ BfError* BfModule::Fail(const StringImpl& error, BfAstNode* refNode, bool isPers
|
||||||
String errorString = error;
|
String errorString = error;
|
||||||
bool isWhileSpecializing = false;
|
bool isWhileSpecializing = false;
|
||||||
if (!AddErrorContext(errorString, refNode, isWhileSpecializing))
|
if (!AddErrorContext(errorString, refNode, isWhileSpecializing))
|
||||||
return false;
|
return NULL;
|
||||||
|
|
||||||
BfError* bfError = NULL;
|
BfError* bfError = NULL;
|
||||||
if (isWhileSpecializing)
|
if (isWhileSpecializing)
|
||||||
|
@ -3143,7 +3143,7 @@ BfError* BfModule::Warn(int warningNum, const StringImpl& warning, BfAstNode* re
|
||||||
String warningString = warning;
|
String warningString = warning;
|
||||||
bool isWhileSpecializing = false;
|
bool isWhileSpecializing = false;
|
||||||
if (!AddErrorContext(warningString, refNode, isWhileSpecializing))
|
if (!AddErrorContext(warningString, refNode, isWhileSpecializing))
|
||||||
return false;
|
return NULL;
|
||||||
bool deferWarning = isWhileSpecializing;
|
bool deferWarning = isWhileSpecializing;
|
||||||
|
|
||||||
if ((mCurMethodState != NULL) && (mCurMethodState->mMixinState != NULL))
|
if ((mCurMethodState != NULL) && (mCurMethodState->mMixinState != NULL))
|
||||||
|
@ -4093,7 +4093,7 @@ BfType* BfModule::ResolveVarFieldType(BfTypeInstance* typeInstance, BfFieldInsta
|
||||||
SetAndRestoreValue<BfTypeInstance*> prevTypeInstance(mCurTypeInstance, typeInstance);
|
SetAndRestoreValue<BfTypeInstance*> prevTypeInstance(mCurTypeInstance, typeInstance);
|
||||||
|
|
||||||
BfTypeState typeState(mCurTypeInstance, mContext->mCurTypeState);
|
BfTypeState typeState(mCurTypeInstance, mContext->mCurTypeState);
|
||||||
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState, mContext->mCurTypeState->mTypeInstance != typeInstance);
|
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState, mContext->mCurTypeState->mType != typeInstance);
|
||||||
|
|
||||||
auto typeDef = typeInstance->mTypeDef;
|
auto typeDef = typeInstance->mTypeDef;
|
||||||
|
|
||||||
|
@ -4140,7 +4140,7 @@ BfType* BfModule::ResolveVarFieldType(BfTypeInstance* typeInstance, BfFieldInsta
|
||||||
{
|
{
|
||||||
BfTypeState typeState;
|
BfTypeState typeState;
|
||||||
typeState.mPrevState = mContext->mCurTypeState;
|
typeState.mPrevState = mContext->mCurTypeState;
|
||||||
typeState.mTypeInstance = typeInstance;
|
typeState.mType = typeInstance;
|
||||||
typeState.mCurFieldDef = field;
|
typeState.mCurFieldDef = field;
|
||||||
typeState.mResolveKind = BfTypeState::ResolveKind_ResolvingVarType;
|
typeState.mResolveKind = BfTypeState::ResolveKind_ResolvingVarType;
|
||||||
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
||||||
|
@ -4291,7 +4291,7 @@ BfTypedValue BfModule::GetFieldInitializerValue(BfFieldInstance* fieldInstance,
|
||||||
ceExecuteId = mCompiler->mCEMachine->mExecuteId;
|
ceExecuteId = mCompiler->mCEMachine->mExecuteId;
|
||||||
|
|
||||||
BfTypeState typeState;
|
BfTypeState typeState;
|
||||||
typeState.mTypeInstance = mCurTypeInstance;
|
typeState.mType = mCurTypeInstance;
|
||||||
typeState.mCurTypeDef = fieldDef->mDeclaringType;
|
typeState.mCurTypeDef = fieldDef->mDeclaringType;
|
||||||
typeState.mCurFieldDef = fieldDef;
|
typeState.mCurFieldDef = fieldDef;
|
||||||
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
||||||
|
@ -10360,7 +10360,7 @@ BfOperatorInfo* BfModule::GetOperatorInfo(BfTypeInstance* typeInstance, BfOperat
|
||||||
SetAndRestoreValue<BfMethodInstance*> prevMethodInstance(mCurMethodInstance, NULL);
|
SetAndRestoreValue<BfMethodInstance*> prevMethodInstance(mCurMethodInstance, NULL);
|
||||||
|
|
||||||
BfTypeState typeState;
|
BfTypeState typeState;
|
||||||
typeState.mTypeInstance = typeInstance;
|
typeState.mType = typeInstance;
|
||||||
typeState.mCurTypeDef = operatorDef->mDeclaringType;
|
typeState.mCurTypeDef = operatorDef->mDeclaringType;
|
||||||
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
||||||
|
|
||||||
|
@ -22239,7 +22239,7 @@ void BfModule::DoMethodDeclaration(BfMethodDeclaration* methodDeclaration, bool
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BfTypeState typeState;
|
BfTypeState typeState;
|
||||||
typeState.mTypeInstance = mCurTypeInstance;
|
typeState.mType = mCurTypeInstance;
|
||||||
typeState.mCurTypeDef = methodDef->mDeclaringType;
|
typeState.mCurTypeDef = methodDef->mDeclaringType;
|
||||||
//typeState.mCurMethodDef = methodDef;
|
//typeState.mCurMethodDef = methodDef;
|
||||||
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
||||||
|
|
|
@ -60,7 +60,7 @@ BfGenericExtensionEntry* BfModule::BuildGenericExtensionInfo(BfTypeInstance* gen
|
||||||
|
|
||||||
BfTypeState typeState;
|
BfTypeState typeState;
|
||||||
typeState.mPrevState = mContext->mCurTypeState;
|
typeState.mPrevState = mContext->mCurTypeState;
|
||||||
typeState.mTypeInstance = genericTypeInst;
|
typeState.mType = genericTypeInst;
|
||||||
typeState.mCurTypeDef = partialTypeDef;
|
typeState.mCurTypeDef = partialTypeDef;
|
||||||
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ bool BfModule::InitGenericParams(BfType* resolvedTypeRef)
|
||||||
BfTypeState typeState;
|
BfTypeState typeState;
|
||||||
typeState.mPrevState = mContext->mCurTypeState;
|
typeState.mPrevState = mContext->mCurTypeState;
|
||||||
typeState.mResolveKind = BfTypeState::ResolveKind_BuildingGenericParams;
|
typeState.mResolveKind = BfTypeState::ResolveKind_BuildingGenericParams;
|
||||||
typeState.mTypeInstance = resolvedTypeRef->ToTypeInstance();
|
typeState.mType = resolvedTypeRef;
|
||||||
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
||||||
|
|
||||||
BF_ASSERT(mCurMethodInstance == NULL);
|
BF_ASSERT(mCurMethodInstance == NULL);
|
||||||
|
@ -162,7 +162,7 @@ bool BfModule::FinishGenericParams(BfType* resolvedTypeRef)
|
||||||
BfTypeState typeState;
|
BfTypeState typeState;
|
||||||
typeState.mPrevState = mContext->mCurTypeState;
|
typeState.mPrevState = mContext->mCurTypeState;
|
||||||
typeState.mResolveKind = BfTypeState::ResolveKind_BuildingGenericParams;
|
typeState.mResolveKind = BfTypeState::ResolveKind_BuildingGenericParams;
|
||||||
typeState.mTypeInstance = resolvedTypeRef->ToTypeInstance();
|
typeState.mType = resolvedTypeRef;
|
||||||
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
||||||
Array<BfTypeReference*> deferredResolveTypes;
|
Array<BfTypeReference*> deferredResolveTypes;
|
||||||
|
|
||||||
|
@ -925,11 +925,12 @@ bool BfModule::CheckCircularDataError()
|
||||||
{
|
{
|
||||||
if (checkTypeState->mPopulateType == BfPopulateType_Declaration)
|
if (checkTypeState->mPopulateType == BfPopulateType_Declaration)
|
||||||
return hadError;
|
return hadError;
|
||||||
if ((checkIdx > 0) && (checkTypeState->mCurBaseTypeRef == NULL) && (checkTypeState->mCurAttributeTypeRef == NULL) && (checkTypeState->mCurFieldDef == NULL))
|
if ((checkIdx > 0) && (checkTypeState->mCurBaseTypeRef == NULL) && (checkTypeState->mCurAttributeTypeRef == NULL) && (checkTypeState->mCurFieldDef == NULL) &&
|
||||||
|
((checkTypeState->mType == NULL) || (checkTypeState->mType->IsTypeInstance())))
|
||||||
return hadError;
|
return hadError;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((checkTypeState->mTypeInstance == mCurTypeInstance) && (checkIdx > 0))
|
if ((checkTypeState->mType == mCurTypeInstance) && (checkIdx > 0))
|
||||||
break;
|
break;
|
||||||
checkTypeState = checkTypeState->mPrevState;
|
checkTypeState = checkTypeState->mPrevState;
|
||||||
checkIdx++;
|
checkIdx++;
|
||||||
|
@ -949,7 +950,8 @@ bool BfModule::CheckCircularDataError()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((checkTypeState->mCurAttributeTypeRef == NULL) && (checkTypeState->mCurBaseTypeRef == NULL) && (checkTypeState->mCurFieldDef == NULL) )
|
if ((checkTypeState->mCurAttributeTypeRef == NULL) && (checkTypeState->mCurBaseTypeRef == NULL) && (checkTypeState->mCurFieldDef == NULL) &&
|
||||||
|
((checkTypeState->mType == NULL) || (checkTypeState->mType->IsTypeInstance())))
|
||||||
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.
|
||||||
|
@ -964,21 +966,27 @@ bool BfModule::CheckCircularDataError()
|
||||||
{
|
{
|
||||||
Fail(StrFormat("Base type '%s' causes a data cycle", BfTypeUtils::TypeToString(checkTypeState->mCurBaseTypeRef).c_str()), checkTypeState->mCurBaseTypeRef, true);
|
Fail(StrFormat("Base type '%s' causes a data cycle", BfTypeUtils::TypeToString(checkTypeState->mCurBaseTypeRef).c_str()), checkTypeState->mCurBaseTypeRef, true);
|
||||||
}
|
}
|
||||||
else if (checkTypeState->mCurFieldDef->mFieldDeclaration != NULL)
|
else if ((checkTypeState->mCurFieldDef != NULL) && (checkTypeState->mCurFieldDef->mFieldDeclaration != NULL))
|
||||||
{
|
{
|
||||||
Fail(StrFormat("Field '%s.%s' causes a data cycle", TypeToString(checkTypeState->mTypeInstance).c_str(), checkTypeState->mCurFieldDef->mName.c_str()),
|
Fail(StrFormat("Field '%s.%s' causes a data cycle", TypeToString(checkTypeState->mType).c_str(), checkTypeState->mCurFieldDef->mName.c_str()),
|
||||||
checkTypeState->mCurFieldDef->mFieldDeclaration->mTypeRef, true);
|
checkTypeState->mCurFieldDef->mFieldDeclaration->mTypeRef, true);
|
||||||
}
|
}
|
||||||
|
else if (checkTypeState->mCurFieldDef != NULL)
|
||||||
|
{
|
||||||
|
Fail(StrFormat("Field '%s.%s' causes a data cycle", TypeToString(checkTypeState->mType).c_str(), checkTypeState->mCurFieldDef->mName.c_str()));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Fail(StrFormat("Field '%s.%s' causes a data cycle", TypeToString(checkTypeState->mTypeInstance).c_str(), checkTypeState->mCurFieldDef->mName.c_str()));
|
Fail(StrFormat("Type '%s' causes a data cycle", TypeToString(checkTypeState->mType).c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto module = GetModuleFor(checkTypeState->mTypeInstance);
|
auto typeInstance = checkTypeState->mType->ToTypeInstance();
|
||||||
|
|
||||||
|
auto module = GetModuleFor(checkTypeState->mType);
|
||||||
if (module != NULL)
|
if (module != NULL)
|
||||||
module->TypeFailed(checkTypeState->mTypeInstance);
|
module->TypeFailed(typeInstance);
|
||||||
else
|
else if (typeInstance != NULL)
|
||||||
checkTypeState->mTypeInstance->mTypeFailed = true;
|
typeInstance->mTypeFailed = true;
|
||||||
|
|
||||||
checkTypeState = checkTypeState->mPrevState;
|
checkTypeState = checkTypeState->mPrevState;
|
||||||
}
|
}
|
||||||
|
@ -1189,9 +1197,10 @@ void BfModule::PopulateType(BfType* resolvedTypeRef, BfPopulateType populateType
|
||||||
if (elementType->IsValueType())
|
if (elementType->IsValueType())
|
||||||
{
|
{
|
||||||
resolvedTypeRef->mDefineState = BfTypeDefineState_ResolvingBaseType;
|
resolvedTypeRef->mDefineState = BfTypeDefineState_ResolvingBaseType;
|
||||||
BfTypeState typeState(mCurTypeInstance, mContext->mCurTypeState);
|
BfTypeState typeState(arrayType, mContext->mCurTypeState);
|
||||||
typeState.mPopulateType = populateType;
|
typeState.mPopulateType = BfPopulateType_Data;
|
||||||
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
||||||
|
SetAndRestoreValue<BfTypeInstance*> prevTypeInstance(mCurTypeInstance, NULL);
|
||||||
|
|
||||||
if (!CheckCircularDataError())
|
if (!CheckCircularDataError())
|
||||||
{
|
{
|
||||||
|
@ -3509,7 +3518,7 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
||||||
BfTypeState typeState;
|
BfTypeState typeState;
|
||||||
typeState.mPrevState = mContext->mCurTypeState;
|
typeState.mPrevState = mContext->mCurTypeState;
|
||||||
typeState.mResolveKind = BfTypeState::ResolveKind_Attributes;
|
typeState.mResolveKind = BfTypeState::ResolveKind_Attributes;
|
||||||
typeState.mTypeInstance = typeInstance;
|
typeState.mType = typeInstance;
|
||||||
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
||||||
|
|
||||||
// This allows us to avoid reentrancy when checking for inner types
|
// This allows us to avoid reentrancy when checking for inner types
|
||||||
|
@ -3969,7 +3978,7 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
||||||
typeState.mPrevState = mContext->mCurTypeState;
|
typeState.mPrevState = mContext->mCurTypeState;
|
||||||
typeState.mCurTypeDef = propDef->mDeclaringType;
|
typeState.mCurTypeDef = propDef->mDeclaringType;
|
||||||
typeState.mCurFieldDef = propDef;
|
typeState.mCurFieldDef = propDef;
|
||||||
typeState.mTypeInstance = typeInstance;
|
typeState.mType = typeInstance;
|
||||||
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
||||||
|
|
||||||
BfAttributeTargets target = BfAttributeTargets_Property;
|
BfAttributeTargets target = BfAttributeTargets_Property;
|
||||||
|
@ -4078,7 +4087,7 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
||||||
typeState.mPrevState = mContext->mCurTypeState;
|
typeState.mPrevState = mContext->mCurTypeState;
|
||||||
typeState.mCurFieldDef = fieldDef;
|
typeState.mCurFieldDef = fieldDef;
|
||||||
typeState.mCurTypeDef = fieldDef->mDeclaringType;
|
typeState.mCurTypeDef = fieldDef->mDeclaringType;
|
||||||
typeState.mTypeInstance = typeInstance;
|
typeState.mType = typeInstance;
|
||||||
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
||||||
|
|
||||||
fieldInstance->mCustomAttributes = GetCustomAttributes(fieldDef->mFieldDeclaration->mAttributes, fieldDef->mIsStatic ? BfAttributeTargets_StaticField : BfAttributeTargets_Field);
|
fieldInstance->mCustomAttributes = GetCustomAttributes(fieldDef->mFieldDeclaration->mAttributes, fieldDef->mIsStatic ? BfAttributeTargets_StaticField : BfAttributeTargets_Field);
|
||||||
|
@ -4584,7 +4593,7 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
||||||
BfTypeState typeState;
|
BfTypeState typeState;
|
||||||
typeState.mPrevState = mContext->mCurTypeState;
|
typeState.mPrevState = mContext->mCurTypeState;
|
||||||
typeState.mCurTypeDef = propDef->mDeclaringType;
|
typeState.mCurTypeDef = propDef->mDeclaringType;
|
||||||
typeState.mTypeInstance = typeInstance;
|
typeState.mType = typeInstance;
|
||||||
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
||||||
ResolveTypeRef(propDef->mTypeRef, BfPopulateType_Identity, BfResolveTypeRefFlag_AllowRef);
|
ResolveTypeRef(propDef->mTypeRef, BfPopulateType_Identity, BfResolveTypeRefFlag_AllowRef);
|
||||||
}
|
}
|
||||||
|
@ -6937,7 +6946,7 @@ BfTypeInstance* BfModule::GetBaseType(BfTypeInstance* typeInst)
|
||||||
auto checkTypeState = mContext->mCurTypeState;
|
auto checkTypeState = mContext->mCurTypeState;
|
||||||
while (checkTypeState != NULL)
|
while (checkTypeState != NULL)
|
||||||
{
|
{
|
||||||
if (checkTypeState->mTypeInstance == typeInst)
|
if (checkTypeState->mType == typeInst)
|
||||||
return NULL;
|
return NULL;
|
||||||
checkTypeState = checkTypeState->mPrevState;
|
checkTypeState = checkTypeState->mPrevState;
|
||||||
}
|
}
|
||||||
|
@ -8125,7 +8134,7 @@ bool BfModule::ResolveTypeResult_Validate(BfTypeReference* typeRef, BfType* reso
|
||||||
if (curGenericTypeInstance->mGenericTypeInfo->mHadValidateErrors)
|
if (curGenericTypeInstance->mGenericTypeInfo->mHadValidateErrors)
|
||||||
doValidate = false;
|
doValidate = false;
|
||||||
}
|
}
|
||||||
if ((mContext->mCurTypeState != NULL) && (mContext->mCurTypeState->mCurBaseTypeRef != NULL) && (!mContext->mCurTypeState->mTypeInstance->IsTypeAlias())) // We validate constraints for base types later
|
if ((mContext->mCurTypeState != NULL) && (mContext->mCurTypeState->mCurBaseTypeRef != NULL) && (!mContext->mCurTypeState->mType->IsTypeAlias())) // We validate constraints for base types later
|
||||||
doValidate = false;
|
doValidate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8564,9 +8573,9 @@ BfTypeDef* BfModule::FindTypeDefRaw(const BfAtomComposite& findName, int numGene
|
||||||
if (mContext->mCurTypeState != NULL)
|
if (mContext->mCurTypeState != NULL)
|
||||||
{
|
{
|
||||||
if (mContext->mCurTypeState->mCurBaseTypeRef != NULL)
|
if (mContext->mCurTypeState->mCurBaseTypeRef != NULL)
|
||||||
skipCheckBaseType = mContext->mCurTypeState->mTypeInstance;
|
skipCheckBaseType = mContext->mCurTypeState->mType->ToTypeInstance();
|
||||||
if (mContext->mCurTypeState->mResolveKind == BfTypeState::ResolveKind_BuildingGenericParams)
|
if (mContext->mCurTypeState->mResolveKind == BfTypeState::ResolveKind_BuildingGenericParams)
|
||||||
skipCheckBaseType = mContext->mCurTypeState->mTypeInstance;
|
skipCheckBaseType = mContext->mCurTypeState->mType->ToTypeInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
BfTypeDefLookupContext lookupCtx;
|
BfTypeDefLookupContext lookupCtx;
|
||||||
|
@ -13119,7 +13128,7 @@ bool BfModule::TypeIsSubTypeOf(BfTypeInstance* srcType, BfTypeInstance* wantType
|
||||||
auto typeState = mContext->mCurTypeState;
|
auto typeState = mContext->mCurTypeState;
|
||||||
while (typeState != NULL)
|
while (typeState != NULL)
|
||||||
{
|
{
|
||||||
if ((typeState->mTypeInstance == srcType) && (typeState->mCurBaseType != NULL))
|
if ((typeState->mType == srcType) && (typeState->mCurBaseType != NULL))
|
||||||
{
|
{
|
||||||
return TypeIsSubTypeOf(typeState->mCurBaseType, wantType, checkAccessibility);
|
return TypeIsSubTypeOf(typeState->mCurBaseType, wantType, checkAccessibility);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue