Markos Zaharioudakis has proposed merging lp:~zorba-coders/zorba/markos-scratch 
into lp:zorba.

Requested reviews:
  Markos Zaharioudakis (markos-za)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/95897

fixed bug #944002
-- 
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/95897
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/compiler/rewriter/rules/nodeid_rules.cpp'
--- src/compiler/rewriter/rules/nodeid_rules.cpp	2012-03-02 11:42:36 +0000
+++ src/compiler/rewriter/rules/nodeid_rules.cpp	2012-03-05 13:33:22 +0000
@@ -605,6 +605,9 @@
 }
 
 
+/*******************************************************************************
+
+********************************************************************************/
 void MarkNodeCopyProps::applyInternal(
     RewriterContext& rCtx,
     expr* node,
@@ -966,15 +969,13 @@
 }
 
 
+/*******************************************************************************
+
+********************************************************************************/
 void MarkNodeCopyProps::markSources(
     const std::vector<expr*>& sources,
     UDFCallChain& udfCaller)
 {
-  user_function* udf = NULL;
-
-  if (udfCaller.theFo)
-    udf = static_cast<user_function*>(udfCaller.theFo->get_func());
-
   std::vector<expr*>::const_iterator ite = sources.begin();
   std::vector<expr*>::const_iterator end = sources.end();
   for (; ite != end; ++ite)
@@ -989,9 +990,6 @@
       if (!e->copyInputNodes())
       {
         e->setCopyInputNodes();
-
-        if (udf)
-          udf->invalidatePlan();
       }
       break;
     }
@@ -1001,9 +999,6 @@
       if (!e->copyInputNodes())
       {
         e->setCopyInputNodes();
-
-        if (udf)
-          udf->invalidatePlan();
       }
       break;
     }

=== modified file 'src/compiler/rewriter/tools/dataflow_annotations.cpp'
--- src/compiler/rewriter/tools/dataflow_annotations.cpp	2012-01-15 09:18:22 +0000
+++ src/compiler/rewriter/tools/dataflow_annotations.cpp	2012-03-05 13:33:22 +0000
@@ -813,6 +813,11 @@
     UDFCallChain* udfCaller,
     std::vector<expr*>& sources)
 {
+  theStartingUdf = NULL;
+
+  if (udfCaller->theFo)
+    theStartingUdf = static_cast<user_function*>(udfCaller->theFo->get_func());
+
   findNodeSourcesRec(node, sources, NULL);
 
   for (csize i = 0; i < sources.size(); ++i)
@@ -847,11 +852,19 @@
     {
       ZORBA_ASSERT(source->get_expr_kind() == doc_expr_kind ||
                    source->get_expr_kind() == elem_expr_kind);
+
+      user_function* udf = theSourceUdfMap.find(source)->second;
+
+      if (udf)
+        udf->invalidatePlan();
     }
   }
 }
 
 
+/*******************************************************************************
+
+********************************************************************************/
 void SourceFinder::findNodeSourcesRec(
     expr* node,
     std::vector<expr*>& sources,
@@ -1014,8 +1027,13 @@
   case elem_expr_kind:
   {
     if (std::find(sources.begin(), sources.end(), node) == sources.end())
+    {
       sources.push_back(node);
 
+      theSourceUdfMap.
+      insert(SourceUdfMapPair(node, (currentUdf ? currentUdf : theStartingUdf)));
+    }
+
     std::vector<expr*> enclosedExprs;
     node->get_fo_exprs_of_kind(FunctionConsts::OP_ENCLOSED_1, false, enclosedExprs);
 

=== modified file 'src/compiler/rewriter/tools/dataflow_annotations.h'
--- src/compiler/rewriter/tools/dataflow_annotations.h	2012-01-15 09:18:22 +0000
+++ src/compiler/rewriter/tools/dataflow_annotations.h	2012-03-05 13:33:22 +0000
@@ -25,7 +25,9 @@
 class UDFCallChain;
 
 
+/*******************************************************************************
 
+********************************************************************************/
 class DataflowAnnotationsComputer 
 {
 public:
@@ -69,6 +71,9 @@
 };
 
 
+/*******************************************************************************
+
+********************************************************************************/
 class SourceFinder
 {
   friend class MarkNodeCopyProps;
@@ -79,9 +84,15 @@
   typedef std::map<user_function*, std::vector<expr*>* > UdfSourcesMap;
   typedef std::pair<user_function*, std::vector<expr*>* > UdfSourcesPair;
 
+  typedef std::map<expr*, user_function*> SourceUdfMap;
+  typedef std::pair<expr*, user_function*> SourceUdfMapPair;
+
 protected:
   VarSourcesMap                theVarSourcesMap;
   UdfSourcesMap                theUdfSourcesMap;
+  SourceUdfMap                 theSourceUdfMap;
+
+  user_function              * theStartingUdf;
   std::vector<fo_expr*>        theUdfCallPath;
 
 protected:

=== modified file 'src/functions/udf.cpp'
--- src/functions/udf.cpp	2012-03-02 11:42:36 +0000
+++ src/functions/udf.cpp	2012-03-05 13:33:22 +0000
@@ -324,6 +324,7 @@
 void user_function::invalidatePlan() 
 {
   thePlan = NULL;
+  theArgVarsRefs.clear();
 }
 
 

=== added file 'test/rbkt/ExpQueryResults/zorba/eval/eval13.xml.res'
--- test/rbkt/ExpQueryResults/zorba/eval/eval13.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/eval/eval13.xml.res	2012-03-05 13:33:22 +0000
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<root><a><b><c/></b></a></root><root><a><b><c/></b></a></root><a><b><c/></b></a><b><c/></b>

=== added file 'test/rbkt/Queries/zorba/eval/eval13.xq'
--- test/rbkt/Queries/zorba/eval/eval13.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/eval/eval13.xq	2012-03-05 13:33:22 +0000
@@ -0,0 +1,34 @@
+import module namespace refl = "http://www.zorba-xquery.com/modules/reflection";;
+
+
+declare function local:dummy($n as node())
+{
+};
+
+
+declare function local:foo($n as node()) as node()*
+{
+  local:dummy($n),
+  $n/ancestor::node()
+};
+
+
+declare function local:constr($n as node()) as node()*
+{
+  local:dummy($n),
+  <root>{$n}</root>
+};
+
+
+declare variable $doc :=
+<a>
+  <b>
+    <c/>
+  </b>
+</a>
+;
+
+
+local:constr($doc)
+,
+refl:eval("local:foo(local:constr($doc)//c)")

=== modified file 'test/rbkt/testdriver.cpp'
--- test/rbkt/testdriver.cpp	2012-03-02 11:42:36 +0000
+++ test/rbkt/testdriver.cpp	2012-03-05 13:33:22 +0000
@@ -26,7 +26,7 @@
 #include <time.h>
 #endif
 
-#define ZORBA_TEST_PLAN_SERIALIZATION
+//#define ZORBA_TEST_PLAN_SERIALIZATION
 
 #include "testdriverconfig.h" // SRC and BIN dir definitions
 #include "specification.h" // parsing spec files

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to