MCPcopy Create free account
hub / github.com/beefytech/Beef / ExecuteCEOnCompile

Method ExecuteCEOnCompile

IDEHelper/Compiler/BfModuleTypeUtils.cpp:2773–2997  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2771}
2772
2773void BfModule::ExecuteCEOnCompile(CeEmitContext* ceEmitContext, BfTypeInstance* typeInstance, BfCEOnCompileKind onCompileKind, bool underlyingTypeDeferred)
2774{
2775 Dictionary<BfTypeInstance*, BfIRValue> prevAttrInstances;
2776
2777 if (typeInstance->mCustomAttributes != NULL)
2778 HandleCEAttributes(ceEmitContext, typeInstance, NULL, typeInstance->mCustomAttributes, prevAttrInstances, underlyingTypeDeferred);
2779
2780 if ((ceEmitContext != NULL) || (onCompileKind == BfCEOnCompileKind_TypeDone))
2781 {
2782 for (auto& fieldInstance : typeInstance->mFieldInstances)
2783 {
2784 if (fieldInstance.mCustomAttributes != NULL)
2785 HandleCEAttributes(ceEmitContext, typeInstance, &fieldInstance, fieldInstance.mCustomAttributes, prevAttrInstances, underlyingTypeDeferred);
2786 }
2787
2788 for (auto methodDef : typeInstance->mTypeDef->mMethods)
2789 {
2790 auto methodDeclaration = methodDef->GetMethodDeclaration();
2791 auto propertyMethodDeclaration = methodDef->GetPropertyMethodDeclaration();
2792 BfAttributeTargets attrTarget = ((methodDef->mMethodType == BfMethodType_Ctor) || (methodDef->mMethodType == BfMethodType_CtorCalcAppend)) ? BfAttributeTargets_Constructor : BfAttributeTargets_Method;
2793 BfAttributeDirective* attributeDirective = NULL;
2794 if (methodDeclaration != NULL)
2795 attributeDirective = methodDeclaration->mAttributes;
2796 else if (propertyMethodDeclaration != NULL)
2797 {
2798 attributeDirective = propertyMethodDeclaration->mAttributes;
2799 if (auto exprBody = BfNodeDynCast<BfPropertyBodyExpression>(propertyMethodDeclaration->mPropertyDeclaration->mDefinitionBlock))
2800 {
2801 attributeDirective = propertyMethodDeclaration->mPropertyDeclaration->mAttributes;
2802 attrTarget = (BfAttributeTargets)(BfAttributeTargets_Property | BfAttributeTargets_Method);
2803 }
2804 }
2805 if (attributeDirective == NULL)
2806 continue;
2807
2808 // Corlib will never need to process
2809 if (methodDef->mDeclaringType->mProject == mContext->mBfObjectType->mTypeDef->mProject)
2810 continue;
2811
2812 if (methodDef->mDeclaringType != mCurTypeInstance->mTypeDef)
2813 {
2814 if (typeInstance->IsUnspecializedTypeVariation())
2815 continue;
2816 if (!typeInstance->IsTypeMemberIncluded(methodDef->mDeclaringType, mCurTypeInstance->mTypeDef, this))
2817 continue;
2818 }
2819
2820 if (methodDef->mIdx >= typeInstance->mMethodInstanceGroups.mSize)
2821 continue;
2822
2823 auto& methodInstanceGroup = typeInstance->mMethodInstanceGroups[methodDef->mIdx];
2824 if (methodInstanceGroup.mDefaultCustomAttributes == NULL)
2825 {
2826 BfTypeState typeState;
2827 typeState.mPrevState = mContext->mCurTypeState;
2828 typeState.mForceActiveTypeDef = methodDef->mDeclaringType;
2829 SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
2830 methodInstanceGroup.mDefaultCustomAttributes = GetCustomAttributes(attributeDirective, attrTarget);

Callers

nothing calls this directly

Calls 15

FailFunction · 0.85
GetMethodDeclarationMethod · 0.80
TryGetValueMethod · 0.80
LocationToStringMethod · 0.80
IsTypeMemberIncludedMethod · 0.45
sizeMethod · 0.45
IsInstanceOfMethod · 0.45
ToTypeInstanceMethod · 0.45
IsEmptyMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected