Update of /cvsroot/monetdb/pathfinder/compiler/algebra/prop
In directory 
sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv14645/compiler/algebra/prop

Modified Files:
      Tag: PF_ROX
        prop_card.c prop_composite_key.c prop_const.c prop_dom.c 
        prop_dom_nat.c prop_guide.c prop_icol.c prop_key.c 
        prop_level.c prop_ocol.c prop_ori_names.c prop_rec_delta.c 
        prop_reqval.c prop_set.c prop_trace_names.c prop_unq_names.c 
Log Message:
propagated changes of Friday 15 Feb 2008 - Monday Feb 18 2008
from the development trunk to the PF_ROX branch


Index: prop_unq_names.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_unq_names.c,v
retrieving revision 1.27.4.1
retrieving revision 1.27.4.2
diff -u -d -r1.27.4.1 -r1.27.4.2
--- prop_unq_names.c    9 Feb 2008 08:40:28 -0000       1.27.4.1
+++ prop_unq_names.c    18 Feb 2008 16:57:23 -0000      1.27.4.2
@@ -39,19 +39,8 @@
 #include "oops.h"
 #include "mem.h"
 
-/*
- * Easily access subtree-parts.
- */
-/** starting from p, make a step left */
-#define L(p) ((p)->child[0])
-/** starting from p, make a step right */
-#define R(p) ((p)->child[1])
-/** starting from p, make a step right, then a step left */
-#define RL(p) L(R(p))
-/** starting from p, make two steps left */
-#define LL(p) L(L(p))
-/** starting from p, make a step left, then a step right */
-#define LR(p) R(L(p))
+/* Easily access subtree-parts */
+#include "child_mnemonic.h"
 
 /* worker for PFprop_unq_name* */
 static PFalg_att_t
@@ -258,7 +247,7 @@
                argument are replaced by the overall join column name
                and all columns that are also referenced on the other
                side will be renamed by introducing a new unique name.
-               All other column stay unchanged. */
+               All other columns stay unchanged. */
             for (unsigned int i = 0; i < L(n)->schema.count; i++) {
                 ori = L(n)->schema.items[i].name;
                 child_unq = PFprop_unq_name (L(n)->prop, ori);
@@ -282,6 +271,8 @@
 
                     add_name_pair (np_list, ori, unq);
                 }
+                else if (child_unq == att2_unq)
+                    add_name_pair (np_list, ori, PFalg_unq_name (ori, id++));
                 else
                     add_name_pair (np_list, ori, child_unq);
 
@@ -311,6 +302,8 @@
 
                     add_name_pair (np_list, ori, unq);
                 }
+                else if (child_unq == att1_unq)
+                    add_name_pair (np_list, ori, PFalg_unq_name (ori, id++));
                 else
                     add_name_pair (np_list, ori, child_unq);
 

Index: prop_ocol.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_ocol.c,v
retrieving revision 1.46.2.1
retrieving revision 1.46.2.2
diff -u -d -r1.46.2.1 -r1.46.2.2
--- prop_ocol.c 9 Feb 2008 08:40:27 -0000       1.46.2.1
+++ prop_ocol.c 18 Feb 2008 16:57:22 -0000      1.46.2.2
@@ -39,13 +39,8 @@
 #include "oops.h"
 #include "mem.h"
 
-/*
- * Easily access subtree-parts.
- */
-/** starting from p, make a step left */
-#define L(p) ((p)->child[0])
-/** starting from p, make a step right */
-#define R(p) ((p)->child[1])
+/* Easily access subtree-parts */
+#include "child_mnemonic.h"
 
 /*
  * access ocol information
@@ -728,7 +723,7 @@
                                                     R(n),
                                                     n->sem.step.iter) };
 
-            if (n->sem.step.axis == alg_attr)
+            if (n->sem.step.spec.axis == alg_attr)
                 ocol_at (n, 1)
                     = (PFalg_schm_item_t) { .name = n->sem.step.item_res,
                                             .type = aat_anode };
@@ -756,7 +751,7 @@
                         PFprop_type_of (R(n), n->sem.step.item));
 #endif
             ocols (n) = copy_ocols (ocols (R(n)), ocols_count (R(n)) + 1);
-            if (n->sem.step.axis == alg_attr)
+            if (n->sem.step.spec.axis == alg_attr)
                 ocol_at (n, ocols_count (n))
                     = (PFalg_schm_item_t) { .name = n->sem.step.item_res,
                                             .type = aat_anode };

Index: prop_const.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_const.c,v
retrieving revision 1.34.4.1
retrieving revision 1.34.4.2
diff -u -d -r1.34.4.1 -r1.34.4.2
--- prop_const.c        9 Feb 2008 08:40:27 -0000       1.34.4.1
+++ prop_const.c        18 Feb 2008 16:57:20 -0000      1.34.4.2
@@ -38,15 +38,8 @@
 #include "oops.h"
 #include "mem.h"
 
-/*
- * Easily access subtree-parts.
- */
-/** starting from p, make a step left */
-#define L(p) ((p)->child[0])
-/** starting from p, make a step right */
-#define R(p) ((p)->child[1])
-/** starting from p, make a step right, then a step left */
-#define RL(p) L(R(p))
+/* Easily access subtree-parts */
+#include "child_mnemonic.h"
 
 /**
  * Test if @a attr is marked constant in property container @a prop.

Index: prop_reqval.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_reqval.c,v
retrieving revision 1.35.2.1
retrieving revision 1.35.2.2
diff -u -d -r1.35.2.1 -r1.35.2.2
--- prop_reqval.c       9 Feb 2008 08:40:27 -0000       1.35.2.1
+++ prop_reqval.c       18 Feb 2008 16:57:23 -0000      1.35.2.2
@@ -41,14 +41,8 @@
 #include "oops.h"
 #include "mem.h"
 
-
-/*
- * Easily access subtree-parts.
- */
-/** starting from p, make a step left */
-#define L(p) ((p)->child[0])
-/** starting from p, make a step right */
-#define R(p) ((p)->child[1])
+/* Easily access subtree-parts */
+#include "child_mnemonic.h"
 
 #define SEEN(p) ((p)->bit_dag)
 
