Annotation of coherent/d/bin/cc/c/n3/itree.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * C compiler intermediate file printer.
                      3:  * Tree handler.
                      4:  */
                      5: #ifdef vax
                      6: #include "INC$LIB:cc3.h"
                      7: #else
                      8: #include "cc3.h"
                      9: #endif
                     10: 
                     11: /*
                     12:  * Print a tree.
                     13:  * The 'op' is the temp. file opcode that introduced the tree.
                     14:  * The conditional trees must read in the label.
                     15:  * The tree is printed between walls, with a title in the first wall.
                     16:  */
                     17: itree(op)
                     18: {
                     19:        strcpy(id, ilonames[op]);
                     20:        if (op==TEXPR || op==FEXPR)
                     21:                sprintf(id, "%s to L%d", ilonames[op], iget());
                     22:        iwall(id);
                     23:        itree1(0);
                     24:        fputc('\t', ofp);
                     25:        iwall(NULL);
                     26: }
                     27: 
                     28: /*
                     29:  * Read and print a tree node and its subtrees.
                     30:  */
                     31: itree1(n)
                     32: int    n;
                     33: {
                     34:        register int    i;
                     35:        register int    op;
                     36:        register int    type;
                     37:        char            *opid;
                     38:        int             seg;
                     39:        dval_t          dval;
                     40:        sizeof_t        offs;
                     41:        int             width, base;
                     42:        extern char     *milnames[];
                     43:        extern char     *mionames[];
                     44:        extern char     *mdlnames[];
                     45:        extern char     *mdonames[];
                     46: 
                     47:        if ((op=iget()) == NIL)
                     48:                return;
                     49:        fputc('\t', ofp);
                     50:        i = n;
                     51:        while (i--)
                     52:                fputc(' ', ofp);
                     53:        if (op < MDLBASE)
                     54:                opid = milnames[op];
                     55:        else if (op < MIOBASE)
                     56:                opid = mdlnames[op-MDLBASE];
                     57:        else if (op < MDOBASE)
                     58:                opid = mionames[op-MIOBASE];
                     59:        else if (op < ETCBASE)
                     60:                opid = mdonames[op-MDOBASE];
                     61:        else
                     62:                sprintf(opid, "Bad == %d", op);
                     63:        type = bget();
                     64:        fprintf(ofp, "%s %s ", opid, tynames[type]);
                     65:        if (type == BLK)
                     66:                fprintf(ofp, "(%d bytes) ", iget());
                     67:        switch (op) {
                     68: 
                     69:        case ICON:
                     70:                fprintf(ofp, "%d", iget());
                     71:                break;
                     72: 
                     73:        case LCON:
                     74:                fprintf(ofp, "%ld", lget());
                     75:                break;
                     76: 
                     77:        case ZCON:
                     78:                fprintf(ofp, "%ld", (long)zget());
                     79:                break;
                     80: 
                     81:        case DCON:
                     82:                dget(dval);
                     83:                gendval(dval);
                     84:                break;
                     85: 
                     86:        case REG:
                     87:                fprintf(ofp, "%s", regnames[iget()]);
                     88:                break;
                     89: 
                     90:        case AID:
                     91:        case PID:
                     92:                fprintf(ofp, "at %ld", (long)zget());
                     93:                break;
                     94: 
                     95:        case LID:
                     96:        case GID:
                     97:                offs = zget();
                     98:                seg = bget();
                     99:                fprintf(ofp, "%s.", segnames[seg]);
                    100:                if (op == LID)
                    101:                        fprintf(ofp, "L%d", iget());
                    102:                else {
                    103:                        sget(id, NCSYMB);
                    104:                        fprintf(ofp, "%s", id);
                    105:                }
                    106:                if (offs != 0) {
                    107:                        if (offs > 0)
                    108:                                fputc('+', ofp);
                    109:                        fprintf(ofp, "%ld", (long)offs);
                    110:                }
                    111:                break;
                    112: 
                    113:        case FIELD:
                    114:                width = bget();
                    115:                base  = bget();
                    116:                fprintf(ofp, "base=%d width=%d\n", base, width);
                    117:                itree1(n+2);
                    118:                return;
                    119: 
                    120:        default:
                    121:                if (op < MIOBASE) {
                    122:                        genmdl(op);
                    123:                        break;
                    124:                } else if (op < MDOBASE) {
                    125:                        fputc('\n', ofp);
                    126:                        itree1(n+2);    /* Left */
                    127:                        itree1(n+2);    /* Right */
                    128:                        return;
                    129:                } else {
                    130:                        genmdo(op);
                    131:                        return;
                    132:                }
                    133:        }
                    134:        fputc('\n', ofp);
                    135: }
                    136: 
                    137: /*
                    138:  * Print a wall with the title string 's' in it.
                    139:  * The wall is always WIDTH long.
                    140:  */
                    141: iwall(s)
                    142: register char  *s;
                    143: {
                    144:        register int n;
                    145:        n = WIDTH;
                    146:        if (s != NULL) {
                    147:                fprintf(ofp, "%s ", s);
                    148:                n -= strlen(s) + 1;
                    149:        }
                    150:        while (--n >= 0)
                    151:                fputc('-', ofp);
                    152:        fputc('\n', ofp);
                    153: }
                    154: 

unix.superglobalmegacorp.com

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