mirror of
https://github.com/Noratrieb/riverdelta.git
synced 2026-01-15 17:05:03 +01:00
allocators and type aliases
This commit is contained in:
parent
60c743d656
commit
f05e5520f3
16 changed files with 283 additions and 121 deletions
|
|
@ -63,14 +63,22 @@ function printFunction(func: FunctionDef<AnyPhase>): string {
|
|||
}
|
||||
|
||||
function printTypeDef(type: TypeDef<AnyPhase>): string {
|
||||
const fields = type.fields.map(
|
||||
({ name, type }) => `${ind(1)}${name.name}: ${printType(type)},`,
|
||||
);
|
||||
switch (type.type.kind) {
|
||||
case "struct": {
|
||||
const { fields } = type.type;
|
||||
|
||||
const fieldPart =
|
||||
type.fields.length === 0 ? "{}" : `{\n${fields.join("\n")}\n}`;
|
||||
const fieldStr = fields.map(
|
||||
({ name, type }) => `${ind(1)}${name.name}: ${printType(type)},`,
|
||||
);
|
||||
const fieldPart =
|
||||
fields.length === 0 ? "{}" : `{\n${fieldStr.join("\n")}\n}`;
|
||||
|
||||
return `type ${type.name} = ${fieldPart};`;
|
||||
return `type ${type.name} = ${fieldPart};`;
|
||||
}
|
||||
case "alias": {
|
||||
return `type ${type.name} = ${printType(type.type.type)}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function printImportDef(def: ImportDef<AnyPhase>): string {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue