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

Commit message:
convert LET vars whose domain sequence has exactly one item to FOR vars; do 
this during codegen instead of during optimization

Requested reviews:
  Markos Zaharioudakis (markos-za)

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

convert LET vars whose domain sequence has exactly one item to FOR vars; do 
this during codegen instead of during optimization
-- 
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/140471
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog	2012-12-14 07:27:04 +0000
+++ ChangeLog	2012-12-18 15:18:46 +0000
@@ -18,6 +18,7 @@
   * 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.
+  * Convert LET vars whose domain sequence has exactly one item to FOR vars.
 
 Bug Fixes/Other Changes:
   * Change XQXQ (XQuery-for-XQuery) module now part of Zorba core

=== modified file 'src/compiler/codegen/plan_visitor.cpp'
--- src/compiler/codegen/plan_visitor.cpp	2012-10-29 11:41:36 +0000
+++ src/compiler/codegen/plan_visitor.cpp	2012-12-18 15:18:46 +0000
@@ -197,6 +197,10 @@
 public:
   PlanIter_t               theInputVar;
   std::vector<PlanIter_t>  theOutputVarRefs;
+  bool                     theIsFakeLetVar;
+
+public:
+  VarRebind() : theIsFakeLetVar(false) {}
 };
 
 
@@ -776,13 +780,16 @@
       ZORBA_ASSERT(i >= 0);
     }
 
+    FlworClauseVarMap* clauseVarMap = theClauseStack[i];
+    flwor_expr* flworExpr = clauseVarMap->theClause->get_flwor_expr();
+    bool isFakeLetVar = clauseVarMap->theVarRebinds[varPos]->theIsFakeLetVar;
+
+    if (isFakeLetVar)
+      isForVar = true;
+
     // Create a var ref iter in the output of C.
     varIter = create_var_iter(var, isForVar);
 
-    FlworClauseVarMap* clauseVarMap = theClauseStack[i];
-
-    flwor_expr* flworExpr = clauseVarMap->theClause->get_flwor_expr();
-
     clauseVarMap->theVarRebinds[varPos]->theOutputVarRefs.push_back(varIter);
 
     if (clauseVarMap->theIsGeneral || flworExpr->is_sequential())
@@ -807,6 +814,7 @@
           clauseVarMap->theVarRebinds.push_back(varRebind);
 
           varRebind->theInputVar = varIter;
+          varRebind->theIsFakeLetVar = isFakeLetVar;
 
           varIter = create_var_iter(var, isForVar);
 
@@ -1097,12 +1105,12 @@
       const flwor_clause::rebind_list_t& gvars = gc->get_grouping_vars();
       const flwor_clause::rebind_list_t& ngvars = gc->get_nongrouping_vars();
 
-      for (ulong i = 0; i < gvars.size(); ++i)
+      for (csize i = 0; i < gvars.size(); ++i)
       {
         gvars[i].first->accept(*this);
       }
 
-      for (ulong i = 0; i < ngvars.size(); ++i)
+      for (csize i = 0; i < ngvars.size(); ++i)
       {
         ngvars[i].first->accept(*this);
       }
@@ -1116,8 +1124,8 @@
     {
       const orderby_clause* oc = reinterpret_cast<const orderby_clause*>(c);
 
-      ulong numCols = oc->num_columns();
-      for (ulong i = 0; i < numCols; ++i)
+      csize numCols = oc->num_columns();
+      for (csize i = 0; i < numCols; ++i)
       {
         oc->get_column_expr(i)->accept(*this);
       }
@@ -1208,11 +1216,15 @@
   case flwor_clause::let_clause:
   {
     const let_clause* lc = static_cast<const let_clause *>(c);
+    xqtref_t domType = lc->get_expr()->get_return_type();
 
     VarRebind_t varRebind = new VarRebind;
     clauseVarMap->theVarExprs.push_back(lc->get_var());
     clauseVarMap->theVarRebinds.push_back(varRebind);
 
+    if (domType->get_quantifier() == TypeConstants::QUANT_ONE)
+      varRebind->theIsFakeLetVar = true;
+
     break;
   }
 
@@ -1513,14 +1525,19 @@
 
     std::vector<PlanIter_t>& varRefs = clauseVarMap->theVarRebinds[0]->theOutputVarRefs;
 
-    return new flwor::LetIterator(sctx,
-                                  var->get_loc(),
-                                  var->get_name(),
-                                  PREV_ITER,
-                                  domainIter,
-                                  varRefs,
-                                  lc->lazyEval(),
-                                  true);  // materilize
+    if (clauseVarMap->theVarRebinds[0]->theIsFakeLetVar)
+    {
+      std::vector<PlanIter_t>* posVarRefs = &no_var_iters;
+
+      return new flwor::ForIterator(sctx, var->get_loc(), var->get_name(),
+                                    PREV_ITER, domainIter, varRefs, *posVarRefs);
+    }
+    else
+    {
+      return new flwor::LetIterator(sctx, var->get_loc(), var->get_name(),
+                                    PREV_ITER, domainIter, varRefs,
+                                    lc->lazyEval(), true);  // materialize
+    }
   }
 
   //
@@ -1894,11 +1911,20 @@
       std::vector<PlanIter_t>& varRefs =
       clauseVarMap->theVarRebinds[0]->theOutputVarRefs;
 
-      forletClauses.push_back(flwor::ForLetClause(var->get_name(),
-                                                  varRefs,
-                                                  domainIter,
-                                                  lc->lazyEval(),
-                                                  true)); // materialize
+      if (clauseVarMap->theVarRebinds[0]->theIsFakeLetVar)
+      {
+        forletClauses.push_back(flwor::ForLetClause(var->get_name(),
+                                                    varRefs,
+                                                    domainIter));
+      }
+      else
+      {
+        forletClauses.push_back(flwor::ForLetClause(var->get_name(),
+                                                    varRefs,
+                                                    domainIter,
+                                                    lc->lazyEval(),
+                                                    true)); // materialize
+      }
       break;
     }
 

=== modified file 'src/compiler/rewriter/rules/flwor_rules.cpp'
--- src/compiler/rewriter/rules/flwor_rules.cpp	2012-10-30 13:33:05 +0000
+++ src/compiler/rewriter/rules/flwor_rules.cpp	2012-12-18 15:18:46 +0000
@@ -218,9 +218,7 @@
   // (a) Remove, if possible, FOR/LET vars that are not referenced anywhere
   // (b) Replace, if possible, FOR/LET vars that are referenced only once, with
   //     their domain expr.
-  // (c) Change a LET var into a FOR var, if its domain expr consists of
-  //     exactly one item.
-  // (d) Remove any unused non-group variables from GROUP BY clauses.
+  // (c) Remove any unused non-group variables from GROUP BY clauses.
   for (csize i = 0; i < numClauses; ++i)
   {
     int numRefs;
@@ -327,7 +325,6 @@
     {
       let_clause* lc = static_cast<let_clause *>(c);
       expr* domExpr = lc->get_expr();
-      TypeConstants::quantifier_t domQuant = domExpr->get_return_type()->get_quantifier();
       var = lc->get_var();
 
       if (safe_to_fold_var(i, numRefs))
@@ -337,12 +334,6 @@
 
         folded = true;
       }
-      else if (domQuant == TypeConstants::QUANT_ONE)
-      {
-        lc->set_kind(flwor_clause::for_clause);
-        var->set_kind(var_expr::for_var);
-        modified = true;
-      }
     }
     default:
       break;

=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/9065.iter'
--- test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/9065.iter	2012-09-19 21:16:15 +0000
+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/9065.iter	2012-12-18 15:18:46 +0000
@@ -16,7 +16,7 @@
       </ChildAxisIterator>
     </HoistIterator>
   </LetVariable>
-  <LetVariable name="$$opt_temp_0" materialize="true">
+  <ForVariable name="$$opt_temp_0">
     <HoistIterator>
       <FnCountIterator>
         <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,author)" typename="*" nill allowed="0">
@@ -28,7 +28,7 @@
         </ChildAxisIterator>
       </FnCountIterator>
     </HoistIterator>
-  </LetVariable>
+  </ForVariable>
   <ForVariable name="er">
     <OpToIterator>
       <SingletonIterator value="xs:integer(1)"/>
@@ -38,7 +38,7 @@
   <WhereClause>
     <TypedValueCompareIterator_INTEGER>
       <UnhoistIterator>
-        <LetVarIterator varname="$$opt_temp_0"/>
+        <ForVarIterator varname="$$opt_temp_0"/>
       </UnhoistIterator>
       <ForVarIterator varname="er"/>
     </TypedValueCompareIterator_INTEGER>

=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/9066.iter'
--- test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/9066.iter	2012-09-19 21:16:15 +0000
+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/9066.iter	2012-12-18 15:18:46 +0000
@@ -5,7 +5,7 @@
       <SingletonIterator value="xs:string(books.xml)"/>
     </FnDocIterator>
   </ForVariable>
-  <LetVariable name="$$opt_temp_0" materialize="true">
+  <ForVariable name="$$opt_temp_0">
     <HoistIterator>
       <FnCountIterator>
         <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,author)" typename="*" nill allowed="0">
@@ -17,7 +17,7 @@
         </ChildAxisIterator>
       </FnCountIterator>
     </HoistIterator>
-  </LetVariable>
+  </ForVariable>
   <ForVariable name="er">
     <OpToIterator>
       <SingletonIterator value="xs:integer(1)"/>
@@ -27,7 +27,7 @@
   <WhereClause>
     <TypedValueCompareIterator_INTEGER>
       <UnhoistIterator>
-        <LetVarIterator varname="$$opt_temp_0"/>
+        <ForVarIterator varname="$$opt_temp_0"/>
       </UnhoistIterator>
       <ForVarIterator varname="er"/>
     </TypedValueCompareIterator_INTEGER>

=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/9067.iter'
--- test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/9067.iter	2012-09-19 21:16:15 +0000
+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/9067.iter	2012-12-18 15:18:46 +0000
@@ -33,7 +33,7 @@
             </FnDocIterator>
           </DescendantAxisIterator>
         </ForVariable>
-        <LetVariable name="$$opt_temp_1" materialize="true">
+        <ForVariable name="$$opt_temp_1">
           <HoistIterator>
             <FnCountIterator>
               <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,author)" typename="*" nill allowed="0">
@@ -41,12 +41,12 @@
               </ChildAxisIterator>
             </FnCountIterator>
           </HoistIterator>
-        </LetVariable>
+        </ForVariable>
         <ForVariable name="er">
           <ProbeIndexPointValueIterator>
             <SingletonIterator value="xs:QName(,,tempIndex0)"/>
             <UnhoistIterator>
-              <LetVarIterator varname="$$opt_temp_1"/>
+              <ForVarIterator varname="$$opt_temp_1"/>
             </UnhoistIterator>
           </ProbeIndexPointValueIterator>
         </ForVariable>

=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/9068.iter'
--- test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/9068.iter	2012-09-19 21:16:15 +0000
+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/9068.iter	2012-12-18 15:18:46 +0000
@@ -40,7 +40,7 @@
             </ChildAxisIterator>
           </HoistIterator>
         </LetVariable>
-        <LetVariable name="$$opt_temp_1" materialize="true">
+        <ForVariable name="$$opt_temp_1">
           <HoistIterator>
             <FnCountIterator>
               <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,author)" typename="*" nill allowed="0">
@@ -48,12 +48,12 @@
               </ChildAxisIterator>
             </FnCountIterator>
           </HoistIterator>
-        </LetVariable>
+        </ForVariable>
         <ForVariable name="er">
           <ProbeIndexPointValueIterator>
             <SingletonIterator value="xs:QName(,,tempIndex0)"/>
             <UnhoistIterator>
