details in OP_CALL + comments

This commit is contained in:
Roberto Ierusalimschy 2017-05-18 16:34:39 -03:00
parent 49f7aab62a
commit 92b3deaffa

21
lvm.c
View File

@ -1,5 +1,5 @@
/* /*
** $Id: lvm.c,v 2.281 2017/05/13 12:57:20 roberto Exp roberto $ ** $Id: lvm.c,v 2.282 2017/05/13 13:54:47 roberto Exp roberto $
** Lua virtual machine ** Lua virtual machine
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -1260,12 +1260,15 @@ void luaV_execute (lua_State *L) {
vmcase(OP_CALL) { vmcase(OP_CALL) {
int b = GETARG_B(i); int b = GETARG_B(i);
int nresults = GETARG_C(i) - 1; int nresults = GETARG_C(i) - 1;
if (b != 0) L->top = ra+b; /* else previous instruction set top */ int isC;
savepc(L); if (b != 0) /* fixed number of arguments? */
if (luaD_precall(L, ra, nresults)) { /* C function? */ L->top = ra + b; /* top signals number of arguments */
if (nresults >= 0) /* else previous instruction set top */
L->top = ci->top; /* adjust results */ Protect(isC = luaD_precall(L, ra, nresults));
Protect((void)0); /* update 'base' */ if (isC) { /* C function? */
if (nresults >= 0) /* fixed number of results? */
L->top = ci->top; /* correct top */
/* else leave top for next instruction */
} }
else { /* Lua function */ else { /* Lua function */
ci = L->ci; ci = L->ci;
@ -1283,8 +1286,8 @@ void luaV_execute (lua_State *L) {
} }
else { else {
/* tail call: put called frame (n) in place of caller one (o) */ /* tail call: put called frame (n) in place of caller one (o) */
CallInfo *nci = L->ci; /* called frame */ CallInfo *nci = L->ci; /* called frame (new) */
CallInfo *oci = nci->previous; /* caller frame */ CallInfo *oci = nci->previous; /* caller frame (old) */
StkId nfunc = nci->func; /* called function */ StkId nfunc = nci->func; /* called function */
StkId ofunc = oci->func; /* caller function */ StkId ofunc = oci->func; /* caller function */
/* last stack slot filled by 'precall' */ /* last stack slot filled by 'precall' */