mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 12:02:21 +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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17885,8 +17888,14 @@ void BfExprEvaluator::Visit(BfIndexerExpression* indexerExpr)
|
||||||
// Try first as a non-static indexer, then as a static indexer
|
// Try first as a non-static indexer, then as a static indexer
|
||||||
for (int pass = 0; pass < 2; pass++)
|
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));
|
||||||
VisitChild(indexerExpr->mTarget);
|
// SetAndRestoreValue<bool> prevHadIgnoredError(mModule->mHadIgnoredError, false);
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
SetAndRestoreValue<BfEvalExprFlags> prevFlags(mBfEvalExprFlags, (BfEvalExprFlags)(mBfEvalExprFlags | BfEvalExprFlags_NoLookupError));
|
||||||
|
VisitChild(indexerExpr->mTarget);
|
||||||
|
}
|
||||||
ResolveGenericType();
|
ResolveGenericType();
|
||||||
target = GetResult(true);
|
target = GetResult(true);
|
||||||
if (target)
|
if (target)
|
||||||
|
@ -17894,6 +17903,7 @@ void BfExprEvaluator::Visit(BfIndexerExpression* indexerExpr)
|
||||||
|
|
||||||
if (pass == 0)
|
if (pass == 0)
|
||||||
{
|
{
|
||||||
|
SetAndRestoreValue<bool> prevIgnoreErrors(mModule->mIgnoreErrors, (mModule->mIgnoreErrors) || (pass == 0));
|
||||||
auto staticType = mModule->ResolveTypeRef(indexerExpr->mTarget, {});
|
auto staticType = mModule->ResolveTypeRef(indexerExpr->mTarget, {});
|
||||||
if (staticType != NULL)
|
if (staticType != NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -833,6 +833,7 @@ BfModule::BfModule(BfContext* context, const StringImpl& moduleName)
|
||||||
mHadBuildError = false;
|
mHadBuildError = false;
|
||||||
mHadBuildWarning = false;
|
mHadBuildWarning = false;
|
||||||
mIgnoreErrors = false;
|
mIgnoreErrors = false;
|
||||||
|
mHadIgnoredError = false;
|
||||||
mIgnoreWarnings = false;
|
mIgnoreWarnings = false;
|
||||||
mReportErrors = true;
|
mReportErrors = true;
|
||||||
mIsInsideAutoComplete = false;
|
mIsInsideAutoComplete = false;
|
||||||
|
@ -2673,6 +2674,7 @@ BfError* BfModule::Fail(const StringImpl& error, BfAstNode* refNode, bool isPers
|
||||||
|
|
||||||
if (mIgnoreErrors)
|
if (mIgnoreErrors)
|
||||||
{
|
{
|
||||||
|
mHadIgnoredError = true;
|
||||||
if (mAttributeState != NULL)
|
if (mAttributeState != NULL)
|
||||||
mAttributeState->mFlags = (BfAttributeState::Flags)(mAttributeState->mFlags | BfAttributeState::Flag_HadError);
|
mAttributeState->mFlags = (BfAttributeState::Flags)(mAttributeState->mFlags | BfAttributeState::Flag_HadError);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -67,7 +67,8 @@ enum BfEvalExprFlags
|
||||||
BfEvalExprFlags_VariableDeclaration = 0x4000,
|
BfEvalExprFlags_VariableDeclaration = 0x4000,
|
||||||
BfEvalExprFlags_NoAutoComplete = 0x8000,
|
BfEvalExprFlags_NoAutoComplete = 0x8000,
|
||||||
BfEvalExprFlags_AllowNonConst = 0x10000,
|
BfEvalExprFlags_AllowNonConst = 0x10000,
|
||||||
BfEvalExprFlags_StringInterpolateFormat = 0x20000
|
BfEvalExprFlags_StringInterpolateFormat = 0x20000,
|
||||||
|
BfEvalExprFlags_NoLookupError = 0x40000,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum BfCastFlags
|
enum BfCastFlags
|
||||||
|
@ -994,6 +995,7 @@ public:
|
||||||
bool mAllowUinitReads;
|
bool mAllowUinitReads;
|
||||||
bool mCancelledDeferredCall;
|
bool mCancelledDeferredCall;
|
||||||
bool mNoObjectAccessChecks;
|
bool mNoObjectAccessChecks;
|
||||||
|
bool mHadIgnoredError;
|
||||||
int mCurLocalVarId; // Can also refer to a label
|
int mCurLocalVarId; // Can also refer to a label
|
||||||
int mCurAccessId; // For checking to see if a block reads from or writes to a local
|
int mCurAccessId; // For checking to see if a block reads from or writes to a local
|
||||||
|
|
||||||
|
@ -1446,6 +1448,7 @@ public:
|
||||||
bool mHadBuildError;
|
bool mHadBuildError;
|
||||||
bool mHadBuildWarning;
|
bool mHadBuildWarning;
|
||||||
bool mIgnoreErrors;
|
bool mIgnoreErrors;
|
||||||
|
bool mHadIgnoredError;
|
||||||
bool mIgnoreWarnings;
|
bool mIgnoreWarnings;
|
||||||
bool mSetIllegalSrcPosition;
|
bool mSetIllegalSrcPosition;
|
||||||
bool mReportErrors; // Still puts system in error state when set to false
|
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;
|
BfDirectStrTypeReference typeRef;
|
||||||
typeRef.Init(identifier->ToString());
|
typeRef.Init(identifier->ToString());
|
||||||
|
// There is no ref node so we ignore errors
|
||||||
auto type = ResolveInnerType(outerType, &typeRef, populateType, ignoreErrors);
|
auto type = ResolveInnerType(outerType, &typeRef, populateType, /*ignoreErrors*/true);
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue