Annotation of 42BSD/ingres/source/ctlmod/treepr.c, revision 1.1.1.1

1.1       root        1: # include      <ingres.h>
                      2: # include      <symbol.h>
                      3: # include      <tree.h>
                      4: # include      <aux.h>
                      5: # include      <sccs.h>
                      6: 
                      7: SCCSID(@(#)treepr.c    7.1     2/5/81)
                      8: 
                      9: /*
                     10: **  TREEPR -- print tree for debugging
                     11: **
                     12: **     This routine prints a tree for debugging.
                     13: **
                     14: **     Parameters:
                     15: **             tree -- root of tree to be printed
                     16: **
                     17: **     Returns:
                     18: **             none
                     19: **
                     20: **     Side Effects:
                     21: **             output to terminal
                     22: */
                     23: 
                     24: treepr(tree)
                     25: QTREE  *tree;
                     26: {
                     27:        register QTREE  *t;
                     28:        register int    i;
                     29: 
                     30:        t = tree;
                     31: 
                     32:        printf("Querytree @ %x:\n", t);
                     33: 
                     34:        /* print range table */
                     35:        for (i = 0; i < MAXVAR + 1; i++)
                     36:        {
                     37:                if (Qt.qt_rangev[i].rngvdesc == NULL)
                     38:                        continue;
                     39:                printf("range of %d is %.14s\n",
                     40:                    i, Qt.qt_rangev[i].rngvdesc->reldum.relid);
                     41:        }
                     42: 
                     43:        /* print query type */
                     44:        if (Qt.qt_qmode >= 0)
                     45:                printf("Qmode %d ", Qt.qt_qmode);
                     46: 
                     47:        /* print result relation if realistic */
                     48:        if (Qt.qt_resvar >= 0)
                     49:                printf("resvar %d ", Qt.qt_resvar);
                     50:        printf("\n");
                     51: 
                     52:        /* print tree */
                     53:        rcsvtrpr(t);
                     54: 
                     55:        /* print exciting final stuff */
                     56:        printf("\n");
                     57: }
                     58: /*
                     59: **  RCSVTRPR -- traverse and print tree
                     60: **
                     61: **     This function does the real stuff for treepr.  It recursively
                     62: **     traverses the tree in postfix order, printing each node.
                     63: **
                     64: **     Parameters:
                     65: **             tree -- the root of the tree to print.
                     66: **
                     67: **     Returns:
                     68: **             none
                     69: **
                     70: **     Side Effects:
                     71: **             none
                     72: **
                     73: **     Trace Flags:
                     74: **             none
                     75: */
                     76: 
                     77: static
                     78: rcsvtrpr(tree)
                     79: QTREE  *tree;
                     80: {
                     81:        register QTREE  *t;
                     82: 
                     83:        t = tree;
                     84: 
                     85:        while (t != NULL)
                     86:        {
                     87:                nodepr(t);
                     88:                rcsvtrpr(t->left);
                     89:                t = t->right;
                     90:        }
                     91: }
                     92: /*
                     93: **  NODEPR -- print tree node for debugging
                     94: **
                     95: **     Parameters:
                     96: **             tree -- the node to print.
                     97: **
                     98: **     Returns:
                     99: **             none
                    100: **
                    101: **     Side Effects:
                    102: **             output to terminal
                    103: */
                    104: 
                    105: nodepr(tree)
                    106: QTREE  *tree;
                    107: {
                    108:        register QTREE  *t;
                    109:        register int    ty;
                    110:        int             l;
                    111:        char            *cp;
                    112: 
                    113:        t = tree;
                    114:        ty = t->sym.type;
                    115:        l = t->sym.len & I1MASK;
                    116: 
                    117:        printf("%x: %x, %x/ ", t, t->left, t->right);
                    118:        xputchar(ty);
                    119:        printf("%d: ", l);
                    120: 
                    121:        switch (ty)
                    122:        {
                    123:          case VAR:
                    124:                printf("%d.%d [", t->sym.value.sym_var.varno,
                    125:                    t->sym.value.sym_var.attno);
                    126:                xputchar(t->sym.value.sym_var.varfrmt);
                    127:                printf("%d]: %x", t->sym.value.sym_var.varfrml & I1MASK,
                    128:                                  t->sym.value.sym_var.valptr);
                    129:                if (t->sym.value.sym_var.varno == -1)
                    130:                {
                    131:                        printf("\n\tSub var: ");
                    132:                        if (t->sym.value.sym_var.valptr != NULL)
                    133:                                nodepr((QTREE *) t->sym.value.sym_var.valptr);
                    134:                        else
                    135:                                printf("ERROR: no value\n");
                    136:                        return;
                    137:                }
                    138:                else
                    139:                {
                    140:                        if (t->sym.value.sym_var.valptr != NULL)
                    141:                        {
                    142:                                printf(" = ");
                    143:                                printatt(t->sym.value.sym_var.varfrmt,
                    144:                                         t->sym.value.sym_var.varfrml,
                    145:                                         t->sym.value.sym_var.valptr);
                    146:                        }
                    147:                }
                    148:                break;
                    149: 
                    150:          case RESDOM:
                    151:                printf("%d [%c%d]", t->sym.value.sym_resdom.resno,
                    152:                    t->sym.value.sym_resdom.resfrmt,
                    153:                    t->sym.value.sym_resdom.resfrml);
                    154:                break;
                    155: 
                    156:          case AOP:
                    157:                printf("%d [%c%d] [%c%d]", t->sym.value.sym_op.opno,
                    158:                    t->sym.value.sym_op.opfrmt, t->sym.value.sym_op.opfrml,
                    159:                    t->sym.value.sym_op.agfrmt, t->sym.value.sym_op.agfrml);
                    160:                break;
                    161: 
                    162:          case UOP:
                    163:          case BOP:
                    164:          case COP:
                    165:          case INT:
                    166:          case QMODE:
                    167:          case RESULTVAR:
                    168:                switch (t->sym.len)
                    169:                {
                    170:                  case 1:
                    171:                  case 2:
                    172:                        printf("%d", t->sym.value.sym_data.i2type);
                    173:                        break;
                    174:                
                    175:                  case 4:
                    176:                        printf("%ld", t->sym.value.sym_data.i4type);
                    177:                        break;
                    178:                }
                    179:                break;
                    180: 
                    181:          case FLOAT:
                    182:                printf("%.10f", t->sym.value.sym_data.f4type);
                    183:                break;
                    184: 
                    185:          case CHAR:
                    186:                cp = t->sym.value.sym_data.c0type;
                    187:                while (l--)
                    188:                        xputchar(*cp++);
                    189:                break;
                    190: 
                    191:          case AND:
                    192:          case ROOT:
                    193:          case AGHEAD:
                    194:                printf("[%d/%d] [%o/%o]",
                    195:                    t->sym.value.sym_root.tvarc, t->sym.value.sym_root.lvarc,
                    196:                    t->sym.value.sym_root.lvarm, t->sym.value.sym_root.rvarm);
                    197:                if (ty != AND)
                    198:                        printf(" (%d)", t->sym.value.sym_root.rootuser);
                    199:                break;
                    200: 
                    201:          case TREE:
                    202:          case OR:
                    203:          case QLEND:
                    204:          case BYHEAD:
                    205:                break;
                    206: 
                    207:          case RESULTID:
                    208:          case SOURCEID:
                    209:                printf("%.14s", t->sym.value.sym_data.c0type);
                    210:                break;
                    211: 
                    212:          default:
                    213:                syserr("nodepr: ty %d", ty);
                    214:        }
                    215:        printf("/\n");
                    216: }

unix.superglobalmegacorp.com

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