-              <LetVarIterator varname="$$opt_temp_1"/>
+              <ForVarIterator varname="$$opt_temp_1"/>
             </UnhoistIterator>
           </ProbeIndexPointValueIterator>
         </ForVariable>

=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/9197.iter'
--- test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/9197.iter	2012-09-19 21:16:15 +0000
+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/9197.iter	2012-12-18 15:18:46 +0000
@@ -36,7 +36,7 @@
                 </FnDocIterator>
               </DescendantAxisIterator>
             </ForVariable>
-            <LetVariable name="$$opt_temp_1" materialize="true">
+            <ForVariable name="$$opt_temp_1">
               <HoistIterator>
                 <FnCountIterator>
                   <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,author)" typename="*" nill allowed="0">
@@ -44,12 +44,12 @@
                   </ChildAxisIterator>
                 </FnCountIterator>
               </HoistIterator>
-            </LetVariable>
+            </ForVariable>
             <ForVariable name="anzahl">
               <ProbeIndexPointValueIterator>
                 <SingletonIterator value="xs:QName(,,tempIndex0)"/>
                 <UnhoistIterator>
-                  <LetVarIterator varname="$$opt_temp_1"/>
+                  <ForVarIterator varname="$$opt_temp_1"/>
                 </UnhoistIterator>
               </ProbeIndexPointValueIterator>
             </ForVariable>

=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/9198.iter'
--- test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/9198.iter	2012-09-19 21:16:15 +0000
+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/9198.iter	2012-12-18 15:18:46 +0000
@@ -36,7 +36,7 @@
                 </FnDocIterator>
               </DescendantAxisIterator>
             </ForVariable>
-            <LetVariable name="$$opt_temp_1" materialize="true">
+            <ForVariable name="$$opt_temp_1">
               <HoistIterator>
                 <FnCountIterator>
                   <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,author)" typename="*" nill allowed="0">
@@ -44,12 +44,12 @@
                   </ChildAxisIterator>
                 </FnCountIterator>
               </HoistIterator>
-            </LetVariable>
+            </ForVariable>
             <ForVariable name="anzahl">
               <ProbeIndexPointValueIterator>
                 <SingletonIterator value="xs:QName(,,tempIndex0)"/>
                 <UnhoistIterator>
-                  <LetVarIterator varname="$$opt_temp_1"/>
+                  <ForVarIterator varname="$$opt_temp_1"/>
                 </UnhoistIterator>
               </ProbeIndexPointValueIterator>
             </ForVariable>

=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/9199.iter'
--- test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/9199.iter	2012-09-19 21:16:15 +0000
+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/9199.iter	2012-12-18 15:18:46 +0000
@@ -36,7 +36,7 @@
                 </FnDocIterator>
               </DescendantAxisIterator>
             </ForVariable>
-            <LetVariable name="$$opt_temp_1" materialize="true">
+            <ForVariable name="$$opt_temp_1">
               <HoistIterator>
                 <FnCountIterator>
                   <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,author)" typename="*" nill allowed="0">
@@ -44,12 +44,12 @@
                   </ChildAxisIterator>
                 </FnCountIterator>
               </HoistIterator>
-            </LetVariable>
+            </ForVariable>
             <ForVariable name="anzahl">
               <ProbeIndexPointValueIterator>
                 <SingletonIterator value="xs:QName(,,tempIndex0)"/>
                 <UnhoistIterator>
-                  <LetVarIterator varname="$$opt_temp_1"/>
+                  <ForVarIterator varname="$$opt_temp_1"/>
                 </UnhoistIterator>
               </ProbeIndexPointValueIterator>
             </ForVariable>

=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/9204.iter'
--- test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/9204.iter	2012-09-19 21:16:15 +0000
+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/9204.iter	2012-12-18 15:18:46 +0000
@@ -33,7 +33,7 @@
             </FnDocIterator>
           </DescendantAxisIterator>
         </ForVariable>
-        <LetVariable name="$$opt_temp_1" materialize="true">
+        <ForVariable name="$$opt_temp_1">
           <HoistIterator>
             <FnCountIterator>
               <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,author)" typename="*" nill allowed="0">
