From 8bac2ad50485ad92fa6e47e9f9649db594795be3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Sun, 16 Jan 2011 22:04:17 +0000 Subject: [PATCH] [INTERPRETER] * BUG: Fix some conversion from Single to other datatypes. git-svn-id: svn://localhost/gambas/trunk@3460 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- main/gbx/gb_error.c | 13 +++++++++++-- main/gbx/gbx_exec_loop.c | 13 +++++++++++++ main/gbx/gbx_value.c | 24 ++++++++++++++++++++++-- 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/main/gbx/gb_error.c b/main/gbx/gb_error.c index a4356dfae..85f6b04d7 100644 --- a/main/gbx/gb_error.c +++ b/main/gbx/gb_error.c @@ -120,6 +120,7 @@ void ERROR_debug(const char *msg, ...) { int i; va_list args; + ERROR_CONTEXT *err; va_start(args, msg); @@ -127,6 +128,16 @@ void ERROR_debug(const char *msg, ...) fprintf(stderr, "- "); vfprintf(stderr, msg, args); + + fprintf(stderr, "\t\t\t\t\t\t\t\t\t"); + DEBUG_where(); + err = ERROR_current; + while (err) + { + fprintf(stderr, "[%p] -> ", err); + err = err->prev; + } + fprintf(stderr, "NULL\n"); } #endif @@ -265,8 +276,6 @@ void ERROR_propagate() (*ph->handler)(); } - //fprintf(stderr, "ERROR_propagate: -> %p\n", ERROR_handler); - longjmp(ERROR_current->env, 1); } diff --git a/main/gbx/gbx_exec_loop.c b/main/gbx/gbx_exec_loop.c index 6c86bb51e..dcbba0f4d 100644 --- a/main/gbx/gbx_exec_loop.c +++ b/main/gbx/gbx_exec_loop.c @@ -487,6 +487,17 @@ _SUBR_CODE: _NEXT: code = *(++PC); + +#if DEBUG_PCODE + DEBUG_where(); + fprintf(stderr, "[%4d] ", (int)(intptr_t)(SP - (VALUE *)STACK_base)); + if (*PC >> 8) + PCODE_dump(stderr, PC - FP->code, PC); + else + fprintf(stderr, "\n"); + fflush(stderr); +#endif + goto *jump_table[code >> 8]; /*-----------------------------------------------*/ @@ -981,6 +992,8 @@ _CALL: __CALL_EVENT: + //if (OP && !strcmp(OBJECT_class(OP)->name, "Workspace")) + // BREAKPOINT(); ind = GB_Raise(OP, val->_function.index, (-EXEC.nparam)); POP(); // function diff --git a/main/gbx/gbx_value.c b/main/gbx/gbx_value.c index 7770ce56f..44c0dfb2a 100644 --- a/main/gbx/gbx_value.c +++ b/main/gbx/gbx_value.c @@ -1360,7 +1360,7 @@ void VALUE_convert_boolean(VALUE *value) { static const void *jump[16] = { - &&__NR, &&__OK, &&__c2b, &&__h2b, &&__i2b, &&__l2b, &&__f2b, &&__f2b, + &&__NR, &&__OK, &&__c2b, &&__h2b, &&__i2b, &&__l2b, &&__g2b, &&__f2b, &&__d2b, &&__s2b, &&__s2b, &&__N, &&__v2, &&__func, &&__N, &&__n2b }; @@ -1395,6 +1395,12 @@ __l2b: value->type = T_BOOLEAN; return; +__g2b: + + value->_integer.value = (value->_single.value != 0) ? -1 : 0; + value->type = T_BOOLEAN; + return; + __f2b: value->_integer.value = (value->_float.value != 0) ? -1 : 0; @@ -1451,7 +1457,7 @@ void VALUE_convert_integer(VALUE *value) { static const void *jump[16] = { - &&__NR, &&__TYPE, &&__TYPE, &&__TYPE, &&__OK, &&__l2i, &&__f2i, &&__f2i, + &&__NR, &&__TYPE, &&__TYPE, &&__TYPE, &&__OK, &&__l2i, &&__g2i, &&__f2i, &&__d2i, &&__s2i, &&__s2i, &&__N, &&__v2, &&__func, &&__N, &&__N }; @@ -1466,6 +1472,11 @@ __l2i: value->_integer.value = (int)value->_long.value; goto __TYPE; +__g2i: + + value->_integer.value = (int)value->_single.value; + goto __TYPE; + __f2i: value->_integer.value = (int)value->_float.value; @@ -1548,9 +1559,12 @@ __i2f: __l2f: value->_float.value = value->_long.value; + value->type = T_FLOAT; + return; __g2f: + value->_float.value = value->_single.value; value->type = T_FLOAT; return; @@ -1637,6 +1651,12 @@ __l2s: return; __g2s: + + LOCAL_format_number(value->_single.value, LF_GENERAL_NUMBER, NULL, 0, &addr, &len, FALSE); + STRING_new_temp_value(value, addr, len); + BORROW(value); + return; + __f2s: LOCAL_format_number(value->_float.value, LF_GENERAL_NUMBER, NULL, 0, &addr, &len, FALSE);