commit 8795aab83ed89f6a93d71d36c8cc37a4887581b2
parent f83db16cabdd3e83986e5f3a74c822baa688649e
Author: Waldemar Celes <celes@tecgraf.puc-rio.br>
Date: Fri, 27 Jan 1995 15:18:47 -0200
new API function lua_pushlocked & lua_checkstack is a macro
Diffstat:
M | opcode.c | | | 39 | +++++++++++++++++++++++---------------- |
1 file changed, 23 insertions(+), 16 deletions(-)
diff --git 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 <setjmp.h>
#include <stdio.h>
@@ -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);