mirror of https://github.com/rusefi/lua.git
details
This commit is contained in:
parent
e962330df9
commit
9e029f98b9
31
ldo.c
31
ldo.c
|
@ -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
|
** Stack and Call structure of Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -52,33 +52,32 @@ static void initCfunc (TObject *o, lua_CFunction f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define STACK_EXTRA 32
|
#define STACK_UNIT 128
|
||||||
#define INIT_STACK_SIZE 32
|
|
||||||
|
|
||||||
|
|
||||||
void luaD_init (void)
|
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.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);
|
initCfunc(&L->errorim, stderrorim);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void luaD_checkstack (int n)
|
void luaD_checkstack (int n)
|
||||||
{
|
{
|
||||||
if (L->stack.last-L->stack.top <= n) {
|
struct Stack *S = &L->stack;
|
||||||
StkId top = L->stack.top-L->stack.stack;
|
if (S->last-S->top <= n) {
|
||||||
int stacksize = (L->stack.last-L->stack.stack)+1+STACK_EXTRA+n;
|
StkId top = S->top-S->stack;
|
||||||
L->stack.stack = luaM_reallocvector(L->stack.stack, stacksize, TObject);
|
int stacksize = (S->last-S->stack)+1+STACK_UNIT+n;
|
||||||
L->stack.last = L->stack.stack+(stacksize-1);
|
S->stack = luaM_reallocvector(S->stack, stacksize, TObject);
|
||||||
L->stack.top = L->stack.stack + top;
|
S->last = S->stack+(stacksize-1);
|
||||||
if (stacksize >= STACK_LIMIT) {
|
S->top = S->stack + top;
|
||||||
if (lua_stackedfunction(100) == LUA_NOOBJECT)
|
if (stacksize >= STACK_LIMIT) { /* stack overflow? */
|
||||||
/* doesn't look like a recursive loop */
|
if (lua_stackedfunction(100) == LUA_NOOBJECT) /* 100 funcs on stack? */
|
||||||
lua_error("Lua2C - C2Lua overflow");
|
lua_error("Lua2C - C2Lua overflow"); /* doesn't look like a rec. loop */
|
||||||
else
|
else
|
||||||
lua_error(stackEM);
|
lua_error("stack size overflow");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
5
lmem.h
5
lmem.h
|
@ -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
|
** Interface to Memory Manager
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -15,10 +15,7 @@
|
||||||
|
|
||||||
/* memory error messages */
|
/* memory error messages */
|
||||||
#define codeEM "code size overflow"
|
#define codeEM "code size overflow"
|
||||||
#define symbolEM "symbol table overflow"
|
|
||||||
#define constantEM "constant table overflow"
|
#define constantEM "constant table overflow"
|
||||||
#define stackEM "stack size overflow"
|
|
||||||
#define lexEM "lex buffer overflow"
|
|
||||||
#define refEM "reference table overflow"
|
#define refEM "reference table overflow"
|
||||||
#define tableEM "table overflow"
|
#define tableEM "table overflow"
|
||||||
#define memEM "not enough memory"
|
#define memEM "not enough memory"
|
||||||
|
|
Loading…
Reference in New Issue