Update of /cvsroot/monetdb/pathfinder/compiler/core
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv20437/compiler/core
Modified Files:
core.c coreopt.brg
Log Message:
propagated changes of Thursday Feb 21 2008 - Friday Feb 22 2008
from the XQuery_0-22 branch to the development trunk
Index: core.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/core/core.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- core.c 11 Jan 2008 10:46:59 -0000 1.57
+++ core.c 22 Feb 2008 12:46:27 -0000 1.58
@@ -164,7 +164,7 @@
PFvar_t *
PFcore_new_var (char *prefix)
{
- char vname[VNAME_MAX];
+ char vname[VNAME_MAX+1];
int l;
/* prefix may not exceed 4 characters */
@@ -172,9 +172,9 @@
/* construct new var name */
if (prefix)
- l = snprintf (vname, VNAME_MAX, "%3s_%04u", prefix, core_vars);
+ l = snprintf (vname, sizeof(vname)-1, "%3s_%04u", prefix, core_vars);
else
- l = snprintf (vname, VNAME_MAX, "v_%04u", core_vars);
+ l = snprintf (vname, sizeof(vname)-1, "v_%04u", core_vars);
/* warn if we needed to truncate the variable name
* (this does not affect the correct core mapping but may
Index: coreopt.brg
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/core/coreopt.brg,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- coreopt.brg 15 Feb 2008 12:15:57 -0000 1.59
+++ coreopt.brg 22 Feb 2008 12:46:27 -0000 1.60
@@ -506,6 +506,7 @@
*/
*p = *R(p);
+
rewritten = true;
break;
@@ -1433,7 +1434,7 @@
store the number of references in the same nesting depth. If the
variables are referenced in a nested scope their counter is set to
-1 to indicate that the may not be rewritten. */
-static void
+static char
collect_var_usage (PFcnode_t *c, char base, PFcnode_t *parent, int child)
{
switch (c->kind) {
@@ -1464,8 +1465,8 @@
case c_flwr:
{
char old_base = base;
- collect_var_usage (L(c), base, c, 0);
- collect_var_usage (R(c), base, c, 1);
+ base = collect_var_usage (L(c), base, c, 0);
+ base = collect_var_usage (R(c), base, c, 1);
/* reset all new scopes introduced by a for loop */
base = old_base;
} break;
@@ -1473,7 +1474,7 @@
case c_let:
assert (L(c)->kind == c_letbind);
- collect_var_usage (LR(c), base, L(c), 1);
+ base = collect_var_usage (LR(c), base, L(c), 1);
/* add variable to the environment */
*((bind_t *) PFarray_add (unused_var_env))
@@ -1485,7 +1486,7 @@
/* record the current scope */
LL(c)->sem.var->base = base;
- collect_var_usage (R(c), base, c, 1);
+ base = collect_var_usage (R(c), base, c, 1);
break;
case c_for:
@@ -1493,7 +1494,7 @@
LL(c)->kind == c_forvars &&
LLL(c)->kind == c_var);
- collect_var_usage (LR(c), base, L(c), 1);
+ base = collect_var_usage (LR(c), base, L(c), 1);
/* a for loop increases the nesting depth */
base++;
@@ -1510,30 +1511,43 @@
LLR(c)->sem.var->base = base;
}
- collect_var_usage (R(c), base, c, 1);
+ base = collect_var_usage (R(c), base, c, 1);
break;
case c_main:
/* first collect global variables before
analyzing user-defined functions */
- collect_var_usage (R(c), base, c, 1);
- collect_var_usage (L(c), base, c, 0);
+ base = collect_var_usage (R(c), base, c, 1);
+ base = collect_var_usage (L(c), base, c, 0);
break;
case c_recursion:
/* ignore recursion variable */
- collect_var_usage (R(c), base, c, 1);
+ base = collect_var_usage (R(c), base, c, 1);
break;
+
+ case c_seed:
+ {
+ char old_base = base;
+ base = collect_var_usage (L(c), base, c, 0);
+ base++;
+ /* avoid that let bindings are expanded
+ into the recursion body */
+ base = collect_var_usage (R(c), base, c, 1);
+ /* reset all new scopes introduced by a for loop */
+ base = old_base;
+ } break;
case c_param:
/* ignore used-defined function variables */
- collect_var_usage (L(c), base, c, 0);
+ base = collect_var_usage (L(c), base, c, 0);
break;
default:
for (unsigned int i = 0; i < PFCNODE_MAXCHILD && c->child[i]; i++)
- collect_var_usage (c->child[i], base, c, i);
+ base = collect_var_usage (c->child[i], base, c, i);
}
+ return base;
}
/**
@@ -1583,7 +1597,7 @@
collect_var_usage (r, 0, NULL, -1);
/* remove all unused variables and expand variables
- that are referenced only once in the same nesting depth*/
+ that are referenced only once in the same nesting depth */
for (unsigned int i = PFarray_last (unused_var_env); i > 0; i--) {
var = ((bind_t *) PFarray_at (unused_var_env, i-1))->var;
p = ((bind_t *) PFarray_at (unused_var_env, i-1))->atom;
-------------------------------------------------------------------------
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