aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lbuiltin.c6
-rw-r--r--lcode.c6
-rw-r--r--ldo.h6
-rw-r--r--llex.c6
-rw-r--r--llex.h6
-rw-r--r--lobject.h46
-rw-r--r--lopcodes.h70
-rw-r--r--lparser.c13
-rw-r--r--lparser.h33
9 files changed, 27 insertions, 165 deletions
diff --git a/lbuiltin.c b/lbuiltin.c
index 41787bcc..544ff3fc 100644
--- a/lbuiltin.c
+++ b/lbuiltin.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbuiltin.c,v 1.95 2000/03/09 00:19:22 roberto Exp roberto $ 2** $Id: lbuiltin.c,v 1.96 2000/03/10 18:37:44 roberto Exp roberto $
3** Built-in functions 3** Built-in functions
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -130,10 +130,6 @@ void luaB__ERRORMESSAGE (lua_State *L) {
130** model but changing `fputs' to put the strings at a proper place 130** model but changing `fputs' to put the strings at a proper place
131** (a console window or a log file, for instance). 131** (a console window or a log file, for instance).
132*/ 132*/
133#ifndef MAXPRINT
134#define MAXPRINT 40 /* arbitrary limit */
135#endif
136
137void luaB_print (lua_State *L) { 133void luaB_print (lua_State *L) {
138 lua_Object args[MAXPRINT]; 134 lua_Object args[MAXPRINT];
139 lua_Object obj; 135 lua_Object obj;
diff --git a/lcode.c b/lcode.c
index 78777e00..d507e179 100644
--- a/lcode.c
+++ b/lcode.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lcode.c,v 1.16 2000/03/20 19:15:37 roberto Exp roberto $ 2** $Id: lcode.c,v 1.17 2000/03/24 12:18:30 roberto Exp roberto $
3** Code generator for Lua 3** Code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -212,10 +212,6 @@ void luaK_kstr (LexState *ls, int c) {
212} 212}
213 213
214 214
215#ifndef LOOKBACKNUMS
216#define LOOKBACKNUMS 20 /* arbitrary limit */
217#endif
218
219static int real_constant (FuncState *fs, Number r) { 215static int real_constant (FuncState *fs, Number r) {
220 /* check whether `r' has appeared within the last LOOKBACKNUMS entries */ 216 /* check whether `r' has appeared within the last LOOKBACKNUMS entries */
221 Proto *f = fs->f; 217 Proto *f = fs->f;
diff --git a/ldo.h b/ldo.h
index 91c7c787..502b2399 100644
--- a/ldo.h
+++ b/ldo.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.h,v 1.16 1999/12/30 18:28:40 roberto Exp roberto $ 2** $Id: ldo.h,v 1.17 2000/01/19 12:00:45 roberto Exp roberto $
3** Stack and Call structure of Lua 3** Stack and Call structure of Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -12,10 +12,6 @@
12#include "lstate.h" 12#include "lstate.h"
13 13
14 14
15#define MULT_RET 255
16
17
18
19/* 15/*
20** macro to increment stack top. 16** macro to increment stack top.
21** There must be always an empty slot at the L->stack.top 17** There must be always an empty slot at the L->stack.top
diff --git a/llex.c b/llex.c
index a3d2cab3..f56b0a21 100644
--- a/llex.c
+++ b/llex.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: llex.c,v 1.52 2000/03/03 14:58:26 roberto Exp roberto $ 2** $Id: llex.c,v 1.53 2000/03/10 18:37:44 roberto Exp roberto $
3** Lexical Analyzer 3** Lexical Analyzer
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -114,10 +114,6 @@ void luaX_setinput (lua_State *L, LexState *LS, ZIO *z) {
114** ======================================================= 114** =======================================================
115*/ 115*/
116 116
117#ifndef PRAGMASIZE
118#define PRAGMASIZE 80 /* arbitrary limit */
119#endif
120
121static void skipspace (LexState *LS) { 117static void skipspace (LexState *LS) {
122 while (LS->current == ' ' || LS->current == '\t' || LS->current == '\r') 118 while (LS->current == ' ' || LS->current == '\t' || LS->current == '\r')
123 next(LS); 119 next(LS);
diff --git a/llex.h b/llex.h
index 26ab95dd..87e6511a 100644
--- a/llex.h
+++ b/llex.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: llex.h,v 1.19 2000/03/03 14:58:26 roberto Exp roberto $ 2** $Id: llex.h,v 1.20 2000/03/10 18:37:44 roberto Exp roberto $
3** Lexical Analyzer 3** Lexical Analyzer
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -35,10 +35,6 @@ enum RESERVED {
35#define NUM_RESERVED ((int)(TK_WHILE-FIRST_RESERVED+1)) 35#define NUM_RESERVED ((int)(TK_WHILE-FIRST_RESERVED+1))
36 36
37 37
38#ifndef MAX_IFS
39#define MAX_IFS 5 /* arbitrary limit */
40#endif
41
42/* `ifState' keeps the state of each nested $if the lexical is dealing with. */ 38/* `ifState' keeps the state of each nested $if the lexical is dealing with. */
43 39
44struct ifState { 40struct ifState {
diff --git a/lobject.h b/lobject.h
index 558af2de..2b3fb2e4 100644
--- a/lobject.h
+++ b/lobject.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.h,v 1.52 2000/03/16 21:06:16 roberto Exp roberto $ 2** $Id: lobject.h,v 1.53 2000/03/20 19:14:54 roberto Exp roberto $
3** Type definitions for Lua objects 3** Type definitions for Lua objects
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -8,8 +8,7 @@
8#define lobject_h 8#define lobject_h
9 9
10 10
11#include <limits.h> 11#include "llims.h"
12
13#include "lua.h" 12#include "lua.h"
14 13
15 14
@@ -26,39 +25,6 @@
26 25
27#define UNUSED(x) (void)x /* to avoid warnings */ 26#define UNUSED(x) (void)x /* to avoid warnings */
28 27
29/*
30** Define the type `number' of Lua
31** GREP LUA_NUMBER to change that
32*/
33#ifndef LUA_NUM_TYPE
34#define LUA_NUM_TYPE double
35#endif
36
37typedef LUA_NUM_TYPE Number;
38
39
40/*
41** type for virtual-machine instructions
42** must be an unsigned with 4 bytes (see details in lopcodes.h)
43*/
44typedef unsigned long Instruction;
45
46
47#define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */
48
49
50/* conversion of pointer to int (for hashing only) */
51/* (the shift removes bits that are usually 0 because of alignment) */
52#define IntPoint(L, p) (((unsigned long)(p)) >> 3)
53
54
55/*
56** number of `blocks' for garbage collection: each reference to other
57** objects count 1, and each 32 bytes of `raw' memory count 1; we add
58** 2 to the total as a minimum (and also to count the overhead of malloc)
59*/
60#define numblocks(L, o,b) ((o)+((b)>>5)+2)
61
62 28
63/* 29/*
64** Lua TYPES 30** Lua TYPES
@@ -112,7 +78,6 @@ typedef struct TObject {
112} TObject; 78} TObject;
113 79
114 80
115
116typedef struct GlobalVar { 81typedef struct GlobalVar {
117 TObject value; 82 TObject value;
118 struct GlobalVar *next; 83 struct GlobalVar *next;
@@ -142,8 +107,6 @@ typedef struct TString {
142} TString; 107} TString;
143 108
144 109
145
146
147/* 110/*
148** Function Prototypes 111** Function Prototypes
149*/ 112*/
@@ -173,8 +136,6 @@ typedef struct LocVar {
173 136
174 137
175 138
176
177
178/* Macros to access structure members */ 139/* Macros to access structure members */
179#define ttype(o) ((o)->ttype) 140#define ttype(o) ((o)->ttype)
180#define nvalue(o) ((o)->value.n) 141#define nvalue(o) ((o)->value.n)
@@ -199,7 +160,6 @@ typedef struct Closure {
199} Closure; 160} Closure;
200 161
201 162
202
203typedef struct Node { 163typedef struct Node {
204 TObject key; 164 TObject key;
205 TObject val; 165 TObject val;
@@ -221,8 +181,6 @@ extern const TObject luaO_nilobject;
221 181
222#define luaO_typename(o) luaO_typenames[ttype(o)] 182#define luaO_typename(o) luaO_typenames[ttype(o)]
223 183
224#define MINPOWER2 4 /* minimum size for "growing" vectors */
225
226unsigned long luaO_power2 (unsigned long n); 184unsigned long luaO_power2 (unsigned long n);
227 185
228#define luaO_equalObj(t1,t2) (ttype(t1) == ttype(t2) && luaO_equalval(t1,t2)) 186#define luaO_equalObj(t1,t2) (ttype(t1) == ttype(t2) && luaO_equalval(t1,t2))
diff --git a/lopcodes.h b/lopcodes.h
index 8d971689..1abeff7f 100644
--- a/lopcodes.h
+++ b/lopcodes.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lopcodes.h,v 1.49 2000/03/13 20:37:16 roberto Exp roberto $ 2** $Id: lopcodes.h,v 1.50 2000/03/16 18:03:09 roberto Exp roberto $
3** Opcodes for Lua virtual machine 3** Opcodes for Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -7,36 +7,32 @@
7#ifndef lopcodes_h 7#ifndef lopcodes_h
8#define lopcodes_h 8#define lopcodes_h
9 9
10#include "llims.h"
10 11
11 12
12/*=========================================================================== 13/*===========================================================================
13 We assume that instructions are unsigned numbers with 4 bytes. 14 We assume that instructions are unsigned numbers.
14 All instructions have an opcode in the 8 bits. Moreover, 15 All instructions have an opcode in the first 6 bits. Moreover,
15 an instruction can have 0, 1, or 2 arguments. There are 4 types of 16 an instruction can have 0, 1, or 2 arguments. There are 4 types of
16 Instructions: 17 Instructions:
17 type 0: no arguments 18 type 0: no arguments
18 type 1: 1 unsigned argument in the higher 24 bits (called `U') 19 type 1: 1 unsigned argument in the higher bits (called `U')
19 type 2: 1 signed argument in the higher 24 bits (`S') 20 type 2: 1 signed argument in the higher bits (`S')
20 type 3: 1st unsigned argument in the higher 16 bits (`A') 21 type 3: 1st unsigned argument in the higher bits (`A')
21 2nd unsigned argument in the middle 8 bits (`B') 22 2nd unsigned argument in the middle bits (`B')
22 23
23 The signed argument is represented in excess 2^23; that is, the number 24 The signed argument is represented in excess 2^K; that is, the number
24 value is the usigned value minus 2^23. 25 value is the usigned value minus 2^K.
26
27 The size of each argument is defined in `llims.h'. The usual is an
28 instruction with 32 bits, U and S arguments with 26 bits (32-6), B
29 argument with 9 bits, and A argument with 17 bits (32-6-9). For small
30 instalations, the instruction size can be 16, so U and S have 10 bits,
31 and A and B have 5 bits each.
25===========================================================================*/ 32===========================================================================*/
26 33
27#define SIZE_INSTRUCTION 32
28
29#define SIZE_OP 8
30#define SIZE_U (SIZE_INSTRUCTION-SIZE_OP)
31#define POS_U SIZE_OP
32#define SIZE_S (SIZE_INSTRUCTION-SIZE_OP)
33#define POS_S SIZE_OP
34#define SIZE_B 8
35#define POS_B SIZE_OP
36#define SIZE_A (SIZE_INSTRUCTION-(SIZE_OP+SIZE_B))
37#define POS_A (SIZE_OP+SIZE_B)
38 34
39#define EXCESS_S (1<<(SIZE_S-1)) /* == 2^23 */ 35#define EXCESS_S (1<<(SIZE_S-1)) /* == 2^K */
40 36
41 37
42/* creates a mask with `n' 1 bits at position `p' */ 38/* creates a mask with `n' 1 bits at position `p' */
@@ -49,11 +45,6 @@
49** the following macros help to manipulate instructions 45** the following macros help to manipulate instructions
50*/ 46*/
51 47
52#define MAXARG_U ((1<<SIZE_U)-1)
53#define MAXARG_S ((1<<(SIZE_S-1))-1) /* `S' is signed */
54#define MAXARG_A ((1<<SIZE_A)-1)
55#define MAXARG_B ((1<<SIZE_B)-1)
56
57#define GET_OPCODE(i) ((OpCode)((i)&MASK1(SIZE_OP,0))) 48#define GET_OPCODE(i) ((OpCode)((i)&MASK1(SIZE_OP,0)))
58#define GETARG_U(i) ((int)((i)>>POS_U)) 49#define GETARG_U(i) ((int)((i)>>POS_U))
59#define GETARG_S(i) ((int)((i)>>POS_S)-EXCESS_S) 50#define GETARG_S(i) ((int)((i)>>POS_S)-EXCESS_S)
@@ -157,29 +148,4 @@ OP_SETLINE/* U - - LINE=u */
157#define ISJUMP(o) (OP_IFNEQJMP <= (o) && (o) <= OP_JMP) 148#define ISJUMP(o) (OP_IFNEQJMP <= (o) && (o) <= OP_JMP)
158 149
159 150
160#define RFIELDS_PER_FLUSH 32 /* records (SETMAP) */
161#define LFIELDS_PER_FLUSH 64 /* FPF - lists (SETLIST) (<=MAXARG_B) */
162
163
164/*
165** we use int to manipulte most arguments, so they must fit
166*/
167#if MAXARG_U > MAX_INT
168#undef MAXARG_U
169#define MAXARG_U MAX_INT
170#endif
171#if MAXARG_S > MAX_INT
172#undef MAXARG_S
173#define MAXARG_S MAX_INT
174#endif
175#if MAXARG_A > MAX_INT
176#undef MAXARG_A
177#define MAXARG_A MAX_INT
178#endif
179#if MAXARG_B > MAX_INT
180#undef MAXARG_B
181#define MAXARG_B MAX_INT
182#endif
183
184
185#endif 151#endif
diff --git a/lparser.c b/lparser.c
index 3a8e9760..8238b996 100644
--- a/lparser.c
+++ b/lparser.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.c,v 1.71 2000/03/20 19:15:37 roberto Exp roberto $ 2** $Id: lparser.c,v 1.72 2000/03/24 12:17:53 roberto Exp roberto $
3** LL(1) Parser and code generator for Lua 3** LL(1) Parser and code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -23,17 +23,6 @@
23 23
24 24
25/* 25/*
26** check whether arbitrary limits fit into respective opcode types
27*/
28#if MAXLOCALS > MAXARG_U || MAXUPVALUES > MAXARG_B || MAXVARSLH > MAXARG_B || \
29 MAXPARAMS > MAXLOCALS || MAXSTACK > MAXARG_A || \
30 LFIELDS_PER_FLUSH > MAXARG_B || MULT_RET > MAXARG_B
31#error invalid limits
32#endif
33
34
35
36/*
37** Constructors descriptor: 26** Constructors descriptor:
38** `n' indicates number of elements, and `k' signals whether 27** `n' indicates number of elements, and `k' signals whether
39** it is a list constructor (k = 0) or a record constructor (k = 1) 28** it is a list constructor (k = 0) or a record constructor (k = 1)
diff --git a/lparser.h b/lparser.h
index d7e70479..896b1eb9 100644
--- a/lparser.h
+++ b/lparser.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.h,v 1.12 2000/03/10 18:37:44 roberto Exp roberto $ 2** $Id: lparser.h,v 1.13 2000/03/13 20:37:16 roberto Exp roberto $
3** LL(1) Parser and code generator for Lua 3** LL(1) Parser and code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -11,37 +11,6 @@
11#include "lzio.h" 11#include "lzio.h"
12 12
13 13
14/* maximum number of local variables */
15#ifndef MAXLOCALS
16#define MAXLOCALS 200 /* arbitrary limit (<=MAXARG_B) */
17#endif
18
19
20/* maximum number of upvalues */
21#ifndef MAXUPVALUES
22#define MAXUPVALUES 32 /* arbitrary limit (<=MAXARG_B) */
23#endif
24
25
26/* maximum number of variables in the left side of an assignment */
27#ifndef MAXVARSLH
28#define MAXVARSLH 100 /* arbitrary limit (<=MAXARG_B) */
29#endif
30
31
32/* maximum number of parameters in a function */
33#ifndef MAXPARAMS
34#define MAXPARAMS 100 /* arbitrary limit (<=MAXLOCALS) */
35#endif
36
37
38/* maximum stack size in a function */
39#ifndef MAXSTACK
40#define MAXSTACK 256 /* arbitrary limit (<=MAXARG_A) */
41#endif
42
43
44
45/* 14/*
46** Expression descriptor 15** Expression descriptor
47*/ 16*/