Space Lua: Refactor control flow signals (#1794)

* Space Lua: Refactor control flow signals

Removes "return throws an exception" failure mode. @zef :)

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Remove unused function

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Remove another unused function

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Remove unused `LuaBreak`/`LuaReturn` exception control flow

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

---------

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
This commit is contained in:
Matouš Jan Fialka
2026-01-29 08:07:26 +01:00
committed by GitHub
parent 5a20a5f8f4
commit e5b4c8feb2
3 changed files with 168 additions and 271 deletions
+10 -1
View File
@@ -31,7 +31,16 @@ export function luaLoad(code: LuaValue, sf: LuaStackFrame): LuaValue {
if (res === undefined) {
return null;
} else {
return new LuaMultiRes(res);
if (res && typeof res === "object" && (res as any).ctrl === "return") {
return new LuaMultiRes((res as any).values);
}
if (res && typeof res === "object" && (res as any).ctrl === "break") {
throw new Error("break outside loop");
}
if (res && typeof res === "object" && (res as any).ctrl === "goto") {
throw new Error("unexpected goto signal");
}
return null;
}
});