mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 03:52:19 +02:00
Support for static indexers
This commit is contained in:
parent
569d121c14
commit
f33e65b56d
1 changed files with 29 additions and 20 deletions
|
@ -17393,10 +17393,31 @@ void BfExprEvaluator::Visit(BfMemberReferenceExpression* memberRefExpr)
|
||||||
|
|
||||||
void BfExprEvaluator::Visit(BfIndexerExpression* indexerExpr)
|
void BfExprEvaluator::Visit(BfIndexerExpression* indexerExpr)
|
||||||
{
|
{
|
||||||
VisitChild(indexerExpr->mTarget);
|
BfTypedValue target;
|
||||||
ResolveGenericType();
|
bool wantStatic = false;
|
||||||
auto target = GetResult(true);
|
// Try first as a non-static indexer, then as a static indexer
|
||||||
if (!target)
|
for (int pass = 0; pass < 2; pass++)
|
||||||
|
{
|
||||||
|
SetAndRestoreValue<bool> ignoreErrors(mModule->mIgnoreErrors, (mModule->mIgnoreErrors) || (pass == 0));
|
||||||
|
VisitChild(indexerExpr->mTarget);
|
||||||
|
ResolveGenericType();
|
||||||
|
target = GetResult(true);
|
||||||
|
if (target)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (pass == 0)
|
||||||
|
{
|
||||||
|
auto staticType = mModule->ResolveTypeRef(indexerExpr->mTarget, {});
|
||||||
|
if (staticType != NULL)
|
||||||
|
{
|
||||||
|
wantStatic = true;
|
||||||
|
target.mType = staticType;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!target.HasType())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BfCheckedKind checkedKind = BfCheckedKind_NotSet;
|
BfCheckedKind checkedKind = BfCheckedKind_NotSet;
|
||||||
|
@ -17434,21 +17455,6 @@ void BfExprEvaluator::Visit(BfIndexerExpression* indexerExpr)
|
||||||
if (target.mType->IsTypeInstance())
|
if (target.mType->IsTypeInstance())
|
||||||
{
|
{
|
||||||
mIndexerValues.clear();
|
mIndexerValues.clear();
|
||||||
// for (BfExpression* expr : indexerExpr->mArguments)
|
|
||||||
// {
|
|
||||||
// if (expr == NULL)
|
|
||||||
// return;
|
|
||||||
// auto argVal = mModule->CreateValueFromExpression(expr);
|
|
||||||
// if (!argVal)
|
|
||||||
// {
|
|
||||||
// mModule->AssertErrorState();
|
|
||||||
// argVal = mModule->GetDefaultTypedValue(mModule->mContext->mBfObjectType);
|
|
||||||
// }
|
|
||||||
// BfResolvedArg resolvedArg;
|
|
||||||
// resolvedArg.mExpression = expr;
|
|
||||||
// resolvedArg.mTypedValue = argVal;
|
|
||||||
// mIndexerValues.push_back(resolvedArg);
|
|
||||||
// }
|
|
||||||
|
|
||||||
SizedArray<BfExpression*, 2> argExprs;
|
SizedArray<BfExpression*, 2> argExprs;
|
||||||
BfSizedArray<BfExpression*> sizedArgExprs(indexerExpr->mArguments);
|
BfSizedArray<BfExpression*> sizedArgExprs(indexerExpr->mArguments);
|
||||||
|
@ -17505,6 +17511,9 @@ void BfExprEvaluator::Visit(BfIndexerExpression* indexerExpr)
|
||||||
// For generic params - check interface constraints for an indexer, call that method
|
// For generic params - check interface constraints for an indexer, call that method
|
||||||
BF_ASSERT(!target.mType->IsGenericParam());
|
BF_ASSERT(!target.mType->IsGenericParam());
|
||||||
|
|
||||||
|
if (checkMethod->mIsStatic != wantStatic)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (checkMethod->mExplicitInterface != NULL)
|
if (checkMethod->mExplicitInterface != NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -17528,7 +17537,7 @@ void BfExprEvaluator::Visit(BfIndexerExpression* indexerExpr)
|
||||||
|
|
||||||
if (!methodMatcher.IsMemberAccessible(curCheckType, checkMethod->mDeclaringType))
|
if (!methodMatcher.IsMemberAccessible(curCheckType, checkMethod->mDeclaringType))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
methodMatcher.mCheckedKind = checkedKind;
|
methodMatcher.mCheckedKind = checkedKind;
|
||||||
methodMatcher.mTarget = target;
|
methodMatcher.mTarget = target;
|
||||||
methodMatcher.CheckMethod(startCheckTypeInst, curCheckType, checkMethod, false);
|
methodMatcher.CheckMethod(startCheckTypeInst, curCheckType, checkMethod, false);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue