aboutsummaryrefslogtreecommitdiff
path: root/lundump.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-03-30 17:29:34 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-03-30 17:29:34 -0300
commit7c9aee64c250e6f56b5788479d62ff9cbc6ad634 (patch)
tree7dde288ca7a62e06ec355ea4907ddb27ea94432a /lundump.h
parente0ff4e5d22bd2dbe74dd588f0710c18ae8a671ab (diff)
downloadlua-7c9aee64c250e6f56b5788479d62ff9cbc6ad634.tar.gz
lua-7c9aee64c250e6f56b5788479d62ff9cbc6ad634.tar.bz2
lua-7c9aee64c250e6f56b5788479d62ff9cbc6ad634.zip
new version by lhf.
Diffstat (limited to 'lundump.h')
-rw-r--r--lundump.h96
1 files changed, 59 insertions, 37 deletions
diff --git a/lundump.h b/lundump.h
index c9c4c417..6b3d1101 100644
--- a/lundump.h
+++ b/lundump.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lundump.h,v 1.4 1998/06/25 16:48:44 roberto Exp roberto $ 2** $Id: lundump.h,v 1.13 1999/03/29 16:16:18 lhf Exp $
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,18 +10,47 @@
10#include "lobject.h" 10#include "lobject.h"
11#include "lzio.h" 11#include "lzio.h"
12 12
13TProtoFunc *luaU_undump1 (ZIO* Z); /* load one chunk */ 13/* -- start of user configuration ------------------------------------------ */
14 14
15#define SIGNATURE "Lua" 15/* LUA_NUMBER
16#define VERSION 0x31 /* last format change was in 3.1 */ 16* choose below the number representation in precompiled chunks by choosing an
17#define VERSION0 0x31 /* last major change was in 3.1 */ 17* an adequate definition for ID_NUMBER.
18* if you change LUA_NUM_TYPE, you must set ID_NUMBER accordingly.
19* the default is ID_REAL8 because the default for LUA_NUM_TYPE is double.
20* if you want to use this default, do nothing.
21* if your machine does not use the IEEE 754 floating-point standard, use
22* ID_NATIVE, but precompiled chunks may not be portable to all architectures.
23*
24* for types other than the ones listed below, you'll have to write your own
25* dump and undump routines, specially if sizeof(long)!=4.
26*/
18 27
19#define IsMain(f) (f->lineDefined==0) 28/* choose one definition for ID_NUMBER and move it to after #endif */
29#if 0
30#define ID_NUMBER ID_INT4 /* 4-byte integers */
31#define ID_NUMBER ID_REAL4 /* 4-byte reals */
32#define ID_NUMBER ID_REAL8 /* 8-byte reals */
33#define ID_NUMBER ID_NATIVE /* whatever your machine uses */
34#endif
20 35
21#define ID_CHUNK 27 /* ESC */ 36/* format for numbers in listings and error messages */
22#define ID_NUM 'N' 37#ifndef NUMBER_FMT
23#define ID_STR 'S' 38#define NUMBER_FMT "%.16g" /* LUA_NUMBER */
24#define ID_FUN 'F' 39#endif
40
41/* -- end of user configuration -- DO NOT CHANGE ANYTHING BELOW THIS LINE -- */
42
43
44TProtoFunc* luaU_undump1(ZIO* Z); /* load one chunk */
45void luaU_testnumber(void); /* test number representation */
46void luaU_badconstant(char* s, int i, TObject* o, TProtoFunc* tf);
47 /* handle cases that cannot happen */
48
49/* definitions for headers of binary files */
50#define VERSION 0x32 /* last format change was in 3.2 */
51#define VERSION0 0x32 /* last major change was in 3.2 */
52#define ID_CHUNK 27 /* binary files start with ESC... */
53#define SIGNATURE "Lua" /* ...followed by this signature */
25 54
26/* number representation */ 55/* number representation */
27#define ID_INT4 'l' /* 4-byte integers */ 56#define ID_INT4 'l' /* 4-byte integers */
@@ -29,53 +58,46 @@ TProtoFunc *luaU_undump1 (ZIO* Z); /* load one chunk */
29#define ID_REAL8 'd' /* 8-byte reals */ 58#define ID_REAL8 'd' /* 8-byte reals */
30#define ID_NATIVE '?' /* whatever your machine uses */ 59#define ID_NATIVE '?' /* whatever your machine uses */
31 60
32/* 61/* the default is ID_REAL8 because the default for LUA_NUM_TYPE is double */
33* use a multiple of PI for testing number representation.
34* multiplying by 1E8 gives notrivial integer values.
35*/
36#define TEST_NUMBER 3.14159265358979323846E8
37
38/* LUA_NUMBER
39* choose one below for the number representation in precompiled chunks.
40* the default is ID_REAL8 because the default for LUA_NUM_TYPE is double.
41* if your machine does not use IEEE 754, use ID_NATIVE.
42* the next version will support conversion to/from IEEE 754.
43*
44* if you change LUA_NUM_TYPE, make sure you set ID_NUMBER accordingly,
45* specially if sizeof(long)!=4.
46* for types other than the ones listed below, you'll have to write your own
47* dump and undump routines.
48*/
49
50#ifndef ID_NUMBER 62#ifndef ID_NUMBER
51#define ID_NUMBER ID_NATIVE 63#define ID_NUMBER ID_REAL8 /* 8-byte reals */
52#endif
53
54#if 0
55#define ID_NUMBER ID_INT4
56#define ID_NUMBER ID_REAL4
57#define ID_NUMBER ID_REAL8
58#define ID_NUMBER ID_NATIVE
59#endif 64#endif
60 65
61#endif 66/* a multiple of PI for testing number representation */
67/* multiplying by 1E8 gives non-trivial integer values */
68#define TEST_NUMBER 3.14159265358979323846E8
62 69
63#if ID_NUMBER==ID_REAL4 70#if ID_NUMBER==ID_REAL4
64 #define DumpNumber DumpFloat 71 #define DumpNumber DumpFloat
65 #define LoadNumber LoadFloat 72 #define LoadNumber LoadFloat
66 #define SIZEOF_NUMBER 4 73 #define SIZEOF_NUMBER 4
74 #define TYPEOF_NUMBER float
75 #define NAMEOF_NUMBER "float"
67#elif ID_NUMBER==ID_REAL8 76#elif ID_NUMBER==ID_REAL8
68 #define DumpNumber DumpDouble 77 #define DumpNumber DumpDouble
69 #define LoadNumber LoadDouble 78 #define LoadNumber LoadDouble
70 #define SIZEOF_NUMBER 8 79 #define SIZEOF_NUMBER 8
80 #define TYPEOF_NUMBER double
81 #define NAMEOF_NUMBER "double"
71#elif ID_NUMBER==ID_INT4 82#elif ID_NUMBER==ID_INT4
72 #define DumpNumber DumpLong 83 #define DumpNumber DumpLong
73 #define LoadNumber LoadLong 84 #define LoadNumber LoadLong
74 #define SIZEOF_NUMBER 4 85 #define SIZEOF_NUMBER 4
86 #define TYPEOF_NUMBER long
87 #define NAMEOF_NUMBER "long"
75#elif ID_NUMBER==ID_NATIVE 88#elif ID_NUMBER==ID_NATIVE
76 #define DumpNumber DumpNative 89 #define DumpNumber DumpNative
77 #define LoadNumber LoadNative 90 #define LoadNumber LoadNative
78 #define SIZEOF_NUMBER sizeof(real) 91 #define SIZEOF_NUMBER sizeof(real)
92 #define TYPEOF_NUMBER real
93 #define NAMEOF_NUMBER "native"
79#else 94#else
80 #error bad ID_NUMBER 95 #error bad ID_NUMBER
81#endif 96#endif
97
98/* formats for error messages */
99#define SOURCE "<%s:%d>"
100#define IN " in %p " SOURCE
101#define INLOC tf,tf->source->str,tf->lineDefined
102
103#endif