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

Commit message:
1. Improved computation of static type for fn:data function, 
2. Improved XQType::toSchemaString() method, 
3. No need to cast xs:untypedAtomic to xs:string in order-by expression, 
4. Fixed iteration over the components of a window clause; this improves static 
type computation of expressions referencing window vars.

Requested reviews:
  Markos Zaharioudakis (markos-za)

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

1. Improved computation of static type for fn:data function, 
2. Improved XQType::toSchemaString() method, 
3. No need to cast xs:untypedAtomic to xs:string in order-by expression, 
4. Fixed iteration over the components of a window clause; this improves static 
type computation of expressions referencing window vars.

-- 
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/139392
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog	2012-12-11 19:23:08 +0000
+++ ChangeLog	2012-12-12 07:38:30 +0000
@@ -14,6 +14,10 @@
   * Various optimizations in the implementation of the optimizer rules.
   * Better computation of the static type for global variables.
   * Optimization of comparison operators when untypedAtomic items are involved.
+  * Improved computation of static type for fn:data function.
+  * Fixed iteration over the components of a window clause; this improves static
+    type computation of expressions referencing window vars.
+  * No need to cast xs:untypedAtomic to xs:string in order-by expression.
 
 Bug Fixes/Other Changes:
   * Change XQXQ (XQuery-for-XQuery) module now part of Zorba core

=== modified file 'src/compiler/expression/expr_iter.cpp'
--- src/compiler/expression/expr_iter.cpp	2012-12-06 22:49:35 +0000
+++ src/compiler/expression/expr_iter.cpp	2012-12-12 07:38:30 +0000
@@ -345,6 +345,10 @@
 
       else if (c->get_kind() == flwor_clause::window_clause)
       {
+        wc = static_cast<window_clause *>(*theClausesIter);
+
+        EXPR_ITER_NEXT(wc->theDomainExpr);
+
         for (theWincondIter = 0; theWincondIter < 2; ++theWincondIter)
         {
           wc = static_cast<window_clause *>(*theClausesIter);
@@ -356,10 +360,6 @@
           if (wincond != 0)
             EXPR_ITER_NEXT(wincond->theCondExpr);
         }
-
-        wc = static_cast<window_clause *>(*theClausesIter);
-
-        EXPR_ITER_NEXT(wc->theDomainExpr);
       }
 
       else if (c->get_kind() == flwor_clause::group_clause)

=== modified file 'src/compiler/rewriter/rules/type_rules.cpp'
--- src/compiler/rewriter/rules/type_rules.cpp	2012-12-06 22:49:35 +0000
+++ src/compiler/rewriter/rules/type_rules.cpp	2012-12-12 07:38:30 +0000
@@ -427,6 +427,7 @@
       }
     }
   }
+#if 0
   else if (node->get_expr_kind() == flwor_expr_kind ||
            node->get_expr_kind() == gflwor_expr_kind)
   {
@@ -465,6 +466,7 @@
     if (modified)
       return node;
   }
+#endif
 
   return NULL;
 }

=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp	2012-12-11 20:27:40 +0000
+++ src/compiler/translator/translator.cpp	2012-12-12 07:38:30 +0000
@@ -4058,7 +4058,7 @@
     expr::checkSimpleExpr(initExpr);
     ve->set_has_initializer(true);
 
-    if (!ve->is_mutable())
+    if (!ve->is_mutable() && !ve->is_external())
     {
       xqtref_t derivedType = initExpr->get_return_type();
 

=== modified file 'src/functions/func_accessors_impl.cpp'
--- src/functions/func_accessors_impl.cpp	2012-10-10 13:35:24 +0000
+++ src/functions/func_accessors_impl.cpp	2012-12-12 07:38:30 +0000
@@ -105,6 +105,10 @@
                                  getListItemType();
         return tm->create_type(*itemType, TypeConstants::QUANT_STAR);
       }
