mirror of
https://github.com/SourMesen/Mesen.git
synced 2025-04-02 10:52:48 -04:00
Debugger: Properly support division by 0 in expressions
This commit is contained in:
parent
423ac65a7e
commit
3fdc000a3d
4 changed files with 18 additions and 4 deletions
|
@ -335,8 +335,19 @@ int32_t ExpressionEvaluator::Evaluate(vector<int> &rpnList, DebugState &state, E
|
|||
resultType = EvalResultType::Numeric;
|
||||
switch(token) {
|
||||
case EvalOperators::Multiplication: token = left * right; break;
|
||||
case EvalOperators::Division: token = left / right; break;
|
||||
case EvalOperators::Modulo: token = left % right; break;
|
||||
case EvalOperators::Division:
|
||||
if(right == 0) {
|
||||
resultType = EvalResultType::DivideBy0;
|
||||
return 0;
|
||||
}
|
||||
token = left / right; break;
|
||||
case EvalOperators::Modulo:
|
||||
if(right == 0) {
|
||||
resultType = EvalResultType::DivideBy0;
|
||||
return 0;
|
||||
}
|
||||
token = left % right;
|
||||
break;
|
||||
case EvalOperators::Addition: token = left + right; break;
|
||||
case EvalOperators::Substration: token = left - right; break;
|
||||
case EvalOperators::ShiftLeft: token = left << right; break;
|
||||
|
|
|
@ -69,7 +69,8 @@ enum EvalResultType
|
|||
{
|
||||
Numeric = 0,
|
||||
Boolean = 1,
|
||||
Invalid = 2
|
||||
Invalid = 2,
|
||||
DivideBy0 = 3
|
||||
};
|
||||
|
||||
class StringHasher
|
||||
|
|
|
@ -35,6 +35,7 @@ namespace Mesen.GUI.Debugger
|
|||
case EvalResultType.Numeric: newValue = useHex ? ("$" + result.ToString("X2")) : result.ToString(); break;
|
||||
case EvalResultType.Boolean: newValue = result == 0 ? "false" : "true"; break;
|
||||
case EvalResultType.Invalid: newValue = "<invalid expression>"; forceHasChanged = true; break;
|
||||
case EvalResultType.DivideBy0: newValue = "<division by zero>"; forceHasChanged = true; break;
|
||||
}
|
||||
|
||||
list.Add(new WatchValueInfo() { Expression = expression, Value = newValue, HasChanged = forceHasChanged || (i < _previousValues.Count ? (_previousValues[i].Value != newValue) : false) });
|
||||
|
|
|
@ -1800,7 +1800,8 @@ namespace Mesen.GUI
|
|||
{
|
||||
Numeric = 0,
|
||||
Boolean = 1,
|
||||
Invalid = 2
|
||||
Invalid = 2,
|
||||
DivideBy0 = 3
|
||||
}
|
||||
|
||||
public enum NesModel
|
||||
|
|
Loading…
Add table
Reference in a new issue