mirror of
https://github.com/Noratrieb/riverdelta.git
synced 2026-01-15 00:45:04 +01:00
make it a wasi executable
This commit is contained in:
parent
8dd7c174ee
commit
1d0e3a3aff
7 changed files with 87 additions and 13 deletions
|
|
@ -102,7 +102,7 @@ export function typeck(ast: Ast): Ast {
|
|||
throw Error(`cycle computing type of #G${index}`);
|
||||
}
|
||||
itemTys.set(index, null);
|
||||
const item = ast[index];
|
||||
const item = ast.items[index];
|
||||
switch (item.kind) {
|
||||
case "function": {
|
||||
const args = item.node.params.map((arg) => lowerAstTy(arg.type));
|
||||
|
|
@ -168,7 +168,38 @@ export function typeck(ast: Ast): Ast {
|
|||
},
|
||||
};
|
||||
|
||||
return foldAst(ast, checker);
|
||||
const typecked = foldAst(ast, checker);
|
||||
|
||||
const main = typecked.items.find((item) => {
|
||||
if (item.kind === "function" && item.node.name === "main") {
|
||||
const func = item.node;
|
||||
if (func.returnType !== undefined) {
|
||||
const ty = func.returnType.ty!;
|
||||
if (ty.kind !== "tuple" || ty.elems.length !== 0) {
|
||||
throw new CompilerError(
|
||||
`\`main\` has an invalid signature. main takes no arguments and returns nothing`,
|
||||
item.span
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
if (!main) {
|
||||
throw new CompilerError(`\`main\` function not found`, {
|
||||
start: 0,
|
||||
end: 1,
|
||||
});
|
||||
}
|
||||
|
||||
typecked.typeckResults = {
|
||||
main: main.id,
|
||||
};
|
||||
|
||||
return typecked;
|
||||
}
|
||||
|
||||
type TyVarRes =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue