diff options
| -rw-r--r-- | ldo.c | 14 | ||||
| -rw-r--r-- | lstate.h | 3 |
2 files changed, 6 insertions, 11 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldo.c,v 1.9 1997/11/19 17:29:23 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 1.10 1997/11/21 19:00:46 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 | */ |
| @@ -58,7 +58,6 @@ static void initCfunc (TObject *o, lua_CFunction f) | |||
| 58 | 58 | ||
| 59 | void luaD_init (void) | 59 | void luaD_init (void) |
| 60 | { | 60 | { |
| 61 | L->stacklimit = STACK_LIMIT; | ||
| 62 | L->stack.stack = luaM_newvector(INIT_STACK_SIZE, TObject); | 61 | L->stack.stack = luaM_newvector(INIT_STACK_SIZE, TObject); |
| 63 | L->stack.top = L->stack.stack; | 62 | L->stack.top = L->stack.stack; |
| 64 | L->stack.last = L->stack.stack+(INIT_STACK_SIZE-1); | 63 | L->stack.last = L->stack.stack+(INIT_STACK_SIZE-1); |
| @@ -71,16 +70,13 @@ void luaD_checkstack (int n) | |||
| 71 | if (L->stack.last-L->stack.top <= n) { | 70 | if (L->stack.last-L->stack.top <= n) { |
| 72 | StkId top = L->stack.top-L->stack.stack; | 71 | StkId top = L->stack.top-L->stack.stack; |
| 73 | int stacksize = (L->stack.last-L->stack.stack)+1+STACK_EXTRA+n; | 72 | int stacksize = (L->stack.last-L->stack.stack)+1+STACK_EXTRA+n; |
| 74 | L->stack.stack = luaM_reallocvector(L->stack.stack, stacksize,TObject); | 73 | L->stack.stack = luaM_reallocvector(L->stack.stack, stacksize, TObject); |
| 75 | L->stack.last = L->stack.stack+(stacksize-1); | 74 | L->stack.last = L->stack.stack+(stacksize-1); |
| 76 | L->stack.top = L->stack.stack + top; | 75 | L->stack.top = L->stack.stack + top; |
| 77 | if (stacksize >= L->stacklimit) { | 76 | if (stacksize >= STACK_LIMIT) { |
| 78 | /* extra space to run error handler */ | 77 | if (lua_stackedfunction(100) == LUA_NOOBJECT) |
| 79 | L->stacklimit = stacksize+STACK_EXTRA; | 78 | /* doesn't look like a recursive loop */ |
| 80 | if (lua_stackedfunction(100) == LUA_NOOBJECT) { | ||
| 81 | /* less than 100 functions on the stack: cannot be recursive loop */ | ||
| 82 | lua_error("Lua2C - C2Lua overflow"); | 79 | lua_error("Lua2C - C2Lua overflow"); |
| 83 | } | ||
| 84 | else | 80 | else |
| 85 | lua_error(stackEM); | 81 | lua_error(stackEM); |
| 86 | } | 82 | } |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lstate.h,v 1.1 1997/11/19 17:30:36 roberto Exp roberto $ | 2 | ** $Id: lstate.h,v 1.2 1997/11/21 19:00:46 roberto Exp roberto $ |
| 3 | ** Global State | 3 | ** Global State |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -47,7 +47,6 @@ struct ref { | |||
| 47 | typedef struct LState { | 47 | typedef struct LState { |
| 48 | struct Stack stack; /* Lua stack */ | 48 | struct Stack stack; /* Lua stack */ |
| 49 | struct C_Lua_Stack Cstack; /* C2lua struct */ | 49 | struct C_Lua_Stack Cstack; /* C2lua struct */ |
| 50 | int stacklimit; /* limit for stack overflow */ | ||
| 51 | void *errorJmp; /* current error recover point */ | 50 | void *errorJmp; /* current error recover point */ |
| 52 | TObject errorim; /* error tag method */ | 51 | TObject errorim; /* error tag method */ |
| 53 | struct C_Lua_Stack Cblocks[MAX_C_BLOCKS]; | 52 | struct C_Lua_Stack Cblocks[MAX_C_BLOCKS]; |
