mirror of
https://github.com/Noratrieb/riverdelta.git
synced 2026-01-15 08:55:04 +01:00
globals
This commit is contained in:
parent
b779a51ef5
commit
f582a5b4c3
9 changed files with 248 additions and 85 deletions
|
|
@ -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`;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue