| 24116 | } |
| 24117 | |
| 24118 | void BfModule::GetMethodCustomAttributes(BfMethodInstance* methodInstance) |
| 24119 | { |
| 24120 | auto methodDef = methodInstance->mMethodDef; |
| 24121 | |
| 24122 | auto customAttributes = methodInstance->GetCustomAttributes(); |
| 24123 | if (customAttributes != NULL) |
| 24124 | return; |
| 24125 | |
| 24126 | auto methodDeclaration = methodDef->GetMethodDeclaration(); |
| 24127 | auto propertyMethodDeclaration = methodDef->GetPropertyMethodDeclaration(); |
| 24128 | auto typeInstance = methodInstance->GetOwner(); |
| 24129 | |
| 24130 | if (typeInstance->IsInstanceOf(mCompiler->mValueTypeTypeDef)) |
| 24131 | return; |
| 24132 | |
| 24133 | BfTypeState typeState(typeInstance); |
| 24134 | SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState); |
| 24135 | SetAndRestoreValue<BfTypeInstance*> prevTypeInstance(mCurTypeInstance, typeInstance); |
| 24136 | SetAndRestoreValue<BfMethodInstance*> prevMethodInstance(mCurMethodInstance, methodInstance); |
| 24137 | |
| 24138 | BfAttributeTargets attrTarget = ((methodDef->mMethodType == BfMethodType_Ctor) || (methodDef->mMethodType == BfMethodType_CtorCalcAppend)) ? BfAttributeTargets_Constructor : BfAttributeTargets_Method; |
| 24139 | BfAttributeDirective* attributeDirective = NULL; |
| 24140 | if (methodDeclaration != NULL) |
| 24141 | attributeDirective = methodDeclaration->mAttributes; |
| 24142 | else if (propertyMethodDeclaration != NULL) |
| 24143 | { |
| 24144 | attributeDirective = propertyMethodDeclaration->mAttributes; |
| 24145 | if (auto exprBody = BfNodeDynCast<BfPropertyBodyExpression>(propertyMethodDeclaration->mPropertyDeclaration->mDefinitionBlock)) |
| 24146 | { |
| 24147 | attributeDirective = propertyMethodDeclaration->mPropertyDeclaration->mAttributes; |
| 24148 | attrTarget = (BfAttributeTargets)(BfAttributeTargets_Property | BfAttributeTargets_Method); |
| 24149 | } |
| 24150 | } |
| 24151 | |
| 24152 | if (attributeDirective != NULL) |
| 24153 | { |
| 24154 | if (methodInstance->GetMethodInfoEx()->mMethodCustomAttributes == NULL) |
| 24155 | methodInstance->mMethodInfoEx->mMethodCustomAttributes = new BfMethodCustomAttributes(); |
| 24156 | |
| 24157 | if ((methodInstance == methodInstance->mMethodInstanceGroup->mDefault) && (methodInstance->mMethodInstanceGroup->mDefaultCustomAttributes != NULL)) |
| 24158 | { |
| 24159 | // Take over previously-generated custom attributes |
| 24160 | methodInstance->mMethodInfoEx->mMethodCustomAttributes->mCustomAttributes = methodInstance->mMethodInstanceGroup->mDefaultCustomAttributes; |
| 24161 | methodInstance->mMethodInstanceGroup->mDefaultCustomAttributes = NULL; |
| 24162 | } |
| 24163 | else |
| 24164 | methodInstance->mMethodInfoEx->mMethodCustomAttributes->mCustomAttributes = GetCustomAttributes(attributeDirective, attrTarget); |
| 24165 | } |
| 24166 | |
| 24167 | if ((propertyMethodDeclaration != NULL) && (propertyMethodDeclaration->mPropertyDeclaration->mAttributes != NULL) && ((attrTarget & BfAttributeTargets_Property) == 0)) |
| 24168 | { |
| 24169 | if (methodInstance->GetMethodInfoEx()->mMethodCustomAttributes != NULL) |
| 24170 | { |
| 24171 | GetCustomAttributes(methodInstance->mMethodInfoEx->mMethodCustomAttributes->mCustomAttributes, propertyMethodDeclaration->mPropertyDeclaration->mAttributes, BfAttributeTargets_Property); |
| 24172 | } |
| 24173 | else |
| 24174 | { |
| 24175 | methodInstance->GetMethodInfoEx()->mMethodCustomAttributes = new BfMethodCustomAttributes(); |
nothing calls this directly
no test coverage detected