summaryrefslogtreecommitdiff
path: root/lundump.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-06-25 13:48:44 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-06-25 13:48:44 -0300
commit07008b5d45da78180c1a0513d63367b7bc228bf4 (patch)
treeb49b068a0a9cc6f8d43994e9c5d0039605774308 /lundump.c
parent8f31eda6495763f9e3de77747ef0b3c74e891b10 (diff)
downloadlua-07008b5d45da78180c1a0513d63367b7bc228bf4.tar.gz
lua-07008b5d45da78180c1a0513d63367b7bc228bf4.tar.bz2
lua-07008b5d45da78180c1a0513d63367b7bc228bf4.zip
details (by lhf)
Diffstat (limited to 'lundump.c')
-rw-r--r--lundump.c36
1 files changed, 11 insertions, 25 deletions
diff --git a/lundump.c b/lundump.c
index a5bd4a35..ed4bd19c 100644
--- a/lundump.c
+++ b/lundump.c
@@ -1,11 +1,10 @@
1/* 1/*
2** $Id: lundump.c,v 1.9 1998/06/13 16:54:15 lhf Exp $ 2** $Id: lundump.c,v 1.10 1998/06/25 15:50:09 lhf Exp $
3** load bytecodes from files 3** load bytecodes from files
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
6 6
7#include <stdio.h> 7#include <stdio.h>
8
9#include "lauxlib.h" 8#include "lauxlib.h"
10#include "lfunc.h" 9#include "lfunc.h"
11#include "lmem.h" 10#include "lmem.h"
@@ -13,21 +12,12 @@
13#include "lundump.h" 12#include "lundump.h"
14 13
15#define LoadBlock(b,size,Z) ezread(Z,b,size) 14#define LoadBlock(b,size,Z) ezread(Z,b,size)
16#define LoadNative(t,D) LoadBlock(&t,sizeof(t),D) 15#define LoadNative(t,Z) LoadBlock(&t,sizeof(t),Z)
17
18/* LUA_NUMBER */
19/* see comment in lundump.h */
20 16
21#if ID_NUMBER==ID_REAL4 17#if ID_NUMBER==ID_NATIVE
22 #define LoadNumber LoadFloat 18 #define doLoadNumber(f,Z) LoadNative(f,Z)
23#elif ID_NUMBER==ID_REAL8
24 #define LoadNumber LoadDouble
25#elif ID_NUMBER==ID_INT4
26 #define LoadNumber LoadLong
27#elif ID_NUMBER==ID_NATIVE
28 #define LoadNumber LoadNative
29#else 19#else
30 #define LoadNumber LoadWhat 20 #define doLoadNumber(f,Z) f=LoadNumber(Z)
31#endif 21#endif
32 22
33static void unexpectedEOZ(ZIO* Z) 23static void unexpectedEOZ(ZIO* Z)
@@ -150,11 +140,7 @@ static void LoadConstants(TProtoFunc* tf, ZIO* Z)
150 { 140 {
151 case ID_NUM: 141 case ID_NUM:
152 ttype(o)=LUA_T_NUMBER; 142 ttype(o)=LUA_T_NUMBER;
153#if ID_NUMBER==ID_NATIVE 143 doLoadNumber(nvalue(o),Z);
154 LoadNative(nvalue(o),Z)
155#else
156 nvalue(o)=LoadNumber(Z);
157#endif
158 break; 144 break;
159 case ID_STR: 145 case ID_STR:
160 ttype(o)=LUA_T_STRING; 146 ttype(o)=LUA_T_STRING;
@@ -200,19 +186,19 @@ static void LoadHeader(ZIO* Z)
200 luaL_verror( 186 luaL_verror(
201 "%s too new: version=0x%02x; expected at most 0x%02x", 187 "%s too new: version=0x%02x; expected at most 0x%02x",
202 zname(Z),version,VERSION); 188 zname(Z),version,VERSION);
203 if (version<0x31) /* major change in 3.1 */ 189 if (version<VERSION0) /* check last major change */
204 luaL_verror( 190 luaL_verror(
205 "%s too old: version=0x%02x; expected at least 0x%02x", 191 "%s too old: version=0x%02x; expected at least 0x%02x",
206 zname(Z),version,0x31); 192 zname(Z),version,VERSION0);
207 id=ezgetc(Z); /* test number representation */ 193 id=ezgetc(Z); /* test number representation */
208 sizeofR=ezgetc(Z); 194 sizeofR=ezgetc(Z);
209 if (id!=ID_NUMBER || sizeofR!=sizeof(real)) 195 if (id!=ID_NUMBER || sizeofR!=sizeof(real))
210 { 196 {
211 luaL_verror("unknown number representation in %s: " 197 luaL_verror("unknown number signature in %s: "
212 "read 0x%02x %d; expected 0x%02x %d", 198 "read 0x%02x%02x; expected 0x%02x%02x",
213 zname(Z),id,sizeofR,ID_NUMBER,sizeof(real)); 199 zname(Z),id,sizeofR,ID_NUMBER,sizeof(real));
214 } 200 }
215 f=LoadNumber(Z); 201 doLoadNumber(f,Z);
216 if (f!=tf) 202 if (f!=tf)
217 luaL_verror("unknown number representation in %s: " 203 luaL_verror("unknown number representation in %s: "
218 "read " NUMBER_FMT "; expected " NUMBER_FMT "", /* LUA_NUMBER */ 204 "read " NUMBER_FMT "; expected " NUMBER_FMT "", /* LUA_NUMBER */