| 17186 | } |
| 17187 | |
| 17188 | void BfExprEvaluator::ResolveAllocTarget(BfAllocTarget& allocTarget, BfAstNode* allocNode, BfTokenNode*& newToken, BfCustomAttributes** outCustomAttributes) |
| 17189 | { |
| 17190 | auto autoComplete = GetAutoComplete(); |
| 17191 | BfAttributeDirective* attributeDirective = NULL; |
| 17192 | |
| 17193 | allocTarget.mRefNode = allocNode; |
| 17194 | newToken = BfNodeDynCast<BfTokenNode>(allocNode); |
| 17195 | if (allocNode == NULL) |
| 17196 | { |
| 17197 | // Scope |
| 17198 | if (mModule->mCurMethodState != NULL) |
| 17199 | allocTarget.mScopeData = mModule->mCurMethodState->mCurScope->GetTargetable(); |
| 17200 | } |
| 17201 | else if (newToken == NULL) |
| 17202 | { |
| 17203 | if (auto scopeNode = BfNodeDynCast<BfScopeNode>(allocNode)) |
| 17204 | { |
| 17205 | newToken = scopeNode->mScopeToken; |
| 17206 | allocTarget.mScopeData = mModule->FindScope(scopeNode->mTargetNode, true); |
| 17207 | |
| 17208 | if (autoComplete != NULL) |
| 17209 | { |
| 17210 | auto targetIdentifier = BfNodeDynCast<BfIdentifierNode>(scopeNode->mTargetNode); |
| 17211 | if ((scopeNode->mTargetNode == NULL) || (targetIdentifier != NULL)) |
| 17212 | autoComplete->CheckLabel(targetIdentifier, scopeNode->mColonToken, allocTarget.mScopeData); |
| 17213 | } |
| 17214 | attributeDirective = scopeNode->mAttributes; |
| 17215 | } |
| 17216 | if (auto newNode = BfNodeDynCast<BfNewNode>(allocNode)) |
| 17217 | { |
| 17218 | newToken = newNode->mNewToken; |
| 17219 | if (auto allocExpr = BfNodeDynCast<BfExpression>(newNode->mAllocNode)) |
| 17220 | { |
| 17221 | allocTarget.mCustomAllocator = mModule->CreateValueFromExpression(allocExpr); |
| 17222 | allocTarget.mRefNode = allocExpr; |
| 17223 | } |
| 17224 | else if (auto scopedInvocationTarget = BfNodeDynCast<BfScopedInvocationTarget>(newNode->mAllocNode)) |
| 17225 | { |
| 17226 | allocTarget.mScopedInvocationTarget = scopedInvocationTarget; |
| 17227 | } |
| 17228 | attributeDirective = newNode->mAttributes; |
| 17229 | } |
| 17230 | } |
| 17231 | else if (newToken->GetToken() == BfToken_Scope) |
| 17232 | { |
| 17233 | if (mModule->mCurMethodState != NULL) |
| 17234 | allocTarget.mScopeData = mModule->mCurMethodState->mCurScope->GetTargetable(); |
| 17235 | } |
| 17236 | |
| 17237 | if (attributeDirective != NULL) |
| 17238 | { |
| 17239 | auto customAttrs = mModule->GetCustomAttributes(attributeDirective, BfAttributeTargets_Alloc, BfGetCustomAttributesFlags_AllowNonConstArgs, allocTarget.mCaptureInfo); |
| 17240 | if (customAttrs != NULL) |
| 17241 | { |
| 17242 | for (auto& attrib : customAttrs->mAttributes) |
| 17243 | { |
| 17244 | if (attrib.mType->IsInstanceOf(mModule->mCompiler->mAlignAttributeTypeDef)) |
| 17245 | { |
nothing calls this directly
no test coverage detected