1
0
Fork 0
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:
Brian Fiete 2020-12-05 04:29:27 -08:00
parent 5096e65fc7
commit b5064536e0
4 changed files with 27 additions and 12 deletions

View file

@ -3768,6 +3768,7 @@ void BfExprEvaluator::Visit(BfIdentifierNode* identifierNode)
}
}
if ((mBfEvalExprFlags & BfEvalExprFlags_NoLookupError) == 0)
mModule->Fail("Identifier not found", identifierNode);
}
}
@ -8722,6 +8723,7 @@ void BfExprEvaluator::LookupQualifiedStaticField(BfQualifiedNameNode* nameNode,
}
}
if ((mBfEvalExprFlags & BfEvalExprFlags_NoLookupError) == 0)
mModule->Fail("Field not found", nameNode->mRight);
return;
}
@ -8825,6 +8827,7 @@ void BfExprEvaluator::LookupQualifiedStaticField(BfAstNode* nameNode, BfIdentifi
}
}
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));
// 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)
{

View file

@ -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;
@ -2673,6 +2674,7 @@ BfError* BfModule::Fail(const StringImpl& error, BfAstNode* refNode, bool isPers
if (mIgnoreErrors)
{
mHadIgnoredError = true;
if (mAttributeState != NULL)
mAttributeState->mFlags = (BfAttributeState::Flags)(mAttributeState->mFlags | BfAttributeState::Flag_HadError);
return NULL;

View file

@ -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
@ -1446,6 +1448,7 @@ public:
bool mHadBuildError;
bool mHadBuildWarning;
bool mIgnoreErrors;
bool mHadIgnoredError;
bool mIgnoreWarnings;
bool mSetIllegalSrcPosition;
bool mReportErrors; // Still puts system in error state when set to false

View file

@ -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;
}