1: # include   "../ingres.h"
   2: # include   "../tree.h"
   3: # include   "../symbol.h"
   4: 
   5: /*
   6: **	MAPVAR -- construct varable maps for ROOT, AND, and AGHEAD nodes.
   7: **	tl is a flag  which indicates if the target list should
   8: **	be included in the mapping.  If tl = 0, it should; else it should not.
   9: */
  10: 
  11: mapvar(tree, tl)
  12: struct querytree    *tree;
  13: int          tl;
  14: {
  15:     register struct querytree   *t;
  16:     register int            rmap, lmap;
  17:     extern struct querytree     *ckvar();
  18: 
  19:     t = tree;
  20:     if (t == 0)
  21:         return (0);
  22: 
  23:     switch (t->sym.type)
  24:     {
  25:       case ROOT:
  26:       case AND:
  27:       case AGHEAD:
  28:         /* map the right side */
  29:         ((struct qt_root *)t)->rvarm = rmap = mapvar(t->right, tl);
  30: 
  31:         /* map the left side or else use existing values */
  32:         if (tl == 0)
  33:         {
  34:             ((struct qt_root *)t)->lvarm = lmap = mapvar(t->left, tl);
  35:             ((struct qt_root *)t)->lvarc = bitcnt(lmap);
  36:         }
  37:         else
  38:             lmap = ((struct qt_root *)t)->lvarm;
  39: 
  40:         /* form map of both sides */
  41:         rmap |= lmap;
  42: 
  43:         /* compute total var count */
  44:         ((struct qt_root *)t)->tvarc = bitcnt(rmap);
  45: 
  46:         return (rmap);
  47: 
  48:       case VAR:
  49:         if (((struct qt_var *)(t = ckvar(t)))->valptr)
  50:             return (0); /* var is a constant */
  51:         return (01 << ((struct qt_var *)t)->varno);
  52:     }
  53: 
  54:     /* node is not a VAR, AND, ROOT, or AGHEAD */
  55:     return (mapvar(t->left, tl) | mapvar(t->right, tl));
  56: }
Last modified: 1995-04-14
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2456
Valid CSS Valid XHTML 1.0 Strict