new API function lua_pushlocked & lua_checkstack is a macro

This commit is contained in:
Waldemar Celes
1995-01-27 15:19:06 -02:00
parent f83db16cab
commit 8795aab83e

View File

@@ -3,7 +3,7 @@
** TecCGraf - PUC-Rio ** TecCGraf - PUC-Rio
*/ */
char *rcs_opcode="$Id: opcode.c,v 3.30 1994/12/28 12:55:47 roberto Exp roberto $"; char *rcs_opcode="$Id: opcode.c,v 3.31 1994/12/30 17:45:11 roberto Exp celes $";
#include <setjmp.h> #include <setjmp.h>
#include <stdio.h> #include <stdio.h>
@@ -96,22 +96,21 @@ static void lua_initstack (void)
/* /*
** Check stack overflow and, if necessary, realloc vector ** Check stack overflow and, if necessary, realloc vector
*/ */
static void lua_checkstack (StkId n) #define lua_checkstack(n) if ((Long)(n) > maxstack) checkstack(n)
static void checkstack (StkId n)
{ {
if ((Long)n > maxstack) StkId t;
{ if (stack == NULL)
StkId t; lua_initstack();
if (stack == NULL) if (maxstack >= MAX_INT)
lua_initstack(); lua_error("stack size overflow");
if (maxstack >= MAX_INT) t = top-stack;
lua_error("stack size overflow"); maxstack *= 2;
t = top-stack; if (maxstack >= MAX_INT)
maxstack *= 2; maxstack = MAX_INT;
if (maxstack >= MAX_INT) stack = growvector(stack, maxstack, Object);
maxstack = MAX_INT; top = stack + t;
stack = growvector(stack, maxstack, Object);
top = stack + t;
}
} }
@@ -565,6 +564,14 @@ lua_Object lua_getlocked (int ref)
} }
void lua_pushlocked (int ref)
{
lua_checkstack(top-stack+1);
*top = *luaI_getlocked(ref);
top++;
}
int lua_lock (void) int lua_lock (void)
{ {
adjustC(1); adjustC(1);