mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-12 13:24:09 +02:00
Pre-widened args for 'i32 = i8 + 100'
This commit is contained in:
parent
07a530c921
commit
e7f079f611
1 changed files with 53 additions and 30 deletions
|
@ -20835,7 +20835,13 @@ void BfExprEvaluator::PerformBinaryOperation(BfExpression* leftExpression, BfExp
|
||||||
if ((binaryOp == BfBinaryOp_NullCoalesce) && (PerformBinaryOperation_NullCoalesce(opToken, leftExpression, rightExpression, leftValue, wantType, NULL)))
|
if ((binaryOp == BfBinaryOp_NullCoalesce) && (PerformBinaryOperation_NullCoalesce(opToken, leftExpression, rightExpression, leftValue, wantType, NULL)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rightValue = mModule->CreateValueFromExpression(rightExpression, wantType, (BfEvalExprFlags)((mBfEvalExprFlags & BfEvalExprFlags_InheritFlags) | BfEvalExprFlags_NoCast));
|
BfType* rightWantType = wantType;
|
||||||
|
if ((mExpectingType != NULL) && (wantType != NULL) && (mExpectingType->IsIntegral()) && (wantType->IsIntegral()) && (mExpectingType->mSize > wantType->mSize) &&
|
||||||
|
((binaryOp == BfBinaryOp_Add) || (binaryOp == BfBinaryOp_Subtract) || (binaryOp == BfBinaryOp_Multiply)))
|
||||||
|
rightWantType = mExpectingType;
|
||||||
|
rightValue = mModule->CreateValueFromExpression(rightExpression, rightWantType, (BfEvalExprFlags)((mBfEvalExprFlags & BfEvalExprFlags_InheritFlags) | BfEvalExprFlags_NoCast));
|
||||||
|
if ((rightWantType != wantType) && (rightValue.mType == rightWantType))
|
||||||
|
wantType = rightWantType;
|
||||||
if ((!leftValue) || (!rightValue))
|
if ((!leftValue) || (!rightValue))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -21268,6 +21274,22 @@ void BfExprEvaluator::PerformBinaryOperation(BfAstNode* leftExpression, BfAstNod
|
||||||
if (!forceLeftType)
|
if (!forceLeftType)
|
||||||
{
|
{
|
||||||
bool handled = false;
|
bool handled = false;
|
||||||
|
|
||||||
|
if (leftValue.mType == rightValue.mType)
|
||||||
|
{
|
||||||
|
// All good
|
||||||
|
handled = true;
|
||||||
|
}
|
||||||
|
else if ((mExpectingType != NULL) &&
|
||||||
|
(mModule->CanCast(leftValue, mExpectingType, BfCastFlags_NoBox)) &&
|
||||||
|
(mModule->CanCast(rightValue, mExpectingType, BfCastFlags_NoBox)) &&
|
||||||
|
(!leftValue.mType->IsVar()) && (!rightValue.mType->IsVar()))
|
||||||
|
{
|
||||||
|
resultType = mExpectingType;
|
||||||
|
handled = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// If one of these is a constant that can be converted into a smaller type, then do that
|
// If one of these is a constant that can be converted into a smaller type, then do that
|
||||||
if (rightValue.mValue.IsConst())
|
if (rightValue.mValue.IsConst())
|
||||||
{
|
{
|
||||||
|
@ -21309,6 +21331,7 @@ void BfExprEvaluator::PerformBinaryOperation(BfAstNode* leftExpression, BfAstNod
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!handled)
|
if (!handled)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue