From 07008b5d45da78180c1a0513d63367b7bc228bf4 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 25 Jun 1998 13:48:44 -0300 Subject: details (by lhf) --- lundump.c | 36 +++++++++++------------------------- lundump.h | 30 +++++++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 28 deletions(-) diff --git a/lundump.c b/lundump.c index a5bd4a35..ed4bd19c 100644 --- a/lundump.c +++ b/lundump.c @@ -1,11 +1,10 @@ /* -** $Id: lundump.c,v 1.9 1998/06/13 16:54:15 lhf Exp $ +** $Id: lundump.c,v 1.10 1998/06/25 15:50:09 lhf Exp $ ** load bytecodes from files ** See Copyright Notice in lua.h */ #include - #include "lauxlib.h" #include "lfunc.h" #include "lmem.h" @@ -13,21 +12,12 @@ #include "lundump.h" #define LoadBlock(b,size,Z) ezread(Z,b,size) -#define LoadNative(t,D) LoadBlock(&t,sizeof(t),D) - -/* LUA_NUMBER */ -/* see comment in lundump.h */ +#define LoadNative(t,Z) LoadBlock(&t,sizeof(t),Z) -#if ID_NUMBER==ID_REAL4 - #define LoadNumber LoadFloat -#elif ID_NUMBER==ID_REAL8 - #define LoadNumber LoadDouble -#elif ID_NUMBER==ID_INT4 - #define LoadNumber LoadLong -#elif ID_NUMBER==ID_NATIVE - #define LoadNumber LoadNative +#if ID_NUMBER==ID_NATIVE + #define doLoadNumber(f,Z) LoadNative(f,Z) #else - #define LoadNumber LoadWhat + #define doLoadNumber(f,Z) f=LoadNumber(Z) #endif static void unexpectedEOZ(ZIO* Z) @@ -150,11 +140,7 @@ static void LoadConstants(TProtoFunc* tf, ZIO* Z) { case ID_NUM: ttype(o)=LUA_T_NUMBER; -#if ID_NUMBER==ID_NATIVE - LoadNative(nvalue(o),Z) -#else - nvalue(o)=LoadNumber(Z); -#endif + doLoadNumber(nvalue(o),Z); break; case ID_STR: ttype(o)=LUA_T_STRING; @@ -200,19 +186,19 @@ static void LoadHeader(ZIO* Z) luaL_verror( "%s too new: version=0x%02x; expected at most 0x%02x", zname(Z),version,VERSION); - if (version<0x31) /* major change in 3.1 */ + if (versionlineDefined==0) @@ -46,12 +47,35 @@ TProtoFunc* luaU_undump1(ZIO* Z); /* load one chunk */ * dump and undump routines. */ -#define ID_NUMBER ID_REAL8 +#ifndef ID_NUMBER +#define ID_NUMBER ID_NATIVE +#endif #if 0 -#define ID_NUMBER ID_REAL4 #define ID_NUMBER ID_INT4 +#define ID_NUMBER ID_REAL4 +#define ID_NUMBER ID_REAL8 #define ID_NUMBER ID_NATIVE #endif #endif + +#if ID_NUMBER==ID_REAL4 + #define DumpNumber DumpFloat + #define LoadNumber LoadFloat + #define SIZEOF_NUMBER 4 +#elif ID_NUMBER==ID_REAL8 + #define DumpNumber DumpDouble + #define LoadNumber LoadDouble + #define SIZEOF_NUMBER 8 +#elif ID_NUMBER==ID_INT4 + #define DumpNumber DumpLong + #define LoadNumber LoadLong + #define SIZEOF_NUMBER 4 +#elif ID_NUMBER==ID_NATIVE + #define DumpNumber DumpNative + #define LoadNumber LoadNative + #define SIZEOF_NUMBER sizeof(real) +#else + #error bad ID_NUMBER +#endif -- cgit v1.2.3-55-g6feb