| 19739 | } |
| 19740 | |
| 19741 | BfMethodDef* BfExprEvaluator::GetPropertyMethodDef(BfPropertyDef* propDef, BfMethodType methodType, BfCheckedKind checkedKind, BfTypedValue propTarget) |
| 19742 | { |
| 19743 | bool allowMut = true; |
| 19744 | if ((propTarget) && (propTarget.mType->IsValueType())) |
| 19745 | { |
| 19746 | if (propTarget.IsReadOnly()) |
| 19747 | { |
| 19748 | allowMut = false; |
| 19749 | } |
| 19750 | else if (!propTarget.IsAddr()) |
| 19751 | { |
| 19752 | mModule->PopulateType(propTarget.mType); |
| 19753 | if (!propTarget.IsValuelessType()) |
| 19754 | allowMut = false; |
| 19755 | } |
| 19756 | } |
| 19757 | |
| 19758 | int bestPri = -1000; |
| 19759 | BfMethodDef* matchedMethod = NULL; |
| 19760 | |
| 19761 | for (auto methodDef : propDef->mMethods) |
| 19762 | { |
| 19763 | if (methodDef->mMethodType != methodType) |
| 19764 | continue; |
| 19765 | |
| 19766 | int curPri = 0; |
| 19767 | |
| 19768 | if (methodDef->mCheckedKind == checkedKind) |
| 19769 | { |
| 19770 | curPri = 5; |
| 19771 | } |
| 19772 | else if ((checkedKind == BfCheckedKind_NotSet) && (methodDef->mCheckedKind == mModule->GetDefaultCheckedKind())) |
| 19773 | curPri = 3; |
| 19774 | else |
| 19775 | curPri = 1; |
| 19776 | |
| 19777 | if (methodDef->mIsMutating) |
| 19778 | { |
| 19779 | if (allowMut) |
| 19780 | curPri++; |
| 19781 | else |
| 19782 | curPri -= 10; |
| 19783 | } |
| 19784 | |
| 19785 | if (curPri > bestPri) |
| 19786 | { |
| 19787 | bestPri = curPri; |
| 19788 | matchedMethod = methodDef; |
| 19789 | } |
| 19790 | } |
| 19791 | |
| 19792 | return matchedMethod; |
| 19793 | |
| 19794 | /*BfMethodDef* matchedMethod = NULL; |
| 19795 | BfMethodDef* backupMethod = NULL; |
| 19796 | for (auto methodDef : propDef->mMethods) |
| 19797 | { |
| 19798 | if (methodDef->mMethodType != methodType) |
no test coverage detected