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:
@@ -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;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user