MCPcopy Create free account
hub / github.com/beefytech/Beef / ResolveTypeRef_Ref

Method ResolveTypeRef_Ref

IDEHelper/Compiler/BfModuleTypeUtils.cpp:11131–13002  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11129}
11130
11131BfType* BfModule::ResolveTypeRef_Ref(BfTypeReference* typeRef, BfPopulateType populateType, BfResolveTypeRefFlags& resolveFlags, int numGenericArgs)
11132{
11133 //BP_ZONE("BfModule::ResolveTypeRef");
11134
11135 if (typeRef == NULL)
11136 {
11137 AssertErrorState();
11138 return NULL;
11139 }
11140
11141 if (resolveFlags & BfResolveTypeRefFlag_AutoComplete)
11142 {
11143 resolveFlags = (BfResolveTypeRefFlags)(resolveFlags & ~BfResolveTypeRefFlag_AutoComplete);
11144 auto autoComplete = mCompiler->GetAutoComplete();
11145 if (autoComplete != NULL)
11146 autoComplete->CheckTypeRef(typeRef, false);
11147 }
11148
11149 if ((resolveFlags & BfResolveTypeRefFlag_AllowRef) == 0)
11150 {
11151 if (auto refTypeRef = BfNodeDynCast<BfRefTypeRef>(typeRef))
11152 {
11153 const char* refTypeStr = BfTokenToString(refTypeRef->mRefToken->mToken);
11154 Fail(StrFormat("Invalid use of '%s'. Only method parameters, return types, and local variables can be declared as %s types", refTypeStr, refTypeStr), refTypeRef->mRefToken);
11155 return ResolveTypeRef(refTypeRef->mElementType, populateType, resolveFlags, numGenericArgs);
11156 }
11157 }
11158
11159 if (auto directTypeRef = BfNodeDynCastExact<BfDirectTypeReference>(typeRef))
11160 {
11161 return directTypeRef->mType;
11162 }
11163
11164 if (auto dotType = BfNodeDynCastExact<BfDotTypeReference>(typeRef))
11165 {
11166 Fail(StrFormat("Invalid use of '%s'", BfTokenToString(dotType->mDotToken->mToken)), typeRef);
11167 return NULL;
11168 }
11169
11170 if (auto varRefType = BfNodeDynCastExact<BfVarRefTypeReference>(typeRef))
11171 {
11172 Fail("Invalid use of 'var ref'. Generally references are generated with a 'var' declaration with 'ref' applied to the initializer", typeRef);
11173 return NULL;
11174 }
11175
11176 if (mNoResolveGenericParams)
11177 resolveFlags = (BfResolveTypeRefFlags)(resolveFlags | BfResolveTypeRefFlag_NoResolveGenericParam);
11178 SetAndRestoreValue<bool> prevNoResolveGenericParams(mNoResolveGenericParams, (resolveFlags & BfResolveTypeRefFlag_NoResolveGenericParam) != 0);
11179
11180 //
11181 resolveFlags = (BfResolveTypeRefFlags)(resolveFlags & ~BfResolveTypeRefFlag_NoResolveGenericParam);
11182
11183 BfTypeInstance* contextTypeInstance = mCurTypeInstance;
11184 BfMethodInstance* contextMethodInstance = mCurMethodInstance;
11185
11186 if ((mCurMethodInstance != NULL) && (mCurMethodInstance->mIsForeignMethodDef))
11187 contextTypeInstance = mCurMethodInstance->mMethodInfoEx->mForeignType;
11188

Callers 2

MatchMethodMethod · 0.80

Calls 15

FailFunction · 0.85
TypeToStringFunction · 0.85
CheckTypeRefMethod · 0.80
GetParserMethod · 0.80
IsNamedTypeReferenceMethod · 0.80
ParseAtomCompositeMethod · 0.80
ContainsNamespaceMethod · 0.80
AppendMethod · 0.80
GetTokenMethod · 0.80
IsDeletingMethod · 0.80
RemoveEntryMethod · 0.80

Tested by

no test coverage detected