@@ -41,7 +41,7 @@
               </ChildAxisIterator>
             </FnCountIterator>
           </HoistIterator>
-        </LetVariable>
+        </ForVariable>
         <ReturnClause>
           <ElementIterator>
             <SingletonIterator value="xs:QName(,,karteikasten)"/>
@@ -51,7 +51,7 @@
                   <ProbeIndexPointValueIterator>
                     <SingletonIterator value="xs:QName(,,tempIndex0)"/>
                     <UnhoistIterator>
-                      <LetVarIterator varname="$$opt_temp_1"/>
+                      <ForVarIterator varname="$$opt_temp_1"/>
                     </UnhoistIterator>
                   </ProbeIndexPointValueIterator>
                 </ForVariable>

=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/9207.iter'
--- test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/9207.iter	2012-09-19 21:16:15 +0000
+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/9207.iter	2012-12-18 15:18:46 +0000
@@ -36,7 +36,7 @@
                 </FnDocIterator>
               </DescendantAxisIterator>
             </ForVariable>
-            <LetVariable name="$$opt_temp_1" materialize="true">
+            <ForVariable name="$$opt_temp_1">
               <HoistIterator>
                 <FnCountIterator>
                   <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,author)" typename="*" nill allowed="0">
@@ -44,12 +44,12 @@
                   </ChildAxisIterator>
                 </FnCountIterator>
               </HoistIterator>
-            </LetVariable>
+            </ForVariable>
             <ForVariable name="anzahl">
               <ProbeIndexPointValueIterator>
                 <SingletonIterator value="xs:QName(,,tempIndex0)"/>
                 <UnhoistIterator>
-                  <LetVarIterator varname="$$opt_temp_1"/>
+                  <ForVarIterator varname="$$opt_temp_1"/>
                 </UnhoistIterator>
               </ProbeIndexPointValueIterator>
             </ForVariable>

=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/gary1.iter'
--- test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/gary1.iter	2012-10-08 12:09:36 +0000
+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/gary1.iter	2012-12-18 15:18:46 +0000
@@ -147,7 +147,7 @@
                         <ForVarIterator varname="j"/>
                       </AttributeAxisIterator>
                     </LetVariable>
-                    <LetVariable name="$$opt_temp_0" materialize="true">
+                    <ForVariable name="$$opt_temp_0">
                       <HoistIterator>
                         <CompareIterator>
                           <FnDataIterator>
@@ -156,7 +156,7 @@
                           <SingletonIterator value="xs:integer(1980)"/>
                         </CompareIterator>
                       </HoistIterator>
-                    </LetVariable>
+                    </ForVariable>
                     <ReturnClause>
                       <ElementIterator>
                         <SingletonIterator value="xs:QName(,,year)"/>
@@ -193,7 +193,7 @@
                                   <IfThenElseIterator>
                                     <AndIterator>
                                       <UnhoistIterator>
-                                        <LetVarIterator varname="$$opt_temp_0"/>
+                                        <ForVarIterator varname="$$opt_temp_0"/>
                                       </UnhoistIterator>
                                       <CompareIterator>
                                         <FnDataIterator>

=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/idx4.iter'
--- test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/idx4.iter	2012-10-08 12:09:36 +0000
+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/idx4.iter	2012-12-18 15:18:46 +0000
@@ -62,13 +62,13 @@
           </flwor::FLWORIterator>
         </CreateInternalIndexIterator>
         <flwor::FLWORIterator>
-          <LetVariable name="$$opt_temp_0" materialize="true">
+          <ForVariable name="$$opt_temp_0">
             <HoistIterator>
               <TreatIterator quant="">
                 <LetVarIterator varname="e"/>
               </TreatIterator>
             </HoistIterator>
-          </LetVariable>
+          </ForVariable>
           <ForVariable name="prefix">
             <flwor::FLWORIterator>
               <ForVariable name="prefixE">
