Skip to content

Commit

Permalink
feat: support enum declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
R-unic committed Oct 1, 2023
1 parent 06bf08d commit 45f1e6a
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/code-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ import {
ThrowStatement,
ModuleDeclaration,
ModuleBlock,
EnumDeclaration,
EnumMember,
Statement,
HeritageClause,
SwitchStatement,
Expand Down Expand Up @@ -469,6 +471,34 @@ export default class CodeGenerator extends StringBuilder {
}

// CLASS STUFF STATEMENTS
case SyntaxKind.EnumDeclaration: {
const declaration = <EnumDeclaration>node;
this.walkModifiers(declaration);
this.append("enum ");
this.walk(declaration.name);
this.pushIndentation();
this.newLine();

for (const member of declaration.members)
this.walk(member);

this.popIndentation();
this.newLine();
this.append("end");
this.newLine();
break;
}
case SyntaxKind.EnumMember: {
const member = <EnumMember>node;
this.walk(member.name);
if (member.initializer) {
this.append(" = ");
this.walk(member.initializer);
}

this.newLine();
break;
}
case SyntaxKind.InterfaceDeclaration: {
return this.error(node, "Interfaces are not supported.", "UnsupportedInterfaces")
}
Expand Down

0 comments on commit 45f1e6a

Please sign in to comment.