# 2.11BSD#431 - /usr/src/ucb/pascal/pxp/stat.c

##### Functions

    asgnop            X
    asrtop            X
    forop             X
    ifop              X
    ppstbl            X
    ppstbl1           X
    ppstbl2           X
    ppstdo            X
    repop             X
    statement         X
    statlist          X
    whilop            X
    withop            X

##### Variables

    cnts              X
    cntstat           X

       1: #
       2: /*
       3:  * pxp - Pascal execution profiler
       4:  *
       5:  * Bill Joy UCB
       6:  * Version 1.2 January 1979
       7:  */
       8:
       9: #include "0.h"
      10: #include "tree.h"
      11:
      12: int cntstat;
      13: int cnts = 2;
      14:
      15: statlist(r)
      16:     int *r;
      17: {
      18:     register int *sl;
      19:
      20:     sl = r;
      21:     if (sl != NIL)
      22:         for (;;) {
      23:             statement(sl[1]);
      24:             sl = sl[2];
      25:             if (sl == NIL)
      26:                 break;
      27:             ppsep(";");
      28:         }
      29:     else
      30:         statement(NIL);
      31: }
      32:
      33:
      34: statement(r)
      35:     int *r;
      36: {
      37:     register int *s;
      38:
      39:     s = r;
      40: top:
      41:     if (cntstat) {
      42:         cntstat = 0;
      43:         getcnt();
      44:     }
      45:     if (s == NIL) {
      46:         putcm();
      47:         ppitem();
      48:         ppid("null");
      49:         return;
      50:     }
      51:     if (s[0] == T_REPEAT)
      52:         setinfo(s[1]);
      53:     else
      54:         setline(s[1]);
      55:     if (s[0] == T_LABEL) {
      56:         cntstat = 1;
      57:         ppnl();
      58:         labeled(s[2]);
      59:         statement(s[3]);
      60:         return;
      61:     }
      62:     switch (s[0]) {
      63:         default:
      64:             panic("stat");
      65:         case T_PCALL:
      66:             ppitem();
      67:             proc(s);
      68:             break;
      69:         case T_IF:
      70:         case T_IFEL:
      71:             ppnl();
      72:             indent();
      73:             ifop(s);
      74:             break;
      75:         case T_WHILE:
      76:             ppnl();
      77:             indent();
      78:             whilop(s);
      79:             break;
      80:         case T_REPEAT:
      81:             ppnl();
      82:             indent();
      83:             repop(s);
      84:             break;
      85:         case T_FORU:
      86:         case T_FORD:
      87:             ppnl();
      88:             indent();
      89:             forop(s);
      90:             break;
      91:         case T_BLOCK:
      92:             ppnl();
      93:             indent();
      94:             ppstbl(s, DECL);
      95:             break;
      96:         case T_ASGN:
      97:             ppitem();
      98:             asgnop(s);
      99:             break;
     100:         case T_GOTO:
     101:             ppitem();
     102:             gotoop(s[2]);
     103:             cntstat = 1;
     104:             break;
     105:         case T_CASE:
     106:             ppnl();
     107:             indent();
     108:             caseop(s);
     109:             break;
     110:         case T_WITH:
     111:             ppnl();
     112:             indent();
     113:             withop(s);
     114:             break;
     115:         case T_ASRT:
     116:             ppitem();
     117:             asrtop(s);
     118:             break;
     119:     }
     120:     setinfo(s[1]);
     121:     putcm();
     122: }
     123:
     124: withop(s)
     125:     int *s;
     126: {
     127:     register *p;
     128:
     129:     ppkw("with");
     130:     ppspac();
     131:     p = s[2];
     132:     if (p != NIL)
     133:         for (;;) {
     134:             lvalue(p[1]);
     135:             p = p[2];
     136:             if (p == NIL)
     137:                 break;
     138:             ppsep(", ");
     139:         }
     140:     else
     141:         ppid("{record variable list}");
     142:     ppstdo(s[3], DECL);
     143: }
     144:
     145: asgnop(r)
     146:     int *r;
     147: {
     148:
     149:     lvalue(r[2]);
     150:     ppsep(" := ");
     151:     rvalue(r[3], NIL);
     152: }
     153:
     154: forop(r)
     155:     int *r;
     156: {
     157:     struct pxcnt scnt;
     158:
     159:     savecnt(&scnt);
     160:     ppkw("for");
     161:     ppspac();
     162:     asgnop(r[2]);
     163:     ppspac();
     164:     ppkw(r[0] == T_FORU ? "to" : "downto");
     165:     ppspac();
     166:     rvalue(r[3], NIL);
     167:     getcnt();
     168:     ppstdo(r[4], STAT);
     169:     if (rescnt(&scnt))
     170:         getcnt();
     171: }
     172:
     173: ifop(r)
     174:     int *r;
     175: {
     176:     register *s;
     177:     struct pxcnt scnt;
     178:
     179:     ppkw("if");
     180:     ppspac();
     181:     rvalue(r[2], NIL);
     182:     ppspac();
     183:     ppkw("then");
     184:     ppspac();
     185:     s = r[3];
     186:     savecnt(&scnt);
     187:     getcnt();
     188:     if (s != NIL && s[0] == T_BLOCK)
     189:         ppstbl1(s, STAT);
     190:     else {
     191:         ppgoin(STAT);
     192:         statement(s);
     193:         ppgoout(STAT);
     194:     }
     195:     if (r[0] == T_IFEL) {
     196:         setcnt(cntof(&scnt)-nowcnt());
     197:         if (s == NIL || s[0] != T_BLOCK) {
     198:             ppnl();
     199:             indent();
     200:         } else {
     201:             ppstbl2();
     202:             ppspac();
     203:         }
     204:         s = r[4];
     205:         ppkw("else");
     206:         unprint();
     207:         ppspac();
     208:         if (s == NIL)
     209:             goto burp;
     210:         if (s[0] == T_BLOCK)
     211:             ppstbl1(s, STAT);
     212:         else if (s[0] == T_IF || s[0] == T_IFEL)
     213:             ifop(s);
     214:         else {
     215: burp:
     216:             ppgoin(STAT);
     217:             statement(s);
     218:             ppgoout(STAT);
     219:         }
     220:     }
     221:     if (rescnt(&scnt))
     222:         getcnt();
     223:     if (r[4] != NIL)
     224:         unprint();
     225:     if (s != NIL && s[0] == T_BLOCK)
     226:         ppstbl2();
     227: }
     228:
     229: whilop(r)
     230:     int *r;
     231: {
     232:     struct pxcnt scnt;
     233:
     234:     ppkw("while");
     235:     ppspac();
     236:     rvalue(r[2], NIL);
     237:     savecnt(&scnt);
     238:     getcnt();
     239:     ppstdo(r[3], STAT);
     240:     if (rescnt(&scnt))
     241:         getcnt();
     242: }
     243:
     244: repop(r)
     245:     int *r;
     246: {
     247:     struct pxcnt scnt;
     248:
     249:     ppkw("repeat");
     250:     ppgoin(STAT);
     251:     savecnt(&scnt);
     252:     getcnt();
     253:     statlist(r[2]);
     254:     ppgoout(DECL);
     255:     ppnl();
     256:     indent();
     257:     ppkw("until");
     258:     ppspac();
     259:     rvalue(r[3], NIL);
     260:     ppgoin(DECL);
     261:     ppgoout(STAT);
     262:     if (rescnt(&scnt))
     263:         getcnt();
     264: }
     265:
     266: ppstbl(r, m)
     267: int *r;
     268: {
     269:     ppstbl1(r, m);
     270:     ppstbl2();
     271: }
     272:
     273: ppstbl1(r, m)
     274: int *r;
     275: {
     276:     ppkw("begin");
     277:     ppgoin(m);
     278:     statlist(r[2]);
     279:     ppgoout(m);
     280: }
     281:
     282: ppstbl2()
     283: {
     284:     ppnl();
     285:     indent();
     286:     ppkw("end");
     287: }
     288:
     289: ppstdo(r, l)
     290: int *r;
     291: {
     292:     register *s;
     293:
     294:     ppspac();
     295:     ppkw("do");
     296:     ppspac();
     297:     s = r;
     298:     if (s != NIL && s[0] == T_BLOCK)
     299:         ppstbl(s, l);
     300:     else {
     301:         ppgoin(l);
     302:         statement(s);
     303:         ppgoout(l);
     304:     }
     305: }
     306:
     307: asrtop(s)
     308:     int *s;
     309: {
     310:
     311:     ppkw("assert");
     312:     ppspac();
     313:     rvalue(s[2], NIL);
     314: }