@@ -83,7 +83,7 @@
                   <NamespaceUriForPrefixIterator>
                     <ForVarIterator varname="prefixE"/>
                     <UnhoistIterator>
-                      <LetVarIterator varname="$$opt_temp_0"/>
+                      <ForVarIterator varname="$$opt_temp_0"/>
                     </UnhoistIterator>
                   </NamespaceUriForPrefixIterator>
                 </HoistIterator>

=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/hashjoin-9065.iter'
--- test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/hashjoin-9065.iter	2012-09-19 21:16:15 +0000
+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/hashjoin-9065.iter	2012-12-18 15:18:46 +0000
@@ -16,7 +16,7 @@
       </ChildAxisIterator>
     </HoistIterator>
   </LetVariable>
-  <LetVariable name="$$opt_temp_0" materialize="true">
+  <ForVariable name="$$opt_temp_0">
     <HoistIterator>
       <FnCountIterator>
         <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,author)" typename="*" nill allowed="0">
@@ -28,7 +28,7 @@
         </ChildAxisIterator>
       </FnCountIterator>
     </HoistIterator>
-  </LetVariable>
+  </ForVariable>
   <ForVariable name="er">
     <OpToIterator>
       <SingletonIterator value="xs:integer(1)"/>
@@ -38,7 +38,7 @@
   <WhereClause>
     <TypedValueCompareIterator_INTEGER>
       <UnhoistIterator>
-        <LetVarIterator varname="$$opt_temp_0"/>
+        <ForVarIterator varname="$$opt_temp_0"/>
       </UnhoistIterator>
       <ForVarIterator varname="er"/>
     </TypedValueCompareIterator_INTEGER>

=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/hashjoin-9198.iter'
--- test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/hashjoin-9198.iter	2012-09-19 21:16:15 +0000
+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/hashjoin-9198.iter	2012-12-18 15:18:46 +0000
@@ -36,7 +36,7 @@
                 </FnDocIterator>
               </DescendantAxisIterator>
             </ForVariable>
-            <LetVariable name="$$opt_temp_1" materialize="true">
+            <ForVariable name="$$opt_temp_1">
               <HoistIterator>
                 <FnCountIterator>
                   <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,author)" typename="*" nill allowed="0">
@@ -44,12 +44,12 @@
                   </ChildAxisIterator>
                 </FnCountIterator>
               </HoistIterator>
-            </LetVariable>
+            </ForVariable>
             <ForVariable name="anzahl">
               <ProbeIndexPointValueIterator>
                 <SingletonIterator value="xs:QName(,,tempIndex0)"/>
                 <UnhoistIterator>
-                  <LetVarIterator varname="$$opt_temp_1"/>
+                  <ForVarIterator varname="$$opt_temp_1"/>
                 </UnhoistIterator>
               </ProbeIndexPointValueIterator>
             </ForVariable>

=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/hashjoin-9199.iter'
--- test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/hashjoin-9199.iter	2012-09-19 21:16:15 +0000
+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/hashjoin-9199.iter	2012-12-18 15:18:46 +0000
@@ -36,7 +36,7 @@
                 </FnDocIterator>
               </DescendantAxisIterator>
             </ForVariable>
-            <LetVariable name="$$opt_temp_1" materialize="true">
+            <ForVariable name="$$opt_temp_1">
               <HoistIterator>
                 <FnCountIterator>
                   <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,author)" typename="*" nill allowed="0">
@@ -44,12 +44,12 @@
                   </ChildAxisIterator>
                 </FnCountIterator>
               </HoistIterator>
-            </LetVariable>
+            </ForVariable>
             <ForVariable name="anzahl">
               <ProbeIndexPointValueIterator>
                 <SingletonIterator value="xs:QName(,,tempIndex0)"/>
                 <UnhoistIterator>
-                  <LetVarIterator varname="$$opt_temp_1"/>
+                  <ForVarIterator varname="$$opt_temp_1"/>
                 </UnhoistIterator>
               </ProbeIndexPointValueIterator>
             </ForVariable>

