diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-05-18 16:34:39 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-05-18 16:34:39 -0300 |
commit | 92b3deaffa642f331326d54a6b93d80240b3af60 (patch) | |
tree | 3b92c46cf8954c40b6ec9d81091ccedff41908bc | |
parent | 49f7aab62af7e5d5b46c551c1620a8a89f448f7e (diff) | |
download | lua-92b3deaffa642f331326d54a6b93d80240b3af60.tar.gz lua-92b3deaffa642f331326d54a6b93d80240b3af60.tar.bz2 lua-92b3deaffa642f331326d54a6b93d80240b3af60.zip |
details in OP_CALL + comments
-rw-r--r-- | lvm.c | 21 |
1 files changed, 12 insertions, 9 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 2.281 2017/05/13 12:57:20 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.282 2017/05/13 13:54:47 roberto Exp roberto $ |
3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -1260,12 +1260,15 @@ void luaV_execute (lua_State *L) { | |||
1260 | vmcase(OP_CALL) { | 1260 | vmcase(OP_CALL) { |
1261 | int b = GETARG_B(i); | 1261 | int b = GETARG_B(i); |
1262 | int nresults = GETARG_C(i) - 1; | 1262 | int nresults = GETARG_C(i) - 1; |
1263 | if (b != 0) L->top = ra+b; /* else previous instruction set top */ | 1263 | int isC; |
1264 | savepc(L); | 1264 | if (b != 0) /* fixed number of arguments? */ |
1265 | if (luaD_precall(L, ra, nresults)) { /* C function? */ | 1265 | L->top = ra + b; /* top signals number of arguments */ |
1266 | if (nresults >= 0) | 1266 | /* else previous instruction set top */ |
1267 | L->top = ci->top; /* adjust results */ | 1267 | Protect(isC = luaD_precall(L, ra, nresults)); |
1268 | Protect((void)0); /* update 'base' */ | 1268 | if (isC) { /* C function? */ |
1269 | if (nresults >= 0) /* fixed number of results? */ | ||
1270 | L->top = ci->top; /* correct top */ | ||
1271 | /* else leave top for next instruction */ | ||
1269 | } | 1272 | } |
1270 | else { /* Lua function */ | 1273 | else { /* Lua function */ |
1271 | ci = L->ci; | 1274 | ci = L->ci; |
@@ -1283,8 +1286,8 @@ void luaV_execute (lua_State *L) { | |||
1283 | } | 1286 | } |
1284 | else { | 1287 | else { |
1285 | /* tail call: put called frame (n) in place of caller one (o) */ | 1288 | /* tail call: put called frame (n) in place of caller one (o) */ |
1286 | CallInfo *nci = L->ci; /* called frame */ | 1289 | CallInfo *nci = L->ci; /* called frame (new) */ |
1287 | CallInfo *oci = nci->previous; /* caller frame */ | 1290 | CallInfo *oci = nci->previous; /* caller frame (old) */ |
1288 | StkId nfunc = nci->func; /* called function */ | 1291 | StkId nfunc = nci->func; /* called function */ |
1289 | StkId ofunc = oci->func; /* caller function */ | 1292 | StkId ofunc = oci->func; /* caller function */ |
1290 | /* last stack slot filled by 'precall' */ | 1293 | /* last stack slot filled by 'precall' */ |