From 7bedc9af65c51968626ef334b118053086163f6a Mon Sep 17 00:00:00 2001 From: gambas Date: Tue, 18 Feb 2020 20:36:45 +0100 Subject: [PATCH] Fix VarPtr() behaviour. [INTERPRETER] * BUG: VarPtr() on local strings are forbidden again. * BUG: VarPtr() on variants now returns a pointer to the variant contents. --- main/gbx/gbx_subr_extern.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/main/gbx/gbx_subr_extern.c b/main/gbx/gbx_subr_extern.c index 60c5af5bc..79bb4815f 100644 --- a/main/gbx/gbx_subr_extern.c +++ b/main/gbx/gbx_subr_extern.c @@ -210,24 +210,16 @@ void SUBR_varptr(ushort code) ptr = &val->_date.date; break; - case T_STRING: - case T_CSTRING: - ptr = val->_string.addr + val->_string.start; - break; - case T_POINTER: ptr = &val->_pointer.value; break; case T_VARIANT: - if (val->_variant.vtype == T_STRING) - ptr = val->_variant.value._string; - else - ptr = &val->_variant.value.data; + ptr = &val->_variant.value.data; break; default: - THROW(E_TYPE, "Number, date, pointer or string", TYPE_get_name(val->type)); + THROW(E_TYPE, "Number, date, or pointer", TYPE_get_name(val->type)); } } else if ((op & 0xF800) == C_PUSH_DYNAMIC) @@ -238,11 +230,15 @@ void SUBR_varptr(ushort code) THROW_ILLEGAL(); ptr = &OP[var->pos]; + if (var->type.id == T_VARIANT) + ptr = &((VARIANT *)ptr)->value.data; } else if ((op & 0xF800) == C_PUSH_STATIC) { var = &CP->load->stat[op & 0x7FF]; ptr = (char *)CP->stat + var->pos; + if (var->type.id == T_VARIANT) + ptr = &((VARIANT *)ptr)->value.data; } else THROW_ILLEGAL();