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: STATIC  int typecnt = -1;
  13: /*
  14:  * Type declaration part
  15:  */
  16: typebeg(l, tline)
  17:     int l, tline;
  18: {
  19: 
  20:     line = l;
  21:     if (nodecl)
  22:         printoff();
  23:     puthedr();
  24:     putcm();
  25:     ppnl();
  26:     indent();
  27:     ppkw("type");
  28:     ppgoin(DECL);
  29:     typecnt = 0;
  30:     setline(tline);
  31: }
  32: 
  33: type(tline, tid, tdecl)
  34:     int tline;
  35:     char *tid;
  36:     int *tdecl;
  37: {
  38: 
  39:     if (typecnt)
  40:         putcm();
  41:     setline(tline);
  42:     ppitem();
  43:     ppid(tid);
  44:     ppsep(" =");
  45:     gtype(tdecl);
  46:     ppsep(";");
  47:     setinfo(tline);
  48:     putcml();
  49:     typecnt++;
  50: }
  51: 
  52: typeend()
  53: {
  54: 
  55:     if (typecnt == -1)
  56:         return;
  57:     if (typecnt == 0)
  58:         ppid("{type decls}");
  59:     ppgoout(DECL);
  60:     typecnt = -1;
  61: }
  62: 
  63: /*
  64:  * A single type declaration
  65:  */
  66: gtype(r)
  67:     register int *r;
  68: {
  69: 
  70:     if (r == NIL) {
  71:         ppid("{type}");
  72:         return;
  73:     }
  74:     if (r[0] != T_ID && r[0] != T_TYPACK)
  75:         setline(r[1]);
  76:     switch (r[0]) {
  77:         default:
  78:             panic("type");
  79:         case T_ID:
  80:             ppspac();
  81:             ppid(r[1]);
  82:             return;
  83:         case T_TYID:
  84:             ppspac();
  85:             ppid(r[2]);
  86:             break;
  87:         case T_TYSCAL:
  88:             ppspac();
  89:             tyscal(r);
  90:             break;
  91:         case T_TYRANG:
  92:             ppspac();
  93:             tyrang(r);
  94:             break;
  95:         case T_TYPTR:
  96:             ppspac();
  97:             ppop("^");
  98:             gtype(r[2]);
  99:             break;
 100:         case T_TYPACK:
 101:             ppspac();
 102:             ppkw("packed");
 103:             gtype(r[2]);
 104:             break;
 105:         case T_TYARY:
 106:             ppspac();
 107:             tyary(r);
 108:             break;
 109:         case T_TYREC:
 110:             ppspac();
 111:             tyrec(r[2], NIL);
 112:             break;
 113:         case T_TYFILE:
 114:             ppspac();
 115:             ppkw("file");
 116:             ppspac();
 117:             ppkw("of");
 118:             gtype(r[2]);
 119:             break;
 120:         case T_TYSET:
 121:             ppspac();
 122:             ppkw("set");
 123:             ppspac();
 124:             ppkw("of");
 125:             gtype(r[2]);
 126:             break;
 127:     }
 128:     setline(r[1]);
 129:     putcml();
 130: }
 131: 
 132: /*
 133:  * Scalar type declaration
 134:  */
 135: tyscal(r)
 136:     register int *r;
 137: {
 138:     register int i;
 139: 
 140:     ppsep("(");
 141:     r = r[2];
 142:     if (r != NIL) {
 143:         i = 0;
 144:         ppgoin(DECL);
 145:         for (;;) {
 146:             ppid(r[1]);
 147:             r = r[2];
 148:             if (r == NIL)
 149:                 break;
 150:             ppsep(", ");
 151:             i++;
 152:             if (i == 7) {
 153:                 ppitem();
 154:                 i = 0;
 155:             }
 156:         }
 157:         ppgoout(DECL);
 158:     } else
 159:         ppid("{constant list}");
 160:     ppsep(")");
 161: }
 162: 
 163: /*
 164:  * Subrange type declaration
 165:  */
 166: tyrang(r)
 167:     register int *r;
 168: {
 169: 
 170:     gconst(r[2]);
 171:     ppsep("..");
 172:     gconst(r[3]);
 173: }
 174: 
 175: /*
 176:  * Array type declaration
 177:  */
 178: tyary(r)
 179:     register int *r;
 180: {
 181:     register int *tl;
 182: 
 183:     ppkw("array");
 184:     ppspac();
 185:     ppsep("[");
 186:     tl = r[2];
 187:     if (tl != NIL) {
 188:         ppunspac();
 189:         for (;;) {
 190:             gtype(tl[1]);
 191:             tl = tl[2];
 192:             if (tl == NIL)
 193:                 break;
 194:             ppsep(",");
 195:         }
 196:     } else
 197:         ppid("{subscr list}");
 198:     ppsep("]");
 199:     ppspac();
 200:     ppkw("of");
 201:     gtype(r[3]);
 202: }

Defined functions

gtype defined in line 66; used 12 times
tyary defined in line 178; used 1 times
type defined in line 33; used 12 times
typebeg defined in line 16; used 2 times
typeend defined in line 52; used 2 times
tyrang defined in line 166; used 1 times
  • in line 93
tyscal defined in line 135; used 1 times
  • in line 89

Defined variables

typecnt defined in line 12; used 6 times
Last modified: 1986-06-01
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2164
Valid CSS Valid XHTML 1.0 Strict