diff options
-rw-r--r-- | ldo.c | 16 |
1 files changed, 6 insertions, 10 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 2.152 2016/07/29 17:12:44 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 2.153 2016/08/01 19:51:24 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 | */ |
@@ -211,9 +211,9 @@ static int stackinuse (lua_State *L) { | |||
211 | CallInfo *ci; | 211 | CallInfo *ci; |
212 | StkId lim = L->top; | 212 | StkId lim = L->top; |
213 | for (ci = L->ci; ci != NULL; ci = ci->previous) { | 213 | for (ci = L->ci; ci != NULL; ci = ci->previous) { |
214 | lua_assert(ci->top <= L->stack_last); | ||
215 | if (lim < ci->top) lim = ci->top; | 214 | if (lim < ci->top) lim = ci->top; |
216 | } | 215 | } |
216 | lua_assert(lim <= L->stack_last); | ||
217 | return cast_int(lim - L->stack) + 1; /* part of stack in use */ | 217 | return cast_int(lim - L->stack) + 1; /* part of stack in use */ |
218 | } | 218 | } |
219 | 219 | ||
@@ -520,19 +520,17 @@ static void finishCcall (lua_State *L, int status) { | |||
520 | /* error status can only happen in a protected call */ | 520 | /* error status can only happen in a protected call */ |
521 | lua_assert((ci->callstatus & CIST_YPCALL) || status == LUA_YIELD); | 521 | lua_assert((ci->callstatus & CIST_YPCALL) || status == LUA_YIELD); |
522 | if (ci->callstatus & CIST_YPCALL) { /* was inside a pcall? */ | 522 | if (ci->callstatus & CIST_YPCALL) { /* was inside a pcall? */ |
523 | ci->callstatus &= ~CIST_YPCALL; /* finish 'lua_pcall' */ | 523 | ci->callstatus &= ~CIST_YPCALL; /* continuation is also inside it */ |
524 | L->errfunc = ci->u.c.old_errfunc; | 524 | L->errfunc = ci->u.c.old_errfunc; /* with the same error function */ |
525 | } | 525 | } |
526 | /* finish 'lua_callk'/'lua_pcall'; CIST_YPCALL and 'errfunc' already | 526 | /* finish 'lua_callk'/'lua_pcall'; CIST_YPCALL and 'errfunc' already |
527 | handled */ | 527 | handled */ |
528 | adjustresults(L, ci->nresults); | 528 | adjustresults(L, ci->nresults); |
529 | /* call continuation function */ | ||
530 | lua_unlock(L); | 529 | lua_unlock(L); |
531 | n = (*ci->u.c.k)(L, status, ci->u.c.ctx); | 530 | n = (*ci->u.c.k)(L, status, ci->u.c.ctx); /* call continuation function */ |
532 | lua_lock(L); | 531 | lua_lock(L); |
533 | api_checknelems(L, n); | 532 | api_checknelems(L, n); |
534 | /* finish 'luaD_precall' */ | 533 | luaD_poscall(L, ci, L->top - n, n); /* finish 'luaD_precall' */ |
535 | luaD_poscall(L, ci, L->top - n, n); | ||
536 | } | 534 | } |
537 | 535 | ||
538 | 536 | ||
@@ -616,7 +614,6 @@ static int resume_error (lua_State *L, const char *msg, int narg) { | |||
616 | ** coroutine. | 614 | ** coroutine. |
617 | */ | 615 | */ |
618 | static void resume (lua_State *L, void *ud) { | 616 | static void resume (lua_State *L, void *ud) { |
619 | int nCcalls = L->nCcalls; | ||
620 | int n = *(cast(int*, ud)); /* number of arguments */ | 617 | int n = *(cast(int*, ud)); /* number of arguments */ |
621 | StkId firstArg = L->top - n; /* first argument */ | 618 | StkId firstArg = L->top - n; /* first argument */ |
622 | CallInfo *ci = L->ci; | 619 | CallInfo *ci = L->ci; |
@@ -642,7 +639,6 @@ static void resume (lua_State *L, void *ud) { | |||
642 | } | 639 | } |
643 | unroll(L, NULL); /* run continuation */ | 640 | unroll(L, NULL); /* run continuation */ |
644 | } | 641 | } |
645 | lua_assert(nCcalls == L->nCcalls); | ||
646 | } | 642 | } |
647 | 643 | ||
648 | 644 | ||