Docs for stdlib

This commit is contained in:
Zef Hemel
2026-07-15 17:55:18 +02:00
parent 23f338dc14
commit 599798c831
11 changed files with 1713 additions and 404 deletions
+28 -16
View File
@@ -24,23 +24,35 @@ export function luaLoad(code: LuaValue, sf: LuaStackFrame): LuaValue {
const globalEnv: LuaEnv = globalEnvMaybe as LuaEnv;
const runner = new LuaBuiltinFunction(async (innerSf: LuaStackFrame) => {
const res = await evalStatement(block, globalEnv, innerSf, true);
if (res === undefined) {
return null;
} else {
if (res && typeof res === "object" && (res as any).ctrl === "return") {
return new LuaMultiRes((res as any).values);
const runner = new LuaBuiltinFunction(
async (innerSf: LuaStackFrame) => {
const res = await evalStatement(block, globalEnv, innerSf, true);
if (res === undefined) {
return null;
} else {
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;
}
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;
}
});
},
{
kind: "builtin",
description: "Executes the Lua chunk compiled by `load`.",
signatures: ["function(...)"],
returns: [{ description: "Values returned by the compiled chunk." }],
},
);
return runner;
} catch (e: any) {