--- hatari/src/debug/evaluate.c 2019/04/09 08:54:22 1.1.1.4 +++ hatari/src/debug/evaluate.c 2019/04/09 08:59:19 1.1.1.8 @@ -21,7 +21,7 @@ const char Eval_fileid[] = "Hatari calcu #include #include #include -#include "breakcond.h" +#include #include "configuration.h" #include "dsp.h" #include "debugcpu.h" @@ -30,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 */ @@ -58,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 { @@ -134,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') { @@ -219,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; } @@ -394,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 */ @@ -469,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? */ @@ -481,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; @@ -511,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]) { @@ -621,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; } @@ -650,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 '+': @@ -680,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 */ @@ -725,7 +728,8 @@ static long long close_bracket (long lon /* fetch the indirect ST RAM value */ addr = val.buf[val.idx]; value = STMemory_ReadLong(addr); - fprintf(stderr, " value in RAM at ($%x).l = $%llx\n", addr, value); + fprintf(stderr, " value in RAM at ($%x).l = $%"PRIx64"\n", + addr, (uint64_t)value); /* restore state before parenthesis */ op.idx = par.opx[par.idx] - 1; val.idx = par.vax[par.idx] - 1;