aboutsummaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-01-10 13:54:51 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-01-10 13:54:51 -0300
commit7ca3c40b50b385ead6b8bc4c54de97b61d11a12a (patch)
tree5c5998f39760b07e05135df56b8a828f2fb685c1 /lvm.c
parent8a3a49250ce4a7e46ec9e90810a61d9f97aece3d (diff)
downloadlua-7ca3c40b50b385ead6b8bc4c54de97b61d11a12a.tar.gz
lua-7ca3c40b50b385ead6b8bc4c54de97b61d11a12a.tar.bz2
lua-7ca3c40b50b385ead6b8bc4c54de97b61d11a12a.zip
Another way to compile goto's
The compilation of a goto or a label just create an entry and generate boilerplate code for the gotos. As we don't know yet whether it needs a CLOSE, we code a jump followed by a CLOSE, which is then dead code. When a block ends (and then we know for sure whether there are variables that need to be closed), we check the goto's against the labels of that block. When closing a goto against a label, if it needs a CLOSE, the compiler swaps the order of the jump and the CLOSE, making the CLOSE active.
Diffstat (limited to 'lvm.c')
-rw-r--r--lvm.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/lvm.c b/lvm.c
index 73d7ee43..074ee718 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1590,6 +1590,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1590 } 1590 }
1591 vmcase(OP_CLOSE) { 1591 vmcase(OP_CLOSE) {
1592 StkId ra = RA(i); 1592 StkId ra = RA(i);
1593 lua_assert(!GETARG_B(i)); /* 'close must be alive */
1593 Protect(luaF_close(L, ra, LUA_OK, 1)); 1594 Protect(luaF_close(L, ra, LUA_OK, 1));
1594 vmbreak; 1595 vmbreak;
1595 } 1596 }