From a9aca0f00bbd8cf9b284957b7a8f5894919847f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Madeleine=20Sydney=20=C5=9Alaga?= Date: Thu, 11 Jun 2026 12:38:01 -0600 Subject: [PATCH] idk --- parse.c | 9 +++++++-- test/tail.ssa | 4 +++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/parse.c b/parse.c index 4042172..957949b 100644 --- a/parse.c +++ b/parse.c @@ -53,7 +53,7 @@ enum Token { Tphi, Tjmp, Tjnz, - Ttail, + Ttail, Tret, Thlt, Texport, @@ -668,6 +668,10 @@ parseline(PState ps) goto Close; case Ttail: curb->jmp.type = Jtail; + curb->jmp.arg = parseref (); + /* Ins *restore = curi; */ + parserefl(1); + /* curi = restore; */ goto Close; case Tjmp: curb->jmp.type = Jjmp; @@ -1440,7 +1444,8 @@ printfn(Fn *fn, FILE *f) fprintf(f, "\tjmp @%s\n", b->s1->name); break; case Jtail: - fprintf (f, "\ttail\n"); + fprintf (f, "\ttail "); + printref (b->jmp.arg, fn, f); break; default: fprintf(f, "\t%s ", jtoa[b->jmp.type]); diff --git a/test/tail.ssa b/test/tail.ssa index 35534ed..17d254b 100644 --- a/test/tail.ssa +++ b/test/tail.ssa @@ -4,5 +4,7 @@ function w $factorial (w %n, w %acc) { @z ret %acc @nz - tail + %n_next =w sub %n, 1 + %acc_next =w mul %n, %acc + tail $factorial (w %n_next, w %acc) } \ No newline at end of file