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

Method CheckLocalMethods

IDEHelper/Compiler/BfExprEvaluator.cpp:17655–17754  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17653}
17654
17655void BfExprEvaluator::CheckLocalMethods(BfAstNode* targetSrc, BfTypeInstance* typeInstance, const StringImpl& methodName, BfMethodMatcher& methodMatcher, BfMethodType methodType)
17656{
17657 auto _GetNodeId = [&]()
17658 {
17659 auto parser = targetSrc->GetSourceData()->ToParserData();
17660 return ((int64)parser->mDataId << 32) + targetSrc->GetSrcStart();
17661 };
17662
17663 BfMethodState* ctxMethodState = NULL;
17664 BfClosureInstanceInfo* ctxClosureInstanceInfo = NULL;
17665
17666 if ((mModule->mCurMethodState != NULL) && (mModule->mCurMethodState->mClosureState != NULL))
17667 {
17668 ctxClosureInstanceInfo = mModule->mCurMethodState->mClosureState->mClosureInstanceInfo;
17669 ctxMethodState = mModule->mCurMethodState;
17670 }
17671
17672 bool atCtxMethodState = false;
17673 auto checkMethodState = mModule->mCurMethodState;
17674 auto rootMethodState = checkMethodState;
17675 while (checkMethodState != NULL)
17676 {
17677 rootMethodState = checkMethodState;
17678
17679 if (checkMethodState == ctxMethodState)
17680 atCtxMethodState = true;
17681
17682 if ((ctxClosureInstanceInfo != NULL) && (!ctxMethodState->mClosureState->mCapturing))
17683 {
17684 BfMethodDef* localMethodDef = NULL;
17685 if (ctxClosureInstanceInfo->mLocalMethodBindings.TryGetValue(_GetNodeId(), &localMethodDef))
17686 {
17687 methodMatcher.CheckMethod(mModule->mCurTypeInstance, mModule->mCurTypeInstance, localMethodDef, true);
17688 BF_ASSERT(methodMatcher.mBestMethodDef != NULL);
17689 return;
17690 }
17691 }
17692 else
17693 {
17694 BfLocalMethod* matchedLocalMethod = NULL;
17695 BfLocalMethod* localMethod = NULL;
17696 if (checkMethodState->mLocalMethodMap.TryGetValue(methodName, &localMethod))
17697 {
17698 auto typeInst = mModule->mCurTypeInstance;
17699 if (checkMethodState->mMixinState != NULL)
17700 typeInst = checkMethodState->mMixinState->mMixinMethodInstance->GetOwner();
17701
17702 while (localMethod != NULL)
17703 {
17704 auto methodDef = mModule->GetLocalMethodDef(localMethod);
17705 if (methodDef->mMethodType == methodType)
17706 {
17707 methodMatcher.CheckMethod(mModule->mCurTypeInstance, typeInst, methodDef, true);
17708 if (methodMatcher.mBestMethodDef == methodDef)
17709 matchedLocalMethod = localMethod;
17710 }
17711 localMethod = localMethod->mNextWithSameName;
17712 }

Callers

nothing calls this directly

Calls 8

GetSourceDataMethod · 0.80
TryGetValueMethod · 0.80
GetLocalMethodDefMethod · 0.80
ToParserDataMethod · 0.45
GetSrcStartMethod · 0.45
CheckMethodMethod · 0.45
GetOwnerMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected