diff options
Diffstat (limited to 'ldo.c')
-rw-r--r-- | ldo.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 2.6 2004/05/31 18:51:50 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 2.7 2004/06/02 19:07:55 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 | */ |
@@ -193,6 +193,7 @@ static StkId adjust_varargs (lua_State *L, int nfixargs, int actual, | |||
193 | } | 193 | } |
194 | if (style != NEWSTYLEVARARG) { /* compatibility with old-style vararg */ | 194 | if (style != NEWSTYLEVARARG) { /* compatibility with old-style vararg */ |
195 | int nvar = actual - nfixargs; /* number of extra arguments */ | 195 | int nvar = actual - nfixargs; /* number of extra arguments */ |
196 | luaC_checkGC(L); | ||
196 | htab = luaH_new(L, nvar, 1); /* create `arg' table */ | 197 | htab = luaH_new(L, nvar, 1); /* create `arg' table */ |
197 | for (i=0; i<nvar; i++) /* put extra arguments into `arg' table */ | 198 | for (i=0; i<nvar; i++) /* put extra arguments into `arg' table */ |
198 | setobj2n(L, luaH_setnum(L, htab, i+LUA_FIRSTINDEX), L->top - nvar + i); | 199 | setobj2n(L, luaH_setnum(L, htab, i+LUA_FIRSTINDEX), L->top - nvar + i); |
@@ -244,14 +245,17 @@ int luaD_precall (lua_State *L, StkId func, int nresults) { | |||
244 | CallInfo *ci; | 245 | CallInfo *ci; |
245 | StkId st, base; | 246 | StkId st, base; |
246 | Proto *p = cl->p; | 247 | Proto *p = cl->p; |
247 | luaD_checkstack(L, p->maxstacksize); | ||
248 | func = restorestack(L, funcr); | ||
249 | if (p->is_vararg) { /* varargs? */ | 248 | if (p->is_vararg) { /* varargs? */ |
250 | int nargs = L->top - func - 1; | 249 | int nargs = L->top - restorestack(L, funcr) - 1; |
250 | luaD_checkstack(L, p->maxstacksize + nargs); | ||
251 | base = adjust_varargs(L, p->numparams, nargs, p->is_vararg); | 251 | base = adjust_varargs(L, p->numparams, nargs, p->is_vararg); |
252 | func = restorestack(L, funcr); | ||
252 | } | 253 | } |
253 | else | 254 | else { |
255 | luaD_checkstack(L, p->maxstacksize); | ||
256 | func = restorestack(L, funcr); | ||
254 | base = func + 1; | 257 | base = func + 1; |
258 | } | ||
255 | ci = ++L->ci; /* now `enter' new function */ | 259 | ci = ++L->ci; /* now `enter' new function */ |
256 | ci->func = func; | 260 | ci->func = func; |
257 | L->base = ci->base = base; | 261 | L->base = ci->base = base; |