aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/cgen.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2022-08-13 07:11:23 +0200
committerlemon <lsof@mailbox.org>2022-08-13 07:11:23 +0200
commit58af6dcf569c7f83b317d30f8dd85d96d314d785 (patch)
tree76d53089d8510ab9cade4e21200b36d648c4ecb6 /bootstrap/cgen.c
parentd98b1ecb7a23b369e533f20386cb7aa83156d25d (diff)
cond switch
Diffstat (limited to 'bootstrap/cgen.c')
-rw-r--r--bootstrap/cgen.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/bootstrap/cgen.c b/bootstrap/cgen.c
index 7519982..baf8999 100644
--- a/bootstrap/cgen.c
+++ b/bootstrap/cgen.c
@@ -442,6 +442,17 @@ genstmt(struct stmt *stmt) {
case Scontinue:
pri("goto _cont%d;\n", stmt->brkcon.id);
break;
+ case Scswitch:
+ pri("if (0) ;\n");
+ for (int i = 0; i < stmt->cswitch.cs.n; ++i) {
+ pri("else if (%e)\n", &stmt->cswitch.cs.d[i].test);
+ genblock(stmt->cswitch.cs.d[i].t);
+ }
+ if (stmt->cswitch.f) {
+ pri("else\n");
+ genblock(*stmt->cswitch.f);
+ }
+ break;
}
}
@@ -626,6 +637,14 @@ liftnested(struct stmt *stmt) {
break;
case Sbreak: case Scontinue:
break;
+ case Scswitch:
+ for (int i = 0; i < stmt->cswitch.cs.n; ++i) {
+ liftnestedex(&stmt->cswitch.cs.d[i].test);
+ liftnested(blocktostmt(stmt->cswitch.cs.d[i].t));
+ }
+ if (stmt->cswitch.f)
+ liftnested(blocktostmt(*stmt->cswitch.f));
+ break;
}
}