1: # include <ingres.h> 2: # include <aux.h> 3: # include <tree.h> 4: # include <symbol.h> 5: # include "globs.h" 6: # include <sccs.h> 7: 8: SCCSID(@(#)makenode.c 8.1 12/31/84) 9: 10: 11: 12: 13: /* 14: ** Make a copy of a tree. 15: */ 16: 17: QTREE * 18: copytree(r, buf) 19: register QTREE *r; 20: char *buf; 21: { 22: register QTREE *q; 23: register int length; 24: extern char *need(); 25: 26: if (r == NULL) 27: return (0); 28: 29: length = r->sym.len & I1MASK; 30: q = (QTREE *) need(buf, length + QT_HDR_SIZ); 31: bmove((char *)&r->sym, (char *)&q->sym, length + SYM_HDR_SIZ); 32: 33: q->left = copytree(r->left, buf); 34: q->right = copytree(r->right, buf); 35: 36: return (q); 37: } 38: /* 39: ** Make a new copy of the root by making 40: ** new AND nodes and connecting them to the 41: ** same branches. 42: ** 43: ** Trace Flags: 44: ** 64 45: */ 46: 47: QTREE * 48: copy_ands(root, buf) 49: QTREE *root; 50: char *buf; 51: { 52: register QTREE *q; 53: register QTREE *x, *y; 54: QTREE *newroot; 55: extern char *need(); 56: register int len; 57: 58: # ifdef xDTR1 59: if (tTf(64, -1)) 60: printf("COPY_ANDS"); 61: # endif 62: newroot = (QTREE *) need(buf, 0); 63: y = 0; 64: 65: for (q=root; q->sym.type != QLEND; q=q->right) 66: { 67: len = q->sym.len & I1MASK; 68: x = (QTREE *) need(buf, len + QT_HDR_SIZ); 69: x->left = q->left; 70: bmove((char *)&q->sym, (char *)&x->sym, len + SYM_HDR_SIZ); 71: if (y) 72: y->right = x; 73: y = x; 74: } 75: y->right = q; 76: 77: # ifdef xDTR1 78: if (tTf(64, 0)) 79: { 80: printf("New tree\n"); 81: treepr(newroot); 82: } 83: # endif 84: return(newroot); 85: } 86: 87: 88: 89: QTREE * 90: makroot(buf) 91: char *buf; 92: { 93: register QTREE *s; 94: extern char *need(); 95: 96: s = (QTREE *) need(buf, QT_HDR_SIZ + sizeof (struct rootnode)); 97: s->right = De.de_qle; 98: s->left = De.de_tr; 99: s->sym.value.sym_root.rootuser = FALSE; 100: s->sym.value.sym_root.lvarm = 0; 101: s->sym.value.sym_root.rvarm = 0; 102: s->sym.value.sym_root.tvarc = 0; 103: s->sym.value.sym_root.lvarc = 0; 104: s->sym.type = ROOT; 105: s->sym.len = sizeof (struct rootnode); 106: return (s); 107: } 108: 109: 110: QTREE * 111: makresdom(buf, node) 112: char *buf; 113: QTREE *node; 114: { 115: register QTREE *res, *n; 116: extern char *need(); 117: 118: n = node; 119: res = (QTREE *) need(buf, QT_HDR_SIZ + sizeof(struct resdomnode)); 120: res->sym.type = RESDOM; 121: res->sym.len = sizeof(struct resdomnode); 122: if (n->sym.type == AOP) 123: { 124: res->sym.value.sym_resdom.resfrmt = n->sym.value.sym_op.agfrmt; 125: res->sym.value.sym_resdom.resfrml = n->sym.value.sym_op.agfrml; 126: } 127: else 128: { 129: res->sym.value.sym_resdom.resfrmt = n->sym.value.sym_var.varfrmt; 130: res->sym.value.sym_resdom.resfrml = n->sym.value.sym_var.varfrml; 131: } 132: return (res); 133: } 134: 135: QTREE * 136: makavar(node, varnum, attnum) 137: QTREE *node; 138: int varnum, attnum; 139: { 140: register QTREE *avar, *n; 141: extern char *need(); 142: 143: n = node; 144: 145: avar = (QTREE *) need(De.de_qbuf, QT_HDR_SIZ + sizeof(struct varnode)); 146: avar->left = avar->right = NULL; 147: avar->sym.value.sym_var.valptr = NULL; 148: avar->sym.type = VAR; 149: avar->sym.len = sizeof(struct varnode); 150: avar->sym.value.sym_var.varfrmt = n->sym.value.sym_var.varfrmt; 151: avar->sym.value.sym_var.varfrml = n->sym.value.sym_var.varfrml; 152: avar->sym.value.sym_var.varno = varnum; 153: avar->sym.value.sym_var.attno = attnum; 154: # ifdef xDTR1 155: if (tTf(64, 3)) 156: { 157: printf("makavar: node=%x ", n); 158: nodepr(avar); 159: } 160: # endif 161: return(avar); 162: }