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

Fixed bug #1016429 (scoping of copy variables in transform expr)
-- 
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/112857
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/compiler/parsetree/parsenode_print_xquery_visitor.cpp'
--- src/compiler/parsetree/parsenode_print_xquery_visitor.cpp	2012-06-28 04:14:03 +0000
+++ src/compiler/parsetree/parsenode_print_xquery_visitor.cpp	2012-06-29 22:08:19 +0000
@@ -1838,9 +1838,9 @@
       os << "copy $";
       n.get_var_list()->accept(*this);
       os << "modify ";
-      n.get_source_expr()->accept(*this);
+      n.get_modify_expr()->accept(*this);
       os << "return ";
-      n.get_target_expr()->accept(*this);
+      n.get_return_expr()->accept(*this);
       return 0;
     }
     DEFAULT_END_VISIT (TransformExpr)

=== modified file 'src/compiler/parsetree/parsenodes.cpp'
--- src/compiler/parsetree/parsenodes.cpp	2012-06-28 04:14:03 +0000
+++ src/compiler/parsetree/parsenodes.cpp	2012-06-29 22:08:19 +0000
@@ -4726,23 +4726,23 @@
 TransformExpr::TransformExpr(
   const QueryLoc& loc,
   rchandle<CopyVarList> var_list_h,
-  rchandle<exprnode> source_expr_h,
-  rchandle<exprnode> target_expr_h)
+  rchandle<exprnode> modifyExpr,
+  rchandle<exprnode> returnExpr)
   :
   exprnode(loc),
   var_list(var_list_h),
-  source_expr(source_expr_h),
-  target_expr(target_expr_h)
+  theModifyExpr(modifyExpr),
+  theReturnExpr(returnExpr)
 {
 }
 
 
-void TransformExpr::accept( parsenode_visitor &v ) const
+void TransformExpr::accept( parsenode_visitor& v ) const
 {
   BEGIN_VISITOR();
   ACCEPT (var_list);
-  ACCEPT (source_expr);
-  ACCEPT (target_expr);
+  ACCEPT (theModifyExpr);
+  ACCEPT (theReturnExpr);
   END_VISITOR();
 }
 
@@ -4754,7 +4754,7 @@
 }
 
 
-void CopyVarList::accept( parsenode_visitor &v ) const
+void CopyVarList::accept( parsenode_visitor& v ) const
 {
   BEGIN_VISITOR();
 
@@ -4781,7 +4781,7 @@
 }
 
 
-void VarBinding::accept( parsenode_visitor &v ) const
+void VarBinding::accept( parsenode_visitor& v ) const
 {
   BEGIN_VISITOR();
   ACCEPT (expr);

=== modified file 'src/compiler/parsetree/parsenodes.h'
--- src/compiler/parsetree/parsenodes.h	2012-06-28 04:14:03 +0000
+++ src/compiler/parsetree/parsenodes.h	2012-06-29 22:08:19 +0000
@@ -5571,20 +5571,20 @@
 {
 protected:
   rchandle<CopyVarList> var_list;
-  rchandle<exprnode> source_expr;
-  rchandle<exprnode> target_expr;
+  rchandle<exprnode>    theModifyExpr;
+  rchandle<exprnode>    theReturnExpr;
 
 public:
   TransformExpr(
     const QueryLoc& loc,
     rchandle<CopyVarList> var_list,
-    rchandle<exprnode> source_expr,
-    rchandle<exprnode> target_expr);
+    rchandle<exprnode> modifyExpr,
+    rchandle<exprnode> returnExpr);
 
 
   rchandle<CopyVarList> get_var_list() const { return var_list; }
-  rchandle<exprnode> get_source_expr() const { return source_expr; }
-  rchandle<exprnode> get_target_expr() const { return target_expr; }
+  rchandle<exprnode> get_modify_expr() const { return theModifyExpr; }
+  rchandle<exprnode> get_return_expr() const { return theReturnExpr; }
 
   void accept(parsenode_visitor&) const;
 };

=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp	2012-06-28 04:14:03 +0000
+++ src/compiler/translator/translator.cpp	2012-06-29 22:08:19 +0000
@@ -13169,8 +13169,8 @@
   transformExpr->setModifyExpr(modifyExpr);
   transformExpr->setReturnExpr(returnExpr);
 
-  const size_t lSize = v.get_var_list()->size();
-  for (size_t i = 0; i < lSize; ++i)
+  const csize lSize = v.get_var_list()->size();
+  for (csize i = 0; i < lSize; ++i)
   {
     pop_scope();
   }
@@ -13193,22 +13193,21 @@
 {
   TRACE_VISIT();
 
-  push_scope();
-  var_expr_t ve = bind_var(loc, v.get_varname(), var_expr::copy_var);
-  push_nodestack(ve.getp());
-
   return no_state;
 }
 
 void end_visit(const VarBinding& v, void*)
 {
-  TRACE_VISIT_OUT ();
+  TRACE_VISIT_OUT();
 
   expr_t sourceExpr = pop_nodestack();
+
   if (sourceExpr->is_updating())
     throw XQUERY_EXCEPTION(err::XUST0001, ERROR_LOC(loc));
 
-  var_expr_t varExpr = pop_nodestack_var();
+  push_scope();
+
+  var_expr_t varExpr = bind_var(loc, v.get_varname(), var_expr::copy_var);
 
   transform_expr* transformExpr =
   dynamic_cast<transform_expr*>(theNodeStack.top().getp());

=== added file 'test/rbkt/Queries/zorba/updates/transform02.spec'
--- test/rbkt/Queries/zorba/updates/transform02.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/updates/transform02.spec	2012-06-29 22:08:19 +0000
@@ -0,0 +1,1 @@
+Error: http://www.w3.org/2005/xqt-errors:XUTY0013

=== added file 'test/rbkt/Queries/zorba/updates/transform02.xq'
--- test/rbkt/Queries/zorba/updates/transform02.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/updates/transform02.xq	2012-06-29 22:08:19 +0000
@@ -0,0 +1,5 @@
+declare variable $filename as xs:string := "test";
+
+copy $filename := $filename
+modify ()
+return $filename

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