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

Fixed #1052383 (accessing context item in eval expr)
-- 
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/125018
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog	2012-09-18 16:29:31 +0000
+++ ChangeLog	2012-09-18 18:40:28 +0000
@@ -43,6 +43,7 @@
   * Fixed bug #866984 (better error message for an eval error)
   * Fixed bug #1047538 (jsoniq: SourceFinder::findLocalNodeSources missing
     json expressions)
+  * Fixed #1052383 (accessing context item in eval expr)
   * Fixed bug #1046559 (dynamic resolution between function invocation and jsoniq
     navigation)
   * Fixed bug #932884 (HTML and XHTML serialization of empty elements)

=== modified file 'src/compiler/rewriter/rules/nodeid_rules.cpp'
--- src/compiler/rewriter/rules/nodeid_rules.cpp	2012-09-17 00:36:37 +0000
+++ src/compiler/rewriter/rules/nodeid_rules.cpp	2012-09-18 18:40:28 +0000
@@ -1318,7 +1318,12 @@
 
     for (csize i = 0; i < numVars; ++i)
     {
-      markForSerialization(e->get_arg_expr(i));
+      expr* arg = e->get_arg_expr(i);
+
+      if (arg == NULL)
+        continue;
+
+      markForSerialization(arg);
     }
 #if 1
     std::vector<VarInfo*> globalVars;

=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp	2012-09-18 16:29:31 +0000
+++ src/compiler/translator/translator.cpp	2012-09-18 18:40:28 +0000
@@ -127,6 +127,7 @@
     StaticContextConsts::xquery_version_t maxLibModuleVersion =
       StaticContextConsts::xquery_version_unknown);
 
+
 /*******************************************************************************
 
 ********************************************************************************/
@@ -2386,9 +2387,11 @@
   // treat_as expr as well, so the ctx item will always appear as being used,
   // and as a result it will always have to be set.
   var_expr* var = bind_var(loc,
-                            DOT_VARNAME,
-                            var_expr::prolog_var,
-                            theSctx->get_context_item_type());
+                           DOT_VARNAME,
+                           var_expr::prolog_var,
+                           theSctx->get_context_item_type());
+
+  var->set_external(true);
   var->set_unique_id(1);
 
   //GlobalBinding b(var, NULL, true);

=== modified file 'src/compiler/translator/translator.h'
--- src/compiler/translator/translator.h	2012-09-17 00:36:37 +0000
+++ src/compiler/translator/translator.h	2012-09-18 18:40:28 +0000
@@ -23,7 +23,7 @@
 namespace zorba
 {
 
-expr* translate (const parsenode &, CompilerCB* aCompilerCB);
+expr* translate (const parsenode& ast, CompilerCB* ccb);
 
 }
 #endif

=== modified file 'src/runtime/eval/eval.cpp'
--- src/runtime/eval/eval.cpp	2012-09-17 00:36:37 +0000
+++ src/runtime/eval/eval.cpp	2012-09-18 18:40:28 +0000
@@ -357,6 +357,9 @@
     store::Item_t itemValue;
     store::TempSeq_t seqValue;
 
+    if (!evalDctx->is_set_variable(outerVar->getId()))
+      continue;
+
     evalDctx->get_variable(outerVar->getId(),
                            outerVar->getName(),
                            loc,

=== added file 'test/rbkt/ExpQueryResults/zorba/eval/ctx_item_01.xml.res'
--- test/rbkt/ExpQueryResults/zorba/eval/ctx_item_01.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/eval/ctx_item_01.xml.res	2012-09-18 18:40:28 +0000
@@ -0,0 +1,1 @@
+<a/>

=== added file 'test/rbkt/ExpQueryResults/zorba/eval/ctx_item_02.xml.res'
--- test/rbkt/ExpQueryResults/zorba/eval/ctx_item_02.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/eval/ctx_item_02.xml.res	2012-09-18 18:40:28 +0000
@@ -0,0 +1,1 @@
+<a/>

=== added file 'test/rbkt/ExpQueryResults/zorba/eval/ctx_item_03.xml.res'
--- test/rbkt/ExpQueryResults/zorba/eval/ctx_item_03.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/eval/ctx_item_03.xml.res	2012-09-18 18:40:28 +0000
@@ -0,0 +1,1 @@
+<a/><a/><b/><c/>

=== added file 'test/rbkt/Queries/zorba/eval/ctx_item_01.xq'
--- test/rbkt/Queries/zorba/eval/ctx_item_01.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/eval/ctx_item_01.xq	2012-09-18 18:40:28 +0000
@@ -0,0 +1,5 @@
+import module namespace refl = "http://www.zorba-xquery.com/modules/reflection";;
+
+declare context item := <doc><a/></doc>;
+
+refl:eval("./a")

=== added file 'test/rbkt/Queries/zorba/eval/ctx_item_02.xq'
--- test/rbkt/Queries/zorba/eval/ctx_item_02.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/eval/ctx_item_02.xq	2012-09-18 18:40:28 +0000
@@ -0,0 +1,5 @@
+import module namespace refl = "http://www.zorba-xquery.com/modules/reflection";;
+
+declare context item := <doc><a/></doc>;
+
+refl:eval("declare context item external; ./a")

=== added file 'test/rbkt/Queries/zorba/eval/ctx_item_03.xq'
--- test/rbkt/Queries/zorba/eval/ctx_item_03.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/eval/ctx_item_03.xq	2012-09-18 18:40:28 +0000
@@ -0,0 +1,11 @@
+import module namespace refl = "http://www.zorba-xquery.com/modules/reflection";;
+
+declare context item := <doc><a/></doc>;
+
+declare variable $x := <b/>;
+
+refl:eval("
+declare context item := <doc><a/><a/></doc>;
+declare variable $y := <c/>;
+(./a, $x, $y)
+")

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