1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 04:22:20 +02:00

Removed result from type population. Fixed early return.

This commit is contained in:
Brian Fiete 2020-08-12 07:42:13 -07:00
parent 5074b3e2ae
commit 14e9f9aa53
2 changed files with 70 additions and 75 deletions

View file

@ -1588,7 +1588,7 @@ public:
bool CheckConstraintState(BfAstNode* refNode); bool CheckConstraintState(BfAstNode* refNode);
bool ShouldAllowMultipleDefinitions(BfTypeInstance* typeInst, BfTypeDef* firstDeclaringTypeDef, BfTypeDef* secondDeclaringTypeDef); bool ShouldAllowMultipleDefinitions(BfTypeInstance* typeInst, BfTypeDef* firstDeclaringTypeDef, BfTypeDef* secondDeclaringTypeDef);
void CheckInjectNewRevision(BfTypeInstance* typeInstance); void CheckInjectNewRevision(BfTypeInstance* typeInstance);
bool InitType(BfType* resolvedTypeRef, BfPopulateType populateType); void InitType(BfType* resolvedTypeRef, BfPopulateType populateType);
BfProtection FixProtection(BfProtection protection, BfProject* defProject); BfProtection FixProtection(BfProtection protection, BfProject* defProject);
bool CheckAccessMemberProtection(BfProtection protection, BfType* memberType); bool CheckAccessMemberProtection(BfProtection protection, BfType* memberType);
bool CheckDefineMemberProtection(BfProtection protection, BfType* memberType); bool CheckDefineMemberProtection(BfProtection protection, BfType* memberType);
@ -1603,14 +1603,14 @@ public:
void AddFailType(BfTypeInstance* typeInstance); void AddFailType(BfTypeInstance* typeInstance);
void MarkDerivedDirty(BfTypeInstance* typeInst); void MarkDerivedDirty(BfTypeInstance* typeInst);
void CheckAddFailType(); void CheckAddFailType();
bool PopulateType(BfType* resolvedTypeRef, BfPopulateType populateType = BfPopulateType_Data); void PopulateType(BfType* resolvedTypeRef, BfPopulateType populateType = BfPopulateType_Data);
BfTypeOptions* GetTypeOptions(BfTypeDef* typeDef); BfTypeOptions* GetTypeOptions(BfTypeDef* typeDef);
bool ApplyTypeOptionMethodFilters(bool includeMethod, BfMethodDef* methodDef, BfTypeOptions* typeOptions); bool ApplyTypeOptionMethodFilters(bool includeMethod, BfMethodDef* methodDef, BfTypeOptions* typeOptions);
int GenerateTypeOptions(BfCustomAttributes* customAttributes, BfTypeInstance* typeInstance, bool checkTypeName); int GenerateTypeOptions(BfCustomAttributes* customAttributes, BfTypeInstance* typeInstance, bool checkTypeName);
void SetTypeOptions(BfTypeInstance* typeInstance); void SetTypeOptions(BfTypeInstance* typeInstance);
BfModuleOptions GetModuleOptions(); BfModuleOptions GetModuleOptions();
BfCheckedKind GetDefaultCheckedKind(); BfCheckedKind GetDefaultCheckedKind();
bool DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateType = BfPopulateType_Data); void DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateType = BfPopulateType_Data);
static BfModule* GetModuleFor(BfType* type); static BfModule* GetModuleFor(BfType* type);
void DoTypeInstanceMethodProcessing(BfTypeInstance* typeInstance); void DoTypeInstanceMethodProcessing(BfTypeInstance* typeInstance);
void RebuildMethods(BfTypeInstance* typeInstance); void RebuildMethods(BfTypeInstance* typeInstance);

View file

