From 83efc3844b800e9d5a29a46dbf9ad565405929d1 Mon Sep 17 00:00:00 2001
From: zesstra <zesstra@zesstra.de>
Date: Sun, 19 Apr 2009 19:44:09 +0200
Subject: [PATCH 3/3] Use LOAD_ macros in F_FLOAT.

The compiler stores float literals with PUT_INT32 and PUT_SHORT. Reading
them from the bytecode was done by memcpy(). Some conditional compilation
was required to read the correct datatypes. This patch implements an old
TODO and makes F_FLOAT use the LOAD_INT32 and LOAD_SHORT macros from
bytecode.h.

Signed-off-by: zesstra <zesstra@zesstra.de>
---
 src/interpret.c |   22 +++++-----------------
 1 files changed, 5 insertions(+), 17 deletions(-)

diff --git a/src/interpret.c b/src/interpret.c
index ea2f5c7..8722d64 100644
--- a/src/interpret.c
+++ b/src/interpret.c
@@ -8525,31 +8525,19 @@ again:
          * TODO: This code makes heavy assumptions about data sizes and
          * TODO:: layout. E.g. there need not be a 16-Bit integral type
          * TODO:: available.
-         * TODO: It should be rewritten to use the LOAD_ macros (but
-         * TODO:: then the compiler needs to use them, too.
+         * TODO: short doesn't to be a 16 bit wide type (which the float format
+         * TODO:: expects). LOAD_INT16 would be nice (change in compiler as well).
          */
 
-#if SIZEOF_CHAR_P == 4
-        sp++;
-        sp->type = T_FLOAT;
-
-        memcpy((char *)&sp->u.mantissa, pc, sizeof(sp->u.mantissa));
-        memcpy((char *)&sp->x.exponent, pc + sizeof(sp->u.mantissa), sizeof(sp->x.exponent));
-        pc += sizeof(sp->u.mantissa)+sizeof(sp->x.exponent);
-#else
         int32 mantissa;
-        /* TODO: int16 */ short exponent;
+        short exponent;
 
         sp++;
         sp->type = T_FLOAT;
-
-        memcpy((char *)&mantissa, pc, sizeof(mantissa));
+        LOAD_INT32(mantissa, pc);
+        LOAD_SHORT(exponent, pc);
         sp->u.mantissa = mantissa;
-
-        memcpy((char *)&exponent, pc + sizeof(mantissa), sizeof(exponent));
         sp->x.exponent = exponent;
-        pc += sizeof(mantissa)+sizeof(exponent);
-#endif
         break;
     }
 
-- 
1.6.1

