From: Toni Wilen Date: Sat, 15 Apr 2023 18:10:10 +0000 (+0300) Subject: Add debugger calculator comparison operators. (not complete) X-Git-Tag: 5.0.0~74 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=062f77a029942ef902e60eab8f6bb6a3c5ec6e3b;p=francis%2Fwinuae.git Add debugger calculator comparison operators. (not complete) --- diff --git a/calc.cpp b/calc.cpp index 81175156..2f1224d9 100644 --- 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; diff --git a/debug.cpp b/debug.cpp index fb82e744..3bf6dc4d 100644 --- 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) {