The parser thought this was a type reference but it may not be
| 400 | |
| 401 | // The parser thought this was a type reference but it may not be |
| 402 | BfTypedValue BfAutoComplete::LookupTypeRefOrIdentifier(BfAstNode* node, bool* isStatic, BfEvalExprFlags evalExprFlags, BfType* expectingType) |
| 403 | { |
| 404 | SetAndRestoreValue<bool> prevIgnoreClassifying(mModule->mIsInsideAutoComplete, true); |
| 405 | |
| 406 | auto _FixType = [](const BfTypedValue& typedValue) |
| 407 | { |
| 408 | if ((typedValue.mType != NULL) && (typedValue.mType->IsAllocType())) |
| 409 | { |
| 410 | BfTypedValue ret = typedValue; |
| 411 | ret.mType = ret.mType->GetUnderlyingType(); |
| 412 | return ret; |
| 413 | } |
| 414 | return typedValue; |
| 415 | }; |
| 416 | |
| 417 | if (auto typeRef = BfNodeDynCast<BfTypeReference>(node)) |
| 418 | { |
| 419 | if (auto namedTypeRef = BfNodeDynCast<BfNamedTypeReference>(typeRef)) |
| 420 | { |
| 421 | BfExprEvaluator exprEvaluator(mModule); |
| 422 | auto identifierResult = exprEvaluator.LookupIdentifier(namedTypeRef->mNameNode); |
| 423 | if (identifierResult) |
| 424 | return identifierResult; |
| 425 | identifierResult = exprEvaluator.GetResult();// We need 'GetResult' to read property values |
| 426 | if (identifierResult.HasType()) |
| 427 | return _FixType(identifierResult); |
| 428 | } |
| 429 | else if (auto qualifiedTypeRef = BfNodeDynCast<BfQualifiedTypeReference>(typeRef)) |
| 430 | { |
| 431 | auto leftValue = LookupTypeRefOrIdentifier(qualifiedTypeRef->mLeft, isStatic); |
| 432 | |
| 433 | if (leftValue.mType) |
| 434 | { |
| 435 | if (leftValue.mType->IsPointer()) |
| 436 | { |
| 437 | mModule->LoadValue(leftValue); |
| 438 | leftValue.mType = leftValue.mType->GetUnderlyingType(); |
| 439 | leftValue.mKind = BfTypedValueKind_Addr; |
| 440 | } |
| 441 | |
| 442 | if (auto rightNamedTypeRef = BfNodeDynCast<BfNamedTypeReference>(qualifiedTypeRef->mRight)) |
| 443 | { |
| 444 | // This keeps the classifier from colorizing properties - this causes 'flashing' when we go back over this with a resolve pass |
| 445 | // that wouldn't catch this |
| 446 | SetAndRestoreValue<bool> prevClassifier(mModule->mCompiler->mResolvePassData->mIsClassifying, false); |
| 447 | |
| 448 | BfExprEvaluator exprEvaluator(mModule); |
| 449 | auto fieldResult = exprEvaluator.LookupField(qualifiedTypeRef->mRight, leftValue, rightNamedTypeRef->mNameNode->ToString()); |
| 450 | if (!fieldResult) // Was property? |
| 451 | fieldResult = exprEvaluator.GetResult(); |
| 452 | if (fieldResult.HasType()) |
| 453 | { |
| 454 | *isStatic = false; |
| 455 | return _FixType(fieldResult); |
| 456 | } |
| 457 | } |
| 458 | } |
| 459 | } |
nothing calls this directly
no test coverage detected