Added constructors to tangible.build, more work on keyword argument parsing, added LS.tailcall.

This commit is contained in:
2025-01-21 20:20:54 -05:00
parent 485caee05d
commit 69cb659d78
6 changed files with 83 additions and 18 deletions

View File

@@ -653,9 +653,26 @@ void LuaCoreStack::guard_nopredict(const char *fn) {
}
}
static int tailcall_continuation(lua_State *L)
{
int base;
lua_getctx(L, &base);
return lua_gettop(L) - base;
}
int LuaDefStack::tailcall_internal(bool passup, int base, int nargs) {
lua_callk(L_, nargs, passup ? LUA_MULTRET : 0, base, tailcall_continuation);
return lua_gettop(L_) - base;
}
LuaKeywordParser::LuaKeywordParser(const LuaCoreStack &LS0, LuaSlot slot)
: keytab(slot.index()), LS(LS0.state(), found, error, key, val) {
: keytab(slot.index()), LS(LS0.state()) {
lua_State *L = LS0.state();
lua_pushnil(L); found.index_ = lua_gettop(L);
lua_pushnil(L); error.index_ = lua_gettop(L);
lua_pushnil(L); key.index_ = lua_gettop(L);
lua_pushnil(L); val.index_ = lua_gettop(L);
istable = LS.istable(keytab);
if (istable) {
LS.rawget(found, keytab, token_found);