This commit is contained in:
Roberto Ierusalimschy 1997-11-26 18:44:52 -02:00
parent e962330df9
commit 9e029f98b9
2 changed files with 16 additions and 20 deletions

31
ldo.c
View File

@ -1,5 +1,5 @@
/*
** $Id: ldo.c,v 1.10 1997/11/21 19:00:46 roberto Exp roberto $
** $Id: ldo.c,v 1.11 1997/11/26 20:28:22 roberto Exp $
** Stack and Call structure of Lua
** See Copyright Notice in lua.h
*/
@ -52,33 +52,32 @@ static void initCfunc (TObject *o, lua_CFunction f)
}
#define STACK_EXTRA 32
#define INIT_STACK_SIZE 32
#define STACK_UNIT 128
void luaD_init (void)
{
L->stack.stack = luaM_newvector(INIT_STACK_SIZE, TObject);
L->stack.stack = luaM_newvector(STACK_UNIT, TObject);
L->stack.top = L->stack.stack;
L->stack.last = L->stack.stack+(INIT_STACK_SIZE-1);
L->stack.last = L->stack.stack+(STACK_UNIT-1);
initCfunc(&L->errorim, stderrorim);
}
void luaD_checkstack (int n)
{
if (L->stack.last-L->stack.top <= n) {
StkId top = L->stack.top-L->stack.stack;
int stacksize = (L->stack.last-L->stack.stack)+1+STACK_EXTRA+n;
L->stack.stack = luaM_reallocvector(L->stack.stack, stacksize, TObject);
L->stack.last = L->stack.stack+(stacksize-1);
L->stack.top = L->stack.stack + top;
if (stacksize >= STACK_LIMIT) {
if (lua_stackedfunction(100) == LUA_NOOBJECT)
/* doesn't look like a recursive loop */
lua_error("Lua2C - C2Lua overflow");
struct Stack *S = &L->stack;
if (S->last-S->top <= n) {
StkId top = S->top-S->stack;
int stacksize = (S->last-S->stack)+1+STACK_UNIT+n;
S->stack = luaM_reallocvector(S->stack, stacksize, TObject);
S->last = S->stack+(stacksize-1);
S->top = S->stack + top;
if (stacksize >= STACK_LIMIT) { /* stack overflow? */
if (lua_stackedfunction(100) == LUA_NOOBJECT) /* 100 funcs on stack? */
lua_error("Lua2C - C2Lua overflow"); /* doesn't look like a rec. loop */
else
lua_error(stackEM);
lua_error("stack size overflow");
}
}
}

5
lmem.h
View File

@ -1,5 +1,5 @@
/*
** $Id: lmem.h,v 1.1 1997/09/16 19:25:59 roberto Exp roberto $
** $Id: lmem.h,v 1.2 1997/11/26 18:53:45 roberto Exp roberto $
** Interface to Memory Manager
** See Copyright Notice in lua.h
*/
@ -15,10 +15,7 @@
/* memory error messages */
#define codeEM "code size overflow"
#define symbolEM "symbol table overflow"
#define constantEM "constant table overflow"
#define stackEM "stack size overflow"
#define lexEM "lex buffer overflow"
#define refEM "reference table overflow"
#define tableEM "table overflow"
#define memEM "not enough memory"