1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 04:22:20 +02:00

Fixed indexer method selection

This commit is contained in:
Brian Fiete 2022-06-08 10:57:30 -07:00
parent 29832cb3bb
commit 35a81b7bbe
2 changed files with 45 additions and 35 deletions

View file

@ -20981,16 +20981,14 @@ void BfExprEvaluator::Visit(BfIndexerExpression* indexerExpr)
{
bool isFailurePass = pass == 1;
BfPropertyDef* foundProp = NULL;
BfTypeInstance* foundPropTypeInst = NULL;
auto curCheckType = startCheckTypeInst;
while (curCheckType != NULL)
{
BfProtectionCheckFlags protectionCheckFlags = BfProtectionCheckFlag_None;
BfPropertyDef* foundProp = NULL;
BfTypeInstance* foundPropTypeInst = NULL;
int matchedIndexCount = 0;
curCheckType->mTypeDef->PopulateMemberSets();
BfMemberSetEntry* entry;
@ -21042,46 +21040,44 @@ void BfExprEvaluator::Visit(BfIndexerExpression* indexerExpr)
methodMatcher.mCheckedKind = checkedKind;
methodMatcher.mTarget = target;
methodMatcher.CheckMethod(startCheckTypeInst, curCheckType, checkMethod, false);
bool hadMatch = methodMatcher.CheckMethod(startCheckTypeInst, curCheckType, checkMethod, false);
if ((methodMatcher.mBestMethodDef == checkMethod) || (methodMatcher.mBackupMethodDef == checkMethod))
if ((hadMatch) || (methodMatcher.mBackupMethodDef == checkMethod))
{
foundPropTypeInst = curCheckType;
foundProp = prop;
matchedIndexCount = (int)checkMethod->mParams.size();
}
}
}
if (foundProp != NULL)
{
mPropSrc = indexerExpr->mOpenBracket;
mPropDef = foundProp;
if (foundProp->mIsStatic)
{
mPropTarget = BfTypedValue(curCheckType);
}
else
{
if (target.mType != foundPropTypeInst)
mPropTarget = mModule->Cast(indexerExpr->mTarget, target, foundPropTypeInst);
else
mPropTarget = target;
}
mOrigPropTarget = mPropTarget;
if (isInlined)
mPropGetMethodFlags = (BfGetMethodInstanceFlags)(mPropGetMethodFlags | BfGetMethodInstanceFlag_ForceInline);
mPropCheckedKind = checkedKind;
if ((target.IsBase()) && (mPropDef->IsVirtual()))
mPropDefBypassVirtual = true;
return;
}
curCheckType = curCheckType->mBaseType;
}
if (foundProp != NULL)
{
mPropSrc = indexerExpr->mOpenBracket;
mPropDef = foundProp;
if (foundProp->mIsStatic)
{
mPropTarget = BfTypedValue(curCheckType);
}
else
{
if (target.mType != foundPropTypeInst)
mPropTarget = mModule->Cast(indexerExpr->mTarget, target, foundPropTypeInst);
else
mPropTarget = target;
}
mOrigPropTarget = mPropTarget;
if (isInlined)
mPropGetMethodFlags = (BfGetMethodInstanceFlags)(mPropGetMethodFlags | BfGetMethodInstanceFlag_ForceInline);
mPropCheckedKind = checkedKind;
if ((target.IsBase()) && (mPropDef->IsVirtual()))
mPropDefBypassVirtual = true;
return;
}
}
mModule->Fail("Unable to find indexer property", indexerExpr->mTarget);