mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Improved static indexer support
This commit is contained in:
parent
5096e65fc7
commit
b5064536e0
4 changed files with 27 additions and 12 deletions
|
@ -3768,7 +3768,8 @@ void BfExprEvaluator::Visit(BfIdentifierNode* identifierNode)
|
|||
}
|
||||
}
|
||||
|
||||
mModule->Fail("Identifier not found", identifierNode);
|
||||
if ((mBfEvalExprFlags & BfEvalExprFlags_NoLookupError) == 0)
|
||||
mModule->Fail("Identifier not found", identifierNode);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4173,7 +4174,7 @@ BfTypedValue BfExprEvaluator::LookupField(BfAstNode* targetSrc, BfTypedValue tar
|
|||
return retVal;
|
||||
}
|
||||
else if (!target)
|
||||
{
|
||||
{
|
||||
if ((flags & BfLookupFieldFlag_CheckingOuter) != 0)
|
||||
mModule->Fail(StrFormat("An instance reference is required to reference non-static outer field '%s.%s'", mModule->TypeToString(curCheckType).c_str(), field->mName.c_str()),
|
||||
targetSrc);
|
||||
|
@ -8722,7 +8723,8 @@ void BfExprEvaluator::LookupQualifiedStaticField(BfQualifiedNameNode* nameNode,
|
|||
}
|
||||
}
|
||||
|
||||
mModule->Fail("Field not found", nameNode->mRight);
|
||||
if ((mBfEvalExprFlags & BfEvalExprFlags_NoLookupError) == 0)
|
||||
mModule->Fail("Field not found", nameNode->mRight);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -8825,7 +8827,8 @@ void BfExprEvaluator::LookupQualifiedStaticField(BfAstNode* nameNode, BfIdentifi
|
|||
}
|
||||
}
|
||||
|
||||
mModule->Fail("Field not found", nameRight);
|
||||
if ((mBfEvalExprFlags & BfEvalExprFlags_NoLookupError) == 0)
|
||||
mModule->Fail("Field not found", nameRight);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -17885,8 +17888,14 @@ void BfExprEvaluator::Visit(BfIndexerExpression* indexerExpr)
|
|||
// Try first as a non-static indexer, then as a static indexer
|
||||
for (int pass = 0; pass < 2; pass++)
|
||||
{
|
||||
SetAndRestoreValue<bool> ignoreErrors(mModule->mIgnoreErrors, (mModule->mIgnoreErrors) || (pass == 0));
|
||||
VisitChild(indexerExpr->mTarget);
|
||||
// SetAndRestoreValue<bool> prevIgnoreErrors(mModule->mIgnoreErrors, (mModule->mIgnoreErrors) || (pass == 0));
|
||||
// SetAndRestoreValue<bool> prevHadIgnoredError(mModule->mHadIgnoredError, false);
|
||||
|
||||
|
||||
{
|
||||
SetAndRestoreValue<BfEvalExprFlags> prevFlags(mBfEvalExprFlags, (BfEvalExprFlags)(mBfEvalExprFlags | BfEvalExprFlags_NoLookupError));
|
||||
VisitChild(indexerExpr->mTarget);
|
||||
}
|
||||
ResolveGenericType();
|
||||
target = GetResult(true);
|
||||
if (target)
|
||||
|
@ -17894,6 +17903,7 @@ void BfExprEvaluator::Visit(BfIndexerExpression* indexerExpr)
|
|||
|
||||
if (pass == 0)
|
||||
{
|
||||
SetAndRestoreValue<bool> prevIgnoreErrors(mModule->mIgnoreErrors, (mModule->mIgnoreErrors) || (pass == 0));
|
||||
auto staticType = mModule->ResolveTypeRef(indexerExpr->mTarget, {});
|
||||
if (staticType != NULL)
|
||||
{
|
||||
|
|
|
@ -833,6 +833,7 @@ BfModule::BfModule(BfContext* context, const StringImpl& moduleName)
|
|||
mHadBuildError = false;
|
||||
mHadBuildWarning = false;
|
||||
mIgnoreErrors = false;
|
||||
mHadIgnoredError = false;
|
||||
mIgnoreWarnings = false;
|
||||
mReportErrors = true;
|
||||
mIsInsideAutoComplete = false;
|
||||
|
@ -2672,7 +2673,8 @@ BfError* BfModule::Fail(const StringImpl& error, BfAstNode* refNode, bool isPers
|
|||
BP_ZONE("BfModule::Fail");
|
||||
|
||||
if (mIgnoreErrors)
|
||||
{
|
||||
{
|
||||
mHadIgnoredError = true;
|
||||
if (mAttributeState != NULL)
|
||||
mAttributeState->mFlags = (BfAttributeState::Flags)(mAttributeState->mFlags | BfAttributeState::Flag_HadError);
|
||||
return NULL;
|
||||
|
|
|
@ -67,7 +67,8 @@ enum BfEvalExprFlags
|
|||
BfEvalExprFlags_VariableDeclaration = 0x4000,
|
||||
BfEvalExprFlags_NoAutoComplete = 0x8000,
|
||||
BfEvalExprFlags_AllowNonConst = 0x10000,
|
||||
BfEvalExprFlags_StringInterpolateFormat = 0x20000
|
||||
BfEvalExprFlags_StringInterpolateFormat = 0x20000,
|
||||
BfEvalExprFlags_NoLookupError = 0x40000,
|
||||
};
|
||||
|
||||
enum BfCastFlags
|
||||
|
@ -994,6 +995,7 @@ public:
|
|||
bool mAllowUinitReads;
|
||||
bool mCancelledDeferredCall;
|
||||
bool mNoObjectAccessChecks;
|
||||
bool mHadIgnoredError;
|
||||
int mCurLocalVarId; // Can also refer to a label
|
||||
int mCurAccessId; // For checking to see if a block reads from or writes to a local
|
||||
|
||||
|
@ -1031,7 +1033,7 @@ public:
|
|||
mAllowUinitReads = false;
|
||||
mCancelledDeferredCall = false;
|
||||
mNoObjectAccessChecks = false;
|
||||
mInDeferredBlock = false;
|
||||
mInDeferredBlock = false;
|
||||
mDeferredLocalAssignData = NULL;
|
||||
mCurLocalVarId = 0;
|
||||
mCurAccessId = 1;
|
||||
|
@ -1445,7 +1447,8 @@ public:
|
|||
bool mWroteToLib;
|
||||
bool mHadBuildError;
|
||||
bool mHadBuildWarning;
|
||||
bool mIgnoreErrors;
|
||||
bool mIgnoreErrors;
|
||||
bool mHadIgnoredError;
|
||||
bool mIgnoreWarnings;
|
||||
bool mSetIllegalSrcPosition;
|
||||
bool mReportErrors; // Still puts system in error state when set to false
|
||||
|
|
|
@ -9566,8 +9566,8 @@ BfType* BfModule::ResolveInnerType(BfType* outerType, BfIdentifierNode* identifi
|
|||
{
|
||||
BfDirectStrTypeReference typeRef;
|
||||
typeRef.Init(identifier->ToString());
|
||||
|
||||
auto type = ResolveInnerType(outerType, &typeRef, populateType, ignoreErrors);
|
||||
// There is no ref node so we ignore errors
|
||||
auto type = ResolveInnerType(outerType, &typeRef, populateType, /*ignoreErrors*/true);
|
||||
return type;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue