From 8795aab83ed89f6a93d71d36c8cc37a4887581b2 Mon Sep 17 00:00:00 2001 From: Waldemar Celes Date: Fri, 27 Jan 1995 15:19:06 -0200 Subject: new API function lua_pushlocked & lua_checkstack is a macro --- opcode.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/opcode.c b/opcode.c index d7b82c50..4f488bb0 100644 --- a/opcode.c +++ b/opcode.c @@ -3,7 +3,7 @@ ** 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 #include @@ -96,22 +96,21 @@ static void lua_initstack (void) /* ** 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) - lua_initstack(); - if (maxstack >= MAX_INT) - lua_error("stack size overflow"); - t = top-stack; - maxstack *= 2; - if (maxstack >= MAX_INT) - maxstack = MAX_INT; - stack = growvector(stack, maxstack, Object); - top = stack + t; - } + StkId t; + if (stack == NULL) + lua_initstack(); + if (maxstack >= MAX_INT) + lua_error("stack size overflow"); + t = top-stack; + maxstack *= 2; + if (maxstack >= MAX_INT) + maxstack = MAX_INT; + 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) { adjustC(1); -- cgit v1.2.3-55-g6feb