New API function 'lua_closeslot'

Closing a to-be-closed variable with 'lua_settop' is too restrictive,
as it erases all slots above the variable. Moreover, it adds side
effects to 'lua_settop', which should be a fairly basic function.
This commit is contained in:
Roberto Ierusalimschy
2021-01-11 15:03:01 -03:00
parent ce101dcaf7
commit cc1692515e
6 changed files with 66 additions and 29 deletions

View File

@@ -1766,6 +1766,9 @@ static struct X { int x; } x;
else if EQ("toclose") {
lua_toclose(L1, getnum);
}
else if EQ("closeslot") {
lua_closeslot(L1, getnum);
}
else luaL_error(L, "unknown instruction %s", buff);
}
return 0;