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

Method CallChainedMethods

IDEHelper/Compiler/BfModule.cpp:19854–19900  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19852}
19853
19854void BfModule::CallChainedMethods(BfMethodInstance* methodInstance, bool reverse)
19855{
19856 Array<BfMethodInstance*> methodInstances;
19857
19858 for (int methodIdx = 0; methodIdx < (int)mCurTypeInstance->mMethodInstanceGroups.size(); methodIdx++)
19859 {
19860 auto& methodInstGroup = mCurTypeInstance->mMethodInstanceGroups[methodIdx];
19861 auto chainedMethodInst = methodInstGroup.mDefault;
19862 if ((chainedMethodInst != NULL) && (chainedMethodInst->mChainType == BfMethodChainType_ChainMember))
19863 {
19864 if ((chainedMethodInst->mMethodDef->mIsStatic == methodInstance->mMethodDef->mIsStatic) &&
19865 (CompareMethodSignatures(methodInstance, chainedMethodInst)))
19866 {
19867 methodInstances.push_back(chainedMethodInst);
19868 }
19869 }
19870 }
19871
19872 std::stable_sort(methodInstances.begin(), methodInstances.end(),
19873 [&](BfMethodInstance* lhs, BfMethodInstance* rhs)
19874 {
19875 bool isBetter;
19876 bool isWorse;
19877 CompareDeclTypes(mCurTypeInstance, lhs->mMethodDef->mDeclaringType, rhs->mMethodDef->mDeclaringType, isBetter, isWorse);
19878 if (isBetter == isWorse)
19879 {
19880 return false;
19881 }
19882 return isWorse;
19883 });
19884
19885 if (reverse)
19886 std::reverse(methodInstances.begin(), methodInstances.end());
19887
19888 for (auto chainedMethodInst : methodInstances)
19889 {
19890 auto declModule = this;
19891 BfGetMethodInstanceFlags flags = BfGetMethodInstanceFlag_None;
19892
19893 auto moduleMethodInst = declModule->GetMethodInstance(mCurTypeInstance, chainedMethodInst->mMethodDef, BfTypeVector(), flags);
19894
19895 BfExprEvaluator exprEvaluator(this);
19896 SizedArray<BfIRValue, 1> args;
19897 exprEvaluator.PushThis(chainedMethodInst->mMethodDef->GetRefNode(), GetThis(), chainedMethodInst, args);
19898 exprEvaluator.CreateCall(NULL, moduleMethodInst.mMethodInstance, moduleMethodInst.mFunc, true, args);
19899 }
19900}
19901
19902void BfModule::AddHotDataReferences(BfHotDataReferenceBuilder* builder)
19903{

Callers

nothing calls this directly

Calls 8

PushThisMethod · 0.80
sizeMethod · 0.45
push_backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
GetMethodInstanceMethod · 0.45
GetRefNodeMethod · 0.45
CreateCallMethod · 0.45

Tested by

no test coverage detected