1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 04:22:20 +02:00

Fixed boxing from ternary operator

This commit is contained in:
Brian Fiete 2020-10-26 12:51:01 -07:00
parent f09a9b41f1
commit 251a8bb379

View file

@ -16046,7 +16046,7 @@ void BfExprEvaluator::Visit(BfConditionalExpression* condExpr)
} }
if (isConstBranch) if (isConstBranch)
{ {
BfExpression* actualExpr = (constResult) ? condExpr->mTrueExpression : condExpr->mFalseExpression; BfExpression* actualExpr = (constResult) ? condExpr->mTrueExpression : condExpr->mFalseExpression;
BfExpression* ignoredExpr = (constResult) ? condExpr->mFalseExpression : condExpr->mTrueExpression; BfExpression* ignoredExpr = (constResult) ? condExpr->mFalseExpression : condExpr->mTrueExpression;
@ -16090,6 +16090,8 @@ void BfExprEvaluator::Visit(BfConditionalExpression* condExpr)
mModule->mBfIRBuilder->CreateCondBr(condResult.mValue, trueBB, falseBB); mModule->mBfIRBuilder->CreateCondBr(condResult.mValue, trueBB, falseBB);
SetAndRestoreValue<bool> prevInCondBlock(mModule->mCurMethodState->mCurScope->mInnerIsConditional, true);
mModule->AddBasicBlock(trueBB); mModule->AddBasicBlock(trueBB);
auto trueValue = mModule->CreateValueFromExpression(condExpr->mTrueExpression, mExpectingType, (BfEvalExprFlags)(BfEvalExprFlags_NoCast | BfEvalExprFlags_CreateConditionalScope)); auto trueValue = mModule->CreateValueFromExpression(condExpr->mTrueExpression, mExpectingType, (BfEvalExprFlags)(BfEvalExprFlags_NoCast | BfEvalExprFlags_CreateConditionalScope));
if ((mExpectingType != NULL) && (trueValue) && (trueValue.mType != mExpectingType)) if ((mExpectingType != NULL) && (trueValue) && (trueValue.mType != mExpectingType))
@ -16116,6 +16118,8 @@ void BfExprEvaluator::Visit(BfConditionalExpression* condExpr)
mModule->FixIntUnknown(falseValue); mModule->FixIntUnknown(falseValue);
} }
prevInCondBlock.Restore();
bool isValid = trueValue && falseValue; bool isValid = trueValue && falseValue;
if (isValid) if (isValid)