| 14456 | } |
| 14457 | |
| 14458 | BfModule* BfModule::GetOrCreateMethodModule(BfMethodInstance* methodInstance) |
| 14459 | { |
| 14460 | BfTypeInstance* typeInst = methodInstance->mMethodInstanceGroup->mOwner; |
| 14461 | |
| 14462 | if (mBfIRBuilder == NULL) |
| 14463 | { |
| 14464 | // To allow for custom attribute data |
| 14465 | PrepareForIRWriting(typeInst); |
| 14466 | } |
| 14467 | |
| 14468 | BfModule* declareModule = this; |
| 14469 | // Get to the optionless branch head -- but this could still be a specialized method module, not the true root |
| 14470 | while ((declareModule->mParentModule != NULL) && (!declareModule->mIsSpecializedMethodModuleRoot)) |
| 14471 | declareModule = declareModule->mParentModule; |
| 14472 | |
| 14473 | // Check for attributes |
| 14474 | if (typeInst == mContext->mBfObjectType) |
| 14475 | { |
| 14476 | auto methodDecl = methodInstance->mMethodDef->GetMethodDeclaration(); |
| 14477 | if (methodDecl != NULL) |
| 14478 | { |
| 14479 | auto attributesDirective = methodDecl->mAttributes; |
| 14480 | if ((attributesDirective != NULL) && (mCompiler->mResolvePassData != NULL)) |
| 14481 | { |
| 14482 | if (auto sourceClassifier = mCompiler->mResolvePassData->GetSourceClassifier(attributesDirective)) |
| 14483 | sourceClassifier->VisitChild(attributesDirective); |
| 14484 | } |
| 14485 | } |
| 14486 | } |
| 14487 | else |
| 14488 | { |
| 14489 | // Only allow attributes on System.Object methods that can be handled inside the DefBuilder |
| 14490 | GetMethodCustomAttributes(methodInstance); |
| 14491 | } |
| 14492 | BF_ASSERT(mModuleOptions == NULL); |
| 14493 | if (methodInstance->GetCustomAttributes() != NULL) |
| 14494 | { |
| 14495 | auto project = typeInst->mTypeDef->mProject; |
| 14496 | BfModuleOptions moduleOptions = declareModule->GetModuleOptions(); |
| 14497 | |
| 14498 | BfModuleOptions wantOptions = moduleOptions; |
| 14499 | auto typeOptions = mSystem->GetTypeOptions(typeInst->mTypeOptionsIdx); |
| 14500 | if (typeOptions != NULL) |
| 14501 | { |
| 14502 | wantOptions.mOptLevel = (BfOptLevel)BfTypeOptions::Apply((int)wantOptions.mOptLevel, (int)typeOptions->mOptimizationLevel); |
| 14503 | wantOptions.mSIMDSetting = (BfSIMDSetting)BfTypeOptions::Apply((int)wantOptions.mSIMDSetting, typeOptions->mSIMDSetting); |
| 14504 | wantOptions.mEmitDebugInfo = (BfSIMDSetting)BfTypeOptions::Apply((int)wantOptions.mEmitDebugInfo, typeOptions->mEmitDebugInfo); |
| 14505 | } |
| 14506 | |
| 14507 | if (!mCompiler->mAttributeTypeOptionMap.IsEmpty()) |
| 14508 | { |
| 14509 | StringT<128> attrName; |
| 14510 | for (auto& customAttrs : methodInstance->GetCustomAttributes()->mAttributes) |
| 14511 | { |
| 14512 | attrName.Clear(); |
| 14513 | customAttrs.mType->mTypeDef->mFullName.ToString(attrName); |
| 14514 | Array<int>* arrPtr; |
| 14515 | if (mCompiler->mAttributeTypeOptionMap.TryGetValue(attrName, &arrPtr)) |
nothing calls this directly
no test coverage detected