Annotation of 40BSD/cmd/pxp/const.c, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.