@@ -57,7 +51,7 @@
 #define EDGE(n) ((n)->refctr)
 
 #define empty_list 0
-#define in(a,b) ((a) & (b))
+#define in(a,b) ((a) & (b) ? true : false)
 
 /**
  * Test if @a attr is in the list of required value columns

Index: prop_set.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_set.c,v
retrieving revision 1.19.4.1
retrieving revision 1.19.4.2
diff -u -d -r1.19.4.1 -r1.19.4.2
--- prop_set.c  9 Feb 2008 08:40:28 -0000       1.19.4.1
+++ prop_set.c  18 Feb 2008 16:57:23 -0000      1.19.4.2
@@ -42,17 +42,8 @@
 #include "mem.h"
 #include <stdio.h>
 
-/*
- * Easily access subtree-parts.
- */
-/** starting from p, make a step left */
-#define L(p) ((p)->child[0])
-/** starting from p, make a step right */
-#define R(p) ((p)->child[1])
-/** starting from p, make two steps left */
-#define RL(p) L(R(p))
-/** starting from p, make two steps right */
-#define RR(p) R(R(p))
+/* Easily access subtree-parts */
+#include "child_mnemonic.h"
 
 /**
  * Test if an operator referenced via its container @a prop

Index: prop_icol.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_icol.c,v
retrieving revision 1.30.4.1
retrieving revision 1.30.4.2
diff -u -d -r1.30.4.1 -r1.30.4.2
--- prop_icol.c 9 Feb 2008 08:40:27 -0000       1.30.4.1
+++ prop_icol.c 18 Feb 2008 16:57:21 -0000      1.30.4.2
@@ -40,17 +40,8 @@
 #include "oops.h"
 #include "mem.h"
 
-/*
- * Easily access subtree-parts.
- */
-/** starting from p, make a step left */
-#define L(p) ((p)->child[0])
-/** starting from p, make a step right */
-#define R(p) ((p)->child[1])
-/** starting from p, make two steps left */
-#define RL(p) L(R(p))
-/** starting from p, make two steps right */
-#define RR(p) R(R(p))
+/* Easily access subtree-parts */
+#include "child_mnemonic.h"
 
 /**
  * Test if @a attr is in the list of icol columns in container @a prop
@@ -58,7 +49,7 @@
 bool
 PFprop_icol (const PFprop_t *prop, PFalg_att_t attr)
 {
-    return prop->icols & attr;
+    return prop->icols & attr ? true : false;
 }
 
 /**
@@ -68,7 +59,7 @@
 bool
 PFprop_icol_left (const PFprop_t *prop, PFalg_att_t attr)
 {
-    return prop->l_icols & attr;
+    return prop->l_icols & attr ? true : false;
 }
 
 /**
@@ -78,7 +69,7 @@
 bool
 PFprop_icol_right (const PFprop_t *prop, PFalg_att_t attr)
 {
-    return prop->r_icols & attr;
+    return prop->r_icols & attr ? true : false;
 }
 
 /**

Index: prop_rec_delta.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_rec_delta.c,v
retrieving revision 1.19.4.1
retrieving revision 1.19.4.2
diff -u -d -r1.19.4.1 -r1.19.4.2
--- prop_rec_delta.c    9 Feb 2008 08:40:27 -0000       1.19.4.1
+++ prop_rec_delta.c    18 Feb 2008 16:57:23 -0000      1.19.4.2
@@ -39,13 +39,8 @@
 #include "oops.h"
 #include "mem.h"
 
-/*
- * Easily access subtree-parts.
- */
-/** starting from p, make a step left */
-#define L(p) ((p)->child[0])
-/** starting from p, make a step right */
-#define R(p) ((p)->child[1])
+/* Easily access subtree-parts */
+#include "child_mnemonic.h"
 
 #define ITER(n) ((n)->prop->icols)
 #define INNER(n) ((n)->prop->l_icols)

Index: prop_level.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_level.c,v
retrieving revision 1.11.4.1
retrieving revision 1.11.4.2
diff -u -d -r1.11.4.1 -r1.11.4.2
--- prop_level.c        9 Feb 2008 08:40:27 -0000       1.11.4.1
+++ prop_level.c        18 Feb 2008 16:57:22 -0000      1.11.4.2
@@ -38,13 +38,8 @@
 #include "oops.h"
 #include "mem.h"
 
-/*
- * Easily access subtree-parts.
- */
-/** starting from p, make a step left */
-#define L(p) ((p)->child[0])
-/** starting from p, make a step right */
-#define R(p) ((p)->child[1])
+/* Easily access subtree-parts */
+#include "child_mnemonic.h"
 
 #define UNKNOWN_LEVEL -1
 
@@ -268,7 +263,7 @@
                 PFalg_att_t item_res = n->sem.step.item_res;
                 int level = PFprop_level (R(n)->prop, n->sem.step.item);
                 if (level >= 0)
