mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
IOnTypeInit + IOnTypeDone combo with IOnFieldInit/IOnMethodInit
This commit is contained in:
parent
a5b032cc39
commit
b3cf2a0d04
1 changed files with 184 additions and 154 deletions
|
@ -2498,6 +2498,22 @@ void BfModule::HandleCEAttributes(CeEmitContext* ceEmitContext, BfTypeInstance*
|
||||||
{
|
{
|
||||||
for (auto& customAttribute : customAttributes->mAttributes)
|
for (auto& customAttribute : customAttributes->mAttributes)
|
||||||
{
|
{
|
||||||
|
bool isFieldApply = false;
|
||||||
|
bool hasFieldApply = false;
|
||||||
|
bool hasTypeApply = false;
|
||||||
|
|
||||||
|
for (int pass = 0; pass < 2; pass++)
|
||||||
|
{
|
||||||
|
if (pass == 1)
|
||||||
|
{
|
||||||
|
if ((hasFieldApply) && (hasTypeApply))
|
||||||
|
{
|
||||||
|
// Keep going - do the field apply now
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if ((customAttribute.mDeclaringType->IsExtension()) && (typeInstance->IsGenericTypeInstance()) && (!typeInstance->IsUnspecializedTypeVariation()))
|
if ((customAttribute.mDeclaringType->IsExtension()) && (typeInstance->IsGenericTypeInstance()) && (!typeInstance->IsUnspecializedTypeVariation()))
|
||||||
{
|
{
|
||||||
if (!typeInstance->IsTypeMemberIncluded(customAttribute.mDeclaringType, typeInstance->mTypeDef, this))
|
if (!typeInstance->IsTypeMemberIncluded(customAttribute.mDeclaringType, typeInstance->mTypeDef, this))
|
||||||
|
@ -2507,7 +2523,6 @@ void BfModule::HandleCEAttributes(CeEmitContext* ceEmitContext, BfTypeInstance*
|
||||||
auto attrType = customAttribute.mType;
|
auto attrType = customAttribute.mType;
|
||||||
|
|
||||||
BfMethodInstance* methodInstance = NULL;
|
BfMethodInstance* methodInstance = NULL;
|
||||||
bool isFieldApply = false;
|
|
||||||
BfIRValue irValue;
|
BfIRValue irValue;
|
||||||
int checkDepth = 0;
|
int checkDepth = 0;
|
||||||
auto checkAttrType = attrType;
|
auto checkAttrType = attrType;
|
||||||
|
@ -2522,20 +2537,34 @@ void BfModule::HandleCEAttributes(CeEmitContext* ceEmitContext, BfTypeInstance*
|
||||||
isFieldApply = false;
|
isFieldApply = false;
|
||||||
isFieldApply = (ceEmitContext != NULL) && (fieldInstance != NULL) && (ifaceEntry.mInterfaceType->IsInstanceOf(mCompiler->mIOnFieldInitTypeDef));
|
isFieldApply = (ceEmitContext != NULL) && (fieldInstance != NULL) && (ifaceEntry.mInterfaceType->IsInstanceOf(mCompiler->mIOnFieldInitTypeDef));
|
||||||
|
|
||||||
if ((isFieldApply) ||
|
if (((ceEmitContext != NULL) && (ifaceEntry.mInterfaceType->IsInstanceOf(mCompiler->mIComptimeTypeApply))) ||
|
||||||
((ceEmitContext != NULL) && (ifaceEntry.mInterfaceType->IsInstanceOf(mCompiler->mIComptimeTypeApply))) ||
|
|
||||||
((ceEmitContext != NULL) && (ifaceEntry.mInterfaceType->IsInstanceOf(mCompiler->mIOnTypeInitTypeDef))) ||
|
((ceEmitContext != NULL) && (ifaceEntry.mInterfaceType->IsInstanceOf(mCompiler->mIOnTypeInitTypeDef))) ||
|
||||||
((ceEmitContext == NULL) && (ifaceEntry.mInterfaceType->IsInstanceOf(mCompiler->mIOnTypeDoneTypeDef))))
|
((ceEmitContext == NULL) && (ifaceEntry.mInterfaceType->IsInstanceOf(mCompiler->mIOnTypeDoneTypeDef))))
|
||||||
{
|
{
|
||||||
// Passes
|
// Passes
|
||||||
|
hasTypeApply = true;
|
||||||
|
if (pass == 1)
|
||||||
|
{
|
||||||
|
// Only find field inits now
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (isFieldApply)
|
||||||
|
{
|
||||||
|
// Field passes
|
||||||
|
hasFieldApply = true;
|
||||||
|
if (methodInstance != NULL)
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
prevAttrInstances.TryGetValue(checkAttrType, &irValue);
|
prevAttrInstances.TryGetValue(checkAttrType, &irValue);
|
||||||
methodInstance = checkAttrType->mInterfaceMethodTable[ifaceEntry.mStartInterfaceTableIdx].mMethodRef;
|
methodInstance = checkAttrType->mInterfaceMethodTable[ifaceEntry.mStartInterfaceTableIdx].mMethodRef;
|
||||||
|
if (pass == 1)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (methodInstance != NULL)
|
if (methodInstance != NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -2687,6 +2716,7 @@ void BfModule::HandleCEAttributes(CeEmitContext* ceEmitContext, BfTypeInstance*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void BfModule::CEMixin(BfAstNode* refNode, const StringImpl& code)
|
void BfModule::CEMixin(BfAstNode* refNode, const StringImpl& code)
|
||||||
{
|
{
|
||||||
|
@ -2747,7 +2777,7 @@ void BfModule::ExecuteCEOnCompile(CeEmitContext* ceEmitContext, BfTypeInstance*
|
||||||
if (typeInstance->mCustomAttributes != NULL)
|
if (typeInstance->mCustomAttributes != NULL)
|
||||||
HandleCEAttributes(ceEmitContext, typeInstance, NULL, typeInstance->mCustomAttributes, prevAttrInstances, underlyingTypeDeferred);
|
HandleCEAttributes(ceEmitContext, typeInstance, NULL, typeInstance->mCustomAttributes, prevAttrInstances, underlyingTypeDeferred);
|
||||||
|
|
||||||
if (ceEmitContext != NULL)
|
if ((ceEmitContext != NULL) || (onCompileKind == BfCEOnCompileKind_TypeDone))
|
||||||
{
|
{
|
||||||
for (auto& fieldInstance : typeInstance->mFieldInstances)
|
for (auto& fieldInstance : typeInstance->mFieldInstances)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue