mirror of
https://github.com/Noratrieb/riverdelta.git
synced 2026-01-16 01:15:03 +01:00
Add support for tuple literals
This commit is contained in:
parent
0c996eb9bc
commit
b64c02cf4a
6 changed files with 82 additions and 35 deletions
16
src/lower.ts
16
src/lower.ts
|
|
@ -616,6 +616,10 @@ function lowerExpr(fcx: FuncContext, instrs: wasm.Instr[], expr: Expr) {
|
|||
case "structLiteral": {
|
||||
todo("struct literal");
|
||||
}
|
||||
case "tupleLiteral": {
|
||||
expr.fields.forEach((field) => lowerExpr(fcx, instrs, field));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
const _: never = expr;
|
||||
}
|
||||
|
|
@ -691,10 +695,7 @@ function computeAbi(ty: TyFn): FnAbi {
|
|||
case "list":
|
||||
todo("list abi");
|
||||
case "tuple":
|
||||
if (param.elems.length === 0) {
|
||||
return [];
|
||||
}
|
||||
todo("complex tuple abi");
|
||||
return param.elems.flatMap(argRetAbi);
|
||||
case "struct":
|
||||
todo("struct ABI");
|
||||
case "never":
|
||||
|
|
@ -741,12 +742,7 @@ function wasmTypeForBody(ty: Ty): wasm.ValType[] {
|
|||
case "list":
|
||||
todo("list types");
|
||||
case "tuple":
|
||||
if (ty.elems.length === 0) {
|
||||
return [];
|
||||
} else if (ty.elems.length === 1) {
|
||||
return wasmTypeForBody(ty.elems[0]);
|
||||
}
|
||||
todo("complex tuples");
|
||||
return ty.elems.flatMap(wasmTypeForBody);
|
||||
case "fn":
|
||||
todo("fn types");
|
||||
case "struct":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue