date and time created 81/03/02 21:27:57 by peter
authorPeter B. Kessler <peter@ucbvax.Berkeley.EDU>
Tue, 3 Mar 1981 13:27:57 +0000 (05:27 -0800)
committerPeter B. Kessler <peter@ucbvax.Berkeley.EDU>
Tue, 3 Mar 1981 13:27:57 +0000 (05:27 -0800)
SCCS-vsn: usr.bin/pascal/pxp/case.c 1.1

usr/src/usr.bin/pascal/pxp/case.c [new file with mode: 0644]

diff --git a/usr/src/usr.bin/pascal/pxp/case.c b/usr/src/usr.bin/pascal/pxp/case.c
new file mode 100644 (file)
index 0000000..99c6df2
--- /dev/null
@@ -0,0 +1,86 @@
+static char *sccsid = "@(#)case.c      1.1 (Berkeley) %G%";
+/* Copyright (c) 1979 Regents of the University of California */
+#
+/*
+ * pxp - Pascal execution profiler
+ *
+ * Bill Joy UCB
+ * Version 1.2 January 1979
+ */
+
+#include "0.h"
+#include "tree.h"
+
+/*
+ * Case statement
+ */
+caseop(r)
+       int *r;
+{
+       register *cl, *cs, i;
+       struct pxcnt scnt;
+
+       savecnt(&scnt);
+       ppkw("case");
+       ppspac();
+       rvalue(r[2], NIL);
+       ppspac();
+       ppkw("of");
+       for (cl = r[3]; cl != NIL;) {
+               cs = cl[1];
+               if (cs == NIL)
+                       continue;
+               baroff();
+               ppgoin(DECL);
+               setline(cs[1]);
+               ppnl();
+               indent();
+               ppbra(NIL);
+               cs = cs[2];
+               if (cs != NIL) {
+                       i = 0;
+                       for (;;) {
+                               gconst(cs[1]);
+                               cs = cs[2];
+                               if (cs == NIL)
+                                       break;
+                               i++;
+                               if (i == 7) {
+                                       ppsep(",");
+                                       ppitem();
+                                       i = 0;
+                               } else
+                                       ppsep(", ");
+                       }
+               } else
+                       ppid("{case label list}");
+               ppket(":");
+               cs = cl[1];
+               cs = cs[3];
+               getcnt();
+               ppgoin(STAT);
+               if (cs != NIL && cs[0] == T_BLOCK) {
+                       ppnl();
+                       indent();
+                       baron();
+                       ppstbl1(cs, STAT);
+                       baroff();
+                       ppstbl2();
+                       baron();
+               } else {
+                       baron();
+                       statement(cs);
+               }
+               ppgoout(STAT);
+               ppgoout(DECL);
+               cl = cl[2];
+               if (cl == NIL)
+                       break;
+               ppsep(";");
+       }
+       if (rescnt(&scnt))
+               getcnt();
+       ppnl();
+       indent();
+       ppkw("end");
+}