]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Debugger calculator OR, AND, XOR operators.
authorToni Wilen <twilen@winuae.net>
Sun, 13 Feb 2022 20:24:53 +0000 (22:24 +0200)
committerToni Wilen <twilen@winuae.net>
Sun, 13 Feb 2022 20:24:53 +0000 (22:24 +0200)
calc.cpp
debug.cpp

index da06292a157ead490d1b5d5ee2b1292a6ac9a9f2..811751567aadb12a29de3bb1a12c89f6abc828fe 100644 (file)
--- a/calc.cpp
+++ b/calc.cpp
@@ -45,7 +45,8 @@ static int op_preced(const TCHAR c)
     switch(c)    {
         case '!':
             return 4;
-               case '*':  case '/': case '\\': case '%':
+        case '*':  case '/': case '\\': case '%':
+        case '|':  case '&': case '^':
             return 3;
         case '+': case '-':
             return 2;
@@ -60,6 +61,7 @@ static bool op_left_assoc(const TCHAR c)
     switch(c)    {
         // left to right
         case '*': case '/': case '%': case '+': case '-':
+        case '|': case '&': case '^':
             return true;
         // right to left
         case '=': case '!':
@@ -72,6 +74,7 @@ static unsigned int op_arg_count(const TCHAR c)
 {
     switch(c)  {
         case '*': case '/': case '%': case '+': case '-': case '=':
+        case '|': case '&': case '^':
             return 2;
         case '!':
             return 1;
@@ -81,7 +84,7 @@ static unsigned int op_arg_count(const TCHAR c)
     return 0;
 }
  
-#define is_operator(c)  (c == '+' || c == '-' || c == '/' || c == '*' || c == '!' || c == '%' || c == '=')
+#define is_operator(c)  (c == '+' || c == '-' || c == '/' || c == '*' || c == '!' || c == '%' || c == '=' || c == '|' || c == '&' || c == '^')
 #define is_function(c)  (c >= 'A' && c <= 'Z')
 #define is_ident(c)     ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z'))
  
@@ -240,7 +243,12 @@ static double docalcx(TCHAR op, double v1, double v2)
                return v1 / v2;
                case '\\':
                return (int)v1 % (int)v2;
-
+        case '|':
+        return (int)v1 | (int)v2;
+        case '&':
+        return (int)v1 & (int)v2;
+        case '^':
+        return (int)v1 ^ (int)v2;
        }
        return 0;
 }
index 89498b13a9e8621e1030d3cf32b9db41254d7bef..d86ac6e69fb2782a173e99ee1f35d9e308781002 100644 (file)
--- a/debug.cpp
+++ b/debug.cpp
@@ -498,7 +498,7 @@ static bool iscancel (int counter)
 static bool isoperator(TCHAR **cp)
 {
        TCHAR c = **cp;
-       return c == '+' || c == '-' || c == '/' || c == '*' || c == '(' || c == ')';
+       return c == '+' || c == '-' || c == '/' || c == '*' || c == '(' || c == ')' || c == '|' || c == '&' || c == '^';
 }
 
 static void ignore_ws (TCHAR **c)