diff options
Diffstat (limited to 'bootstrap/cgen.c')
| -rw-r--r-- | bootstrap/cgen.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/bootstrap/cgen.c b/bootstrap/cgen.c index 8bea8bc..769d2e9 100644 --- a/bootstrap/cgen.c +++ b/bootstrap/cgen.c @@ -367,6 +367,25 @@ genstmt(struct stmt *stmt) { } pri("}\n"); break; + case Seuswitch: + pri("{ %t __stmp = %e;\n", stmt->euswitch.test.ty, &stmt->euswitch.test); + pri("switch (__stmp.t) {", &stmt->euswitch.test); + for (int i = 0; i < stmt->euswitch.cs.n; ++i) { + struct euswitchcase c = stmt->euswitch.cs.d[i]; + pri("case /* %s */ %I: ", c.fld->name, c.vval); + if (c.capt) + pri("{ %t %s_%d = __stmp.u.%s;\n", c.fld->ty, c.capt, c.captid, c.fld->name); + genblock(c.t); + if (c.capt) + pri("}\n"); + pri("break;\n"); + } + if (stmt->iswitch.f) { + pri("default: "); + genblock(*stmt->iswitch.f); + } + pri("}\n"); pri("}\n"); + break; case Sreturn: pri("return"); if (stmt->retex) @@ -519,6 +538,14 @@ liftnested(struct stmt *stmt) { if (stmt->retex) liftnestedex(stmt->retex); break; + case Seuswitch: + liftnestedex(&stmt->euswitch.test); + for (int i = 0; i < stmt->euswitch.cs.n; ++i) { + liftnested(blocktostmt(stmt->euswitch.cs.d[i].t)); + } + if (stmt->euswitch.f) + liftnested(blocktostmt(*stmt->euswitch.f)); + break; } } |