@ -463,7 +463,7 @@ void BfModule::CheckInjectNewRevision(BfTypeInstance* typeInstance)
} }
} }
bool BfModule::InitType(BfType* resolvedTypeRef, BfPopulateType populateType) void BfModule::InitType(BfType* resolvedTypeRef, BfPopulateType populateType)
{ {
BP_ZONE("BfModule::InitType"); BP_ZONE("BfModule::InitType");
@ -567,7 +567,7 @@ bool BfModule::InitType(BfType* resolvedTypeRef, BfPopulateType populateType)
// Do it here so the location we attempted to specialize this type will throw the failure if there is one // Do it here so the location we attempted to specialize this type will throw the failure if there is one
if (!BuildGenericParams(resolvedTypeRef)) if (!BuildGenericParams(resolvedTypeRef))
return false; return;
} }
BfLogSysM("%p InitType: %s Type: %p TypeDef: %p Revision:%d\n", mContext, TypeToString(resolvedTypeRef).c_str(), resolvedTypeRef, (typeInst != NULL) ? typeInst->mTypeDef : NULL, mCompiler->mRevision); BfLogSysM("%p InitType: %s Type: %p TypeDef: %p Revision:%d\n", mContext, TypeToString(resolvedTypeRef).c_str(), resolvedTypeRef, (typeInst != NULL) ? typeInst->mTypeDef : NULL, mCompiler->mRevision);
@ -582,7 +582,7 @@ bool BfModule::InitType(BfType* resolvedTypeRef, BfPopulateType populateType)
mCompiler->mStats.mTypesQueued++; mCompiler->mStats.mTypesQueued++;
mCompiler->UpdateCompletion(); mCompiler->UpdateCompletion();
} }
return PopulateType(resolvedTypeRef, populateType); PopulateType(resolvedTypeRef, populateType);
} }
void BfModule::AddFieldDependency(BfTypeInstance* typeInstance, BfFieldInstance* fieldInstance, BfType* fieldType) void BfModule::AddFieldDependency(BfTypeInstance* typeInstance, BfFieldInstance* fieldInstance, BfType* fieldType)
@ -878,10 +878,10 @@ bool BfModule::CheckCircularDataError()
} }
} }
bool BfModule::PopulateType(BfType* resolvedTypeRef, BfPopulateType populateType) void BfModule::PopulateType(BfType* resolvedTypeRef, BfPopulateType populateType)
{ {
if ((populateType == BfPopulateType_Declaration) && (resolvedTypeRef->mDefineState >= BfTypeDefineState_Declared)) if ((populateType == BfPopulateType_Declaration) && (resolvedTypeRef->mDefineState >= BfTypeDefineState_Declared))
return true; return;
// Are we "demanding" to reify a type that is currently resolve-only? // Are we "demanding" to reify a type that is currently resolve-only?
if ((mIsReified) && (populateType >= BfPopulateType_Declaration)) if ((mIsReified) && (populateType >= BfPopulateType_Declaration))
@ -935,7 +935,7 @@ bool BfModule::PopulateType(BfType* resolvedTypeRef, BfPopulateType populateType
} }
if (!resolvedTypeRef->IsIncomplete()) if (!resolvedTypeRef->IsIncomplete())
return true; return;
auto typeInstance = resolvedTypeRef->ToTypeInstance(); auto typeInstance = resolvedTypeRef->ToTypeInstance();
CheckInjectNewRevision(typeInstance); CheckInjectNewRevision(typeInstance);
@ -1002,7 +1002,7 @@ bool BfModule::PopulateType(BfType* resolvedTypeRef, BfPopulateType populateType
resolvedTypeRef->mDefineState = BfTypeDefineState_Defined; resolvedTypeRef->mDefineState = BfTypeDefineState_Defined;
} }
refType->mSize = refType->mAlign = mSystem->mPtrSize; refType->mSize = refType->mAlign = mSystem->mPtrSize;
return true; return;
} }
if (resolvedTypeRef->IsTypeAlias()) if (resolvedTypeRef->IsTypeAlias())
@ -1126,7 +1126,7 @@ bool BfModule::PopulateType(BfType* resolvedTypeRef, BfPopulateType populateType
resolvedTypeRef->mRebuildFlags = BfTypeRebuildFlag_None; resolvedTypeRef->mRebuildFlags = BfTypeRebuildFlag_None;
bool isValueless = arrayType->IsValuelessType(); bool isValueless = arrayType->IsValuelessType();
return true; return;
} }
if (isNew) if (isNew)
@ -1135,12 +1135,12 @@ bool BfModule::PopulateType(BfType* resolvedTypeRef, BfPopulateType populateType
if (typeInstance != NULL) if (typeInstance != NULL)
{ {
if ((populateType == BfPopulateType_Data) && (typeInstance->mNeedsMethodProcessing)) if ((populateType == BfPopulateType_Data) && (typeInstance->mNeedsMethodProcessing))
return true; return;
typeDef = typeInstance->mTypeDef; typeDef = typeInstance->mTypeDef;
} }
if (resolvedTypeRef->IsMethodRef()) if (resolvedTypeRef->IsMethodRef())
return true; return;
if (resolvedTypeRef->IsPointer()) if (resolvedTypeRef->IsPointer())
{ {
@ -1149,7 +1149,7 @@ bool BfModule::PopulateType(BfType* resolvedTypeRef, BfPopulateType populateType
PopulateType(pointerType->mElementType, BfPopulateType_Declaration); PopulateType(pointerType->mElementType, BfPopulateType_Declaration);
pointerType->mSize = pointerType->mAlign = mSystem->mPtrSize; pointerType->mSize = pointerType->mAlign = mSystem->mPtrSize;
resolvedTypeRef->mDefineState = BfTypeDefineState_Defined; resolvedTypeRef->mDefineState = BfTypeDefineState_Defined;
return true; return;
} }
if (resolvedTypeRef->IsGenericParam()) if (resolvedTypeRef->IsGenericParam())
@ -1159,7 +1159,7 @@ bool BfModule::PopulateType(BfType* resolvedTypeRef, BfPopulateType populateType
genericParamType->mSize = mContext->mBfObjectType->mSize; genericParamType->mSize = mContext->mBfObjectType->mSize;
genericParamType->mAlign = mContext->mBfObjectType->mAlign; genericParamType->mAlign = mContext->mBfObjectType->mAlign;
resolvedTypeRef->mDefineState = BfTypeDefineState_Defined; resolvedTypeRef->mDefineState = BfTypeDefineState_Defined;
return true; return;
} }
if (resolvedTypeRef->IsModifiedTypeType()) if (resolvedTypeRef->IsModifiedTypeType())
@ -1169,7 +1169,7 @@ bool BfModule::PopulateType(BfType* resolvedTypeRef, BfPopulateType populateType
resolvedTypeRef->mSize = mContext->mBfObjectType->mSize; resolvedTypeRef->mSize = mContext->mBfObjectType->mSize;
resolvedTypeRef->mAlign = mContext->mBfObjectType->mAlign; resolvedTypeRef->mAlign = mContext->mBfObjectType->mAlign;
resolvedTypeRef->mDefineState = BfTypeDefineState_Defined; resolvedTypeRef->mDefineState = BfTypeDefineState_Defined;
return true; return;
} }
if (resolvedTypeRef->IsConcreteInterfaceType()) if (resolvedTypeRef->IsConcreteInterfaceType())
@ -1179,7 +1179,7 @@ bool BfModule::PopulateType(BfType* resolvedTypeRef, BfPopulateType populateType
resolvedTypeRef->mSize = concreteInterfaceType->mInterface->mSize; resolvedTypeRef->mSize = concreteInterfaceType->mInterface->mSize;
resolvedTypeRef->mAlign = concreteInterfaceType->mInterface->mAlign; resolvedTypeRef->mAlign = concreteInterfaceType->mInterface->mAlign;
resolvedTypeRef->mDefineState = BfTypeDefineState_Defined; resolvedTypeRef->mDefineState = BfTypeDefineState_Defined;
return true; return;
} }
if (resolvedTypeRef->IsConstExprValue()) if (resolvedTypeRef->IsConstExprValue())
@ -1187,13 +1187,13 @@ bool BfModule::PopulateType(BfType* resolvedTypeRef, BfPopulateType populateType
resolvedTypeRef->mSize = 0; resolvedTypeRef->mSize = 0;
resolvedTypeRef->mAlign = 0; resolvedTypeRef->mAlign = 0;
resolvedTypeRef->mDefineState = BfTypeDefineState_Defined; resolvedTypeRef->mDefineState = BfTypeDefineState_Defined;
return true; return;
} }
// The autocomplete pass doesn't need to do the method processing, allow type to be (partially) incomplete // The autocomplete pass doesn't need to do the method processing, allow type to be (partially) incomplete
if ((mCompiler->mResolvePassData != NULL) && (mCompiler->mResolvePassData->mAutoComplete != NULL) && if ((mCompiler->mResolvePassData != NULL) && (mCompiler->mResolvePassData->mAutoComplete != NULL) &&
(typeInstance != NULL) && (typeInstance->mNeedsMethodProcessing) && (!typeInstance->IsDelegate())) (typeInstance != NULL) && (typeInstance->mNeedsMethodProcessing) && (!typeInstance->IsDelegate()))
return true; return;
BfPrimitiveType* primitiveType = NULL; BfPrimitiveType* primitiveType = NULL;
if (typeInstance == NULL) if (typeInstance == NULL)
@ -1212,7 +1212,7 @@ bool BfModule::PopulateType(BfType* resolvedTypeRef, BfPopulateType populateType
case BfTypeCode_None: case BfTypeCode_None:
primitiveType->mSize = primitiveType->mAlign = 0; primitiveType->mSize = primitiveType->mAlign = 0;
resolvedTypeRef->mDefineState = BfTypeDefineState_Defined; resolvedTypeRef->mDefineState = BfTypeDefineState_Defined;
return true; return;
case BfTypeCode_Self: case BfTypeCode_Self:
case BfTypeCode_Dot: case BfTypeCode_Dot:
case BfTypeCode_Var: case BfTypeCode_Var:
@ -1223,38 +1223,38 @@ bool BfModule::PopulateType(BfType* resolvedTypeRef, BfPopulateType populateType
primitiveType->mAlign = objType->mAlign; primitiveType->mAlign = objType->mAlign;
resolvedTypeRef->mDefineState = BfTypeDefineState_Defined; resolvedTypeRef->mDefineState = BfTypeDefineState_Defined;
} }
return true; return;
case BfTypeCode_NullPtr: case BfTypeCode_NullPtr:
primitiveType->mSize = primitiveType->mAlign = mSystem->mPtrSize; primitiveType->mSize = primitiveType->mAlign = mSystem->mPtrSize;
primitiveType->mDefineState = BfTypeDefineState_Defined; primitiveType->mDefineState = BfTypeDefineState_Defined;
return true; return;
case BfTypeCode_Boolean: case BfTypeCode_Boolean:
PRIMITIVE_TYPE("bool", Int1, 1, DW_ATE_boolean); PRIMITIVE_TYPE("bool", Int1, 1, DW_ATE_boolean);
return true; return;
case BfTypeCode_Int8: case BfTypeCode_Int8:
PRIMITIVE_TYPE("sbyte", Int8, 1, DW_ATE_signed); PRIMITIVE_TYPE("sbyte", Int8, 1, DW_ATE_signed);
return true; return;
case BfTypeCode_UInt8: case BfTypeCode_UInt8:
PRIMITIVE_TYPE("byte", Int8, 1, DW_ATE_unsigned); PRIMITIVE_TYPE("byte", Int8, 1, DW_ATE_unsigned);
return true; return;
case BfTypeCode_Int16: case BfTypeCode_Int16:
PRIMITIVE_TYPE("short", Int16, 2, DW_ATE_signed); PRIMITIVE_TYPE("short", Int16, 2, DW_ATE_signed);
return true; return;
case BfTypeCode_UInt16: case BfTypeCode_UInt16:
PRIMITIVE_TYPE("ushort", Int16, 2, DW_ATE_unsigned); PRIMITIVE_TYPE("ushort", Int16, 2, DW_ATE_unsigned);
return true; return;
case BfTypeCode_Int32: case BfTypeCode_Int32:
PRIMITIVE_TYPE("int", Int32, 4, DW_ATE_signed); PRIMITIVE_TYPE("int", Int32, 4, DW_ATE_signed);
return true; return;
case BfTypeCode_UInt32: case BfTypeCode_UInt32:
PRIMITIVE_TYPE("uint", Int32, 4, DW_ATE_unsigned); PRIMITIVE_TYPE("uint", Int32, 4, DW_ATE_unsigned);
return true; return;
case BfTypeCode_Int64: case BfTypeCode_Int64:
PRIMITIVE_TYPE("long", Int64, 8, DW_ATE_signed); PRIMITIVE_TYPE("long", Int64, 8, DW_ATE_signed);
return true; return;
case BfTypeCode_UInt64: case BfTypeCode_UInt64:
PRIMITIVE_TYPE("ulong", Int64, 8, DW_ATE_unsigned); PRIMITIVE_TYPE("ulong", Int64, 8, DW_ATE_unsigned);
return true; return;
case BfTypeCode_IntPtr: case BfTypeCode_IntPtr:
if (mSystem->mPtrSize == 4) if (mSystem->mPtrSize == 4)
{ {
@ -1264,7 +1264,7 @@ bool BfModule::PopulateType(BfType* resolvedTypeRef, BfPopulateType populateType
{ {
PRIMITIVE_TYPE("intptr", Int64, 8, DW_ATE_signed); PRIMITIVE_TYPE("intptr", Int64, 8, DW_ATE_signed);
} }
return true; return;
case BfTypeCode_UIntPtr: case BfTypeCode_UIntPtr:
if (mSystem->mPtrSize == 4) if (mSystem->mPtrSize == 4)
{ {
@ -1274,25 +1274,25 @@ bool BfModule::PopulateType(BfType* resolvedTypeRef, BfPopulateType populateType
{ {
PRIMITIVE_TYPE("uintptr", Int64, 8, DW_ATE_unsigned); PRIMITIVE_TYPE("uintptr", Int64, 8, DW_ATE_unsigned);
} }
return true; return;
case BfTypeCode_IntUnknown: case BfTypeCode_IntUnknown:
case BfTypeCode_UIntUnknown: case BfTypeCode_UIntUnknown:
return true; return;
case BfTypeCode_Char8: case BfTypeCode_Char8:
PRIMITIVE_TYPE("char8", Int8, 1, DW_ATE_unsigned_char); PRIMITIVE_TYPE("char8", Int8, 1, DW_ATE_unsigned_char);
return true; return;
case BfTypeCode_Char16: case BfTypeCode_Char16:
PRIMITIVE_TYPE("char16", Int16, 2, DW_ATE_unsigned_char); PRIMITIVE_TYPE("char16", Int16, 2, DW_ATE_unsigned_char);
return true; return;
case BfTypeCode_Char32: case BfTypeCode_Char32:
PRIMITIVE_TYPE("char32", Int32, 4, DW_ATE_unsigned_char); PRIMITIVE_TYPE("char32", Int32, 4, DW_ATE_unsigned_char);
return true; return;
case BfTypeCode_Float: case BfTypeCode_Float:
PRIMITIVE_TYPE("float", Float, 4, DW_ATE_float); PRIMITIVE_TYPE("float", Float, 4, DW_ATE_float);
return true; return;
case BfTypeCode_Double: case BfTypeCode_Double:
PRIMITIVE_TYPE("double", Double, 8, DW_ATE_float); PRIMITIVE_TYPE("double", Double, 8, DW_ATE_float);
return true; return;
case BfTypeCode_Object: case BfTypeCode_Object:
case BfTypeCode_Struct: case BfTypeCode_Struct:
case BfTypeCode_Interface: case BfTypeCode_Interface:
@ -1306,7 +1306,7 @@ bool BfModule::PopulateType(BfType* resolvedTypeRef, BfPopulateType populateType
default: default:
//NotImpl(resolvedTypeRef->mTypeRef); //NotImpl(resolvedTypeRef->mTypeRef);
BFMODULE_FATAL(this, "Invalid type"); BFMODULE_FATAL(this, "Invalid type");
return false; return;
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@ -1333,16 +1333,15 @@ bool BfModule::PopulateType(BfType* resolvedTypeRef, BfPopulateType populateType
} }
if (typeInstance == NULL) if (typeInstance == NULL)
return true; return;
if (typeInstance->mModule == NULL) if (typeInstance->mModule == NULL)
{ {
BF_ASSERT(typeInstance->mTypeFailed); BF_ASSERT(typeInstance->mTypeFailed);
return false; return;
} }
auto result = typeInstance->mModule->DoPopulateType(typeInstance, populateType); typeInstance->mModule->DoPopulateType(typeInstance, populateType);
return result;
} }
BfTypeOptions* BfModule::GetTypeOptions(BfTypeDef* typeDef) BfTypeOptions* BfModule::GetTypeOptions(BfTypeDef* typeDef)
@ -1795,8 +1794,8 @@ void BfModule::SetTypeOptions(BfTypeInstance* typeInstance)
typeInstance->mTypeOptionsIdx = GenerateTypeOptions(typeInstance->mCustomAttributes, typeInstance, true); typeInstance->mTypeOptionsIdx = GenerateTypeOptions(typeInstance->mCustomAttributes, typeInstance, true);
} }
bool BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateType) void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateType)
{ {
auto typeInstance = resolvedTypeRef->ToTypeInstance(); auto typeInstance = resolvedTypeRef->ToTypeInstance();
auto typeDef = typeInstance->mTypeDef; auto typeDef = typeInstance->mTypeDef;
@ -1810,7 +1809,7 @@ bool BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
if (!typeInstance->mBaseType->IsIncomplete()) if (!typeInstance->mBaseType->IsIncomplete())
typeInstance->mBaseTypeMayBeIncomplete = false; typeInstance->mBaseTypeMayBeIncomplete = false;
if (!typeInstance->mTypeIncomplete) if (!typeInstance->mTypeIncomplete)
return true; return;
} }
typeInstance->mBaseTypeMayBeIncomplete = false; typeInstance->mBaseTypeMayBeIncomplete = false;
@ -1826,7 +1825,7 @@ bool BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
canDoMethodProcessing = true; canDoMethodProcessing = true;
if (typeInstance->mResolvingConstField) if (typeInstance->mResolvingConstField)
return !typeInstance->mTypeFailed; return;
auto _CheckTypeDone = [&]() auto _CheckTypeDone = [&]()
{ {
@ -1841,11 +1840,11 @@ bool BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
}; };
if (_CheckTypeDone()) if (_CheckTypeDone())
return true; return;
// Partial population break out point // Partial population break out point
if ((populateType >= BfPopulateType_Identity) && (populateType <= BfPopulateType_IdentityNoRemapAlias)) if ((populateType >= BfPopulateType_Identity) && (populateType <= BfPopulateType_IdentityNoRemapAlias))
return true; return;
if (!resolvedTypeRef->IsValueType()) if (!resolvedTypeRef->IsValueType())
{ {
@ -1882,11 +1881,11 @@ bool BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
{ {
typeInstance->mTypeIncomplete = false; typeInstance->mTypeIncomplete = false;
resolvedTypeRef->mDefineState = BfTypeDefineState_DefinedAndMethodsSlotted; resolvedTypeRef->mDefineState = BfTypeDefineState_DefinedAndMethodsSlotted;
return true; return;
} }
if (_CheckTypeDone()) if (_CheckTypeDone())
return true; return;
// Don't do TypeToString until down here. Otherwise we can infinitely loop on BuildGenericParams // Don't do TypeToString until down here. Otherwise we can infinitely loop on BuildGenericParams
@ -1903,7 +1902,7 @@ bool BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
if (typeInstance->mIsFinishingType) if (typeInstance->mIsFinishingType)
{ {
// This type already failed // This type already failed
return true; return;
} }
CheckCircularDataError(); CheckCircularDataError();
@ -2115,7 +2114,7 @@ bool BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
} }
if (populateType == BfPopulateType_Declaration) if (populateType == BfPopulateType_Declaration)
{ {
return true; return;
} }
if ((!mCompiler->mIsResolveOnly) && (!typeInstance->mHasBeenInstantiated)) if ((!mCompiler->mIsResolveOnly) && (!typeInstance->mHasBeenInstantiated))
@ -2241,7 +2240,7 @@ bool BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
if (typeInstance->mDefineState >= BfTypeDefineState_Defined) if (typeInstance->mDefineState >= BfTypeDefineState_Defined)
{ {
prevDefineState.CancelRestore(); prevDefineState.CancelRestore();
return true; return;
} }
if (checkType != NULL) if (checkType != NULL)
@ -2447,7 +2446,7 @@ bool BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
if (!typeInstance->IsIncomplete()) if (!typeInstance->IsIncomplete())
{ {
// Re-entry may cause this type to be completed already // Re-entry may cause this type to be completed already
return true; return;
} }
//BfLogSysM("Adding DerivedFrom dependency. Used:%p Using:%p\n", baseType, typeInstance); //BfLogSysM("Adding DerivedFrom dependency. Used:%p Using:%p\n", baseType, typeInstance);
@ -2478,7 +2477,7 @@ bool BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
} }
if (populateType <= BfPopulateType_BaseType) if (populateType <= BfPopulateType_BaseType)
return true; return;
if ((typeInstance->mBaseType != NULL) && (!typeInstance->IsTypedPrimitive())) if ((typeInstance->mBaseType != NULL) && (!typeInstance->IsTypedPrimitive()))
{ {
@ -2540,7 +2539,7 @@ bool BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
} }
if (populateType <= BfPopulateType_Interfaces) if (populateType <= BfPopulateType_Interfaces)
return true; return;
prevSkipTypeProtectionChecks.Restore(); prevSkipTypeProtectionChecks.Restore();
typeInstance->mInstSize = std::max(0, typeInstance->mInstSize); typeInstance->mInstSize = std::max(0, typeInstance->mInstSize);
@ -2781,7 +2780,7 @@ bool BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
if (!resolvedTypeRef->IsIncomplete()) if (!resolvedTypeRef->IsIncomplete())
{ {
// We finished resolving ourselves through a re-entry, so we're actually done here // We finished resolving ourselves through a re-entry, so we're actually done here
return true; return;
} }
for (auto& resolveEntry : deferredVarResolves) for (auto& resolveEntry : deferredVarResolves)
@ -2800,7 +2799,7 @@ bool BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
} }
if (typeInstance->mResolvingConstField) if (typeInstance->mResolvingConstField)
return !typeInstance->mTypeFailed; return;
for (auto& fieldInstanceRef : typeInstance->mFieldInstances) for (auto& fieldInstanceRef : typeInstance->mFieldInstances)
{ {
@ -2852,11 +2851,9 @@ bool BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
} }
} }
if ((!typeInstance->IsIncomplete()) || (typeInstance->mNeedsMethodProcessing)) if (_CheckTypeDone())
{ return;
return !typeInstance->mTypeFailed;
}
BF_ASSERT(mContext->mCurTypeState == &typeState); BF_ASSERT(mContext->mCurTypeState == &typeState);
//BF_ASSERT(!typeInstance->mIsFinishingType); //BF_ASSERT(!typeInstance->mIsFinishingType);
@ -3404,6 +3401,7 @@ bool BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
CheckAddFailType(); CheckAddFailType();
BfLogSysM("Setting mNeedsMethodProcessing on %p\n", typeInstance);
typeInstance->mNeedsMethodProcessing = true; typeInstance->mNeedsMethodProcessing = true;
typeInstance->mIsFinishingType = false; typeInstance->mIsFinishingType = false;
@ -3732,7 +3730,7 @@ bool BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
typeInstance->mHasBeenInstantiated = true; typeInstance->mHasBeenInstantiated = true;
if (populateType == BfPopulateType_Data) if (populateType == BfPopulateType_Data)
return true; return;
disableYield.Release(); disableYield.Release();
prevTypeState.Restore(); prevTypeState.Restore();
@ -3741,9 +3739,7 @@ bool BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
{ {
if (typeInstance->mNeedsMethodProcessing) // May have been handled by GetRawMethodInstanceAtIdx above if (typeInstance->mNeedsMethodProcessing) // May have been handled by GetRawMethodInstanceAtIdx above
DoTypeInstanceMethodProcessing(typeInstance); DoTypeInstanceMethodProcessing(typeInstance);
} }
return true;
} }
void BfModule::DoTypeInstanceMethodProcessing(BfTypeInstance* typeInstance) void BfModule::DoTypeInstanceMethodProcessing(BfTypeInstance* typeInstance)
@ -3879,6 +3875,7 @@ void BfModule::DoTypeInstanceMethodProcessing(BfTypeInstance* typeInstance)
auto isBoxed = typeInstance->IsBoxed(); auto isBoxed = typeInstance->IsBoxed();
BfLogSysM("Setting mTypeIncomplete = false on %p\n", typeInstance);
typeInstance->mNeedsMethodProcessing = false; typeInstance->mNeedsMethodProcessing = false;
typeInstance->mTypeIncomplete = false; typeInstance->mTypeIncomplete = false;
@ -6525,8 +6522,7 @@ BfType* BfModule::ResolveType(BfType* lookupType, BfPopulateType populateType)
} }
resolvedEntry->mValue = lookupType; resolvedEntry->mValue = lookupType;
if (!InitType(lookupType, populateType)) InitType(lookupType, populateType);
return NULL;
return lookupType; return lookupType;
} }
@ -6872,9 +6868,8 @@ BfType* BfModule::ResolveTypeResult(BfTypeReference* typeRef, BfType* resolvedTy
auto populateModule = this; auto populateModule = this;
if ((resolveFlags & BfResolveTypeRefFlag_NoReify) != 0) if ((resolveFlags & BfResolveTypeRefFlag_NoReify) != 0)
populateModule = mContext->mUnreifiedModule; populateModule = mContext->mUnreifiedModule;
bool hadError = false; populateModule->PopulateType(resolvedTypeRef, populateType);
hadError = !populateModule->PopulateType(resolvedTypeRef, populateType);
if ((genericTypeInstance != NULL) && (genericTypeInstance != mCurTypeInstance) && (populateType > BfPopulateType_Identity)) if ((genericTypeInstance != NULL) && (genericTypeInstance != mCurTypeInstance) && (populateType > BfPopulateType_Identity))
{ {