aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-06-09 13:32:18 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-06-09 13:32:18 -0300
commit35a6aad0d745d3acb9d5feb895f84a05ae8bf5ba (patch)
treee76e37bcd9d7981ffad7d642b0884553dc2413e1
parent23f0ff95177eda2e0a80e3a48562cc6837705735 (diff)
downloadlua-35a6aad0d745d3acb9d5feb895f84a05ae8bf5ba.tar.gz
lua-35a6aad0d745d3acb9d5feb895f84a05ae8bf5ba.tar.bz2
lua-35a6aad0d745d3acb9d5feb895f84a05ae8bf5ba.zip
added comments
-rw-r--r--ldo.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/ldo.c b/ldo.c
index ae58cda7..c6cf8c8b 100644
--- a/ldo.c
+++ b/ldo.c
@@ -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*/
415static void finishCcall (lua_State *L) { 419static 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*/
440static void unroll (lua_State *L, void *ud) { 449static 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*/
458static CallInfo *findpcall (lua_State *L) { 466static 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*/
468static int recover (lua_State *L, int status) { 481static int recover (lua_State *L, int status) {
469 StkId oldtop; 482 StkId oldtop;
470 CallInfo *ci = findpcall(L); 483 CallInfo *ci = findpcall(L);