-                    switch (n->sem.step.axis) {
+                    switch (n->sem.step.spec.axis) {
                         case alg_attr:
                         case alg_chld:
                             mark_level (n->prop, item_res, level+1);

Index: prop_dom_nat.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_dom_nat.c,v
retrieving revision 1.15.4.1
retrieving revision 1.15.4.2
diff -u -d -r1.15.4.1 -r1.15.4.2
--- prop_dom_nat.c      9 Feb 2008 08:40:27 -0000       1.15.4.1
+++ prop_dom_nat.c      18 Feb 2008 16:57:21 -0000      1.15.4.2
@@ -54,15 +54,8 @@
 #include "oops.h"
 #include "mem.h"
 
-/*
- * Easily access subtree-parts.
- */
-/** starting from p, make a step left */
-#define L(p) ((p)->child[0])
-/** starting from p, make a step right */
-#define R(p) ((p)->child[1])
-/** starting from p, make a step right, then a step left */
-#define RL(p) L(R(p))
+/* Easily access subtree-parts */
+#include "child_mnemonic.h"
 
 /** Identifier for the (statically known) empty domain */
 #define EMPTYDOM 1

Index: prop_trace_names.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_trace_names.c,v
retrieving revision 1.14.4.1
retrieving revision 1.14.4.2
diff -u -d -r1.14.4.1 -r1.14.4.2
--- prop_trace_names.c  9 Feb 2008 08:40:28 -0000       1.14.4.1
+++ prop_trace_names.c  18 Feb 2008 16:57:23 -0000      1.14.4.2
@@ -40,17 +40,8 @@
 #include "oops.h"
 #include "mem.h"
 
-/*
- * Easily access subtree-parts.
- */
-/** starting from p, make a step left */
-#define L(p) ((p)->child[0])
-/** starting from p, make a step right */
-#define R(p) ((p)->child[1])
-/** starting from p, make a step right, then a step left */
-#define RL(p) L(R(p))
-/** starting from p, make two steps right */
-#define RR(p) R(R(p))
+/* Easily access subtree-parts */
+#include "child_mnemonic.h"
 
 /* store the number of incoming edges for each operator
    in the state_label field */

Index: prop_key.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_key.c,v
retrieving revision 1.37.4.1
retrieving revision 1.37.4.2
diff -u -d -r1.37.4.1 -r1.37.4.2
--- prop_key.c  9 Feb 2008 08:40:27 -0000       1.37.4.1
+++ prop_key.c  18 Feb 2008 16:57:21 -0000      1.37.4.2
@@ -39,17 +39,8 @@
 #include "mem.h"
 #include "qname.h"
 
-/*
- * Easily access subtree-parts.
- */
-/** starting from p, make a step left */
-#define L(p) ((p)->child[0])
-/** starting from p, make a step right */
-#define R(p) ((p)->child[1])
-/** starting from p, make two steps left */
-#define LL(p) (L(L(p)))
-/** starting from p, make a step left, then a step right */
-#define LR(p) R(L(p))
+/* Easily access subtree-parts */
+#include "child_mnemonic.h"
 
 /**
  * worker for PFprop_key;
@@ -546,22 +537,23 @@
             break;
 
         case la_guide_step:
-            if ((n->sem.step.axis == alg_chld ||
-                 n->sem.step.axis == alg_attr ||
-                 n->sem.step.axis == alg_self) &&
+            if ((n->sem.step.spec.axis == alg_chld ||
+                 n->sem.step.spec.axis == alg_attr ||
+                 n->sem.step.spec.axis == alg_self) &&
                 find_guide_max (n->sem.step.guide_count,
                                 n->sem.step.guides) <= 1)
                 union_ (n->prop->keys, n->sem.step.iter);
         case la_step:
-            if (n->sem.step.axis == alg_chld &&
+            if (n->sem.step.spec.axis == alg_chld &&
                 PFprop_key (R(n)->prop, n->sem.step.item))
                 union_ (n->prop->keys, n->sem.step.item_res);
 
             /* if attribute step is only a 'filter' (at most a single
                attribute for each context node) we can copy all keys */
-            if (n->sem.step.axis == alg_attr &&
-                ! (PFQNAME_NS_WILDCARD (n->sem.step.ty.name)
-                   || PFQNAME_LOC_WILDCARD (n->sem.step.ty.name)) &&
+            if (n->sem.step.spec.axis == alg_attr &&
+                n->sem.step.spec.kind == node_kind_attr &&
+                ! (PFQNAME_NS_WILDCARD (n->sem.step.spec.qname)
+                   || PFQNAME_LOC_WILDCARD (n->sem.step.spec.qname)) &&
                 PFprop_key (R(n)->prop, n->sem.step.item))
                 union_ (n->prop->keys, n->sem.step.iter);
 
@@ -570,16 +562,16 @@
             break;
 
         case la_guide_step_join:
-            if ((n->sem.step.axis == alg_chld ||
-                 n->sem.step.axis == alg_attr ||
-                 n->sem.step.axis == alg_self) &&
+            if ((n->sem.step.spec.axis == alg_chld ||
+                 n->sem.step.spec.axis == alg_attr ||
+                 n->sem.step.spec.axis == alg_self) &&
                 find_guide_max (n->sem.step.guide_count,
                                 n->sem.step.guides) <= 1)
                 copy (n->prop->keys, R(n)->prop->keys);
             if (with_guide_info &&
                 PFprop_level_right (n->prop, n->sem.step.item) >= 0 &&
-                (n->sem.step.axis == alg_desc ||
-                 n->sem.step.axis == alg_desc_s) &&
+                (n->sem.step.spec.axis == alg_desc ||
+                 n->sem.step.spec.axis == alg_desc_s) &&
                 PFprop_guide_count (R(n)->prop, n->sem.step.item) &&
                 find_guide_max_rec (
                     n->sem.step.guide_count,
@@ -589,21 +581,22 @@
                 copy (n->prop->keys, R(n)->prop->keys);
         case la_step_join:
             if ((key_worker (R(n)->prop->keys, n->sem.step.item) &&
-                 (n->sem.step.axis == alg_attr ||
-                  n->sem.step.axis == alg_chld ||
-                  n->sem.step.axis == alg_self)) ||
+                 (n->sem.step.spec.axis == alg_attr ||
+                  n->sem.step.spec.axis == alg_chld ||
+                  n->sem.step.spec.axis == alg_self)) ||
                 (PFprop_level_right (n->prop, n->sem.step.item) >= 0 &&
                  key_worker (R(n)->prop->keys, n->sem.step.item) &&
-                 (n->sem.step.axis == alg_desc ||
-                  n->sem.step.axis == alg_desc_s))) {
+                 (n->sem.step.spec.axis == alg_desc ||
+                  n->sem.step.spec.axis == alg_desc_s))) {
                 union_ (n->prop->keys, n->sem.step.item_res);
             }
 
             /* if attribute step is only a 'filter' (at most a single
                attribute for each context node) we can copy all keys */
-            if (n->sem.step.axis == alg_attr &&
-                ! (PFQNAME_NS_WILDCARD (n->sem.step.ty.name)
-                   || PFQNAME_LOC_WILDCARD (n->sem.step.ty.name)) &&
+            if (n->sem.step.spec.axis == alg_attr &&
+                n->sem.step.spec.kind == node_kind_attr &&
+                ! (PFQNAME_NS_WILDCARD (n->sem.step.spec.qname)
+                   || PFQNAME_LOC_WILDCARD (n->sem.step.spec.qname)) &&
                 PFprop_key (R(n)->prop, n->sem.step.item))
                 copy (n->prop->keys, R(n)->prop->keys);
 

Index: prop_guide.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_guide.c,v
retrieving revision 1.19.4.1
retrieving revision 1.19.4.2
diff -u -d -r1.19.4.1 -r1.19.4.2
--- prop_guide.c        9 Feb 2008 08:40:27 -0000       1.19.4.1
+++ prop_guide.c        18 Feb 2008 16:57:21 -0000      1.19.4.2
@@ -37,12 +37,11 @@
 
 #include "properties.h"
 #include "alg_dag.h"
-#include "subtyping.h"
+
+/* Easily access subtree-parts */
+#include "child_mnemonic.h"
 
 #define SEEN(n) ((n)->bit_dag)
-/* left and right child*/
-#define L(n) ((n)->child[0])
-#define R(n) ((n)->child[1])
 /* prop of n */
 #define PROP(n) ((n)->prop)
 /* guide_mapping_list of n */
@@ -53,78 +52,6 @@
     { .prefix = "",
       .uri    = "" };
 
-/* get the corresponding PFguide_mapping_t element from @a guide_mapping_list
- * where the columns are equal */
-static PFguide_mapping_t *get_guide_mapping(PFarray_t *guide_mapping_list,
-        PFalg_att_t column);
-
-/* Copy @a guide_mapping element */
-static PFguide_mapping_t *copy_guide_mapping(
-        PFguide_mapping_t *guide_mapping);
-
-/* Deep copy of @a guide_mapping_list */
-static PFarray_t *deep_copy_guide_mapping_list(
-        PFarray_t *guide_mapping_list);
-
-/* the elements of @a list2 will be copied in @a list1  */
-static PFarray_t *merge_guide_mapping_list(PFarray_t *list1, PFarray_t *list2);
-
-/* Create a PFty_t from a guide element */
-static PFty_t  create_PFty_t(PFguide_tree_t *n);
-
-/* Returns all ancestor of @a n */
-static PFarray_t *getAncestorFromGuide(PFguide_tree_t *n, PFty_t type);
-
-/* Get recursive all descendant elements */
-static PFarray_t *getDescendantFromGuideRec(PFguide_tree_t *n, PFty_t type,
-    PFarray_t *descendant);
-
-/* Returns all descendant of @a n if they are a suptype of @a type */
-static PFarray_t *getDescendantFromGuide(PFguide_tree_t *n, PFty_t type);
-
-/* copy guide nodes from left child guide_mapping_list to @a n */
-static void copyL(PFla_op_t *n);
-
-/* copy guide nodes from right child guide_mapping_list to @a n */
-static void copyR(PFla_op_t *n);
-
-/* copy guide nodes from left and right child guide_mapping_list to @a n */
-static void copyLR(PFla_op_t *n);
-
-/* add a PFguide_mapping_t to a @guide_mapping_list  if the @a column
- * do not exist, otherwise it will be added only @a guide in the
- * corresponding PFguide_mapping_t in @guide_mapping_list */
-static PFarray_t* add_guide(PFarray_t *guide_mapping_list,
-        PFguide_tree_t  *guide, PFalg_att_t column);
-
-/* initialize the guide property in @a n */
-static void copy_doc_tbl(PFla_op_t *n, PFguide_tree_t *guide);
-
-/* Copy guides for the project operator */
-static void copy_project(PFla_op_t *n);
-
-/* Remove duplicate guides from array */
-static void remove_duplicate(PFla_op_t *n);
-
-/* Copy guides for the step operator*/
-static void copy_step(PFla_op_t *n);
-
-/* copy all guides from @a n->sem.step.guides to @a n->prop->guide_list */
-static void copy_guide_step(PFla_op_t *n);
-
-/* Copy guides for the step operator*/
-static void copy_step_join(PFla_op_t *n);
-
-/* Union between left and right child guide nodes */
-static void copy_disunion(PFla_op_t  *n);
-
-/* Intersect between left and right child guide nodes */
-static void copy_intersect(PFla_op_t  *n);
-
-/* Infer domain properties; worker for prop_infer(). */
-static void infer_guide(PFla_op_t *n, PFguide_tree_t *guide);
-
-
 /* ++++++++++++++++++++++++++++++++++++ */
 
 /* get the corresponding PFguide_mapping_t element from @a guide_mapping_list
@@ -229,94 +156,90 @@
     return list1;
 }
 
-/* Create a PFty_t type from a guide node */
-static PFty_t
-create_PFty_t(PFguide_tree_t *n)
+/* Apply kind and name test */
+static bool
+node_test (PFguide_tree_t *n, PFalg_step_spec_t spec)
 {
-
     assert(n);
 
-    PFty_t  ret;
-    switch(n->kind) {
-        case(elem):
-            ret = PFty_elem(PFqname(PFns_guide, n->tag_name),
-                PFty_xs_anyType());
-            break;
-        case(attr):
-            ret = PFty_attr(PFqname(PFns_guide, n->tag_name),
-                PFty_star(PFty_atomic()));
-            break;
-        case(text):
-            ret = PFty_text();
-            break;
-        case(comm):
-            ret = PFty_comm();
-            break;
-        case(pi):
-            ret = PFty_pi(NULL);
-            break;
-        case(doc):
-            ret = PFty_doc(PFty_xs_anyNode());
+    switch (spec.kind) {
+        case node_kind_node:
+            return n->kind != attr;
+        case node_kind_doc:
+            return n->kind == doc;
+        case node_kind_elem:
+            return n->kind == elem &&
+                   !PFqname_eq (spec.qname,
+                                PFqname(PFns_guide, n->tag_name));
+        case node_kind_attr:
+            return n->kind == attr &&
+                   !PFqname_eq (spec.qname,
+                                PFqname(PFns_guide, n->tag_name));
+        case node_kind_text:
+            return n->kind == text;
+        case node_kind_comm:
+            return n->kind == comm;
+        case node_kind_pi:
+            return n->kind == pi &&
+                   !PFqname_eq (spec.qname,
+                                PFqname(PFns_wild, NULL));
     }
-    return ret;
+    return false;
 }
 
 /* return the ancestors of @a n */
 static PFarray_t *
-getAncestorFromGuide(PFguide_tree_t *n, PFty_t type)
+getAncestorFromGuide (PFguide_tree_t *n, PFalg_step_spec_t spec)
 {
     assert(n);
 
-    PFarray_t  *parents = PFarray(sizeof(PFguide_tree_t**));
-    PFguide_tree_t  *node = n->parent;
+    PFarray_t      *ancestors = PFarray(sizeof(PFguide_tree_t**));
+    PFguide_tree_t *node      = n->parent;
 
     /* compute ancestors */
-    while(node != NULL) {
-         if(PFty_subtype(create_PFty_t(node), type)) {
-            *(PFguide_tree_t**) PFarray_add(parents) = node;
-        }
+    while (node != NULL) {
+        if (node_test (node, spec))
+            *(PFguide_tree_t**) PFarray_add (ancestors) = node;
         node = node->parent;
     }
 
-    return parents;
+    return ancestors;
 }
 
-/* Get recursive all descendant elements that are subtypes
- * of @type */
-static PFarray_t *
-getDescendantFromGuideRec(PFguide_tree_t *n, PFty_t type,
-    PFarray_t *descendant)
+/* Use recursion to collect all descendants */
+static void
+getDescendantFromGuideRec (PFguide_tree_t *n, PFalg_step_spec_t spec,
+                           PFarray_t *descendants)
 {
-    if(n == NULL)
-        return NULL;
+    if (n == NULL)
+        return;
 
-    PFarray_t  *childs = n->child_list; /* all childs of n */
-    PFguide_tree_t  *element = NULL;    /* one child element */
-    if(childs == NULL)
-        return NULL;
+    PFarray_t       *children = n->child_list; /* all children of n */
+    PFguide_tree_t  *element  = NULL;          /* one child element */
 
-    /* loop over all child element of @a n */
-    for(unsigned int i = 0; i < PFarray_last(childs); i++) {
-        element = *((PFguide_tree_t**) PFarray_at(childs, i));
-        /* get recursive all descendant element */
-        getDescendantFromGuideRec(element, type, descendant);
-        /* add element if it is a subtype of @a type*/
-        if(PFty_subtype(create_PFty_t(element),type)) {
-            *((PFguide_tree_t**) PFarray_add(descendant)) = element;
+    if (children == NULL)
+        return;
+
+    /* loop over all children elements of @a n */
+    for (unsigned int i = 0; i < PFarray_last (children); i++) {
+        element = *((PFguide_tree_t**) PFarray_at (children, i));
+        /* recursively get all descendants */
+        getDescendantFromGuideRec (element, spec, descendants);
+
+        /* add node if the node test succeeds */
+        if (node_test (element, spec)) {
+            *((PFguide_tree_t**) PFarray_add(descendants)) = element;
         }
     }
-
-    return descendant;
 }
 
 /* Returns all descendant of @a n if they are a suptype of @a type */
 static PFarray_t *
-getDescendantFromGuide(PFguide_tree_t *n, PFty_t type)
+getDescendantFromGuide(PFguide_tree_t *n, PFalg_step_spec_t spec)
 {
-    PFarray_t  *descendant =  PFarray(sizeof(PFguide_tree_t**));
-
-    PFarray_t *ret =  getDescendantFromGuideRec(n, type, descendant);
-    return ret;
+    PFarray_t *descendant = PFarray (sizeof (PFguide_tree_t **));
+    getDescendantFromGuideRec (n, spec, descendant);
+    return descendant;
 }
 
 /* copy guide nodes from left and right child guide_mapping_list to @a n */
@@ -328,7 +251,7 @@
     assert(L(n));
     assert(PROP(L(n)));
 
-    /* Deep copy of left childs guide_mapping_list */
+    /* Deep copy of left children guide_mapping_list */
     MAPPING_LIST(n) = deep_copy_guide_mapping_list(MAPPING_LIST(L(n)));
 
     return;
@@ -343,7 +266,7 @@
     assert(R(n));
     assert(PROP(R(n)));
 
-    /* Deep copy of right childs guide_mapping_list */
+    /* Deep copy of right children guide_mapping_list */
     MAPPING_LIST(n) = deep_copy_guide_mapping_list(MAPPING_LIST(R(n)));
 
     return;
@@ -550,7 +473,7 @@
     assert(R(n));
     assert(PROP(R(n)));
 
-    PFalg_axis_t  axis = n->sem.step.axis; /* axis step */
+    PFalg_axis_t  axis = n->sem.step.spec.axis; /* axis step */
     PFarray_t *guide_mapping_list = MAPPING_LIST(R(n));
 
     PFalg_att_t column_in = n->sem.step.item,  /* input column */
@@ -560,7 +483,7 @@
     PFarray_t *guide_list = NULL;
     PFguide_tree_t  *element = NULL, *element2 = NULL, *child_element = NULL;
     PFarray_t       *new_guide_mapping_list = NULL;   /* return array */
-    PFarray_t       *childs = NULL; /* childs of guide nodes */
+    PFarray_t       *children = NULL; /* children of guide nodes */
     PFarray_t       *help_array = NULL;
 
     /* delete guide for axis following/preceding
@@ -592,15 +515,13 @@
         return;
     }
 
-    /* if axis is NOT the attribute axis, but the ty is ty_attr
-     * the guides will be emty */
-    if(axis != alg_attr) {
-        if(n->sem.step.ty.type == ty_attr) {
-            new_guide_mapping_list = add_guide(new_guide_mapping_list,
-                    child_element, column_out);
-            MAPPING_LIST(n) = new_guide_mapping_list;
-            return;
-        }
+    /* if axis is NOT the attribute axis, but the kind is attribute
+       the guides will be empty */
+    if (axis != alg_attr && n->sem.step.spec.kind == node_kind_attr) {
+        new_guide_mapping_list = add_guide(new_guide_mapping_list,
+                child_element, column_out);
+        MAPPING_LIST(n) = new_guide_mapping_list;
+        return;
     }
     switch(axis) {
         case(alg_chld):
@@ -608,17 +529,18 @@
             /* child step for all guide nodes */
             for(unsigned int i = 0; i < PFarray_last(guide_list); i++) {
                 element = *((PFguide_tree_t**) PFarray_at(guide_list, i));
-                childs = element->child_list;
-                if(childs == NULL)
+                children = element->child_list;
+                if(children == NULL)
                     continue;
-                /* subtype check for all childs */
-                for(unsigned int j = 0; j < PFarray_last(childs); j++) {
-                    child_element= *((PFguide_tree_t**) PFarray_at(childs,j));
-                    if(PFty_subtype(
-                            create_PFty_t(child_element),
-                            n->sem.step.ty)) {
+                /* apply node test for all children */
+                for(unsigned int j = 0; j < PFarray_last(children); j++) {
+                    child_element= *((PFguide_tree_t**) 
PFarray_at(children,j));
+                    if (node_test (child_element, n->sem.step.spec)) {
                         /* add child */
-                        new_guide_mapping_list = 
add_guide(new_guide_mapping_list, child_element, column_out);
+                        new_guide_mapping_list = add_guide(
+                                                     new_guide_mapping_list,
+                                                     child_element,
+                                                     column_out);
                     }
                 }
             }
@@ -629,11 +551,13 @@
 
             for(unsigned int i = 0; i < PFarray_last(guide_list); i++) {
                 element = *((PFguide_tree_t**) PFarray_at(guide_list, i));
-                /* subtype check for all childs */
-                if(PFty_subtype(create_PFty_t(element),
-                        n->sem.step.ty)) {
+                /* apply node test for all children */
+                if (node_test (element, n->sem.step.spec)) {
                     /* add guide nodes to return array */
-                    new_guide_mapping_list = add_guide(new_guide_mapping_list, 
element, column_out);
+                    new_guide_mapping_list = add_guide(
+                                                new_guide_mapping_list,
+                                                element,
+                                                column_out);
                 }
             }
             break;
@@ -642,11 +566,13 @@
         /* ancestor-or-self axis */
             for(unsigned int i = 0; i < PFarray_last(guide_list); i++) {
                 element = *((PFguide_tree_t**) PFarray_at(guide_list, i));
-                /* subtype check for all childs */
-                if(PFty_subtype(create_PFty_t(element),
-                        n->sem.step.ty)) {
+                /* apply node test for all children */
+                if (node_test (element, n->sem.step.spec)) {
                     /* add guide nodes to return array */
-                    new_guide_mapping_list = add_guide(new_guide_mapping_list, 
element, column_out);
+                    new_guide_mapping_list = add_guide(
+                                                 new_guide_mapping_list,
+                                                 element,
+                                                 column_out);
                 }
             }
             /* NO BREAK! */
@@ -655,16 +581,15 @@
             for(unsigned int i = 0; i < PFarray_last(guide_list); i++) {
                 /* find all ancestor */
                 element = *((PFguide_tree_t**) PFarray_at(guide_list, i));
-                help_array = getAncestorFromGuide(element, n->sem.step.ty);
-                if(help_array == NULL)
-                    continue;
+                help_array = getAncestorFromGuide (element, n->sem.step.spec);
+                assert (help_array);
                 /* add ancestor to return array */
-                for(unsigned int k = 0; k < PFarray_last(help_array); k++) {
-                    element2= *((PFguide_tree_t**) PFarray_at(help_array, k));
-                    if(PFty_subtype(create_PFty_t(element2),
-                            n->sem.step.ty)) {
-                        new_guide_mapping_list = 
add_guide(new_guide_mapping_list, element2, column_out);
-                    }
+                for (unsigned int k = 0; k < PFarray_last (help_array); k++) {
+                    element2 = *((PFguide_tree_t**) PFarray_at (help_array, 
k));
+                    new_guide_mapping_list = add_guide(
+                                                 new_guide_mapping_list,
+                                                 element2,
+                                                 column_out);
                 }
             }
             break;
@@ -674,11 +599,12 @@
                 element = *((PFguide_tree_t**) PFarray_at(guide_list, i));
                 if(element->parent == NULL)
                     break;
-                if(PFty_subtype(create_PFty_t(element->parent),
-                            n->sem.step.ty)) {
+                if (node_test (element->parent, n->sem.step.spec)) {
                     /* add guide nodes to return array */
-                    new_guide_mapping_list = add_guide(new_guide_mapping_list, 
element->parent,
-                            column_out);
+                    new_guide_mapping_list = add_guide(
+                                                 new_guide_mapping_list,
+                                                 element->parent,
+                                                 column_out);
                 }
             }
             break;
@@ -686,10 +612,12 @@
         /* descendant-or-self axis */
             for(unsigned int i = 0; i < PFarray_last(guide_list); i++) {
                 element = *((PFguide_tree_t**) PFarray_at(guide_list, i));
-                if(PFty_subtype(create_PFty_t(element),
-                        n->sem.step.ty)) {
+                if (node_test (element, n->sem.step.spec)) {
                     /* add guide nodes to return array */
-                    new_guide_mapping_list = add_guide(new_guide_mapping_list, 
element, column_out);
+                    new_guide_mapping_list = add_guide(
+                                                 new_guide_mapping_list,
+                                                 element,
+                                                 column_out);
                 }
             }
             /* NO BREAK! */
@@ -697,16 +625,15 @@
         /* descendant axis */
             for(unsigned int i = 0; i < PFarray_last(guide_list); i++) {
                 element = *((PFguide_tree_t**) PFarray_at(guide_list, i));
-                help_array = getDescendantFromGuide(element,n->sem.step.ty);
-                if(help_array == NULL)
-                    continue;
+                help_array = getDescendantFromGuide (element, 
n->sem.step.spec);
+                assert (help_array);
                 /* add descendant to return array */
-                for(unsigned int k = 0; k < PFarray_last(help_array); k++) {
-                    element2= *((PFguide_tree_t**) PFarray_at(help_array, k));
-                    if(PFty_promotable(create_PFty_t(element2),
-                            n->sem.step.ty)) {
-                        new_guide_mapping_list = 
add_guide(new_guide_mapping_list, element2, column_out);
-                    }
+                for (unsigned int k = 0; k < PFarray_last (help_array); k++) {
+                    element2 = *((PFguide_tree_t**) PFarray_at (help_array, 
k));
+                    new_guide_mapping_list = add_guide(
+                                                 new_guide_mapping_list,
+                                                 element2,
+                                                 column_out);
                 }
             }
             break;
@@ -714,18 +641,18 @@
         /* attribute axis */
             for(unsigned int i = 0; i < PFarray_last(guide_list); i++) {
                 element = *((PFguide_tree_t**) PFarray_at(guide_list, i));
-                childs = element->child_list;
-                if(childs == NULL)
+                children = element->child_list;
+                if(children == NULL)
                     continue;
-                /* subtype check for all childs */
-                for(unsigned int j = 0; j < PFarray_last(childs); j++) {
-                    child_element= *((PFguide_tree_t**) PFarray_at(childs,j));
-                    if(PFty_subtype(
-                            create_PFty_t(child_element),
-                            n->sem.step.ty)) {
+                /* apply node test for all children */
+                for(unsigned int j = 0; j < PFarray_last(children); j++) {
+                    child_element= *((PFguide_tree_t**) 
PFarray_at(children,j));
+                    if (node_test (child_element, n->sem.step.spec)) {
                         /* add guide nodes to return array */
                         new_guide_mapping_list = add_guide(
-                        new_guide_mapping_list, child_element, column_out);
+                                                     new_guide_mapping_list,
+                                                     child_element,
+                                                     column_out);
                     }
                 }
             }
@@ -852,7 +779,7 @@
     assert(R(n));
     assert(PROP(R(n)));
 
-    /* Deep copy of right childs guide_mapping_list */
+    /* Deep copy of right children guide_mapping_list */
     PFarray_t *right_guide_mapping_list =
             deep_copy_guide_mapping_list(MAPPING_LIST(R(n)));
 

Index: prop_ori_names.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_ori_names.c,v
retrieving revision 1.27.4.1
retrieving revision 1.27.4.2
diff -u -d -r1.27.4.1 -r1.27.4.2
--- prop_ori_names.c    9 Feb 2008 08:40:27 -0000       1.27.4.1
+++ prop_ori_names.c    18 Feb 2008 16:57:23 -0000      1.27.4.2
@@ -50,13 +50,8 @@
 #include "oops.h"
 #include "mem.h"
 
-/*
- * Easily access subtree-parts.
- */
-/** starting from p, make a step left */
-#define L(p) ((p)->child[0])
-/** starting from p, make a step right */
-#define R(p) ((p)->child[1])
+/* Easily access subtree-parts */
+#include "child_mnemonic.h"
 
 /* reuse the icols field to maintain the bitlist of free variables */
 #define FREE(n) ((n)->prop->l_icols)

Index: prop_card.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_card.c,v
retrieving revision 1.31
retrieving revision 1.31.4.1
diff -u -d -r1.31 -r1.31.4.1
--- prop_card.c 11 Jan 2008 10:46:59 -0000      1.31
+++ prop_card.c 18 Feb 2008 16:57:20 -0000      1.31.4.1
@@ -38,13 +38,8 @@
 #include "oops.h"
 #include "mem.h"
 
-/*
- * Easily access subtree-parts.
- */
-/** starting from p, make a step left */
-#define L(p) ((p)->child[0])
-/** starting from p, make a step right */
-#define R(p) ((p)->child[1])
+/* Easily access subtree-parts */
+#include "child_mnemonic.h"
 
 /**
  * Return cardinality stored in property container @a prop.

Index: prop_composite_key.c
===================================================================
RCS file: 
/cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_composite_key.c,v
retrieving revision 1.11.4.1
retrieving revision 1.11.4.2
diff -u -d -r1.11.4.1 -r1.11.4.2
--- prop_composite_key.c        9 Feb 2008 08:40:26 -0000       1.11.4.1
+++ prop_composite_key.c        18 Feb 2008 16:57:20 -0000      1.11.4.2
@@ -39,17 +39,8 @@
 #include "mem.h"
 #include "qname.h"
 
-/*
- * Easily access subtree-parts.
- */
-/** starting from p, make a step left */
-#define L(p) ((p)->child[0])
-/** starting from p, make a step right */
-#define R(p) ((p)->child[1])
-/** starting from p, make two steps left */
-#define LL(p) (L(L(p)))
-/** starting from p, make a step left, then a step right */
-#define LR(p) R(L(p))
+/* Easily access subtree-parts */
+#include "child_mnemonic.h"
 
 /**
  * worker for PFprop_ckey;
@@ -615,7 +606,7 @@
 
         case la_step:
         case la_guide_step:
-            if (n->sem.step.axis == alg_chld &&
+            if (n->sem.step.spec.axis == alg_chld &&
                 PFprop_key (R(n)->prop, n->sem.step.iter) &&
                 PFprop_key (R(n)->prop, n->sem.step.item))
                 union_ (n->prop->ckeys, n->sem.step.item_res);

Index: prop_dom.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_dom.c,v
retrieving revision 1.47.4.1
retrieving revision 1.47.4.2
diff -u -d -r1.47.4.1 -r1.47.4.2
--- prop_dom.c  9 Feb 2008 08:40:27 -0000       1.47.4.1
+++ prop_dom.c  18 Feb 2008 16:57:20 -0000      1.47.4.2
@@ -48,15 +48,8 @@
 #include "oops.h"
 #include "mem.h"
 
-/*
- * Easily access subtree-parts.
- */
-/** starting from p, make a step left */
-#define L(p) ((p)->child[0])
-/** starting from p, make a step right */
-#define R(p) ((p)->child[1])
-/** starting from p, make a step right, then a step left */
-#define RL(p) L(R(p))
+/* Easily access subtree-parts */
+#include "child_mnemonic.h"
 
 /** Identifier for the (statically known) empty domain */
 #define EMPTYDOM 1
@@ -951,9 +944,9 @@
             break;
 
         case la_guide_step:
-            if ((n->sem.step.axis == alg_chld ||
-                 n->sem.step.axis == alg_attr ||
-                 n->sem.step.axis == alg_self) &&
+            if ((n->sem.step.spec.axis == alg_chld ||
+                 n->sem.step.spec.axis == alg_attr ||
+                 n->sem.step.spec.axis == alg_self) &&
                 find_guide_min (n->sem.step.guide_count,
                                 n->sem.step.guides) > 0)
                 add_dom (n->prop,
@@ -979,9 +972,9 @@
             break;
 
         case la_guide_step_join:
-            if ((n->sem.step.axis == alg_chld ||
-                 n->sem.step.axis == alg_attr ||
-                 n->sem.step.axis == alg_self) &&
+            if ((n->sem.step.spec.axis == alg_chld ||
+                 n->sem.step.spec.axis == alg_attr ||
+                 n->sem.step.spec.axis == alg_self) &&
                 find_guide_min (n->sem.step.guide_count,
                                 n->sem.step.guides) > 0)
                 bulk_add_dom (n->prop, R(n));


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins

Reply via email to