Update of /cvsroot/monetdb/pathfinder/compiler/core
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv23023/compiler/core

Modified Files:
      Tag: PF_ROX
        coreopt.brg 
Log Message:
propagated changes of Wednesday Jan 30 2008 - Saturday Feb 09 2008
from the development trunk to the PF_ROX branch


Index: coreopt.brg
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/core/coreopt.brg,v
retrieving revision 1.56
retrieving revision 1.56.2.1
diff -u -d -r1.56 -r1.56.2.1
--- coreopt.brg 22 Jan 2008 14:40:24 -0000      1.56
+++ coreopt.brg 9 Feb 2008 08:40:28 -0000       1.56.2.1
@@ -392,6 +392,7 @@
 /* ... and so on ... */
 #define LRL(p) L(R(L(p)))
 #define RRL(p) L(R(R(p)))
+#define RRR(p) R(R(R(p)))
 #define RRRL(p) L(R(R(R(p))))
 #define RRRRL(p) L(R(R(R(R(p)))))
 #define RRRRRL(p) L(R(R(R(R(R(p))))))
@@ -400,8 +401,10 @@
 #define LLR(p) R(L(L(p)))
 #define LRR(p) R(R(L(p)))
 #define LLLL(p) L(L(L(L(p))))
-#define LRLL(p) L(L(R(L(p))))
+#define LLLR(p) R(L(L(L(p))))
 #define LLRL(p) L(R(L(L(p))))
+#define LRLL(p) L(L(R(L(p))))
+#define RLLL(p) L(L(L(R(p))))
 #define LRLR(p) R(L(R(L(p))))
 #define LLRR(p) R(R(L(L(p))))
 #define RLR(p) R(L(R(p)))
@@ -614,24 +617,24 @@
 
                 PFcnode_t *c = R(p);
 
-                if (LLR(p)->kind != c_nil) {
+                if (LLR(p)->kind != c_nil)
                     c = let (letbind (LLR(p), num (1)), c);
 
-                    /* fix types */
-                    TY(LR(c)) = PFty_xs_integer ();
-                    c->sem.flwr.quantifier = PFty_one;
-                }
-
                 *p = *let (letbind (LLL(p), LR(p)), c);
-                /* type let binding */
-                p->sem.flwr.quantifier = PFty_one;
 
-                relabel (p, kids);
+                /* type-check what we just created */
+                PFty_check (flwr (p, num(1)));
+
                 rewritten = true;
 
+                /*
+                 * Re-label entire subtree. Type-checking may have
+                 * modified all the state labels in the subtree, so
+                 * we have to restore them.
+                 */
+                PFcoreopt_label (p);
                 break;
             }
-
             break;
 
         /* OptBindExpr:        let (letbind (var,
@@ -659,14 +662,18 @@
             if (RLR(p)->kind == c_orderby)
                 RLR(p) = R(RLR(p));
     
-            /* type let binding */
-            p->sem.flwr.quantifier    = 
-            R(p)->sem.flwr.quantifier = RR(p)->sem.flwr.quantifier;
+            /* type-check what we just created */
+            PFty_check (flwr (p, num(1)));
 
-            relabel (p, kids);
             rewritten = true;
-            break;
 
+            /*
+             * Re-label entire subtree. Type-checking may have
+             * modified all the state labels in the subtree, so
+             * we have to restore them.
+             */
+            PFcoreopt_label (p);
+            break;
 
         /* OptBindExpr:        let (letbind (var,
                                              flwr (let (letbind (var, 
@@ -690,12 +697,17 @@
                                          LRR(p))),
                           R(p)));                        /*     ret e''      */
 
-            /* type let binding */
-            p->sem.flwr.quantifier    = 
-            R(p)->sem.flwr.quantifier = RR(p)->sem.flwr.quantifier;
+            /* type-check what we just created */
+            PFty_check (flwr (p, num (1)));
 
-            relabel (p, kids);
             rewritten = true;
+
+            /*
+             * Re-label entire subtree. Type-checking may have
+             * modified all the state labels in the subtree, so
+             * we have to restore them.
+             */
+            PFcoreopt_label (p);
             break;
 
         /* CoreExpr:           typesw (CoreExpr,
@@ -998,6 +1010,46 @@
                     rewritten = true;
                     break;
                 }
+                /**
+                 * try to find a positional predicate:
+                 *
+                 *                flwr
+                 *                /  \
+                 *              for   if_________
+                 *              /      \         \ 
+                 *           forbind   apply(eq) then_else
+                 *            /          \         \      \
+                 *         forvars       arg      var(a)  empty
+                 *          /   \       /   \
+                 *       var(a) var(p)      arg
+                 *                         /   \
+                 *                      var(p)   
+                 */
+                else if (LL(p)->kind == c_flwr &&
+                         L(LL(p))->kind == c_for &&
+                         LL(LL(p))->kind == c_forbind &&
+                         LLL(LL(p))->kind == c_forvars &&
+                         LLLR(LL(p))->kind == c_var &&
+                         LLLL(LL(p))->kind == c_var &&
+                         R(LL(p))->kind == c_if &&
+                         RL(LL(p))->kind == c_apply &&
+                         ! PFqname_eq (RL(LL(p))->sem.fun->qname,
+                                       PFqname (PFns_op, "eq")) &&
+                         RLL(LL(p))->kind == c_arg &&
+                         R(RLL(LL(p)))->kind == c_arg &&
+                         RL(RLL(LL(p)))->kind == c_var &&
+                         LLLR(LL(p))->sem.var == RL(RLL(LL(p)))->sem.var &&
+                         RR(LL(p))->kind == c_then_else &&
+                         RRL(LL(p))->kind == c_var &&
+                         LLLL(LL(p))->sem.var == RRL(LL(p))->sem.var &&
+                         RRR(LL(p))->kind == c_empty) {
+                    /* remove function and replace flwr type */
+                    PFty_t ty = TY(p);
+                    *p = *LL(p);
+                    TY(p) = ty;
+                    rewritten = true;
+                    break;
+                }
             }
             
             /*


-------------------------------------------------------------------------
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