This commit is contained in:
nora 2023-07-31 20:26:50 +02:00
parent b779a51ef5
commit f582a5b4c3
9 changed files with 248 additions and 85 deletions

View file

@ -24,7 +24,7 @@ function printStringLiteral(lit: StringLiteral): string {
}
function printItem(item: Item<AnyPhase>): string {
const id = `/*${item.id}*/ `;
const id = `/*${item.id.toString()}*/ `;
switch (item.kind) {
case "function": {
@ -42,6 +42,15 @@ function printItem(item: Item<AnyPhase>): string {
case "extern": {
return id + `extern mod ${item.node.name};`;
}
case "global": {
return (
id +
`global ${item.node.name}: ${printType(item.node.type)} = ${printExpr(
item.node.init,
0
)};`
);
}
}
}
@ -207,7 +216,7 @@ function printRes(res: Resolution): string {
case "local":
return `#${res.index}`;
case "item":
return `#G${res.id}`;
return `#I${res.id.toString()}`;
case "builtin": {
return `#B`;
}