--- hatari/src/debug/evaluate.c 2019/04/09 08:55:35 1.1.1.5 +++ hatari/src/debug/evaluate.c 2019/04/09 08:59:19 1.1.1.8 @@ -22,7 +22,6 @@ const char Eval_fileid[] = "Hatari calcu #include #include #include -#include "breakcond.h" #include "configuration.h" #include "dsp.h" #include "debugcpu.h" @@ -31,6 +30,8 @@ const char Eval_fileid[] = "Hatari calcu #include "m68000.h" #include "stMemory.h" #include "symbols.h" +#include "vars.h" + /* define which character indicates which type of number on expression */ #define PREFIX_BIN '%' /* binary decimal */ @@ -59,7 +60,7 @@ const char Eval_fileid[] = "Hatari calcu static struct { const char *error; /* global error code */ bool valid; /* value validation */ -} id = {0, 0}; +} id = { NULL, 0 }; /* parenthesis and function stacks */ static struct { @@ -135,7 +136,7 @@ static int getNumber(const char *str, Ui fprintf(stderr, "Value missing!\n"); return 0; } - + /* determine correct number base */ if (str[0] == '0') { @@ -220,7 +221,7 @@ static int getValue(const char *str, Uin *base = 0; /* no base (e.g. variable) */ /* internal Hatari variable? */ - if (BreakCond_GetHatariVariable(name, number)) { + if (Vars_GetVariableValue(name, number)) { return len; } @@ -395,7 +396,7 @@ const char* Eval_Expression(const char * long long value; int dummy, offset = 0; char mark; - + /* Uses global variables: */ par.idx = 0; /* parenthesis stack pointer */ @@ -470,8 +471,8 @@ const char* Eval_Expression(const char * /* until exit or error message */ } while(mark && !id.error); - /* result of evaluation */ - if (val.idx >= 0) + /* result of evaluation */ + if (val.idx >= 0) *out = val.buf[val.idx]; /* something to return? */ @@ -482,9 +483,10 @@ const char* Eval_Expression(const char * operation (value, LOWEST_PREDECENCE); if (par.idx) /* mismatched */ id.error = CLAC_PAR_ERR; + else if (val.idx < 0) + id.error = CLAC_PRG_ERR; else /* result out */ *out = val.buf[val.idx]; - } else { if ((val.idx < 0) && (op.idx < 0)) { id.error = CLAC_EXP_ERR; @@ -512,12 +514,11 @@ static void operation (long long value, * operation executed if the next one is on same or lower level */ /* something to calc? */ - if(id.valid == true) { - + if (id.valid == true) { /* add new items to stack */ PUSH(op, oper); PUSH(val, value); - + /* more than 1 operator */ if(op.idx > par.opx[par.idx]) { @@ -622,19 +623,19 @@ static int get_level (int offset) case '&': case '^': return 0; - + case '>': /* bit shifting */ case '<': return 1; - + case '+': case '-': return 2; - + case '*': case '/': return 3; - + default: id.error = CLAC_PRG_ERR; } @@ -651,18 +652,19 @@ static long long apply_op (char opcode, /* returns the result of operation */ switch (opcode) { - case '|': + case '|': value1 |= value2; break; - case '&': + case '&': value1 &= value2; break; - case '^': + case '^': value1 ^= value2; break; - case '>': + case '>': value1 >>= value2; - case '<': + break; + case '<': value1 <<= value2; break; case '+': @@ -681,7 +683,7 @@ static long long apply_op (char opcode, else id.error = CLAC_DEF_ERR; break; - default: + default: id.error = CLAC_PRG_ERR; } return value1; /* return result */