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

Method CompareMethods

IDEHelper/Compiler/BfExprEvaluator.cpp:754–1300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

752}
753
754void BfMethodMatcher::CompareMethods(BfMethodInstance* prevMethodInstance, BfTypeVector* prevGenericArgumentsSubstitute,
755 BfMethodInstance* newMethodInstance, BfTypeVector* genericArgumentsSubstitute,
756 bool* outNewIsBetter, bool* outNewIsWorse, bool allowSpecializeFail)
757{
758 if (prevMethodInstance == newMethodInstance)
759 {
760 *outNewIsBetter = false;
761 *outNewIsWorse = true;
762 return;
763 }
764
765 #define SET_BETTER_OR_WORSE(lhs, rhs) \
766 if ((!isBetter) && (lhs) && !(rhs)) isBetter = true; \
767 if ((!isWorse) && !(lhs) && (rhs)) isWorse = true;
768
769 #define RETURN_BETTER_OR_WORSE(lhs, rhs) \
770 if ((!isBetter) && (lhs) && !(rhs)) { *outNewIsBetter = true; *outNewIsWorse = false; return; } \
771 if ((!isWorse) && !(lhs) && (rhs)) { *outNewIsBetter = false; *outNewIsWorse = true; return; };
772
773 #define RETURN_RESULTS \
774 *outNewIsBetter = isBetter; \
775 *outNewIsWorse = isWorse; \
776 return;
777
778 int numUsedParams = 0;
779 int prevNumUsedParams = 0;
780 bool usedExtendedForm = false;
781 bool prevUsedExtendedForm = false;
782
783 bool isBetter = false;
784 bool isWorse = false;
785 int argIdx;
786
787 BfMethodDef* prevMethodDef = prevMethodInstance->mMethodDef;
788 BfMethodDef* newMethodDef = newMethodInstance->mMethodDef;
789
790 if (prevMethodDef == mBackupMethodDef)
791 {
792 // This can happen for extension methods and such
793 *outNewIsBetter = true;
794 *outNewIsWorse = false;
795 return;
796 }
797
798 if (newMethodDef->mExplicitInterface != prevMethodDef->mExplicitInterface)
799 {
800 if (mModule->CompareMethodSignatures(newMethodInstance, prevMethodInstance))
801 {
802 SET_BETTER_OR_WORSE(newMethodDef->mExplicitInterface != NULL, prevMethodDef->mExplicitInterface != NULL);
803 *outNewIsBetter = isBetter;
804 *outNewIsWorse = isWorse;
805 return;
806 }
807 }
808
809 bool anyIsExtension = false;
810
811 int newImplicitParamCount = newMethodInstance->GetImplicitParamCount();

Callers

nothing calls this directly

Calls 15

GetImplicitParamCountMethod · 0.80
HasAppendMethod · 0.80
WasGenericParamMethod · 0.80
FixIntUnknownMethod · 0.80
GetFakeTypedValueMethod · 0.80
GetParamKindMethod · 0.80
HasParamsArrayMethod · 0.80
AreConstraintsSubsetMethod · 0.80
HasExternConstraintsMethod · 0.80

Tested by

no test coverage detected