Annotation of coherent/b/bin/c/n1/tree0.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * The routines in this file
        !             3:  * read in expression trees from the intermediate
        !             4:  * file. They are used by both the modify phase and the
        !             5:  * code generation phase.
        !             6:  */
        !             7: #ifdef   vax
        !             8: #include "INC$LIB:cc1.h"
        !             9: #else
        !            10: #include "cc1.h"
        !            11: #endif
        !            12: 
        !            13: /*
        !            14:  * Read in a tree.
        !            15:  * The tree is built up in the
        !            16:  * tree buffer.
        !            17:  * Return a pointer to the top
        !            18:  * of the tree.
        !            19:  */
        !            20: TREE *
        !            21: treeget()
        !            22: {
        !            23: 
        !            24:        newtree(sizeof(TREE));
        !            25:        return (treeget1());
        !            26: }
        !            27: 
        !            28: /*
        !            29:  * This recursive routine is
        !            30:  * the real workhorse of the tree
        !            31:  * reader.
        !            32:  * It build the node and calls
        !            33:  * itself to grab the subtrees of
        !            34:  * the node.
        !            35:  */
        !            36: TREE *
        !            37: treeget1()
        !            38: {
        !            39:        register TREE *tp;
        !            40:        register op;
        !            41: 
        !            42:        if ((op=iget()) == NIL)
        !            43:                return (NULL);
        !            44:        tp = alocnode();
        !            45:        tp->t_op = op;
        !            46:        tp->t_type = bget();
        !            47:        tp->t_size = 0;
        !            48:        if (tp->t_type == BLK)
        !            49:                tp->t_size = iget();
        !            50:        switch (op) {
        !            51: 
        !            52:        case ICON:
        !            53:                tp->t_ival = iget();
        !            54:                break;
        !            55: 
        !            56:        case LCON:
        !            57:                tp->t_lval = lget();
        !            58:                break;
        !            59: 
        !            60:        case DCON:
        !            61:                dget(tp->t_dval);
        !            62:                break;
        !            63: 
        !            64:        case AID:
        !            65:        case PID:
        !            66:                tp->t_offs = zget();
        !            67:                break;
        !            68: 
        !            69:        case LID:
        !            70:                tp->t_offs = zget();
        !            71:                tp->t_seg = bget();
        !            72:                tp->t_label  = iget();
        !            73:                break;
        !            74: 
        !            75:        case GID:
        !            76:                tp->t_offs = zget();
        !            77:                tp->t_seg = bget();
        !            78:                sget(id, NCSYMB);
        !            79:                tp->t_sp = gidpool(id);
        !            80:                break;
        !            81: 
        !            82:        case REG:
        !            83:                tp->t_reg = iget();
        !            84:                break;
        !            85: 
        !            86:        case FIELD:
        !            87:                tp->t_width = bget();
        !            88:                tp->t_base  = bget();
        !            89:                tp->t_lp = treeget1();
        !            90:                break;
        !            91: 
        !            92:        default:
        !            93:                tp->t_lp = treeget1();
        !            94:                tp->t_rp = treeget1();
        !            95:        }
        !            96:        return (tp);
        !            97: }
        !            98: 
        !            99: /*
        !           100:  * Walk a tree, calling the supplied
        !           101:  * function at each node. The order of the
        !           102:  * walk is left, right, root.
        !           103:  */
        !           104: walk(tp, f)
        !           105: TREE   *tp;
        !           106: int    (*f)();
        !           107: {
        !           108:        walk1(tp, NULL, f);
        !           109: }
        !           110: 
        !           111: walk1(tp, ptp, f)
        !           112: register TREE  *tp;
        !           113: TREE           *ptp;
        !           114: int            (*f)();
        !           115: {
        !           116:        register TREE   *stp;
        !           117: 
        !           118:        if (!isleaf(tp->t_op)) {
        !           119:                walk1(tp->t_lp, tp, f);
        !           120:                if (tp->t_op!=FIELD && (stp=tp->t_rp)!=NULL)
        !           121:                        walk1(stp, tp, f);
        !           122:        }
        !           123:        (*f)(tp, ptp);
        !           124: }

unix.superglobalmegacorp.com

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