| 12564 | } |
| 12565 | |
| 12566 | void BfModule::GetCustomAttributes(BfCustomAttributes* customAttributes, BfAttributeDirective* attributesDirective, BfAttributeTargets attrTarget, BfGetCustomAttributesFlags flags, BfCaptureInfo* captureInfo) |
| 12567 | { |
| 12568 | bool allowNonConstArgs = (flags & BfGetCustomAttributesFlags_AllowNonConstArgs) != 0; |
| 12569 | bool keepConstsInModule = (flags & BfGetCustomAttributesFlags_KeepConstsInModule) != 0; |
| 12570 | |
| 12571 | if (!mCompiler->mHasRequiredTypes) |
| 12572 | return; |
| 12573 | |
| 12574 | if ((attributesDirective != NULL) && (mCompiler->mResolvePassData != NULL)) |
| 12575 | { |
| 12576 | if (auto sourceClassifier = mCompiler->mResolvePassData->GetSourceClassifier(attributesDirective)) |
| 12577 | sourceClassifier->VisitChild(attributesDirective); |
| 12578 | } |
| 12579 | |
| 12580 | SetAndRestoreValue<bool> prevIsCapturingMethodMatchInfo; |
| 12581 | if (mCompiler->IsAutocomplete()) |
| 12582 | prevIsCapturingMethodMatchInfo.Init(mCompiler->mResolvePassData->mAutoComplete->mIsCapturingMethodMatchInfo, false); |
| 12583 | |
| 12584 | BfTypeInstance* baseAttrTypeInst = mContext->mUnreifiedModule->ResolveTypeDef(mCompiler->mAttributeTypeDef)->ToTypeInstance(); |
| 12585 | BfAttributeTargets targetOverride = (BfAttributeTargets)0; |
| 12586 | |
| 12587 | BfTypeDef* activeTypeDef = GetActiveTypeDef(); |
| 12588 | BfAutoComplete* autoComplete = NULL; |
| 12589 | if (mCompiler->mResolvePassData != NULL) |
| 12590 | autoComplete = mCompiler->mResolvePassData->mAutoComplete; |
| 12591 | |
| 12592 | for (; attributesDirective != NULL; attributesDirective = attributesDirective->mNextAttribute) |
| 12593 | { |
| 12594 | if (auto tokenNode = BfNodeDynCast<BfTokenNode>(attributesDirective->mAttributeTargetSpecifier)) |
| 12595 | { |
| 12596 | if (captureInfo == NULL) |
| 12597 | { |
| 12598 | Fail("Capture specifiers can only be used in lambda allocations", tokenNode); |
| 12599 | continue; |
| 12600 | } |
| 12601 | |
| 12602 | BfCaptureInfo::Entry captureEntry; |
| 12603 | captureEntry.mRefNode = tokenNode; |
| 12604 | captureEntry.mCaptureType = BfCaptureType_Copy; |
| 12605 | if (tokenNode->mToken == BfToken_Ampersand) |
| 12606 | captureEntry.mCaptureType = BfCaptureType_Reference; |
| 12607 | if (tokenNode->mToken == BfToken_Question) |
| 12608 | captureEntry.mCaptureType = BfCaptureType_Auto; |
| 12609 | if (!attributesDirective->mArguments.IsEmpty()) |
| 12610 | { |
| 12611 | if (auto identifierNode = BfNodeDynCast<BfIdentifierNode>(attributesDirective->mArguments[0])) |
| 12612 | captureEntry.mNameNode = identifierNode; |
| 12613 | else if (auto thisExpr = BfNodeDynCast<BfThisExpression>(attributesDirective->mArguments[0])) |
| 12614 | { |
| 12615 | captureEntry.mNameNode = thisExpr; |
| 12616 | } |
| 12617 | |
| 12618 | if ((captureEntry.mNameNode != NULL) && (autoComplete != NULL)) |
| 12619 | autoComplete->CheckIdentifier(captureEntry.mNameNode); |
| 12620 | } |
| 12621 | captureInfo->mCaptures.Add(captureEntry); |
| 12622 | continue; |
| 12623 | } |
no test coverage detected