mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
Fixed dyn scope detection in null conditional
This commit is contained in:
parent
e018c08134
commit
b10edc6f0a
1 changed files with 21 additions and 7 deletions
|
@ -3020,16 +3020,24 @@ void BfExprEvaluator::Evaluate(BfAstNode* astNode, bool propogateNullConditional
|
|||
// ParenthesizedExpression breaks null conditional chain
|
||||
if (astNode->IsExact<BfParenthesizedExpression>())
|
||||
propogateNullConditional = false;
|
||||
|
||||
bool scopeWasConditional = false;
|
||||
|
||||
BfPendingNullConditional* pendingNullCond = NULL;
|
||||
mInsidePendingNullable = false;
|
||||
if (mModule->mCurMethodState != NULL)
|
||||
{
|
||||
scopeWasConditional = mModule->mCurMethodState->mCurScope->mIsConditional;
|
||||
pendingNullCond = mModule->mCurMethodState->mPendingNullConditional;
|
||||
if (!propogateNullConditional)
|
||||
mModule->mCurMethodState->mPendingNullConditional = NULL;
|
||||
}
|
||||
mInsidePendingNullable = pendingNullCond != NULL;
|
||||
|
||||
if (pendingNullCond != NULL)
|
||||
{
|
||||
mInsidePendingNullable = true;
|
||||
mModule->mCurMethodState->mCurScope->mIsConditional = true;
|
||||
}
|
||||
}
|
||||
|
||||
astNode->Accept(this);
|
||||
GetResult();
|
||||
|
||||
|
@ -3042,11 +3050,17 @@ void BfExprEvaluator::Evaluate(BfAstNode* astNode, bool propogateNullConditional
|
|||
if ((mBfEvalExprFlags & BfEvalExprFlags_AllowIntUnknown) == 0)
|
||||
mModule->FixIntUnknown(mResult);
|
||||
|
||||
if ((!propogateNullConditional) && (mModule->mCurMethodState != NULL))
|
||||
if (mModule->mCurMethodState != NULL)
|
||||
{
|
||||
if (mModule->mCurMethodState->mPendingNullConditional != NULL)
|
||||
mResult = mModule->FlushNullConditional(mResult, ignoreNullConditional);
|
||||
mModule->mCurMethodState->mPendingNullConditional = pendingNullCond;
|
||||
if (mInsidePendingNullable)
|
||||
mModule->mCurMethodState->mCurScope->mIsConditional = scopeWasConditional;
|
||||
|
||||
if (!propogateNullConditional)
|
||||
{
|
||||
if (mModule->mCurMethodState->mPendingNullConditional != NULL)
|
||||
mResult = mModule->FlushNullConditional(mResult, ignoreNullConditional);
|
||||
mModule->mCurMethodState->mPendingNullConditional = pendingNullCond;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue