diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1998-12-15 12:59:43 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1998-12-15 12:59:43 -0200 |
commit | 21cff3015a325e2f965d762de5c733f0cf8525cd (patch) | |
tree | 526a76f7df3abaff9fa77f68c14c6c12c3169857 | |
parent | 5ca2709ba055901ba9d658aa2ca51e0682dfdb30 (diff) | |
download | lua-21cff3015a325e2f965d762de5c733f0cf8525cd.tar.gz lua-21cff3015a325e2f965d762de5c733f0cf8525cd.tar.bz2 lua-21cff3015a325e2f965d762de5c733f0cf8525cd.zip |
details (for regularity)
-rw-r--r-- | lmem.h | 7 | ||||
-rw-r--r-- | lua.h | 8 | ||||
-rw-r--r-- | lundump.c | 36 | ||||
-rw-r--r-- | lundump.h | 4 |
4 files changed, 26 insertions, 29 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lmem.h,v 1.4 1997/12/01 20:30:44 roberto Exp roberto $ | 2 | ** $Id: lmem.h,v 1.5 1997/12/17 20:48:58 roberto Exp roberto $ |
3 | ** Interface to Memory Manager | 3 | ** Interface to Memory Manager |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -8,10 +8,7 @@ | |||
8 | #define lmem_h | 8 | #define lmem_h |
9 | 9 | ||
10 | 10 | ||
11 | #ifndef NULL | 11 | #include <stdlib.h> |
12 | #define NULL 0 | ||
13 | #endif | ||
14 | |||
15 | 12 | ||
16 | /* memory error messages */ | 13 | /* memory error messages */ |
17 | #define codeEM "code size overflow" | 14 | #define codeEM "code size overflow" |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.h,v 1.23 1998/06/18 16:51:53 roberto Exp roberto $ | 2 | ** $Id: lua.h,v 1.24 1998/08/21 17:43:44 roberto Exp roberto $ |
3 | ** Lua - An Extensible Extension Language | 3 | ** Lua - An Extensible Extension Language |
4 | ** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil | 4 | ** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil |
5 | ** e-mail: lua@tecgraf.puc-rio.br | 5 | ** e-mail: lua@tecgraf.puc-rio.br |
@@ -20,12 +20,12 @@ | |||
20 | 20 | ||
21 | #define LUA_ANYTAG (-1) | 21 | #define LUA_ANYTAG (-1) |
22 | 22 | ||
23 | typedef void (*lua_CFunction) (void); | ||
24 | typedef unsigned int lua_Object; | ||
25 | |||
26 | typedef struct lua_State lua_State; | 23 | typedef struct lua_State lua_State; |
27 | extern lua_State *lua_state; | 24 | extern lua_State *lua_state; |
28 | 25 | ||
26 | typedef void (*lua_CFunction) (void); | ||
27 | typedef unsigned int lua_Object; | ||
28 | |||
29 | void lua_open (void); | 29 | void lua_open (void); |
30 | void lua_close (void); | 30 | void lua_close (void); |
31 | lua_State *lua_setstate (lua_State *st); | 31 | lua_State *lua_setstate (lua_State *st); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lundump.c,v 1.10 1998/06/25 15:50:09 lhf Exp $ | 2 | ** $Id: lundump.c,v 1.4 1998/06/25 16:48:44 roberto Exp roberto $ |
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 | */ |
@@ -20,32 +20,32 @@ | |||
20 | #define doLoadNumber(f,Z) f=LoadNumber(Z) | 20 | #define doLoadNumber(f,Z) f=LoadNumber(Z) |
21 | #endif | 21 | #endif |
22 | 22 | ||
23 | static void unexpectedEOZ(ZIO* Z) | 23 | static void unexpectedEOZ (ZIO* Z) |
24 | { | 24 | { |
25 | luaL_verror("unexpected end of file in %s",zname(Z)); | 25 | luaL_verror("unexpected end of file in %s",zname(Z)); |
26 | } | 26 | } |
27 | 27 | ||
28 | static int ezgetc(ZIO* Z) | 28 | static int ezgetc (ZIO* Z) |
29 | { | 29 | { |
30 | int c=zgetc(Z); | 30 | int c=zgetc(Z); |
31 | if (c==EOZ) unexpectedEOZ(Z); | 31 | if (c==EOZ) unexpectedEOZ(Z); |
32 | return c; | 32 | return c; |
33 | } | 33 | } |
34 | 34 | ||
35 | static void ezread(ZIO* Z, void* b, int n) | 35 | static void ezread (ZIO* Z, void* b, int n) |
36 | { | 36 | { |
37 | int r=zread(Z,b,n); | 37 | int r=zread(Z,b,n); |
38 | if (r!=0) unexpectedEOZ(Z); | 38 | if (r!=0) unexpectedEOZ(Z); |
39 | } | 39 | } |
40 | 40 | ||
41 | static unsigned int LoadWord(ZIO* Z) | 41 | static unsigned int LoadWord (ZIO* Z) |
42 | { | 42 | { |
43 | unsigned int hi=ezgetc(Z); | 43 | unsigned int hi=ezgetc(Z); |
44 | unsigned int lo=ezgetc(Z); | 44 | unsigned int lo=ezgetc(Z); |
45 | return (hi<<8)|lo; | 45 | return (hi<<8)|lo; |
46 | } | 46 | } |
47 | 47 | ||
48 | static unsigned long LoadLong(ZIO* Z) | 48 | static unsigned long LoadLong (ZIO* Z) |
49 | { | 49 | { |
50 | unsigned long hi=LoadWord(Z); | 50 | unsigned long hi=LoadWord(Z); |
51 | unsigned long lo=LoadWord(Z); | 51 | unsigned long lo=LoadWord(Z); |
@@ -55,7 +55,7 @@ static unsigned long LoadLong(ZIO* Z) | |||
55 | #if ID_NUMBER==ID_REAL4 | 55 | #if ID_NUMBER==ID_REAL4 |
56 | /* LUA_NUMBER */ | 56 | /* LUA_NUMBER */ |
57 | /* assumes sizeof(long)==4 and sizeof(float)==4 (IEEE) */ | 57 | /* assumes sizeof(long)==4 and sizeof(float)==4 (IEEE) */ |
58 | static float LoadFloat(ZIO* Z) | 58 | static float LoadFloat (ZIO* Z) |
59 | { | 59 | { |
60 | unsigned long l=LoadLong(Z); | 60 | unsigned long l=LoadLong(Z); |
61 | float f=*(float*)&l; | 61 | float f=*(float*)&l; |
@@ -66,7 +66,7 @@ static float LoadFloat(ZIO* Z) | |||
66 | #if ID_NUMBER==ID_REAL8 | 66 | #if ID_NUMBER==ID_REAL8 |
67 | /* LUA_NUMBER */ | 67 | /* LUA_NUMBER */ |
68 | /* assumes sizeof(long)==4 and sizeof(double)==8 (IEEE) */ | 68 | /* assumes sizeof(long)==4 and sizeof(double)==8 (IEEE) */ |
69 | static double LoadDouble(ZIO* Z) | 69 | static double LoadDouble (ZIO* Z) |
70 | { | 70 | { |
71 | unsigned long l[2]; | 71 | unsigned long l[2]; |
72 | double f; | 72 | double f; |
@@ -86,7 +86,7 @@ static double LoadDouble(ZIO* Z) | |||
86 | } | 86 | } |
87 | #endif | 87 | #endif |
88 | 88 | ||
89 | static Byte* LoadCode(ZIO* Z) | 89 | static Byte* LoadCode (ZIO* Z) |
90 | { | 90 | { |
91 | unsigned long size=LoadLong(Z); | 91 | unsigned long size=LoadLong(Z); |
92 | unsigned int s=size; | 92 | unsigned int s=size; |
@@ -97,7 +97,7 @@ static Byte* LoadCode(ZIO* Z) | |||
97 | return b; | 97 | return b; |
98 | } | 98 | } |
99 | 99 | ||
100 | static TaggedString* LoadTString(ZIO* Z) | 100 | static TaggedString* LoadTString (ZIO* Z) |
101 | { | 101 | { |
102 | int size=LoadWord(Z); | 102 | int size=LoadWord(Z); |
103 | if (size==0) | 103 | if (size==0) |
@@ -110,7 +110,7 @@ static TaggedString* LoadTString(ZIO* Z) | |||
110 | } | 110 | } |
111 | } | 111 | } |
112 | 112 | ||
113 | static void LoadLocals(TProtoFunc* tf, ZIO* Z) | 113 | static void LoadLocals (TProtoFunc* tf, ZIO* Z) |
114 | { | 114 | { |
115 | int i,n=LoadWord(Z); | 115 | int i,n=LoadWord(Z); |
116 | if (n==0) return; | 116 | if (n==0) return; |
@@ -124,9 +124,9 @@ static void LoadLocals(TProtoFunc* tf, ZIO* Z) | |||
124 | tf->locvars[i].varname=NULL; | 124 | tf->locvars[i].varname=NULL; |
125 | } | 125 | } |
126 | 126 | ||
127 | static TProtoFunc* LoadFunction(ZIO* Z); | 127 | static TProtoFunc* LoadFunction (ZIO* Z); |
128 | 128 | ||
129 | static void LoadConstants(TProtoFunc* tf, ZIO* Z) | 129 | static void LoadConstants (TProtoFunc* tf, ZIO* Z) |
130 | { | 130 | { |
131 | int i,n=LoadWord(Z); | 131 | int i,n=LoadWord(Z); |
132 | tf->nconsts=n; | 132 | tf->nconsts=n; |
@@ -157,7 +157,7 @@ static void LoadConstants(TProtoFunc* tf, ZIO* Z) | |||
157 | } | 157 | } |
158 | } | 158 | } |
159 | 159 | ||
160 | static TProtoFunc* LoadFunction(ZIO* Z) | 160 | static TProtoFunc* LoadFunction (ZIO* Z) |
161 | { | 161 | { |
162 | TProtoFunc* tf=luaF_newproto(); | 162 | TProtoFunc* tf=luaF_newproto(); |
163 | tf->lineDefined=LoadWord(Z); | 163 | tf->lineDefined=LoadWord(Z); |
@@ -168,7 +168,7 @@ static TProtoFunc* LoadFunction(ZIO* Z) | |||
168 | return tf; | 168 | return tf; |
169 | } | 169 | } |
170 | 170 | ||
171 | static void LoadSignature(ZIO* Z) | 171 | static void LoadSignature (ZIO* Z) |
172 | { | 172 | { |
173 | char* s=SIGNATURE; | 173 | char* s=SIGNATURE; |
174 | while (*s!=0 && ezgetc(Z)==*s) | 174 | while (*s!=0 && ezgetc(Z)==*s) |
@@ -176,7 +176,7 @@ static void LoadSignature(ZIO* Z) | |||
176 | if (*s!=0) luaL_verror("bad signature in %s",zname(Z)); | 176 | if (*s!=0) luaL_verror("bad signature in %s",zname(Z)); |
177 | } | 177 | } |
178 | 178 | ||
179 | static void LoadHeader(ZIO* Z) | 179 | static void LoadHeader (ZIO* Z) |
180 | { | 180 | { |
181 | int version,id,sizeofR; | 181 | int version,id,sizeofR; |
182 | real f=-TEST_NUMBER,tf=TEST_NUMBER; | 182 | real f=-TEST_NUMBER,tf=TEST_NUMBER; |
@@ -205,7 +205,7 @@ static void LoadHeader(ZIO* Z) | |||
205 | zname(Z),(double)f,(double)tf); | 205 | zname(Z),(double)f,(double)tf); |
206 | } | 206 | } |
207 | 207 | ||
208 | static TProtoFunc* LoadChunk(ZIO* Z) | 208 | static TProtoFunc* LoadChunk (ZIO* Z) |
209 | { | 209 | { |
210 | LoadHeader(Z); | 210 | LoadHeader(Z); |
211 | return LoadFunction(Z); | 211 | return LoadFunction(Z); |
@@ -215,7 +215,7 @@ static TProtoFunc* LoadChunk(ZIO* Z) | |||
215 | ** load one chunk from a file or buffer | 215 | ** load one chunk from a file or buffer |
216 | ** return main if ok and NULL at EOF | 216 | ** return main if ok and NULL at EOF |
217 | */ | 217 | */ |
218 | TProtoFunc* luaU_undump1(ZIO* Z) | 218 | TProtoFunc* luaU_undump1 (ZIO* Z) |
219 | { | 219 | { |
220 | int c=zgetc(Z); | 220 | int c=zgetc(Z); |
221 | if (c==ID_CHUNK) | 221 | if (c==ID_CHUNK) |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lundump.h,v 1.7 1998/06/25 15:50:09 lhf Exp $ | 2 | ** $Id: lundump.h,v 1.4 1998/06/25 16:48:44 roberto Exp roberto $ |
3 | ** load pre-compiled Lua chunks | 3 | ** load pre-compiled Lua chunks |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -10,7 +10,7 @@ | |||
10 | #include "lobject.h" | 10 | #include "lobject.h" |
11 | #include "lzio.h" | 11 | #include "lzio.h" |
12 | 12 | ||
13 | TProtoFunc* luaU_undump1(ZIO* Z); /* load one chunk */ | 13 | TProtoFunc *luaU_undump1 (ZIO* Z); /* load one chunk */ |
14 | 14 | ||
15 | #define SIGNATURE "Lua" | 15 | #define SIGNATURE "Lua" |
16 | #define VERSION 0x31 /* last format change was in 3.1 */ | 16 | #define VERSION 0x31 /* last format change was in 3.1 */ |