From: Toni Wilen Date: Sun, 13 Feb 2022 20:24:53 +0000 (+0200) Subject: Debugger calculator OR, AND, XOR operators. X-Git-Tag: 41000~267 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=3f42a74762affbf23d80bef92d402265850bcbe0;p=francis%2Fwinuae.git Debugger calculator OR, AND, XOR operators. --- diff --git a/calc.cpp b/calc.cpp index da06292a..81175156 100644 --- 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; } diff --git a/debug.cpp b/debug.cpp index 89498b13..d86ac6e6 100644 --- 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)