#### Defined functions

asgnop defined in line 145; used 2 times

- in line 98, 162

asrtop defined in line 307; used 1 times

- in line 117

forop defined in line 154; used 1 times

- in line 89

ifop defined in line 173; used 2 times

- in line 73, 213

ppstbl defined in line 266; used 2 times

- in line 94, 299

ppstbl1 defined in line 273; used 4 times

- in line 189, 211, 269
- in /usr/src/ucb/pascal/pxp/case.c line 64

ppstbl2 defined in line 282; used 4 times

- in line 201, 226, 270
- in /usr/src/ucb/pascal/pxp/case.c line 66

ppstdo defined in line 289; used 3 times

- in line 142, 168, 239

repop defined in line 244; used 1 times

- in line 83

statement defined in line 34; used 7 times

- in line 23, 30, 59, 192, 217, 302
- in /usr/src/ucb/pascal/pxp/case.c line 70

statlist defined in line 15; used 3 times

- in line 253, 278
- in /usr/src/ucb/pascal/pxp/fdec.c line 202

whilop defined in line 229; used 1 times

- in line 78

withop defined in line 124; used 1 times

- in line 113

#### Defined variables

cnts defined in line 13; never used
cntstat defined in line 12; used 4 times

- in line 41-42(2), 56, 103

Last modified: 1986-05-31 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 1029 |