| 2495 | } |
| 2496 | |
| 2497 | void BfModule::HandleCEAttributes(CeEmitContext* ceEmitContext, BfTypeInstance* typeInstance, BfFieldInstance* fieldInstance, BfCustomAttributes* customAttributes, Dictionary<BfTypeInstance*, BfIRValue>& prevAttrInstances, bool underlyingTypeDeferred) |
| 2498 | { |
| 2499 | for (auto& customAttribute : customAttributes->mAttributes) |
| 2500 | { |
| 2501 | bool isFieldApply = false; |
| 2502 | bool hasFieldApply = false; |
| 2503 | bool hasTypeApply = false; |
| 2504 | |
| 2505 | for (int pass = 0; pass < 2; pass++) |
| 2506 | { |
| 2507 | if (pass == 1) |
| 2508 | { |
| 2509 | if ((hasFieldApply) && (hasTypeApply)) |
| 2510 | { |
| 2511 | // Keep going - do the field apply now |
| 2512 | } |
| 2513 | else |
| 2514 | break; |
| 2515 | } |
| 2516 | |
| 2517 | if ((customAttribute.mDeclaringType->IsExtension()) && (typeInstance->IsGenericTypeInstance()) && (!typeInstance->IsUnspecializedTypeVariation())) |
| 2518 | { |
| 2519 | if (!typeInstance->IsTypeMemberIncluded(customAttribute.mDeclaringType, typeInstance->mTypeDef, this)) |
| 2520 | continue; |
| 2521 | } |
| 2522 | |
| 2523 | auto attrType = customAttribute.mType; |
| 2524 | |
| 2525 | BfMethodInstance* methodInstance = NULL; |
| 2526 | BfIRValue irValue; |
| 2527 | int checkDepth = 0; |
| 2528 | auto checkAttrType = attrType; |
| 2529 | while (checkAttrType != NULL) |
| 2530 | { |
| 2531 | mContext->mUnreifiedModule->PopulateType(checkAttrType, BfPopulateType_DataAndMethods); |
| 2532 | if (checkAttrType->mDefineState < BfTypeDefineState_DefinedAndMethodsSlotted) |
| 2533 | break; |
| 2534 | |
| 2535 | for (auto& ifaceEntry : checkAttrType->mInterfaces) |
| 2536 | { |
| 2537 | isFieldApply = false; |
| 2538 | isFieldApply = (ceEmitContext != NULL) && (fieldInstance != NULL) && (ifaceEntry.mInterfaceType->IsInstanceOf(mCompiler->mIOnFieldInitTypeDef)); |
| 2539 | |
| 2540 | if (((ceEmitContext != NULL) && (ifaceEntry.mInterfaceType->IsInstanceOf(mCompiler->mIComptimeTypeApply))) || |
| 2541 | ((ceEmitContext != NULL) && (ifaceEntry.mInterfaceType->IsInstanceOf(mCompiler->mIOnTypeInitTypeDef))) || |
| 2542 | ((ceEmitContext == NULL) && (ifaceEntry.mInterfaceType->IsInstanceOf(mCompiler->mIOnTypeDoneTypeDef)))) |
| 2543 | { |
| 2544 | // Passes |
| 2545 | hasTypeApply = true; |
| 2546 | if (pass == 1) |
| 2547 | { |
| 2548 | // Only find field inits now |
| 2549 | continue; |
| 2550 | } |
| 2551 | } |
| 2552 | else if (isFieldApply) |
| 2553 | { |
| 2554 | // Field passes |
nothing calls this directly
no test coverage detected