idk
This commit is contained in:
9
parse.c
9
parse.c
@@ -53,7 +53,7 @@ enum Token {
|
|||||||
Tphi,
|
Tphi,
|
||||||
Tjmp,
|
Tjmp,
|
||||||
Tjnz,
|
Tjnz,
|
||||||
Ttail,
|
Ttail,
|
||||||
Tret,
|
Tret,
|
||||||
Thlt,
|
Thlt,
|
||||||
Texport,
|
Texport,
|
||||||
@@ -668,6 +668,10 @@ parseline(PState ps)
|
|||||||
goto Close;
|
goto Close;
|
||||||
case Ttail:
|
case Ttail:
|
||||||
curb->jmp.type = Jtail;
|
curb->jmp.type = Jtail;
|
||||||
|
curb->jmp.arg = parseref ();
|
||||||
|
/* Ins *restore = curi; */
|
||||||
|
parserefl(1);
|
||||||
|
/* curi = restore; */
|
||||||
goto Close;
|
goto Close;
|
||||||
case Tjmp:
|
case Tjmp:
|
||||||
curb->jmp.type = Jjmp;
|
curb->jmp.type = Jjmp;
|
||||||
@@ -1440,7 +1444,8 @@ printfn(Fn *fn, FILE *f)
|
|||||||
fprintf(f, "\tjmp @%s\n", b->s1->name);
|
fprintf(f, "\tjmp @%s\n", b->s1->name);
|
||||||
break;
|
break;
|
||||||
case Jtail:
|
case Jtail:
|
||||||
fprintf (f, "\ttail\n");
|
fprintf (f, "\ttail ");
|
||||||
|
printref (b->jmp.arg, fn, f);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(f, "\t%s ", jtoa[b->jmp.type]);
|
fprintf(f, "\t%s ", jtoa[b->jmp.type]);
|
||||||
|
|||||||
@@ -4,5 +4,7 @@ function w $factorial (w %n, w %acc) {
|
|||||||
@z
|
@z
|
||||||
ret %acc
|
ret %acc
|
||||||
@nz
|
@nz
|
||||||
tail
|
%n_next =w sub %n, 1
|
||||||
|
%acc_next =w mul %n, %acc
|
||||||
|
tail $factorial (w %n_next, w %acc)
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user