=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/hashjoin-gary1.iter'
--- test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/hashjoin-gary1.iter	2012-10-08 12:09:36 +0000
+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/hashjoin-gary1.iter	2012-12-18 15:18:46 +0000
@@ -147,7 +147,7 @@
                         <ForVarIterator varname="j"/>
                       </AttributeAxisIterator>
                     </LetVariable>
-                    <LetVariable name="$$opt_temp_0" materialize="true">
+                    <ForVariable name="$$opt_temp_0">
                       <HoistIterator>
                         <CompareIterator>
                           <FnDataIterator>
@@ -156,7 +156,7 @@
                           <SingletonIterator value="xs:integer(1980)"/>
                         </CompareIterator>
                       </HoistIterator>
-                    </LetVariable>
+                    </ForVariable>
                     <ReturnClause>
                       <ElementIterator copyInputNodes="false">
                         <SingletonIterator value="xs:QName(,,year)"/>
@@ -193,7 +193,7 @@
                                   <IfThenElseIterator>
                                     <AndIterator>
                                       <UnhoistIterator>
-                                        <LetVarIterator varname="$$opt_temp_0"/>
+                                        <ForVarIterator varname="$$opt_temp_0"/>
                                       </UnhoistIterator>
                                       <CompareIterator>
                                         <FnDataIterator>

=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/hashjoin-idx4.iter'
--- test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/hashjoin-idx4.iter	2012-10-08 12:09:36 +0000
+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/hashjoin-idx4.iter	2012-12-18 15:18:46 +0000
@@ -62,13 +62,13 @@
           </flwor::FLWORIterator>
         </CreateInternalIndexIterator>
         <flwor::FLWORIterator>
-          <LetVariable name="$$opt_temp_0" materialize="true">
+          <ForVariable name="$$opt_temp_0">
             <HoistIterator>
               <TreatIterator quant="">
                 <LetVarIterator varname="e"/>
               </TreatIterator>
             </HoistIterator>
-          </LetVariable>
+          </ForVariable>
           <ForVariable name="prefix">
             <flwor::FLWORIterator>
               <ForVariable name="prefixE">
@@ -83,7 +83,7 @@
                   <NamespaceUriForPrefixIterator>
                     <ForVarIterator varname="prefixE"/>
                     <UnhoistIterator>
-                      <LetVarIterator varname="$$opt_temp_0"/>
+                      <ForVarIterator varname="$$opt_temp_0"/>
                     </UnhoistIterator>
                   </NamespaceUriForPrefixIterator>
                 </HoistIterator>

=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/udf/udf-recursive-1.iter'
--- test/rbkt/ExpCompilerResults/IterPlan/zorba/udf/udf-recursive-1.iter	2012-10-19 20:42:38 +0000
+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/udf/udf-recursive-1.iter	2012-12-18 15:18:46 +0000
@@ -5,9 +5,9 @@
 
 Iterator tree for local:get-request-id2:
 <flwor::FLWORIterator>
-  <LetVariable name="p" materialize="true">
+  <ForVariable name="p">
     <LetVarIterator varname="p"/>
-  </LetVariable>
+  </ForVariable>
   <ReturnClause>
     <UDFunctionCallIterator cached="true">
       <SingletonIterator value="xs:integer(4)"/>
@@ -18,9 +18,9 @@
 Iterator tree for local:get-request-id1:
 <PromoteIterator type="xs:string">
   <flwor::FLWORIterator>
-    <LetVariable name="p" materialize="true">
+    <ForVariable name="p">
       <LetVarIterator varname="p"/>
-    </LetVariable>
+    </ForVariable>
     <ReturnClause>
       <flwor::FLWORIterator>
         <ForVariable name="i">

=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/w3c/rdb-queries-results-q5.iter'
--- test/rbkt/ExpCompilerResults/IterPlan/zorba/w3c/rdb-queries-results-q5.iter	2012-09-27 11:14:04 +0000
+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/w3c/rdb-queries-results-q5.iter	2012-12-18 15:18:46 +0000
@@ -78,7 +78,7 @@
                   </DescendantAxisIterator>
                 </NodeSortIterator>
               </ForVariable>