+      else if (TypeOps::is_equal(tm, *cType, *RTM.UNTYPED_ATOMIC_TYPE_ONE))
+      {
+        return tm->create_builtin_atomic_type(store::XS_UNTYPED_ATOMIC, q);
+      }
       else if (TypeOps::is_equal(tm, *cType, *RTM.UNTYPED_TYPE))
       {
         return tm->create_builtin_atomic_type(store::XS_UNTYPED_ATOMIC, q);

=== modified file 'src/types/typeimpl.cpp'
--- src/types/typeimpl.cpp	2012-09-19 21:16:15 +0000
+++ src/types/typeimpl.cpp	2012-12-12 07:38:30 +0000
@@ -270,6 +270,11 @@
 
   switch (type_kind())
   {
+  case NONE_KIND:
+  {
+    result = "none";
+    break;
+  }
   case EMPTY_KIND:
   {
     result = "empty-sequence()";
@@ -283,11 +288,13 @@
   case ITEM_KIND:
   {
     result = "item()";
+    result += TypeOps::decode_quantifier(get_quantifier());
     break;
   }
   case STRUCTURED_ITEM_KIND:
   {
     result = "structured-item()";
+    result += TypeOps::decode_quantifier(get_quantifier());
     break;
   }
 
@@ -311,6 +318,7 @@
       result = "array()";
     }
 
+    result += TypeOps::decode_quantifier(get_quantifier());
     break;
   }
 #endif
@@ -318,11 +326,19 @@
   case NODE_TYPE_KIND:
   {
     result = static_cast<const NodeXQType*>(this)->toSchemaStringInternal();
+    result += TypeOps::decode_quantifier(get_quantifier());
     break;
   }
   case FUNCTION_TYPE_KIND:
   {
     result = toString();
+    result += TypeOps::decode_quantifier(get_quantifier());
+    break;
+  }
+  case ANY_FUNCTION_TYPE_KIND:
+  {
+    result = "function(*)";
+    result += TypeOps::decode_quantifier(get_quantifier());
     break;
   }
   case ANY_TYPE_KIND:
@@ -335,22 +351,19 @@
     result = "xs:anySimpleType";
     break;
   }
-  case ANY_FUNCTION_TYPE_KIND:
-  {
-    result = "function(*)";
-    break;
-  }
   case UNTYPED_KIND:
   {
+    result = "xs:untyped";
+    break;
+  }
+  default:
+  {
     result = toString();
+    result += TypeOps::decode_quantifier(get_quantifier());
     break;
   }
-  default:
-    return toString();
-    break;
   }
 
-  result += TypeOps::decode_quantifier(get_quantifier());
   return result;
 }
 

=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/q19.iter'
--- test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/q19.iter	2012-10-08 12:09:36 +0000
+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/q19.iter	2012-12-12 07:38:30 +0000
@@ -18,15 +18,13 @@
       </DescendantAxisIterator>
     </ForVariable>
     <OrderBySpec>
-      <CastIterator type="xs:string">
-        <FnDataIterator>
-          <FnZeroOrOneIterator>
-            <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,location)" typename="*" nill allowed="0">
-              <ForVarIterator varname="b"/>
-            </ChildAxisIterator>
-          </FnZeroOrOneIterator>
-        </FnDataIterator>
-      </CastIterator>
+      <FnDataIterator>
+        <FnZeroOrOneIterator>
+          <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,location)" typename="*" nill allowed="0">
+            <ForVarIterator varname="b"/>
+          </ChildAxisIterator>
+        </FnZeroOrOneIterator>
+      </FnDataIterator>
     </OrderBySpec>
     <ReturnClause>
       <ElementIterator copyInputNodes="false">

=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/xmark/q19.iter'
--- test/rbkt/ExpCompilerResults/IterPlan/zorba/xmark/q19.iter	2012-10-08 12:09:36 +0000
+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/xmark/q19.iter	2012-12-12 07:38:30 +0000
@@ -18,15 +18,13 @@
       </DescendantAxisIterator>
     </ForVariable>
     <OrderBySpec>
-      <CastIterator type="xs:string">
-        <FnDataIterator>
-          <FnZeroOrOneIterator>
-            <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,location)" typename="*" nill allowed="0">
-              <ForVarIterator varname="b"/>
-            </ChildAxisIterator>
-          </FnZeroOrOneIterator>
-        </FnDataIterator>
-      </CastIterator>
+      <FnDataIterator>
+        <FnZeroOrOneIterator>
+          <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,location)" typename="*" nill allowed="0">
+            <ForVarIterator varname="b"/>
+          </ChildAxisIterator>
+        </FnZeroOrOneIterator>
+      </FnDataIterator>
     </OrderBySpec>
     <ReturnClause>
       <ElementIterator>

=== modified file 'test/rbkt/Queries/zorba/xmark/q19.xq'
--- test/rbkt/Queries/zorba/xmark/q19.xq	2012-09-19 21:16:15 +0000
+++ test/rbkt/Queries/zorba/xmark/q19.xq	2012-12-12 07:38:30 +0000
@@ -1,7 +1,9 @@
 declare variable $input-context external;
-let $auction := doc($input-context) return
-for $b in $auction/site/regions//item
-let $k := $b/name/text()
-stable order by zero-or-one($b/location) ascending empty greatest
-return <item name="{$k}">{$b/location/text()}</item>
+
+let $auction := doc($input-context)
+return
+  for $b in $auction/site/regions//item
+  let $k := $b/name/text()
+  stable order by zero-or-one($b/location) ascending empty greatest
+  return <item name="{$k}">{$b/location/text()}</item>
 

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