]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Add debugger calculator comparison operators. (not complete)
authorToni Wilen <twilen@winuae.net>
Sat, 15 Apr 2023 18:10:10 +0000 (21:10 +0300)
committerToni Wilen <twilen@winuae.net>
Sat, 15 Apr 2023 18:10:10 +0000 (21:10 +0300)
calc.cpp
debug.cpp

index 811751567aadb12a29de3bb1a12c89f6abc828fe..2f1224d968d2f4c3dd5ba7c1571c91ad6ddd84cc 100644 (file)
--- a/calc.cpp
+++ b/calc.cpp
@@ -50,7 +50,7 @@ static int op_preced(const TCHAR c)
             return 3;
         case '+': case '-':
             return 2;
-        case '=':
+        case '=': case '@': case '>': case '<':
             return 1;
     }
     return 0;
@@ -64,7 +64,7 @@ static bool op_left_assoc(const TCHAR c)
         case '|': case '&': case '^':
             return true;
         // right to left
-        case '=': case '!':
+        case '=': case '!': case '@': case '>': case '<':
             return false;
     }
     return false;
@@ -73,7 +73,7 @@ static bool op_left_assoc(const TCHAR c)
 static unsigned int op_arg_count(const TCHAR c)
 {
     switch(c)  {
-        case '*': case '/': case '%': case '+': case '-': case '=':
+        case '*': case '/': case '%': case '+': case '-': case '=': case '@': case '<': case '>':
         case '|': case '&': case '^':
             return 2;
         case '!':
@@ -84,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 == '=' || c == '|' || c == '&' || c == '^')
+#define is_operator(c)  (c == '+' || c == '-' || 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'))
  
@@ -249,6 +249,12 @@ static double docalcx(TCHAR op, double v1, double v2)
         return (int)v1 & (int)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;
 }
@@ -428,6 +434,10 @@ static bool parse_values(const TCHAR *ins, TCHAR *out)
                        in[3] = ' ';
                        in[4] = ' ';
                }
+        if (*in == '=' && *(in + 1) == '=') {
+            *in = '@';
+            *(in + 1) = ' ';
+        }
                if (_istdigit (*in)) {
                        if (ident >= MAX_VALUES)
                                return false;
index fb82e744cb192a26310c7147773a7f253ce4dabc..3bf6dc4d81dcdbbefc54e28f0f3c7d24d956e8ef 100644 (file)
--- a/debug.cpp
+++ b/debug.cpp
@@ -499,7 +499,7 @@ static bool iscancel (int counter)
 static bool isoperator(TCHAR **cp)
 {
        TCHAR c = **cp;
-       return c == '+' || c == '-' || c == '/' || c == '*' || c == '(' || c == ')' || c == '|' || c == '&' || c == '^';
+       return c == '+' || c == '-' || c == '/' || c == '*' || c == '(' || c == ')' || c == '|' || c == '&' || c == '^' || c == '=' || c == '>' || c == '<';
 }
 
 static void ignore_ws (TCHAR **c)
@@ -890,8 +890,18 @@ static int checkvaltype (TCHAR **cp, uae_u32 *val, int *size, TCHAR def)
        p = form;
        for (;;) {
                uae_u32 v;
-               if (!checkvaltype2 (cp, &v, def))
+               if (!checkvaltype2 (cp, &v, def)) {
+                       if (isoperator(cp) || gotop) {
+                               for (;;) {
+                                       *p = readchar(cp);
+                                       if (*p == 0) {
+                                               goto docalc;
+                                       }
+                                       p++;
+                               }
+                       }
                        return 0;
+               }
                *val = v;
                // stupid but works!
                _stprintf(p, _T("%u"), v);
@@ -920,6 +930,7 @@ static int checkvaltype (TCHAR **cp, uae_u32 *val, int *size, TCHAR def)
                }
                return 1;
        }
+docalc:
        if (calc (form, &out)) {
                *val = (uae_u32)out;
                if (size && *size == 0) {