Skip to content

Commit 69a2956

Browse files
authored
Merge pull request #4 from jsonjoy-com/codegen-while
feat: 🎸 add while blocks to codegen
2 parents 5afc2d1 + f825aa5 commit 69a2956

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/codegen/Codegen.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,18 @@ export class Codegen<
127127
this.js('}');
128128
}
129129

130+
public while(condition: string, block: () => void): void {
131+
this.js('while (' + condition + ') {');
132+
block();
133+
this.js('}');
134+
}
135+
136+
public doWhile(block: () => void, condition: string): void {
137+
this.js('do {');
138+
block();
139+
this.js('} while (' + condition + ');');
140+
}
141+
130142
public switch(
131143
expression: string,
132144
cases: [match: string | number | boolean | null, block: () => void, noBreak?: boolean][],

0 commit comments

Comments
 (0)