X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/ecce6a1f289ce6db3bd5e49ff446ef7159991418..4b9ccde74dc34e450ed96bcd3d044f78cf393d8d:/usr/src/cmd/pi/case.c diff --git a/usr/src/cmd/pi/case.c b/usr/src/cmd/pi/case.c index e1f45b377a..5b4e7bbc8c 100644 --- a/usr/src/cmd/pi/case.c +++ b/usr/src/cmd/pi/case.c @@ -1,13 +1,8 @@ /* Copyright (c) 1979 Regents of the University of California */ -# -/* - * pi - Pascal interpreter code translator - * - * Charles Haley, Bill Joy UCB - * Version 1.2 November 1978 - */ -#include "whoami" +static char sccsid[] = "@(#)case.c 1.3 3/8/81"; + +#include "whoami.h" #include "0.h" #include "tree.h" #include "opcode.h" @@ -22,6 +17,7 @@ struct ct { int cline; }; +#ifdef OBJ /* * Caseop generates the * pascal case statement code @@ -38,7 +34,8 @@ caseop(r) char *brtab0; char *csend; int w, i, j, m, n; - int nr, goc; + int goc; + bool nr; goc = gocnt; /* @@ -48,7 +45,7 @@ caseop(r) * low lwb(p) * high upb(p) */ - p = rvalue((int *) r[2], NLNIL); + p = rvalue((int *) r[2], NLNIL , RREQ ); if (p != NIL) { if (isnta(p, "bcsi")) { error("Case selectors cannot be %ss", nameof(p)); @@ -85,7 +82,7 @@ caseop(r) * Allocate case table space */ ctab = i = malloc(n * sizeof *ctab); - if (i == -1) { + if (i == 0) { error("Ran out of memory (case)"); pexit(DIED); } @@ -104,7 +101,7 @@ caseop(r) gconst(cs[1]); if (p == NIL || con.ctype == NIL) continue; - if (incompat(con.ctype, p, NIL)) { + if (incompat(con.ctype, p, NIL )) { cerror("Case label type clashed with case selector expression type"); continue; } @@ -136,16 +133,19 @@ caseop(r) * branch table */ if (p != NIL) { - put2(O_CASE1OP + (w >> 1), n); + put(2, O_CASE1OP + (w >> 1), n); brtab = brtab0 = lc; putspace(n * 2); - put1(O_CASEBEG); + put(1, O_CASEBEG); for (i=0; i> 1), ctab[i].clong); - put1(O_CASEEND); + if (w <= 2) + put(2 ,O_CASE1 + (w >> 1), (int)ctab[i].clong); + else + put(2 ,O_CASE4, ctab[i].clong); + put(1, O_CASEEND); } csend = getlab(); - put2(O_TRA, csend); + put(2, O_TRA, csend); /* * Free the case * table space. @@ -159,23 +159,23 @@ caseop(r) * statement with a branch back * to the TRA above. */ - nr = 1; + nr = TRUE; for (cl = r[3]; cl != NIL; cl = cl[2]) { cs = cl[1]; if (cs == NIL) continue; if (p != NIL) for (cs = cs[2]; cs != NIL; cs = cs[2]) { - patchfil(brtab - 1, lc - brtab0, 1); + patchfil(brtab - 1, (long)(lc - brtab0), 1); brtab++; } cs = cl[1]; putcnt(); level++; statement(cs[3]); - nr &= noreach; + nr = (noreach && nr); noreach = 0; - put2(O_TRA, csend); + put(2, O_TRA, csend); level--; if (gotos[cbn]) ungoto(); @@ -188,3 +188,4 @@ caseop(r) if (goc != gocnt) putcnt(); } +#endif OBJ