From 759aa3ba69268ed43a86e10fd6d906755f5665d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Fri, 30 Dec 2011 20:49:54 +0000 Subject: [PATCH] [INTERPRETER] * BUG: Fix support for Single constants. git-svn-id: svn://localhost/gambas/trunk@4370 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- main/gbx/gbx_class.h | 1 + main/gbx/gbx_class_desc.h | 1 + main/gbx/gbx_class_load.c | 7 ++++++- main/gbx/gbx_class_load.h | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/main/gbx/gbx_class.h b/main/gbx/gbx_class.h index 52b2cbb8b..e2f89b4c4 100644 --- a/main/gbx/gbx_class.h +++ b/main/gbx/gbx_class.h @@ -64,6 +64,7 @@ typedef union { int type; struct { int type; double value; } PACKED _float; + struct { int type; float value; } PACKED _single; struct { int type; int value; } PACKED _integer; struct { int type; int64_t value; } PACKED _long; struct { int type; char *addr; int len; } PACKED _string; diff --git a/main/gbx/gbx_class_desc.h b/main/gbx/gbx_class_desc.h index 4b248c267..a9f47de79 100644 --- a/main/gbx/gbx_class_desc.h +++ b/main/gbx/gbx_class_desc.h @@ -138,6 +138,7 @@ typedef union { int _integer; double _float; + float _single; char *_string; int64_t _long; void *_pointer; diff --git a/main/gbx/gbx_class_load.c b/main/gbx/gbx_class_load.c index ade75d680..ad0e88e6f 100644 --- a/main/gbx/gbx_class_load.c +++ b/main/gbx/gbx_class_load.c @@ -1074,7 +1074,10 @@ void CLASS_load_without_init(CLASS *class) cc->_string.addr += (intptr_t)class->string; if (NUMBER_from_string(NB_READ_FLOAT, cc->_string.addr, strlen(cc->_string.addr), &value)) THROW(E_CLASS, ClassName, "Bad constant", ""); - cc->_float.value = value._float.value; + if (cc->type == T_SINGLE) + cc->_single.value = (float)value._float.value; + else + cc->_float.value = value._float.value; break; } } @@ -1145,6 +1148,8 @@ void CLASS_load_without_init(CLASS *class) desc->constant.value._float = cc->_float.value; else if (desc->constant.type == T_LONG) desc->constant.value._long = cc->_long.value; + else if (desc->constant.type == T_SINGLE) + desc->constant.value._single = cc->_single.value; else { desc->constant.type = T_CSTRING; diff --git a/main/gbx/gbx_class_load.h b/main/gbx/gbx_class_load.h index 050022f27..a43a0134c 100644 --- a/main/gbx/gbx_class_load.h +++ b/main/gbx/gbx_class_load.h @@ -54,6 +54,7 @@ typedef union { TYPE_32 type; struct { TYPE_32 type; double value; } PACKED _float; + struct { TYPE_32 type; float value; } PACKED _single; struct { TYPE_32 type; int value; } PACKED _integer; struct { TYPE_32 type; int64_t value; } PACKED _long; struct { TYPE_32 type; ptr32_t addr; int len; } PACKED _string;