aboutsummaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-10-17 10:44:42 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-10-17 10:44:42 -0300
commitbd96330d037660d9a1769c6c0d989f017e5f0278 (patch)
treec3f4580c628a71f512b057b7f52987153cb88d74 /lvm.c
parent4cd1f4aac01184765818e0cebf02da454ccf6590 (diff)
downloadlua-bd96330d037660d9a1769c6c0d989f017e5f0278.tar.gz
lua-bd96330d037660d9a1769c6c0d989f017e5f0278.tar.bz2
lua-bd96330d037660d9a1769c6c0d989f017e5f0278.zip
First "complete" implementation of to-be-closed variables
Still missing: - handling of memory errors when creating upvalue (must run closing method all the same) - interaction with coroutines
Diffstat (limited to 'lvm.c')
-rw-r--r--lvm.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/lvm.c b/lvm.c
index fdd99a42..e2994aa9 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1452,13 +1452,12 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1452 vmbreak; 1452 vmbreak;
1453 } 1453 }
1454 vmcase(OP_CLOSE) { 1454 vmcase(OP_CLOSE) {
1455 luaF_close(L, ra); 1455 luaF_close(L, ra, LUA_OK);
1456 vmbreak; 1456 vmbreak;
1457 } 1457 }
1458 vmcase(OP_TBC) { 1458 vmcase(OP_TBC) {
1459 UpVal *up = luaF_findupval(L, ra); /* create new upvalue */ 1459 UpVal *up = luaF_findupval(L, ra); /* create new upvalue */
1460 up->tt = LUA_TUPVALTBC; /* mark it to be closed */ 1460 up->tt = LUA_TUPVALTBC; /* mark it to be closed */
1461 setnilvalue(s2v(ra)); /* intialize it with nil */
1462 vmbreak; 1461 vmbreak;
1463 } 1462 }
1464 vmcase(OP_JMP) { 1463 vmcase(OP_JMP) {
@@ -1591,7 +1590,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1591 int nparams1 = GETARG_C(i); 1590 int nparams1 = GETARG_C(i);
1592 if (nparams1) /* vararg function? */ 1591 if (nparams1) /* vararg function? */
1593 delta = ci->u.l.nextraargs + nparams1; 1592 delta = ci->u.l.nextraargs + nparams1;
1594 luaF_close(L, base); /* close upvalues from current call */ 1593 luaF_close(L, base, LUA_OK); /* close upvalues from current call */
1595 } 1594 }
1596 if (!ttisfunction(s2v(ra))) { /* not a function? */ 1595 if (!ttisfunction(s2v(ra))) { /* not a function? */
1597 luaD_tryfuncTM(L, ra); /* try '__call' metamethod */ 1596 luaD_tryfuncTM(L, ra); /* try '__call' metamethod */
@@ -1625,7 +1624,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1625 int nparams1 = GETARG_C(i); 1624 int nparams1 = GETARG_C(i);
1626 if (nparams1) /* vararg function? */ 1625 if (nparams1) /* vararg function? */
1627 ci->func -= ci->u.l.nextraargs + nparams1; 1626 ci->func -= ci->u.l.nextraargs + nparams1;
1628 luaF_close(L, base); /* there may be open upvalues */ 1627 luaF_close(L, base, LUA_OK); /* there may be open upvalues */
1629 } 1628 }
1630 halfProtect(luaD_poscall(L, ci, n)); 1629 halfProtect(luaD_poscall(L, ci, n));
1631 return; 1630 return;