aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/cgen.c
diff options
context:
space:
mode:
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;
}
}