zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #05651
[Merge] lp:~zorba-coders/zorba/markos-scratch into lp:zorba
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/95512
Fixed another bug involving eval and the no-copy rule
--
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/95512
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-01 11:24:40 +0000
+++ src/compiler/rewriter/rules/nodeid_rules.cpp 2012-03-02 07:23:22 +0000
@@ -576,7 +576,7 @@
std::vector<expr*> sources;
UDFCallChain dummyUdfCaller;
theSourceFinder->findNodeSources(rCtx.theRoot, &dummyUdfCaller, sources);
- markSources(sources);
+ markSources(sources, dummyUdfCaller);
}
}
else
@@ -584,7 +584,7 @@
std::vector<expr*> sources;
UDFCallChain dummyUdfCaller;
theSourceFinder->findNodeSources(rCtx.theRoot, &dummyUdfCaller, sources);
- markSources(sources);
+ markSources(sources, dummyUdfCaller);
}
UDFCallChain dummyUdfCaller;
@@ -635,7 +635,7 @@
{
std::vector<expr*> sources;
theSourceFinder->findNodeSources((*e)[0], &udfCaller, sources);
- markSources(sources);
+ markSources(sources, udfCaller);
}
else
{
@@ -654,7 +654,7 @@
{
std::vector<expr*> sources;
theSourceFinder->findNodeSources((*e)[0], &udfCaller, sources);
- markSources(sources);
+ markSources(sources, udfCaller);
break;
}
}
@@ -718,7 +718,7 @@
{
std::vector<expr*> sources;
theSourceFinder->findNodeSources(e->get_arg(i), &udfCaller, sources);
- markSources(sources);
+ markSources(sources, udfCaller);
}
}
}
@@ -733,7 +733,7 @@
{
std::vector<expr*> sources;
theSourceFinder->findNodeSources(e->get_arg(i), &udfCaller, sources);
- markSources(sources);
+ markSources(sources, udfCaller);
}
}
}
@@ -760,7 +760,7 @@
validate_expr* e = static_cast<validate_expr *>(node);
std::vector<expr*> sources;
theSourceFinder->findNodeSources(e->get_expr(), &udfCaller, sources);
- markSources(sources);
+ markSources(sources, udfCaller);
break;
}
@@ -773,7 +773,7 @@
std::vector<expr*> sources;
theSourceFinder->findNodeSources(e->getTargetExpr(), &udfCaller, sources);
- markSources(sources);
+ markSources(sources, udfCaller);
static_context* sctx = e->get_sctx();
@@ -785,7 +785,7 @@
{
std::vector<expr*> sources;
theSourceFinder->findNodeSources(e->getSourceExpr(), &udfCaller, sources);
- markSources(sources);
+ markSources(sources, udfCaller);
}
break;
@@ -806,7 +806,7 @@
{
std::vector<expr*> sources;
theSourceFinder->findNodeSources((*ite)->getExpr(), &udfCaller, sources);
- markSources(sources);
+ markSources(sources, udfCaller);
}
}
@@ -841,7 +841,7 @@
{
std::vector<expr*> sources;
theSourceFinder->findNodeSources(child, &udfCaller, sources);
- markSources(sources);
+ markSources(sources, udfCaller);
}
else
{
@@ -875,7 +875,7 @@
std::vector<expr*> sources;
theSourceFinder->findNodeSources(arg, &udfCaller, sources);
- markSources(sources);
+ markSources(sources, udfCaller);
}
std::vector<var_expr_t> globalVars;
@@ -887,7 +887,7 @@
std::vector<expr*> sources;
theSourceFinder->findNodeSources(globalVar, &udfCaller, sources);
- markSources(sources);
+ markSources(sources, udfCaller);
}
break;
@@ -905,7 +905,7 @@
std::vector<expr*> sources;
theSourceFinder->findNodeSources(e->get_range(), &udfCaller, sources);
- markSources(sources);
+ markSources(sources, udfCaller);
break;
}
@@ -926,7 +926,7 @@
{
std::vector<expr*> sources;
theSourceFinder->findNodeSources((*ite).getp(), &udfCaller, sources);
- markSources(sources);
+ markSources(sources, udfCaller);
}
break;
@@ -966,8 +966,15 @@
}
-void MarkNodeCopyProps::markSources(const std::vector<expr*>& sources)
+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)
@@ -979,13 +986,25 @@
case doc_expr_kind:
{
doc_expr* e = static_cast<doc_expr*>(source);
- e->setCopyInputNodes();
+ if (!e->copyInputNodes())
+ {
+ e->setCopyInputNodes();
+
+ if (udf && udf->getBody() != NULL)
+ udf->setBody(NULL);
+ }
break;
}
case elem_expr_kind:
{
elem_expr* e = static_cast<elem_expr*>(source);
- e->setCopyInputNodes();
+ if (!e->copyInputNodes())
+ {
+ e->setCopyInputNodes();
+
+ if (udf && udf->getBody() != NULL)
+ udf->setBody(NULL);
+ }
break;
}
default:
=== modified file 'src/compiler/rewriter/rules/ruleset.h'
--- src/compiler/rewriter/rules/ruleset.h 2012-02-16 12:56:35 +0000
+++ src/compiler/rewriter/rules/ruleset.h 2012-03-02 07:23:22 +0000
@@ -132,10 +132,10 @@
//typedef std::vector<fo_expr*> UdfCalls;
protected:
- SourceFinder * theSourceFinder;
+ SourceFinder * theSourceFinder;
- UdfCalls theProcessedUDFCalls;
- //UdfCalls theUdfCallPath;
+ UdfCalls theProcessedUDFCalls;
+ //UdfCalls theUdfCallPath;
public:
MarkNodeCopyProps()
@@ -149,7 +149,7 @@
protected:
void applyInternal(RewriterContext& rCtx, expr* node, UDFCallChain& udfCaller);
- void markSources(const std::vector<expr*>& sources);
+ void markSources(const std::vector<expr*>& sources, UDFCallChain& udfCaller);
void markForSerialization(expr* node);
};
=== modified file 'src/runtime/core/fncall_iterator.cpp'
--- src/runtime/core/fncall_iterator.cpp 2012-01-11 17:30:25 +0000
+++ src/runtime/core/fncall_iterator.cpp 2012-03-02 07:23:22 +0000
@@ -358,6 +358,7 @@
std::vector<PlanIter_t>::const_iterator argsIte = theChildren.begin();
std::vector<PlanIter_t>::const_iterator argsEnd = theChildren.end();
std::vector<store::Iterator_t>::iterator argWrapsIte = state->theArgWrappers.begin();
+
const std::vector<ArgVarRefs>& argsRefs = theUDF->getArgVarsRefs();
std::vector<ArgVarRefs>::const_iterator argsRefsIte = argsRefs.begin();
=== modified file 'src/runtime/core/fncall_iterator.h'
--- src/runtime/core/fncall_iterator.h 2011-12-21 14:40:33 +0000
+++ src/runtime/core/fncall_iterator.h 2012-03-02 07:23:22 +0000
@@ -86,7 +86,7 @@
class UDFunctionCallIteratorState : public PlanIteratorState
{
public:
- PlanIterator * thePlan;
+ PlanIter_t thePlan;
PlanState * thePlanState;
uint32_t thePlanStateSize;
dynamic_context * theLocalDCtx;
=== added file 'test/rbkt/ExpQueryResults/zorba/eval/eval12.xml.res'
--- test/rbkt/ExpQueryResults/zorba/eval/eval12.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/eval/eval12.xml.res 2012-03-02 07:23: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/eval12.xq'
--- test/rbkt/Queries/zorba/eval/eval12.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/eval/eval12.xq 2012-03-02 07:23: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)")
Follow ups