diff options
| author | 2022-08-05 17:36:51 +0200 | |
|---|---|---|
| committer | 2022-08-05 17:36:51 +0200 | |
| commit | c2a13e05596c724fbdbc3e8ff1266c099b675e56 (patch) | |
| tree | 3be2194055a624d718c94c528651d487b2571273 /bootstrap/cgen.c | |
| parent | d95555f87eced5fcb3458d76c765afe2de89bdcb (diff) | |
modify let and static decls to allow multiple vars
this involved transforming statement and declaration parsing code to
use a CPS-like style to yield many decls within one lexical decl
Diffstat (limited to 'bootstrap/cgen.c')
| -rw-r--r-- | bootstrap/cgen.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/bootstrap/cgen.c b/bootstrap/cgen.c index b4cea42..9e13e12 100644 --- a/bootstrap/cgen.c +++ b/bootstrap/cgen.c @@ -295,14 +295,16 @@ genstmt(struct stmt *stmt) { genblock(stmt->loop.body); break; case Sfor: - pri("for (\n"); - if (stmt->loop.ini) - genstmt(stmt->loop.ini); + pri("{\n"); + for (int i = 0; i < stmt->loop.ini.n; ++i) + genstmt(&stmt->loop.ini.d[i]); + pri("for (; "); pri("%e;", &stmt->loop.test); if (stmt->loop.next) pri(" %e", stmt->loop.next); pri(")"); genblock(stmt->loop.body); + pri("}\n"); break; case Siswitch: pri("switch (%e) {", &stmt->iswitch.test); @@ -434,7 +436,8 @@ liftnested(struct stmt *stmt) { liftnested(blocktostmt(stmt->loop.body)); break; case Sfor: - liftnested(stmt->loop.ini); + for (int i = 0; i < stmt->loop.ini.n; ++i) + liftnested(&stmt->loop.ini.d[i]); liftnestedex(&stmt->loop.test); liftnestedex(stmt->loop.next); liftnested(blocktostmt(stmt->loop.body)); |