[INTERPRETER]

* BUG: Fix some conversion from Single to other datatypes.


git-svn-id: svn://localhost/gambas/trunk@3460 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2011-01-16 22:04:17 +00:00
parent 9cfcbde8c9
commit 8bac2ad504
3 changed files with 46 additions and 4 deletions

View file

@ -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);
}

View file

@ -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

View file

@ -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);