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(@(#)setvar.c	8.1	12/31/84)
   9: 
  10: /*
  11: ** SETVAR -- Routines to convert a VAR to a constant and back to a VAR
  12: **
  13: **	This file contains the routines for tuple substitution.
  14: **
  15: **	Setvar -- Make a VAR node reference its position in the tuple.
  16: **
  17: **	Clrvar -- Make the VAR node refer back to a VAR
  18: */
  19: /*
  20: **  SETVAR
  21: **
  22: **	Var's are changed to reference their values in a tuple.
  23: **	ROOT and AND nodes are changed to update the variable maps.
  24: **
  25: **	Trace Flags:
  26: **		53
  27: */
  28: 
  29: setvar(tree, var, intid, tuple)
  30: register QTREE  *tree;
  31: int     var;
  32: TID     *intid;
  33: char        *tuple;
  34: {
  35:     register int    mask, nvc;
  36:     DESC        *readopen();
  37:     extern QTREE    *ckvar();
  38: 
  39:     if (tree == NULL)
  40:         return;
  41:     switch (tree->sym.type)
  42:     {
  43:       case VAR:
  44:         if ((tree=ckvar(tree))->sym.value.sym_var.varno == var)
  45:         {
  46: #			ifdef xDTR1
  47:             if (tTf(53, 0))
  48:             {
  49:                 printf("setvar:%d;tree:", var);
  50:                 nodepr(tree);
  51:             }
  52: #			endif
  53:             if (tree->sym.value.sym_var.attno)
  54:                 tree->sym.value.sym_var.valptr =
  55:                     (ANYTYPE *) (tuple + readopen(var)->reloff[tree->sym.value.sym_var.attno]);
  56:             else
  57:                 tree->sym.value.sym_var.valptr = (ANYTYPE *) intid;
  58:         }
  59:         return;
  60: 
  61:       case ROOT:
  62:       case AND:
  63:         mask = 01 << var;
  64:         nvc = tree->sym.value.sym_root.tvarc;
  65:         if (tree->sym.value.sym_root.lvarm & mask)
  66:         {
  67:             setvar(tree->left, var, intid, tuple);
  68:             tree->sym.value.sym_root.lvarm &=  ~mask;
  69:             --tree->sym.value.sym_root.lvarc;
  70:             nvc = tree->sym.value.sym_root.tvarc - 1;
  71:         }
  72:         if (tree->sym.value.sym_root.rvarm & mask)
  73:         {
  74:             setvar(tree->right, var, intid, tuple);
  75:             tree->sym.value.sym_root.rvarm &=  ~mask;
  76:             nvc = tree->sym.value.sym_root.tvarc - 1;
  77:         }
  78:         tree->sym.value.sym_root.tvarc = nvc;
  79:         return;
  80: 
  81:       default:
  82:         setvar(tree->left, var, intid, tuple);
  83:         setvar(tree->right, var, intid, tuple);
  84:         return;
  85:     }
  86: }
  87: /*
  88: **	Clearvar is the opposite of setvar. For
  89: **	each occurence of var1 in the tree, clear
  90: **	the valptr.
  91: */
  92: 
  93: clearvar(tree, var)
  94: register QTREE  *tree;
  95: register int    var;
  96: {
  97:     extern QTREE    *ckvar();
  98: 
  99:     if (tree == NULL)
 100:         return;
 101: 
 102:     if (tree->sym.type == VAR)
 103:     {
 104:         if ((tree = ckvar(tree))->sym.value.sym_var.varno == var)
 105:             tree->sym.value.sym_var.valptr = 0;
 106:         return;
 107:     }
 108:     clearvar(tree->left, var);
 109:     clearvar(tree->right, var);
 110: }

Defined functions

clearvar defined in line 93; used 4 times
setvar defined in line 8; used 5 times
Last modified: 1986-04-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 909
Valid CSS Valid XHTML 1.0 Strict