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

Modified Files:
        core.c coreopt.brg fs.brg simplify.brg 
Log Message:


For sake of recognition 

-- The endless Odyssey through the pathfinder code checking
   for correct initialization of global variables (Part 3).

   This time---checking all files in folders:
    o compiler/core
    o compiler/sql


U core.c
Index: core.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/core/core.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- core.c      17 Mar 2008 17:41:21 -0000      1.61
+++ core.c      3 Apr 2008 07:26:29 -0000       1.62
@@ -158,7 +158,7 @@
  *   a three digit, zero-padded integer number
  * @return the new variable
  */
-unsigned int core_vars; /* global for core_new_var (TODO REMOVE) */
+static unsigned int core_vars; /* global for core_new_var (TODO REMOVE) */
 
 
 PFvar_t *
@@ -1717,4 +1717,11 @@
     return APPLY (PFcore_function (PFqname (PFns_fn, "boolean")), n);
 }
 
+/* initializing global variables */
+void
+PFcore_init (void)
+{
+     core_vars = 0;
+}
+
 /* vim:set shiftwidth=4 expandtab: */

U simplify.brg
Index: simplify.brg
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/core/simplify.brg,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- simplify.brg        17 Mar 2008 17:41:22 -0000      1.38
+++ simplify.brg        3 Apr 2008 07:26:31 -0000       1.39
@@ -718,6 +718,14 @@
 
 }
 
+/* initialize global  variables */
+static void
+PFsimplify_init (void)
+{
+    /* set up variable replacement environment */
+    for (unsigned short i = 0; i < HASH_BUCKETS; i++)
+        var_env[i] = PFarray (sizeof (bind_t), 128);
+}
 
 /**
  * Simplify XQuery Core tree.
@@ -730,9 +738,8 @@
 {
     assert (r);
 
-    /* set up variable replacement environment */
-    for (unsigned short i = 0; i < HASH_BUCKETS; i++)
-        var_env[i] = PFarray (sizeof (bind_t), 128);
+    /* initialize global  variables */
+    PFsimplify_init ();
 
     /* label the Core tree bottom up */
     PFsimplify_label (r);

U coreopt.brg
Index: coreopt.brg
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/core/coreopt.brg,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -d -r1.65 -r1.66
--- coreopt.brg 28 Mar 2008 16:17:19 -0000      1.65
+++ coreopt.brg 3 Apr 2008 07:26:30 -0000       1.66
@@ -1573,6 +1573,21 @@
     return base;
 }
 
+/* initialize global variables */
+static void
+PFcoreopt_init (void)
+{
+    /* set up variable replacement environment */
+    for (unsigned short i = 0; i < HASH_BUCKETS; i++)
+        var_env[i] = PFarray (sizeof (bind_t), 128);
+
+    /* set up a variable environment to record unused variables */
+    unused_var_env = PFarray (sizeof (bind_t), 128);
+    /* set up a variable environment to record variable references */
+    used_var_env = PFarray (sizeof (bind_t), HASH_BUCKETS * 128);
+}
+
+
 /**
  * Optimize Core tree, with static type information available.
  *
@@ -1587,14 +1602,8 @@
 
     assert (r);
 
-    /* set up variable replacement environment */
-    for (unsigned short i = 0; i < HASH_BUCKETS; i++)
-        var_env[i] = PFarray (sizeof (bind_t), 128);
-
-    /* set up a variable environment to record unused variables */
-    unused_var_env = PFarray (sizeof (bind_t), 128),
-    /* set up a variable environment to record variable references */
-    used_var_env = PFarray (sizeof (bind_t), HASH_BUCKETS * 128),
+    /* initialize global variables */
+    PFcoreopt_init ();
 
     /* label the Core tree bottom up */
     PFcoreopt_label (r);

U fs.brg
Index: fs.brg
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/core/fs.brg,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- fs.brg      17 Mar 2008 17:41:22 -0000      1.67
+++ fs.brg      3 Apr 2008 07:26:31 -0000       1.68
@@ -4016,19 +4016,16 @@
 }
 
 
-/**
- * Compile parse tree into XQuery Core tree.
- *
- * @param r root of the abstract syntax tree
- * @return the Core equivalent of @a r
- */
-PFcnode_t *
-PFfs (PFpnode_t *r, PFquery_t *query)
+/* initialize global values */
+void 
+PFfs_init (void)
 {
-    assert (r);
+    PFquery = NULL;
 
-    PFquery = query;
-    core_vars = 0;
+    /* initially, the context item is undefined */
+    fs_dot = NULL;
+    fs_position = NULL;
+    fs_last = NULL;
 
     /* initially, there is no function on the current function stack */
     funs = PFarray (sizeof (PFfun_t *), 20);
@@ -4039,11 +4036,6 @@
     /* initially, there nothing on the current argument number stack */
     arg_num = PFarray (sizeof (short), 20);
 
-    /* initially, the context item is undefined */
-    fs_dot = NULL;
-    fs_position = NULL;
-    fs_last = NULL;
-
     /* We collect function signatures in the query prolog here. */
     fun_sigs = nil ();
 
@@ -4051,6 +4043,23 @@
      * in a root/hole pair. */
     var_decls.root = var_decls.hole = NULL;
 
+    any = PFty_xs_anyType ();
+}
+
+/**
+ * Compile parse tree into XQuery Core tree.
+ *
+ * @param r root of the abstract syntax tree
+ * @return the Core equivalent of @a r
+ */
+PFcnode_t *
+PFfs (PFpnode_t *r, PFquery_t *query)
+{
+    assert (r);
+
+    PFfs_init ();
+    PFquery = query;
+
     /* label the parse tree bottom up */
     PFfs_label (r);
 


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins

Reply via email to