mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Improved populate reentrancy with custom attrs on nested type
This commit is contained in:
parent
7f340f7c82
commit
2c907aa13a
2 changed files with 27 additions and 9 deletions
|
@ -11702,7 +11702,17 @@ void BfModule::GetCustomAttributes(BfCustomAttributes* customAttributes, BfAttri
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
BfType* attrType = ResolveTypeRef(attributesDirective->mAttributeTypeRef, BfPopulateType_Identity, (BfResolveTypeRefFlags)(BfResolveTypeRefFlag_Attribute | BfResolveTypeRefFlag_NoReify));
|
BfType* attrType;
|
||||||
|
if (mContext->mCurTypeState != NULL)
|
||||||
|
{
|
||||||
|
SetAndRestoreValue<BfTypeReference*> prevTypeRef(mContext->mCurTypeState->mCurAttributeTypeRef, attributesDirective->mAttributeTypeRef);
|
||||||
|
attrType = ResolveTypeRef(attributesDirective->mAttributeTypeRef, BfPopulateType_Identity, (BfResolveTypeRefFlags)(BfResolveTypeRefFlag_Attribute | BfResolveTypeRefFlag_NoReify));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
attrType = ResolveTypeRef(attributesDirective->mAttributeTypeRef, BfPopulateType_Identity, (BfResolveTypeRefFlags)(BfResolveTypeRefFlag_Attribute | BfResolveTypeRefFlag_NoReify));
|
||||||
|
}
|
||||||
|
|
||||||
BfTypeDef* attrTypeDef = NULL;
|
BfTypeDef* attrTypeDef = NULL;
|
||||||
if ((attrType != NULL) && (attrType->IsTypeInstance()))
|
if ((attrType != NULL) && (attrType->IsTypeInstance()))
|
||||||
attrTypeDef = attrType->ToTypeInstance()->mTypeDef;
|
attrTypeDef = attrType->ToTypeInstance()->mTypeDef;
|
||||||
|
|
|
@ -3873,7 +3873,7 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
||||||
if ((checkType != NULL) && (!checkType->IsInterface()) && (populateBase))
|
if ((checkType != NULL) && (!checkType->IsInterface()) && (populateBase))
|
||||||
{
|
{
|
||||||
SetAndRestoreValue<BfTypeInstance*> prevBaseType(mContext->mCurTypeState->mCurBaseType, checkType->ToTypeInstance());
|
SetAndRestoreValue<BfTypeInstance*> prevBaseType(mContext->mCurTypeState->mCurBaseType, checkType->ToTypeInstance());
|
||||||
PopulateType(checkType, BfPopulateType_Data);
|
PopulateType(checkType, (populateType <= BfPopulateType_BaseType) ? BfPopulateType_BaseType : BfPopulateType_Data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeInstance->mDefineState >= BfTypeDefineState_Defined)
|
if (typeInstance->mDefineState >= BfTypeDefineState_Defined)
|
||||||
|
@ -4331,22 +4331,30 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
||||||
SetAndRestoreValue<bool> prevSkipTypeProtectionChecks(typeInstance->mSkipTypeProtectionChecks, true);
|
SetAndRestoreValue<bool> prevSkipTypeProtectionChecks(typeInstance->mSkipTypeProtectionChecks, true);
|
||||||
if (typeDef->mIsCombinedPartial)
|
if (typeDef->mIsCombinedPartial)
|
||||||
{
|
{
|
||||||
|
auto customAttributes = new BfCustomAttributes();
|
||||||
|
|
||||||
for (auto partialTypeDef : typeDef->mPartials)
|
for (auto partialTypeDef : typeDef->mPartials)
|
||||||
{
|
{
|
||||||
if (partialTypeDef->mTypeDeclaration->mAttributes == NULL)
|
if (partialTypeDef->mTypeDeclaration->mAttributes == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
typeState.mCurTypeDef = partialTypeDef;
|
typeState.mCurTypeDef = partialTypeDef;
|
||||||
if (typeInstance->mCustomAttributes == NULL)
|
GetCustomAttributes(customAttributes, partialTypeDef->mTypeDeclaration->mAttributes, attrTarget);
|
||||||
typeInstance->mCustomAttributes = new BfCustomAttributes();
|
|
||||||
GetCustomAttributes(typeInstance->mCustomAttributes, partialTypeDef->mTypeDeclaration->mAttributes, attrTarget);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeInstance->mCustomAttributes == NULL)
|
||||||
|
typeInstance->mCustomAttributes = customAttributes;
|
||||||
|
else
|
||||||
|
delete customAttributes;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
auto customAttributes = new BfCustomAttributes();
|
||||||
typeInstance->mCustomAttributes = new BfCustomAttributes();
|
GetCustomAttributes(customAttributes, typeDef->mTypeDeclaration->mAttributes, attrTarget);
|
||||||
GetCustomAttributes(typeInstance->mCustomAttributes, typeDef->mTypeDeclaration->mAttributes, attrTarget);
|
if (typeInstance->mCustomAttributes == NULL)
|
||||||
|
typeInstance->mCustomAttributes = customAttributes;
|
||||||
|
else
|
||||||
|
delete customAttributes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue