aboutsummaryrefslogtreecommitdiff
path: root/ldo.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-08-29 17:43:28 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-08-29 17:43:28 -0300
commita97f29f15487c5f584185f646f9cfc06a04b26ca (patch)
treee7ffd959fb80f9622d74a2efadfd7880037d64ca /ldo.c
parent4135f4f5862b57d9dbf3e9b7c6507f5c86516327 (diff)
downloadlua-a97f29f15487c5f584185f646f9cfc06a04b26ca.tar.gz
lua-a97f29f15487c5f584185f646f9cfc06a04b26ca.tar.bz2
lua-a97f29f15487c5f584185f646f9cfc06a04b26ca.zip
explicit stack control in the API
Diffstat (limited to 'ldo.c')
-rw-r--r--ldo.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/ldo.c b/ldo.c
index 907e62a6..79cf25a2 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 1.89 2000/08/29 14:57:23 roberto Exp roberto $ 2** $Id: ldo.c,v 1.90 2000/08/29 19:01:34 roberto Exp roberto $
3** Stack and Call structure of Lua 3** Stack and Call structure of Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -53,14 +53,8 @@ void luaD_checkstack (lua_State *L, int n) {
53 lua_error(L, "BAD STACK OVERFLOW! DATA CORRUPTED!"); 53 lua_error(L, "BAD STACK OVERFLOW! DATA CORRUPTED!");
54 } 54 }
55 else { 55 else {
56 lua_Debug dummy;
57 L->stack_last += EXTRA_STACK; /* to be used by error message */ 56 L->stack_last += EXTRA_STACK; /* to be used by error message */
58 if (lua_getstack(L, L->stacksize/SLOTS_PER_F, &dummy) == 0) { 57 lua_error(L, "stack overflow");
59 /* too few funcs on stack: doesn't look like a recursion loop */
60 lua_error(L, "Lua2C - C2Lua overflow");
61 }
62 else
63 lua_error(L, "stack overflow; possible recursion loop");
64 } 58 }
65 } 59 }
66} 60}
@@ -140,7 +134,7 @@ static StkId callCclosure (lua_State *L, const struct Closure *cl, StkId base) {
140 StkId old_Cbase = L->Cbase; 134 StkId old_Cbase = L->Cbase;
141 int n; 135 int n;
142 L->Cbase = base; /* new base for C function */ 136 L->Cbase = base; /* new base for C function */
143 luaD_checkstack(L, nup); 137 luaD_checkstack(L, nup+LUA_MINSTACK); /* assures minimum stack size */
144 for (n=0; n<nup; n++) /* copy upvalues as extra arguments */ 138 for (n=0; n<nup; n++) /* copy upvalues as extra arguments */
145 *(L->top++) = cl->upvalue[n]; 139 *(L->top++) = cl->upvalue[n];
146 n = (*cl->f.c)(L); /* do the actual call */ 140 n = (*cl->f.c)(L); /* do the actual call */