-              <LetVariable name="$$opt_temp_3" materialize="true">
+              <ForVariable name="$$opt_temp_3">
                 <HoistIterator>
                   <CompareIterator>
                     <FnDataIterator>
@@ -89,7 +89,7 @@
                     <SingletonIterator value="xs:string(Tom Jones)"/>
                   </CompareIterator>
                 </HoistIterator>
-              </LetVariable>
+              </ForVariable>
               <ForVariable name="buyer">
                 <UnhoistIterator>
                   <LetVarIterator varname="$$opt_temp_0"/>
@@ -182,7 +182,7 @@
                   </FnDataIterator>
                 </HoistIterator>
               </LetVariable>
-              <LetVariable name="$$opt_temp_5" materialize="true">
+              <ForVariable name="$$opt_temp_5">
                 <HoistIterator>
                   <ContainsIterator>
                     <PromoteIterator type="xs:string">
@@ -197,8 +197,8 @@
                     <SingletonIterator value="xs:string(Bicycle)"/>
                   </ContainsIterator>
                 </HoistIterator>
-              </LetVariable>
-              <LetVariable name="$$opt_temp_4" materialize="true">
+              </ForVariable>
+              <ForVariable name="$$opt_temp_4">
                 <HoistIterator>
                   <CompareIterator>
                     <FnDataIterator>
@@ -213,7 +213,7 @@
                     </FnDataIterator>
                   </CompareIterator>
                 </HoistIterator>
-              </LetVariable>
+              </ForVariable>
               <ForVariable name="highbid">
                 <NodeSortIterator distinct="true" ascending="true">
                   <ProbeIndexPointGeneralIterator>
@@ -227,13 +227,13 @@
               <WhereClause>
                 <AndIterator>
                   <UnhoistIterator>
-                    <LetVarIterator varname="$$opt_temp_3"/>
-                  </UnhoistIterator>
-                  <UnhoistIterator>
-                    <LetVarIterator varname="$$opt_temp_4"/>
-                  </UnhoistIterator>
-                  <UnhoistIterator>
-                    <LetVarIterator varname="$$opt_temp_5"/>
+                    <ForVarIterator varname="$$opt_temp_3"/>
+                  </UnhoistIterator>
+                  <UnhoistIterator>
+                    <ForVarIterator varname="$$opt_temp_4"/>
+                  </UnhoistIterator>
+                  <UnhoistIterator>
+                    <ForVarIterator varname="$$opt_temp_5"/>
                   </UnhoistIterator>
                   <SingletonIterator value="xs:boolean(true)"/>
                   <CompareIterator>

=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/xray/ppm_10.iter'
--- test/rbkt/ExpCompilerResults/IterPlan/zorba/xray/ppm_10.iter	2012-12-06 22:49:35 +0000
+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/xray/ppm_10.iter	2012-12-18 15:18:46 +0000
@@ -214,13 +214,13 @@
               <SingletonIterator value="xs:decimal(0.5)"/>
             </SpecificNumArithIterator_AddOperation_DECIMAL>
           </ForVariable>
-          <LetVariable name="$$opt_temp_1" materialize="true">
+          <ForVariable name="$$opt_temp_1">
             <HoistIterator>
               <PromoteIterator type="xs:double">
                 <ForVarIterator varname="y-recentered"/>
               </PromoteIterator>
             </HoistIterator>
-          </LetVariable>
+          </ForVariable>
           <ForVariable name="x">
             <UnhoistIterator>
               <LetVarIterator varname="$$opt_temp_0"/>
@@ -245,7 +245,7 @@
                       </SpecificNumArithIterator_MultiplyOperation_DECIMAL>
                     </PromoteIterator>
                     <UnhoistIterator>
-                      <LetVarIterator varname="$$opt_temp_1"/>
+                      <ForVarIterator varname="$$opt_temp_1"/>
                     </UnhoistIterator>
                   </UDFunctionCallIterator>
                 </ForVariable>

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