1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 03:28:20 +02:00

Added overflow operators &+, &-, &*

This commit is contained in:
Brian Fiete 2021-07-15 06:01:17 -07:00
parent 8d2b222c1a
commit d475d3641f
7 changed files with 151 additions and 25 deletions

View file

@ -5975,13 +5975,13 @@ void DbgExprEvaluator::PerformBinaryOperation(ASTREF(BfExpression*)& leftExpress
// One pointer
if ((!otherType->IsInteger()) ||
((binaryOp != BfBinaryOp_Add) && (binaryOp != BfBinaryOp_Subtract) && (!isCompare)))
((binaryOp != BfBinaryOp_Add) && (binaryOp != BfBinaryOp_Subtract) && (binaryOp != BfBinaryOp_OverflowAdd) && (binaryOp != BfBinaryOp_OverflowSubtract) && (!isCompare)))
{
Fail("Can only add or subtract integer values from pointers", rightExpression);
return;
}
if ((binaryOp == BfBinaryOp_Add) || (binaryOp == BfBinaryOp_Subtract))
if ((binaryOp == BfBinaryOp_Add) || (binaryOp == BfBinaryOp_Subtract) || (binaryOp == BfBinaryOp_OverflowAdd) || (binaryOp == BfBinaryOp_OverflowSubtract))
{
auto underlyingType = otherType->GetUnderlyingType();
mResult.mType = resultType;
@ -6262,6 +6262,7 @@ void DbgExprEvaluator::PerformBinaryOperation(DbgType* resultType, DbgTypedValue
switch (binaryOp)
{
case BfBinaryOp_Add:
case BfBinaryOp_OverflowAdd:
if (resultType->mTypeCode == DbgType_Single)
mResult.mSingle = convLeftValue.mSingle + convRightValue.mSingle;
else if (resultType->mTypeCode == DbgType_Double)
@ -6270,6 +6271,7 @@ void DbgExprEvaluator::PerformBinaryOperation(DbgType* resultType, DbgTypedValue
mResult.mInt64 = convLeftValue.GetInt64() + convRightValue.GetInt64();
break;
case BfBinaryOp_Subtract:
case BfBinaryOp_OverflowSubtract:
if (resultType->mTypeCode == DbgType_Single)
mResult.mSingle = convLeftValue.mSingle - convRightValue.mSingle;
else if (resultType->mTypeCode == DbgType_Double)
@ -6278,6 +6280,7 @@ void DbgExprEvaluator::PerformBinaryOperation(DbgType* resultType, DbgTypedValue
mResult.mInt64 = convLeftValue.GetInt64() - convRightValue.GetInt64();
break;
case BfBinaryOp_Multiply:
case BfBinaryOp_OverflowMultiply:
if (resultType->mTypeCode == DbgType_Single)
mResult.mSingle = convLeftValue.mSingle * convRightValue.mSingle;
else if (resultType->mTypeCode == DbgType_Double)