mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-14 14:24:10 +02:00
Fixed invalid cond expr mExpectingType cast with BfEvalExprFlags_NoCast
This commit is contained in:
parent
a85b09729c
commit
60c19c4160
1 changed files with 4 additions and 2 deletions
|
@ -17797,9 +17797,11 @@ void BfExprEvaluator::Visit(BfConditionalExpression* condExpr)
|
||||||
|
|
||||||
SetAndRestoreValue<bool> prevInCondBlock(mModule->mCurMethodState->mCurScope->mInnerIsConditional, true);
|
SetAndRestoreValue<bool> prevInCondBlock(mModule->mCurMethodState->mCurScope->mInnerIsConditional, true);
|
||||||
|
|
||||||
|
bool wantExpectingCast = (mExpectingType != NULL) && ((mBfEvalExprFlags & BfEvalExprFlags_NoCast) == 0);
|
||||||
|
|
||||||
mModule->AddBasicBlock(trueBB);
|
mModule->AddBasicBlock(trueBB);
|
||||||
auto trueValue = mModule->CreateValueFromExpression(condExpr->mTrueExpression, mExpectingType, (BfEvalExprFlags)((mBfEvalExprFlags & BfEvalExprFlags_InheritFlags) | BfEvalExprFlags_NoCast | BfEvalExprFlags_CreateConditionalScope));
|
auto trueValue = mModule->CreateValueFromExpression(condExpr->mTrueExpression, mExpectingType, (BfEvalExprFlags)((mBfEvalExprFlags & BfEvalExprFlags_InheritFlags) | BfEvalExprFlags_NoCast | BfEvalExprFlags_CreateConditionalScope));
|
||||||
if ((mExpectingType != NULL) && (trueValue) && (trueValue.mType != mExpectingType))
|
if ((wantExpectingCast) && (trueValue) && (trueValue.mType != mExpectingType))
|
||||||
{
|
{
|
||||||
// In some cases like typed primitives - we CAN individually cast each value which it's a constant still, but not after the merging
|
// In some cases like typed primitives - we CAN individually cast each value which it's a constant still, but not after the merging
|
||||||
// IE: Color c = isOver ? 0xFF000000 : 0xFFFFFFFF;
|
// IE: Color c = isOver ? 0xFF000000 : 0xFFFFFFFF;
|
||||||
|
@ -17815,7 +17817,7 @@ void BfExprEvaluator::Visit(BfConditionalExpression* condExpr)
|
||||||
mModule->AddBasicBlock(falseBB);
|
mModule->AddBasicBlock(falseBB);
|
||||||
auto falseValue = mModule->CreateValueFromExpression(condExpr->mFalseExpression, mExpectingType, (BfEvalExprFlags)((mBfEvalExprFlags & BfEvalExprFlags_InheritFlags) | BfEvalExprFlags_NoCast | BfEvalExprFlags_CreateConditionalScope));
|
auto falseValue = mModule->CreateValueFromExpression(condExpr->mFalseExpression, mExpectingType, (BfEvalExprFlags)((mBfEvalExprFlags & BfEvalExprFlags_InheritFlags) | BfEvalExprFlags_NoCast | BfEvalExprFlags_CreateConditionalScope));
|
||||||
auto falseBlockPos = mModule->mBfIRBuilder->GetInsertBlock();
|
auto falseBlockPos = mModule->mBfIRBuilder->GetInsertBlock();
|
||||||
if ((mExpectingType != NULL) && (falseValue) && (falseValue.mType != mExpectingType))
|
if ((wantExpectingCast) && (falseValue) && (falseValue.mType != mExpectingType))
|
||||||
{
|
{
|
||||||
auto checkFalseValue = mModule->Cast(condExpr->mFalseExpression, falseValue, mExpectingType, BfCastFlags_SilentFail);
|
auto checkFalseValue = mModule->Cast(condExpr->mFalseExpression, falseValue, mExpectingType, BfCastFlags_SilentFail);
|
||||||
if (checkFalseValue)
|
if (checkFalseValue)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue