Commit | Line | Data |
---|---|---|
c125706d PK |
1 | static char *sccsid = "@(#)case.c 1.1 (Berkeley) %G%"; |
2 | /* Copyright (c) 1979 Regents of the University of California */ | |
3 | # | |
4 | /* | |
5 | * pxp - Pascal execution profiler | |
6 | * | |
7 | * Bill Joy UCB | |
8 | * Version 1.2 January 1979 | |
9 | */ | |
10 | ||
11 | #include "0.h" | |
12 | #include "tree.h" | |
13 | ||
14 | /* | |
15 | * Case statement | |
16 | */ | |
17 | caseop(r) | |
18 | int *r; | |
19 | { | |
20 | register *cl, *cs, i; | |
21 | struct pxcnt scnt; | |
22 | ||
23 | savecnt(&scnt); | |
24 | ppkw("case"); | |
25 | ppspac(); | |
26 | rvalue(r[2], NIL); | |
27 | ppspac(); | |
28 | ppkw("of"); | |
29 | for (cl = r[3]; cl != NIL;) { | |
30 | cs = cl[1]; | |
31 | if (cs == NIL) | |
32 | continue; | |
33 | baroff(); | |
34 | ppgoin(DECL); | |
35 | setline(cs[1]); | |
36 | ppnl(); | |
37 | indent(); | |
38 | ppbra(NIL); | |
39 | cs = cs[2]; | |
40 | if (cs != NIL) { | |
41 | i = 0; | |
42 | for (;;) { | |
43 | gconst(cs[1]); | |
44 | cs = cs[2]; | |
45 | if (cs == NIL) | |
46 | break; | |
47 | i++; | |
48 | if (i == 7) { | |
49 | ppsep(","); | |
50 | ppitem(); | |
51 | i = 0; | |
52 | } else | |
53 | ppsep(", "); | |
54 | } | |
55 | } else | |
56 | ppid("{case label list}"); | |
57 | ppket(":"); | |
58 | cs = cl[1]; | |
59 | cs = cs[3]; | |
60 | getcnt(); | |
61 | ppgoin(STAT); | |
62 | if (cs != NIL && cs[0] == T_BLOCK) { | |
63 | ppnl(); | |
64 | indent(); | |
65 | baron(); | |
66 | ppstbl1(cs, STAT); | |
67 | baroff(); | |
68 | ppstbl2(); | |
69 | baron(); | |
70 | } else { | |
71 | baron(); | |
72 | statement(cs); | |
73 | } | |
74 | ppgoout(STAT); | |
75 | ppgoout(DECL); | |
76 | cl = cl[2]; | |
77 | if (cl == NIL) | |
78 | break; | |
79 | ppsep(";"); | |
80 | } | |
81 | if (rescnt(&scnt)) | |
82 | getcnt(); | |
83 | ppnl(); | |
84 | indent(); | |
85 | ppkw("end"); | |
86 | } |