diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-06-09 13:32:18 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-06-09 13:32:18 -0300 |
| commit | 35a6aad0d745d3acb9d5feb895f84a05ae8bf5ba (patch) | |
| tree | e76e37bcd9d7981ffad7d642b0884553dc2413e1 /ldo.c | |
| parent | 23f0ff95177eda2e0a80e3a48562cc6837705735 (diff) | |
| download | lua-35a6aad0d745d3acb9d5feb895f84a05ae8bf5ba.tar.gz lua-35a6aad0d745d3acb9d5feb895f84a05ae8bf5ba.tar.bz2 lua-35a6aad0d745d3acb9d5feb895f84a05ae8bf5ba.zip | |
added comments
Diffstat (limited to '')
| -rw-r--r-- | ldo.c | 25 |
1 files changed, 19 insertions, 6 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldo.c,v 2.115 2014/03/21 13:52:33 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 2.116 2014/05/08 13:52:20 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 | */ |
| @@ -412,6 +412,10 @@ void luaD_call (lua_State *L, StkId func, int nResults, int allowyield) { | |||
| 412 | } | 412 | } |
| 413 | 413 | ||
| 414 | 414 | ||
| 415 | /* | ||
| 416 | ** Completes the execution of an interrupted C function, calling its | ||
| 417 | ** continuation function. | ||
| 418 | */ | ||
| 415 | static void finishCcall (lua_State *L) { | 419 | static void finishCcall (lua_State *L) { |
| 416 | CallInfo *ci = L->ci; | 420 | CallInfo *ci = L->ci; |
| 417 | int n; | 421 | int n; |
| @@ -437,13 +441,16 @@ static void finishCcall (lua_State *L) { | |||
| 437 | } | 441 | } |
| 438 | 442 | ||
| 439 | 443 | ||
| 444 | /* | ||
| 445 | ** Executes "full continuation" (everything in the stack) of a | ||
| 446 | ** previously interrupted coroutine until the stack is empty (or another | ||
| 447 | ** interruption long-jumps out of the loop) | ||
| 448 | */ | ||
| 440 | static void unroll (lua_State *L, void *ud) { | 449 | static void unroll (lua_State *L, void *ud) { |
| 441 | UNUSED(ud); | 450 | UNUSED(ud); |
| 442 | for (;;) { | 451 | while (L->ci != &L->base_ci) { /* something in the stack */ |
| 443 | if (L->ci == &L->base_ci) /* stack is empty? */ | ||
| 444 | return; /* coroutine finished normally */ | ||
| 445 | if (!isLua(L->ci)) /* C function? */ | 452 | if (!isLua(L->ci)) /* C function? */ |
| 446 | finishCcall(L); | 453 | finishCcall(L); /* complete its execution */ |
| 447 | else { /* Lua function */ | 454 | else { /* Lua function */ |
| 448 | luaV_finishOp(L); /* finish interrupted instruction */ | 455 | luaV_finishOp(L); /* finish interrupted instruction */ |
| 449 | luaV_execute(L); /* execute down to higher C 'boundary' */ | 456 | luaV_execute(L); /* execute down to higher C 'boundary' */ |
| @@ -453,7 +460,8 @@ static void unroll (lua_State *L, void *ud) { | |||
| 453 | 460 | ||
| 454 | 461 | ||
| 455 | /* | 462 | /* |
| 456 | ** check whether thread has a suspended protected call | 463 | ** Try to find a suspended protected call (a "recover point") for the |
| 464 | ** given thread. | ||
| 457 | */ | 465 | */ |
| 458 | static CallInfo *findpcall (lua_State *L) { | 466 | static CallInfo *findpcall (lua_State *L) { |
| 459 | CallInfo *ci; | 467 | CallInfo *ci; |
| @@ -465,6 +473,11 @@ static CallInfo *findpcall (lua_State *L) { | |||
| 465 | } | 473 | } |
| 466 | 474 | ||
| 467 | 475 | ||
| 476 | /* | ||
| 477 | ** Recovers from an error in a coroutine. Finds a recover point (if | ||
| 478 | ** there is one) and completes the execution of the interrupted | ||
| 479 | ** 'luaD_pcall'. If there is no recover point, returns zero. | ||
| 480 | */ | ||
| 468 | static int recover (lua_State *L, int status) { | 481 | static int recover (lua_State *L, int status) { |
| 469 | StkId oldtop; | 482 | StkId oldtop; |
| 470 | CallInfo *ci = findpcall(L); | 483 | CallInfo *ci = findpcall(L); |
