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 constcnt = -1; 13: 14: /* 15: * The const declaration part 16: */ 17: constbeg(l, cline) 18: int l, cline; 19: { 20: 21: line = l; 22: if (nodecl) 23: printoff(); 24: puthedr(); 25: putcm(); 26: ppnl(); 27: indent(); 28: ppkw("const"); 29: ppgoin(DECL); 30: constcnt = 0; 31: setline(cline); 32: } 33: 34: const(cline, cid, cdecl) 35: int cline; 36: char *cid; 37: int *cdecl; 38: { 39: 40: if (constcnt) 41: putcm(); 42: setline(cline); 43: ppitem(); 44: ppid(cid); 45: ppsep(" = "); 46: gconst(cdecl); 47: ppsep(";"); 48: constcnt++; 49: setinfo(cline); 50: putcml(); 51: } 52: 53: constend() 54: { 55: 56: if (constcnt == -1) 57: return; 58: if (nodecl) 59: return; 60: if (constcnt == 0) 61: ppid("{const decls}"); 62: ppgoout(DECL); 63: constcnt = -1; 64: } 65: 66: /* 67: * A constant in an expression 68: * or a declaration. 69: */ 70: gconst(r) 71: int *r; 72: { 73: register *cn; 74: 75: cn = r; 76: loop: 77: if (cn == NIL) { 78: ppid("{constant}"); 79: return; 80: } 81: switch (cn[0]) { 82: default: 83: panic("gconst"); 84: case T_PLUSC: 85: ppop("+"); 86: cn = cn[1]; 87: goto loop; 88: case T_MINUSC: 89: ppop("-"); 90: cn = cn[1]; 91: goto loop; 92: case T_ID: 93: ppid(cn[1]); 94: return; 95: case T_CBINT: 96: case T_CINT: 97: case T_CFINT: 98: ppnumb(cn[1]); 99: if (cn[0] == T_CBINT) 100: ppsep("b"); 101: return; 102: case T_CSTRNG: 103: ppstr(cn[1]); 104: return; 105: } 106: }