From 213e9febc889d5aaae8ef0e8b777cdb4889e30c1 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 24 Mar 2000 14:26:08 -0300 Subject: limits now are in `llims.n' --- lbuiltin.c | 6 +----- lcode.c | 6 +----- ldo.h | 6 +----- llex.c | 6 +----- llex.h | 6 +----- lobject.h | 46 ++--------------------------------------- lopcodes.h | 70 ++++++++++++++++---------------------------------------------- lparser.c | 13 +----------- lparser.h | 33 +---------------------------- 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 @@ /* -** $Id: lbuiltin.c,v 1.95 2000/03/09 00:19:22 roberto Exp roberto $ +** $Id: lbuiltin.c,v 1.96 2000/03/10 18:37:44 roberto Exp roberto $ ** Built-in functions ** See Copyright Notice in lua.h */ @@ -130,10 +130,6 @@ void luaB__ERRORMESSAGE (lua_State *L) { ** model but changing `fputs' to put the strings at a proper place ** (a console window or a log file, for instance). */ -#ifndef MAXPRINT -#define MAXPRINT 40 /* arbitrary limit */ -#endif - void luaB_print (lua_State *L) { lua_Object args[MAXPRINT]; 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 @@ /* -** $Id: lcode.c,v 1.16 2000/03/20 19:15:37 roberto Exp roberto $ +** $Id: lcode.c,v 1.17 2000/03/24 12:18:30 roberto Exp roberto $ ** Code generator for Lua ** See Copyright Notice in lua.h */ @@ -212,10 +212,6 @@ void luaK_kstr (LexState *ls, int c) { } -#ifndef LOOKBACKNUMS -#define LOOKBACKNUMS 20 /* arbitrary limit */ -#endif - static int real_constant (FuncState *fs, Number r) { /* check whether `r' has appeared within the last LOOKBACKNUMS entries */ 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 @@ /* -** $Id: ldo.h,v 1.16 1999/12/30 18:28:40 roberto Exp roberto $ +** $Id: ldo.h,v 1.17 2000/01/19 12:00:45 roberto Exp roberto $ ** Stack and Call structure of Lua ** See Copyright Notice in lua.h */ @@ -12,10 +12,6 @@ #include "lstate.h" -#define MULT_RET 255 - - - /* ** macro to increment stack top. ** 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 @@ /* -** $Id: llex.c,v 1.52 2000/03/03 14:58:26 roberto Exp roberto $ +** $Id: llex.c,v 1.53 2000/03/10 18:37:44 roberto Exp roberto $ ** Lexical Analyzer ** See Copyright Notice in lua.h */ @@ -114,10 +114,6 @@ void luaX_setinput (lua_State *L, LexState *LS, ZIO *z) { ** ======================================================= */ -#ifndef PRAGMASIZE -#define PRAGMASIZE 80 /* arbitrary limit */ -#endif - static void skipspace (LexState *LS) { while (LS->current == ' ' || LS->current == '\t' || LS->current == '\r') next(LS); diff --git a/llex.h b/llex.h index 26ab95dd..87e6511a 100644 --- a/llex.h +++ b/llex.h @@ -1,5 +1,5 @@ /* -** $Id: llex.h,v 1.19 2000/03/03 14:58:26 roberto Exp roberto $ +** $Id: llex.h,v 1.20 2000/03/10 18:37:44 roberto Exp roberto $ ** Lexical Analyzer ** See Copyright Notice in lua.h */ @@ -35,10 +35,6 @@ enum RESERVED { #define NUM_RESERVED ((int)(TK_WHILE-FIRST_RESERVED+1)) -#ifndef MAX_IFS -#define MAX_IFS 5 /* arbitrary limit */ -#endif - /* `ifState' keeps the state of each nested $if the lexical is dealing with. */ struct ifState { diff --git a/lobject.h b/lobject.h index 558af2de..2b3fb2e4 100644 --- a/lobject.h +++ b/lobject.h @@ -1,5 +1,5 @@ /* -** $Id: lobject.h,v 1.52 2000/03/16 21:06:16 roberto Exp roberto $ +** $Id: lobject.h,v 1.53 2000/03/20 19:14:54 roberto Exp roberto $ ** Type definitions for Lua objects ** See Copyright Notice in lua.h */ @@ -8,8 +8,7 @@ #define lobject_h -#include - +#include "llims.h" #include "lua.h" @@ -26,39 +25,6 @@ #define UNUSED(x) (void)x /* to avoid warnings */ -/* -** Define the type `number' of Lua -** GREP LUA_NUMBER to change that -*/ -#ifndef LUA_NUM_TYPE -#define LUA_NUM_TYPE double -#endif - -typedef LUA_NUM_TYPE Number; - - -/* -** type for virtual-machine instructions -** must be an unsigned with 4 bytes (see details in lopcodes.h) -*/ -typedef unsigned long Instruction; - - -#define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */ - - -/* conversion of pointer to int (for hashing only) */ -/* (the shift removes bits that are usually 0 because of alignment) */ -#define IntPoint(L, p) (((unsigned long)(p)) >> 3) - - -/* -** number of `blocks' for garbage collection: each reference to other -** objects count 1, and each 32 bytes of `raw' memory count 1; we add -** 2 to the total as a minimum (and also to count the overhead of malloc) -*/ -#define numblocks(L, o,b) ((o)+((b)>>5)+2) - /* ** Lua TYPES @@ -112,7 +78,6 @@ typedef struct TObject { } TObject; - typedef struct GlobalVar { TObject value; struct GlobalVar *next; @@ -142,8 +107,6 @@ typedef struct TString { } TString; - - /* ** Function Prototypes */ @@ -173,8 +136,6 @@ typedef struct LocVar { - - /* Macros to access structure members */ #define ttype(o) ((o)->ttype) #define nvalue(o) ((o)->value.n) @@ -199,7 +160,6 @@ typedef struct Closure { } Closure; - typedef struct Node { TObject key; TObject val; @@ -221,8 +181,6 @@ extern const TObject luaO_nilobject; #define luaO_typename(o) luaO_typenames[ttype(o)] -#define MINPOWER2 4 /* minimum size for "growing" vectors */ - unsigned long luaO_power2 (unsigned long n); #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 @@ /* -** $Id: lopcodes.h,v 1.49 2000/03/13 20:37:16 roberto Exp roberto $ +** $Id: lopcodes.h,v 1.50 2000/03/16 18:03:09 roberto Exp roberto $ ** Opcodes for Lua virtual machine ** See Copyright Notice in lua.h */ @@ -7,36 +7,32 @@ #ifndef lopcodes_h #define lopcodes_h +#include "llims.h" /*=========================================================================== - We assume that instructions are unsigned numbers with 4 bytes. - All instructions have an opcode in the 8 bits. Moreover, + We assume that instructions are unsigned numbers. + All instructions have an opcode in the first 6 bits. Moreover, an instruction can have 0, 1, or 2 arguments. There are 4 types of Instructions: type 0: no arguments - type 1: 1 unsigned argument in the higher 24 bits (called `U') - type 2: 1 signed argument in the higher 24 bits (`S') - type 3: 1st unsigned argument in the higher 16 bits (`A') - 2nd unsigned argument in the middle 8 bits (`B') - - The signed argument is represented in excess 2^23; that is, the number - value is the usigned value minus 2^23. + type 1: 1 unsigned argument in the higher bits (called `U') + type 2: 1 signed argument in the higher bits (`S') + type 3: 1st unsigned argument in the higher bits (`A') + 2nd unsigned argument in the middle bits (`B') + + The signed argument is represented in excess 2^K; that is, the number + value is the usigned value minus 2^K. + + The size of each argument is defined in `llims.h'. The usual is an + instruction with 32 bits, U and S arguments with 26 bits (32-6), B + argument with 9 bits, and A argument with 17 bits (32-6-9). For small + instalations, the instruction size can be 16, so U and S have 10 bits, + and A and B have 5 bits each. ===========================================================================*/ -#define SIZE_INSTRUCTION 32 - -#define SIZE_OP 8 -#define SIZE_U (SIZE_INSTRUCTION-SIZE_OP) -#define POS_U SIZE_OP -#define SIZE_S (SIZE_INSTRUCTION-SIZE_OP) -#define POS_S SIZE_OP -#define SIZE_B 8 -#define POS_B SIZE_OP -#define SIZE_A (SIZE_INSTRUCTION-(SIZE_OP+SIZE_B)) -#define POS_A (SIZE_OP+SIZE_B) -#define EXCESS_S (1<<(SIZE_S-1)) /* == 2^23 */ +#define EXCESS_S (1<<(SIZE_S-1)) /* == 2^K */ /* creates a mask with `n' 1 bits at position `p' */ @@ -49,11 +45,6 @@ ** the following macros help to manipulate instructions */ -#define MAXARG_U ((1<>POS_U)) #define GETARG_S(i) ((int)((i)>>POS_S)-EXCESS_S) @@ -157,29 +148,4 @@ OP_SETLINE/* U - - LINE=u */ #define ISJUMP(o) (OP_IFNEQJMP <= (o) && (o) <= OP_JMP) -#define RFIELDS_PER_FLUSH 32 /* records (SETMAP) */ -#define LFIELDS_PER_FLUSH 64 /* FPF - lists (SETLIST) (<=MAXARG_B) */ - - -/* -** we use int to manipulte most arguments, so they must fit -*/ -#if MAXARG_U > MAX_INT -#undef MAXARG_U -#define MAXARG_U MAX_INT -#endif -#if MAXARG_S > MAX_INT -#undef MAXARG_S -#define MAXARG_S MAX_INT -#endif -#if MAXARG_A > MAX_INT -#undef MAXARG_A -#define MAXARG_A MAX_INT -#endif -#if MAXARG_B > MAX_INT -#undef MAXARG_B -#define MAXARG_B MAX_INT -#endif - - #endif diff --git a/lparser.c b/lparser.c index 3a8e9760..8238b996 100644 --- a/lparser.c +++ b/lparser.c @@ -1,5 +1,5 @@ /* -** $Id: lparser.c,v 1.71 2000/03/20 19:15:37 roberto Exp roberto $ +** $Id: lparser.c,v 1.72 2000/03/24 12:17:53 roberto Exp roberto $ ** LL(1) Parser and code generator for Lua ** See Copyright Notice in lua.h */ @@ -22,17 +22,6 @@ #include "lstring.h" -/* -** check whether arbitrary limits fit into respective opcode types -*/ -#if MAXLOCALS > MAXARG_U || MAXUPVALUES > MAXARG_B || MAXVARSLH > MAXARG_B || \ - MAXPARAMS > MAXLOCALS || MAXSTACK > MAXARG_A || \ - LFIELDS_PER_FLUSH > MAXARG_B || MULT_RET > MAXARG_B -#error invalid limits -#endif - - - /* ** Constructors descriptor: ** `n' indicates number of elements, and `k' signals whether diff --git a/lparser.h b/lparser.h index d7e70479..896b1eb9 100644 --- a/lparser.h +++ b/lparser.h @@ -1,5 +1,5 @@ /* -** $Id: lparser.h,v 1.12 2000/03/10 18:37:44 roberto Exp roberto $ +** $Id: lparser.h,v 1.13 2000/03/13 20:37:16 roberto Exp roberto $ ** LL(1) Parser and code generator for Lua ** See Copyright Notice in lua.h */ @@ -11,37 +11,6 @@ #include "lzio.h" -/* maximum number of local variables */ -#ifndef MAXLOCALS -#define MAXLOCALS 200 /* arbitrary limit (<=MAXARG_B) */ -#endif - - -/* maximum number of upvalues */ -#ifndef MAXUPVALUES -#define MAXUPVALUES 32 /* arbitrary limit (<=MAXARG_B) */ -#endif - - -/* maximum number of variables in the left side of an assignment */ -#ifndef MAXVARSLH -#define MAXVARSLH 100 /* arbitrary limit (<=MAXARG_B) */ -#endif - - -/* maximum number of parameters in a function */ -#ifndef MAXPARAMS -#define MAXPARAMS 100 /* arbitrary limit (<=MAXLOCALS) */ -#endif - - -/* maximum stack size in a function */ -#ifndef MAXSTACK -#define MAXSTACK 256 /* arbitrary limit (<=MAXARG_A) */ -#endif - - - /* ** Expression descriptor */ -- cgit v1.2.3-55-g6feb