Merge lp:~zorba-coders/zorba/markos-scratch into lp:zorba

Proposed by Markos Zaharioudakis
Status: Merged
Approved by: Markos Zaharioudakis
Approved revision: 10995
Merged at revision: 11140
Proposed branch: lp:~zorba-coders/zorba/markos-scratch
Merge into: lp:zorba
Diff against target: 2346 lines (+502/-655)
40 files modified
ChangeLog (+4/-1)
src/compiler/api/compiler_api.cpp (+28/-9)
src/compiler/api/compilercb.cpp (+3/-0)
src/compiler/api/compilercb.h (+26/-11)
src/compiler/expression/expr_base.cpp (+39/-36)
src/compiler/expression/expr_base.h (+26/-11)
src/compiler/expression/expr_clone.cpp (+1/-1)
src/compiler/expression/expr_iter.cpp (+2/-2)
src/compiler/expression/expr_put.cpp (+2/-2)
src/compiler/expression/expr_type.cpp (+36/-3)
src/compiler/expression/script_exprs.cpp (+15/-17)
src/compiler/expression/script_exprs.h (+48/-53)
src/compiler/expression/var_expr.cpp (+15/-2)
src/compiler/expression/var_expr.h (+11/-7)
src/compiler/rewriter/rules/hoist_rules.cpp (+2/-2)
src/compiler/rewriter/rules/index_join_rule.cpp (+3/-2)
src/compiler/rewriter/rules/nodeid_rules.cpp (+3/-15)
src/compiler/rewriter/rules/type_rules.cpp (+58/-88)
src/compiler/rewriter/tools/dataflow_annotations.cpp (+9/-33)
test/parser/CMakeLists.txt (+3/-3)
test/rbkt/ExpCompilerResults/IterPlan/zorba/collections/count_dynamic_zorba_collection.iter (+2/-10)
test/rbkt/ExpCompilerResults/IterPlan/zorba/collections/count_static_zorba_collection.iter (+2/-10)
test/rbkt/ExpCompilerResults/IterPlan/zorba/collections/count_w3c_collection.iter (+2/-10)
test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/idx1.iter (+14/-18)
test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/idx2.iter (+14/-18)
test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/idx5.iter (+29/-83)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/dataguide-c.iter (+5/-25)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/dataguide-nc.iter (+5/-25)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/hashjoin-idx1.iter (+14/-18)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/node-copy-01.iter (+3/-7)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/node-copy-02.iter (+6/-10)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/node-copy-03.iter (+6/-10)
test/rbkt/ExpCompilerResults/IterPlan/zorba/optim/positioned-access.iter (+2/-10)
test/rbkt/ExpCompilerResults/IterPlan/zorba/optim/var_inline_01.iter (+13/-28)
test/rbkt/ExpCompilerResults/IterPlan/zorba/udf/udf1.iter (+1/-5)
test/rbkt/ExpCompilerResults/IterPlan/zorba/windowing/q10.iter (+7/-11)
test/rbkt/ExpCompilerResults/IterPlan/zorba/windowing/q4.iter (+28/-31)
test/rbkt/ExpCompilerResults/IterPlan/zorba/windowing/q9.iter (+10/-14)
test/rbkt/ExpCompilerResults/IterPlan/zorba/xray/ppm_10.iter (+3/-12)
test/rbkt/Queries/zorba/windowing/q4.xq (+2/-2)
To merge this branch: bzr merge lp:~zorba-coders/zorba/markos-scratch
Reviewer Review Type Date Requested Status
Markos Zaharioudakis Approve
Review via email: mp+138556@code.launchpad.net

Commit message

1. Better computation of the static type for global variables
2. Optimization of comparison operators when untypedAtomic items are involved.

Description of the change

1. Better computation of the static type for global variables
2. Optimization of comparison operators when untypedAtomic items are involved.

To post a comment you must log in.
10995. By Markos Zaharioudakis

1. Better computation of the static type for global variables, 2. Optimization of comparison operators when untypedAtomic items are involved

Revision history for this message
Markos Zaharioudakis (markos-za) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job markos-scratch-2012-12-06T22-59-53.623Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2012-11-29 19:17:08 +0000
3+++ ChangeLog 2012-12-06 22:51:20 +0000
4@@ -12,6 +12,8 @@
5
6 Optimizations:
7 * Various optimizations in the implementation of the optimizer rules.
8+ * Better computation of the static type for global variables.
9+ * Optimization of comparison operators when untypedAtomic items are involved.
10
11 Bug Fixes/Other Changes:
12 * Change XQXQ (XQuery-for-XQuery) module now part of Zorba core
13@@ -28,9 +30,10 @@
14 * Fixed bug #1065321 (following:text() doesn't return results in doc order)
15 * Fixed bug #1067706 (wrong const folding in mutually recursive udfs)
16 * Fixed bug #1021492 (while computeing the "sources" of a prolog var, skip
17- any var-setting exprs that appear in non-used (and non-optimized) functions).
18+ any var-setting exprs that appear in non-used (and non-optimized) functions).
19 * Fixed bug #1070551 (zerr:ZOSE0003 stream read failure)
20
21+
22 version 2.7
23
24 New Features:
25
26=== modified file 'src/compiler/api/compiler_api.cpp'
27--- src/compiler/api/compiler_api.cpp 2012-10-08 12:09:36 +0000
28+++ src/compiler/api/compiler_api.cpp 2012-12-06 22:51:20 +0000
29@@ -138,10 +138,10 @@
30 #ifdef ZORBA_XQUERYX
31 char* converted_xquery_str = NULL;
32 std::string xquery_str;
33- bool is_xqueryx = false;
34+ bool is_xqueryx = false;
35+
36 {
37- char strtemp[1000];
38- //int nr_read = 1;
39+ char strtemp[1000];
40 do
41 {
42 strtemp[0] = 0;
43@@ -175,26 +175,30 @@
44 {
45 xquery_stream = new std::istringstream(xquery_str);
46 }
47-#endif
48+#endif // ZORBA_XQUERYX
49+
50+ theCompilerCB->setPhase(CompilerCB::PARSING);
51
52 xquery_driver lDriver(&*theCompilerCB);
53 lDriver.parse_stream(*xquery_stream, aFileName);
54
55+ theCompilerCB->setPhase(CompilerCB::NONE);
56+
57 #ifdef ZORBA_XQUERYX
58 delete xquery_stream;
59- if(is_xqueryx)
60+ if (is_xqueryx)
61 {
62 xqxconvertor->freeResult(converted_xquery_str);
63 }
64 #endif
65+
66 parsenode_t node = lDriver.get_expr();
67
68 if (typeid (*node) == typeid (ParseErrorNode))
69 {
70 ParseErrorNode* pen = static_cast<ParseErrorNode *>(&*node);
71- throw XQUERY_EXCEPTION_VAR(
72- pen->err, ERROR_PARAMS(pen->msg), ERROR_LOC(pen->get_location())
73- );
74+ throw XQUERY_EXCEPTION_VAR(pen->err,
75+ ERROR_PARAMS(pen->msg), ERROR_LOC(pen->get_location()));
76 }
77
78 return node;
79@@ -285,7 +289,11 @@
80 audit::XQUERY_COMPILATION_CODEGENERATION_DURATION,
81 lTimer);
82
83+ theCompilerCB->setPhase(CompilerCB::CODEGEN);
84+
85 plan = codegen("main query", rootExpr, theCompilerCB, nextDynamicVarId);
86+
87+ theCompilerCB->setPhase(CompilerCB::NONE);
88 }
89
90 //theCompilerCB->getExprManager()->garbageCollect();
91@@ -306,8 +314,12 @@
92 time::get_current_walltime(startTime);
93 #endif
94
95+ theCompilerCB->setPhase(CompilerCB::TRANSLATION);
96+
97 expr* lExpr = translate(*aParsenode, theCompilerCB);
98
99+ theCompilerCB->setPhase(CompilerCB::NONE);
100+
101 #if 0
102 std::cout << "Num exprs after translation = "
103 << theCompilerCB->getExprManager()->numExprs()
104@@ -321,7 +333,7 @@
105 if ( lExpr == NULL )
106 {
107 // TODO: can this happen?
108- throw ZORBA_EXCEPTION( zerr::ZAPI0002_XQUERY_COMPILATION_FAILED );
109+ throw ZORBA_EXCEPTION(zerr::ZAPI0002_XQUERY_COMPILATION_FAILED);
110 }
111
112 return lExpr;
113@@ -333,6 +345,8 @@
114 ********************************************************************************/
115 expr* XQueryCompiler::optimize(expr* lExpr)
116 {
117+ theCompilerCB->setPhase(CompilerCB::OPTIMIZATION);
118+
119 // Build the call-graph among the udfs that are actually used in the query
120 // program.
121 UDFGraph udfGraph(lExpr);
122@@ -343,7 +357,10 @@
123 udfGraph.inferDeterminism();
124
125 if (theCompilerCB->theConfig.opt_level <= CompilerCB::config::O0)
126+ {
127+ theCompilerCB->setPhase(CompilerCB::NONE);
128 return lExpr;
129+ }
130
131 // Optimize the udfs.
132 udfGraph.optimizeUDFs(theCompilerCB);
133@@ -362,6 +379,8 @@
134 if ( theCompilerCB->theConfig.optimize_cb != NULL )
135 theCompilerCB->theConfig.optimize_cb(lExpr, "main query");
136
137+ theCompilerCB->setPhase(CompilerCB::NONE);
138+
139 return lExpr;
140 }
141
142
143=== modified file 'src/compiler/api/compilercb.cpp'
144--- src/compiler/api/compilercb.cpp 2012-10-24 11:32:56 +0000
145+++ src/compiler/api/compilercb.cpp 2012-12-06 22:51:20 +0000
146@@ -113,6 +113,7 @@
147 #ifdef ZORBA_WITH_DEBUGGER
148 theDebuggerCommons(0),
149 #endif
150+ thePhase(NONE),
151 theHasEval(false),
152 theIsEval(false),
153 theIsLoadProlog(false),
154@@ -141,6 +142,7 @@
155 #ifdef ZORBA_WITH_DEBUGGER
156 theDebuggerCommons(cb.theDebuggerCommons),
157 #endif
158+ thePhase(NONE),
159 theHasEval(false),
160 theIsEval(false),
161 theIsLoadProlog(false),
162@@ -167,6 +169,7 @@
163 #ifdef ZORBA_WITH_DEBUGGER
164 theDebuggerCommons(NULL),
165 #endif
166+ thePhase(RUNTIME),
167 theHasEval(false),
168 theIsEval(false),
169 theNextVisitId(1),
170
171=== modified file 'src/compiler/api/compilercb.h'
172--- src/compiler/api/compilercb.h 2012-10-24 11:32:56 +0000
173+++ src/compiler/api/compilercb.h 2012-12-06 22:51:20 +0000
174@@ -132,7 +132,7 @@
175 Pointer to the function to call to print the expr tree that results from
176 translating the query AST.
177 ********************************************************************************/
178-class ZORBA_DLL_PUBLIC CompilerCB : public zorba::serialization::SerializeBaseClass
179+class CompilerCB : public zorba::serialization::SerializeBaseClass
180 {
181 public:
182 struct config : public zorba::serialization::SerializeBaseClass
183@@ -168,8 +168,22 @@
184 void serialize(::zorba::serialization::Archiver& ar);
185 };
186
187+ typedef enum
188+ {
189+ NONE,
190+ PARSING,
191+ TRANSLATION,
192+ OPTIMIZATION,
193+ CODEGEN,
194+ RUNTIME
195+ } ProcessingPhase;
196+
197 typedef std::map<csize, static_context_t> SctxMap;
198
199+ typedef std::multimap<const expr*, pragma*> PragmaMap;
200+
201+ typedef PragmaMap::const_iterator PragmaMapIter;
202+
203 public:
204 XQueryDiagnostics * theXQueryDiagnostics;
205
206@@ -181,6 +195,8 @@
207 DebuggerCommons * theDebuggerCommons;
208 #endif
209
210+ ProcessingPhase thePhase;
211+
212 bool theHasEval;
213
214 bool theIsEval;
215@@ -197,15 +213,13 @@
216
217 uint32_t theTempIndexCounter;
218
219- ulong theNextVisitId;
220+ uint8_t theNextVisitId;
221
222 config theConfig;
223
224 ExprManager * const theEM;
225
226- typedef std::multimap<const expr*, pragma*> PragmaMap;
227- typedef PragmaMap::const_iterator PragmaMapIter;
228- PragmaMap thePragmas;
229+ PragmaMap thePragmas;
230
231 public:
232 SERIALIZABLE_CLASS(CompilerCB);
233@@ -219,6 +233,10 @@
234
235 ~CompilerCB();
236
237+ ProcessingPhase getPhase() const { return thePhase; }
238+
239+ void setPhase(ProcessingPhase v) { thePhase = v; }
240+
241 bool isLoadPrologQuery() const { return theIsLoadProlog; }
242
243 void setLoadPrologQuery() { theIsLoadProlog = true; }
244@@ -240,12 +258,9 @@
245 //
246 void add_pragma(const expr* e, pragma* p);
247
248- void
249- lookup_pragmas(const expr* e, std::vector<pragma*>& pragmas) const;
250-
251- bool
252- lookup_pragma(const expr* e, const zstring& localname, pragma*&) const;
253-
254+ void lookup_pragmas(const expr* e, std::vector<pragma*>& pragmas) const;
255+
256+ bool lookup_pragma(const expr* e, const zstring& localname, pragma*&) const;
257 };
258
259
260
261=== modified file 'src/compiler/expression/expr_base.cpp'
262--- src/compiler/expression/expr_base.cpp 2012-10-31 08:02:16 +0000
263+++ src/compiler/expression/expr_base.cpp 2012-12-06 22:51:20 +0000
264@@ -128,7 +128,9 @@
265 theCCB(NULL),
266 theSctx(NULL),
267 theUDF(NULL),
268- theFlags1(0)
269+ theAnnotationFlags(0),
270+ theBoolFlags(0),
271+ theVisitId(0)
272 {
273 }
274
275@@ -148,7 +150,8 @@
276 theUDF(udf),
277 theLoc(loc),
278 theKind(k),
279- theFlags1(0),
280+ theAnnotationFlags(0),
281+ theBoolFlags(0),
282 theVisitId(0)
283 {
284 theScriptingKind = UNKNOWN_SCRIPTING_KIND;
285@@ -328,7 +331,7 @@
286 if (getDereferencesNodes() != ANNOTATION_TRUE_FIXED)
287 setDereferencesNodes(ANNOTATION_FALSE);
288
289- //theFlags1 = 0;
290+ //theAnnotationFlags = 0;
291 //setNonDiscardable(ANNOTATION_FALSE);
292 //setUnfoldable(ANNOTATION_FALSE);
293
294@@ -374,14 +377,14 @@
295 ********************************************************************************/
296 BoolAnnotationValue expr::getProducesSortedNodes() const
297 {
298- return (BoolAnnotationValue)(theFlags1 & PRODUCES_SORTED_NODES_MASK);
299+ return (BoolAnnotationValue)(theAnnotationFlags & PRODUCES_SORTED_NODES_MASK);
300 }
301
302
303 void expr::setProducesSortedNodes(BoolAnnotationValue v)
304 {
305- theFlags1 &= ~PRODUCES_SORTED_NODES_MASK;
306- theFlags1 |= v;
307+ theAnnotationFlags &= ~PRODUCES_SORTED_NODES_MASK;
308+ theAnnotationFlags |= v;
309 }
310
311
312@@ -398,14 +401,14 @@
313 BoolAnnotationValue expr::getProducesDistinctNodes() const
314 {
315 return (BoolAnnotationValue)
316- ((theFlags1 & PRODUCES_DISTINCT_NODES_MASK) >> PRODUCES_DISTINCT_NODES);
317+ ((theAnnotationFlags & PRODUCES_DISTINCT_NODES_MASK) >> PRODUCES_DISTINCT_NODES);
318 }
319
320
321 void expr::setProducesDistinctNodes(BoolAnnotationValue v)
322 {
323- theFlags1 &= ~PRODUCES_DISTINCT_NODES_MASK;
324- theFlags1 |= (v << PRODUCES_DISTINCT_NODES);
325+ theAnnotationFlags &= ~PRODUCES_DISTINCT_NODES_MASK;
326+ theAnnotationFlags |= (v << PRODUCES_DISTINCT_NODES);
327 }
328
329
330@@ -422,14 +425,14 @@
331 BoolAnnotationValue expr::getIgnoresSortedNodes() const
332 {
333 return (BoolAnnotationValue)
334- ((theFlags1 & IGNORES_SORTED_NODES_MASK) >> IGNORES_SORTED_NODES);
335+ ((theAnnotationFlags & IGNORES_SORTED_NODES_MASK) >> IGNORES_SORTED_NODES);
336 }
337
338
339 void expr::setIgnoresSortedNodes(BoolAnnotationValue v)
340 {
341- theFlags1 &= ~IGNORES_SORTED_NODES_MASK;
342- theFlags1 |= (v << IGNORES_SORTED_NODES);
343+ theAnnotationFlags &= ~IGNORES_SORTED_NODES_MASK;
344+ theAnnotationFlags |= (v << IGNORES_SORTED_NODES);
345 }
346
347
348@@ -446,14 +449,14 @@
349 BoolAnnotationValue expr::getIgnoresDuplicateNodes() const
350 {
351 return (BoolAnnotationValue)
352- ((theFlags1 & IGNORES_DUPLICATE_NODES_MASK) >> IGNORES_DUPLICATE_NODES);
353+ ((theAnnotationFlags & IGNORES_DUPLICATE_NODES_MASK) >> IGNORES_DUPLICATE_NODES);
354 }
355
356
357 void expr::setIgnoresDuplicateNodes(BoolAnnotationValue v)
358 {
359- theFlags1 &= ~IGNORES_DUPLICATE_NODES_MASK;
360- theFlags1 |= (v << IGNORES_DUPLICATE_NODES);
361+ theAnnotationFlags &= ~IGNORES_DUPLICATE_NODES_MASK;
362+ theAnnotationFlags |= (v << IGNORES_DUPLICATE_NODES);
363 }
364
365
366@@ -469,14 +472,14 @@
367 BoolAnnotationValue expr::getNonDiscardable() const
368 {
369 return (BoolAnnotationValue)
370- ((theFlags1 & NON_DISCARDABLE_MASK) >> NON_DISCARDABLE);
371+ ((theAnnotationFlags & NON_DISCARDABLE_MASK) >> NON_DISCARDABLE);
372 }
373
374
375 void expr::setNonDiscardable(BoolAnnotationValue v)
376 {
377- theFlags1 &= ~NON_DISCARDABLE_MASK;
378- theFlags1 |= (v << NON_DISCARDABLE);
379+ theAnnotationFlags &= ~NON_DISCARDABLE_MASK;
380+ theAnnotationFlags |= (v << NON_DISCARDABLE);
381 }
382
383
384@@ -493,14 +496,14 @@
385 BoolAnnotationValue expr::getUnfoldable() const
386 {
387 return (BoolAnnotationValue)
388- ((theFlags1 & UNFOLDABLE_MASK) >> UNFOLDABLE);
389+ ((theAnnotationFlags & UNFOLDABLE_MASK) >> UNFOLDABLE);
390 }
391
392
393 void expr::setUnfoldable(BoolAnnotationValue v)
394 {
395- theFlags1 &= ~UNFOLDABLE_MASK;
396- theFlags1 |= (v << UNFOLDABLE);
397+ theAnnotationFlags &= ~UNFOLDABLE_MASK;
398+ theAnnotationFlags |= (v << UNFOLDABLE);
399 }
400
401
402@@ -517,14 +520,14 @@
403 BoolAnnotationValue expr::getContainsRecursiveCall() const
404 {
405 return (BoolAnnotationValue)
406- ((theFlags1 & CONTAINS_RECURSIVE_CALL_MASK) >> CONTAINS_RECURSIVE_CALL);
407+ ((theAnnotationFlags & CONTAINS_RECURSIVE_CALL_MASK) >> CONTAINS_RECURSIVE_CALL);
408 }
409
410
411 void expr::setContainsRecursiveCall(BoolAnnotationValue v)
412 {
413- theFlags1 &= ~CONTAINS_RECURSIVE_CALL_MASK;
414- theFlags1 |= (v << CONTAINS_RECURSIVE_CALL);
415+ theAnnotationFlags &= ~CONTAINS_RECURSIVE_CALL_MASK;
416+ theAnnotationFlags |= (v << CONTAINS_RECURSIVE_CALL);
417 }
418
419
420@@ -541,14 +544,14 @@
421 BoolAnnotationValue expr::getContainsPragma() const
422 {
423 return (BoolAnnotationValue)
424- ((theFlags1 & CONTAINS_PRAGMA_MASK) >> CONTAINS_PRAGMA);
425+ ((theAnnotationFlags & CONTAINS_PRAGMA_MASK) >> CONTAINS_PRAGMA);
426 }
427
428
429 void expr::setContainsPragma(BoolAnnotationValue v)
430 {
431- theFlags1 &= ~CONTAINS_PRAGMA_MASK;
432- theFlags1 |= (v << CONTAINS_PRAGMA);
433+ theAnnotationFlags &= ~CONTAINS_PRAGMA_MASK;
434+ theAnnotationFlags |= (v << CONTAINS_PRAGMA);
435 }
436
437
438@@ -566,14 +569,14 @@
439 BoolAnnotationValue expr::getConstructsNodes() const
440 {
441 return (BoolAnnotationValue)
442- ((theFlags1 & CONSTRUCTS_NODES_MASK) >> CONSTRUCTS_NODES);
443+ ((theAnnotationFlags & CONSTRUCTS_NODES_MASK) >> CONSTRUCTS_NODES);
444 }
445
446
447 void expr::setConstructsNodes(BoolAnnotationValue v)
448 {
449- theFlags1 &= ~CONSTRUCTS_NODES_MASK;
450- theFlags1 |= (v << CONSTRUCTS_NODES);
451+ theAnnotationFlags &= ~CONSTRUCTS_NODES_MASK;
452+ theAnnotationFlags |= (v << CONSTRUCTS_NODES);
453 }
454
455
456@@ -591,14 +594,14 @@
457 BoolAnnotationValue expr::getDereferencesNodes() const
458 {
459 return (BoolAnnotationValue)
460- ((theFlags1 & DEREFERENCES_NODES_MASK) >> DEREFERENCES_NODES);
461+ ((theAnnotationFlags & DEREFERENCES_NODES_MASK) >> DEREFERENCES_NODES);
462 }
463
464
465 void expr::setDereferencesNodes(BoolAnnotationValue v)
466 {
467- theFlags1 &= ~DEREFERENCES_NODES_MASK;
468- theFlags1 |= (v << DEREFERENCES_NODES);
469+ theAnnotationFlags &= ~DEREFERENCES_NODES_MASK;
470+ theAnnotationFlags |= (v << DEREFERENCES_NODES);
471 }
472
473
474@@ -620,14 +623,14 @@
475 BoolAnnotationValue expr::getMustCopyNodes() const
476 {
477 return (BoolAnnotationValue)
478- ((theFlags1 & MUST_COPY_NODES_MASK) >> MUST_COPY_NODES);
479+ ((theAnnotationFlags & MUST_COPY_NODES_MASK) >> MUST_COPY_NODES);
480 }
481
482
483 void expr::setMustCopyNodes(BoolAnnotationValue v)
484 {
485- theFlags1 &= ~MUST_COPY_NODES_MASK;
486- theFlags1 |= (v << MUST_COPY_NODES);
487+ theAnnotationFlags &= ~MUST_COPY_NODES_MASK;
488+ theAnnotationFlags |= (v << MUST_COPY_NODES);
489 }
490
491
492
493=== modified file 'src/compiler/expression/expr_base.h'
494--- src/compiler/expression/expr_base.h 2012-10-26 07:13:42 +0000
495+++ src/compiler/expression/expr_base.h 2012-12-06 22:51:20 +0000
496@@ -169,6 +169,11 @@
497 DEREFERENCES_NODES_MASK = 0xC00000
498 } AnnotationMask;
499
500+ typedef enum
501+ {
502+ IN_TYPE_COMPUTE = 0x1
503+ } BoolFlags;
504+
505
506 protected:
507 static expr* iter_end_expr;
508@@ -189,12 +194,14 @@
509
510 xqtref_t theType;
511
512- uint32_t theFlags1;
513+ uint32_t theAnnotationFlags;
514+
515+ uint8_t theBoolFlags;
516+
517+ uint8_t theVisitId;
518
519 FreeVars theFreeVars;
520
521- int theVisitId;
522-
523 public:
524 static bool is_sequential(unsigned short theScriptingKind);
525
526@@ -224,9 +231,9 @@
527
528 void set_loc(const QueryLoc& loc) { theLoc = loc; }
529
530- uint32_t getFlags() const { return theFlags1; }
531+ uint32_t getAnnotationFlags() const { return theAnnotationFlags; }
532
533- void setFlags(uint32_t flags) { theFlags1 = flags; }
534+ void setAnnotationFlags(uint32_t flags) { theAnnotationFlags = flags; }
535
536 unsigned short get_scripting_detail() const { return theScriptingKind; }
537
538@@ -263,6 +270,20 @@
539 std::string toString() const;
540
541 public:
542+ //
543+ void setVisitId(uint8_t id) { theVisitId = id; }
544+
545+ bool isVisited(uint8_t id) const { return theVisitId == id; }
546+
547+ uint8_t getVisitId() const { return theVisitId; }
548+
549+ // Transient flag used only during the type computation for global vars
550+ bool isInTypeCompute() const { return theBoolFlags & IN_TYPE_COMPUTE; }
551+
552+ void setInTypeCompute() { theBoolFlags |= IN_TYPE_COMPUTE; }
553+
554+ void resetInTypeCompute() { theBoolFlags &= ~IN_TYPE_COMPUTE; }
555+
556 // Annotation : produces-sorted-nodes
557 BoolAnnotationValue getProducesSortedNodes() const;
558
559@@ -351,12 +372,6 @@
560 void setFreeVars(FreeVars& s);
561
562 //
563- void setVisitId(int id) { theVisitId = id; }
564-
565- bool isVisited(int id) const { return theVisitId == id; }
566-
567- int getVisitId() const { return theVisitId; }
568-
569 bool is_constant() const;
570
571 bool is_nondeterministic() const;
572
573=== modified file 'src/compiler/expression/expr_clone.cpp'
574--- src/compiler/expression/expr_clone.cpp 2012-10-24 11:32:56 +0000
575+++ src/compiler/expression/expr_clone.cpp 2012-12-06 22:51:20 +0000
576@@ -618,7 +618,7 @@
577 udf,
578 theLoc,
579 varCopy,
580- (e->theInitExpr ? e->theInitExpr->clone(udf, subst) : NULL));
581+ (e->theExpr ? e->theExpr->clone(udf, subst) : NULL));
582
583 break;
584 }
585
586=== modified file 'src/compiler/expression/expr_iter.cpp'
587--- src/compiler/expression/expr_iter.cpp 2012-10-24 11:32:56 +0000
588+++ src/compiler/expression/expr_iter.cpp 2012-12-06 22:51:20 +0000
589@@ -825,8 +825,8 @@
590
591 EXPR_ITER_BEGIN();
592
593- if (varDeclExpr->theInitExpr)
594- EXPR_ITER_NEXT(varDeclExpr->theInitExpr);
595+ if (varDeclExpr->theExpr)
596+ EXPR_ITER_NEXT(varDeclExpr->theExpr);
597
598 EXPR_ITER_END();
599 return;
600
601=== modified file 'src/compiler/expression/expr_put.cpp'
602--- src/compiler/expression/expr_put.cpp 2012-10-30 10:02:56 +0000
603+++ src/compiler/expression/expr_put.cpp 2012-12-06 22:51:20 +0000
604@@ -462,8 +462,8 @@
605 BEGIN_PUT(var_decl_expr);
606
607 theVarExpr->put(os);
608- if (theInitExpr)
609- theInitExpr->put(os);
610+ if (theExpr)
611+ theExpr->put(os);
612
613 END_PUT();
614 }
615
616=== modified file 'src/compiler/expression/expr_type.cpp'
617--- src/compiler/expression/expr_type.cpp 2012-10-31 08:02:16 +0000
618+++ src/compiler/expression/expr_type.cpp 2012-12-06 22:51:20 +0000
619@@ -31,6 +31,9 @@
620 #include "compiler/expression/var_expr.h"
621 #include "compiler/expression/expr.h"
622 #include "compiler/expression/expr_iter.h"
623+
624+#include "compiler/api/compilercb.h"
625+
626 #include "compiler/xqddf/collection_decl.h"
627
628 #include "functions/function.h"
629@@ -118,9 +121,9 @@
630
631 TypeConstants::quantifier_t quant = TypeConstants::QUANT_ONE;
632
633- ulong numClauses = e->num_clauses();
634+ csize numClauses = e->num_clauses();
635
636- for (ulong i = 0; i < numClauses && quant != TypeConstants::QUANT_STAR; ++i)
637+ for (csize i = 0; i < numClauses && quant != TypeConstants::QUANT_STAR; ++i)
638 {
639 const flwor_clause* c = e->theClauses[i];
640
641@@ -213,8 +216,38 @@
642 }
643 case var_expr::prolog_var:
644 {
645- // For const global vars, their type is set in
646+ // NOTE: For const global vars, their declared type is set to the
647+ // type of their init expr, if any. This is done in
648 // translator::end_visit(const GlobalVarDecl& v, void*)
649+
650+ csize numSetExprs = e->num_set_exprs();
651+
652+ if (e->get_ccb()->getPhase() == CompilerCB::OPTIMIZATION &&
653+ numSetExprs > 0 &&
654+ !e->is_external() &&
655+ !e->isInTypeCompute())
656+ {
657+ e->setInTypeCompute();
658+
659+ var_set_expr* setExpr = e->get_set_expr(0);
660+
661+ derivedType = setExpr->get_expr()->get_return_type();
662+
663+ for (csize i = 1; i < numSetExprs; ++i)
664+ {
665+ if (derivedType == rtm.ITEM_TYPE_STAR)
666+ break;
667+
668+ setExpr = e->get_set_expr(i);
669+
670+ derivedType = TypeOps::union_type(*derivedType,
671+ *setExpr->get_expr()->get_return_type(),
672+ tm);
673+ }
674+
675+ e->resetInTypeCompute();
676+ }
677+
678 break;
679 }
680 case var_expr::local_var: // TODO: compute derived type for const local vars.
681
682=== modified file 'src/compiler/expression/script_exprs.cpp'
683--- src/compiler/expression/script_exprs.cpp 2012-10-24 11:32:56 +0000
684+++ src/compiler/expression/script_exprs.cpp 2012-12-06 22:51:20 +0000
685@@ -208,17 +208,11 @@
686 var_expr* varExpr,
687 expr* initExpr)
688 :
689- expr(ccb, sctx, udf, loc, var_decl_expr_kind),
690- theVarExpr(varExpr),
691- theInitExpr(initExpr)
692+ var_set_expr(ccb, sctx, udf, loc, varExpr, initExpr, true)
693 {
694+ theKind = var_decl_expr_kind;
695+
696 compute_scripting_kind();
697-
698- // var_decl_expr is unfoldable because it requires access to the dyn ctx.
699- setUnfoldable(ANNOTATION_TRUE_FIXED);
700-
701- if (initExpr)
702- varExpr->add_set_expr(this);
703 }
704
705
706@@ -234,17 +228,17 @@
707 void var_decl_expr::compute_scripting_kind()
708 {
709 if (theVarExpr->get_kind() == var_expr::prolog_var)
710- checkSimpleExpr(theInitExpr);
711+ checkSimpleExpr(theExpr);
712 else
713- checkNonUpdating(theInitExpr);
714+ checkNonUpdating(theExpr);
715
716- if (theInitExpr == NULL)
717+ if (theExpr == NULL)
718 {
719 theScriptingKind = SIMPLE_EXPR;
720 }
721 else
722 {
723- theScriptingKind = theInitExpr->get_scripting_detail();
724+ theScriptingKind = theExpr->get_scripting_detail();
725 }
726 }
727
728@@ -258,7 +252,8 @@
729 user_function* udf,
730 const QueryLoc& loc,
731 var_expr* varExpr,
732- expr* setExpr)
733+ expr* setExpr,
734+ bool isDecl)
735 :
736 expr(ccb, sctx, udf, loc, var_set_expr_kind),
737 theVarExpr(varExpr),
738@@ -267,12 +262,15 @@
739 assert(varExpr->get_kind() == var_expr::prolog_var ||
740 varExpr->get_kind() == var_expr::local_var);
741
742- compute_scripting_kind();
743+ if (!isDecl)
744+ compute_scripting_kind();
745
746- // var_set_expr is unfoldable because it requires access to the dyn ctx.
747+ // var_set_expr and var_decl_expr are unfoldable because they require access
748+ // to the dyn ctx.
749 setUnfoldable(ANNOTATION_TRUE_FIXED);
750
751- varExpr->add_set_expr(this);
752+ if (setExpr)
753+ varExpr->add_set_expr(this);
754 }
755
756
757
758=== modified file 'src/compiler/expression/script_exprs.h'
759--- src/compiler/expression/script_exprs.h 2012-10-24 11:32:56 +0000
760+++ src/compiler/expression/script_exprs.h 2012-12-06 22:51:20 +0000
761@@ -181,6 +181,52 @@
762
763 /*******************************************************************************
764
765+ AssignStatement ::= "$" VarName ":=" ExprSingle ";"
766+
767+ The RHS of the assignment must be a non-updating expr.
768+
769+ var_set_expr is used to assign a value to a prolog or block-local var. During
770+ runtime, the function computes theExpr and stores the resulting value inside
771+ the appropriate dynamic ctx (global or local), at the location that is identified
772+ by the variable id.
773+********************************************************************************/
774+class var_set_expr : public expr
775+{
776+ friend class ExprManager;
777+ friend class ExprIterator;
778+ friend class expr;
779+
780+protected:
781+ var_expr * theVarExpr;
782+ expr * theExpr;
783+
784+protected:
785+ var_set_expr(
786+ CompilerCB* ccb,
787+ static_context* sctx,
788+ user_function* udf,
789+ const QueryLoc& loc,
790+ var_expr* varExpr,
791+ expr* setExpr,
792+ bool isDecl = false);
793+
794+public:
795+ ~var_set_expr();
796+
797+ var_expr* get_var_expr() const { return theVarExpr; }
798+
799+ expr* get_expr() const { return theExpr; }
800+
801+ void compute_scripting_kind();
802+
803+ void accept(expr_visitor&);
804+
805+ std::ostream& put(std::ostream&) const;
806+};
807+
808+
809+/*******************************************************************************
810+
811 For Global Var:
812 ----------------
813
814@@ -207,17 +253,13 @@
815 Note: the init expr must be non-updating. For global vars, it must also be
816 non-sequential.
817 ********************************************************************************/
818-class var_decl_expr : public expr
819+class var_decl_expr : public var_set_expr
820 {
821 friend class ExprManager;
822 friend class ExprIterator;
823 friend class expr;
824
825 protected:
826- var_expr * theVarExpr;
827- expr * theInitExpr;
828-
829-protected:
830 var_decl_expr(
831 CompilerCB* ccb,
832 static_context* sctx,
833@@ -229,54 +271,7 @@
834 public:
835 ~var_decl_expr();
836
837- var_expr* get_var_expr() const { return theVarExpr; }
838-
839- expr* get_init_expr() const { return theInitExpr; }
840-
841- void compute_scripting_kind();
842-
843- void accept(expr_visitor&);
844-
845- std::ostream& put(std::ostream&) const;
846-};
847-
848-
849-/*******************************************************************************
850-
851- AssignStatement ::= "$" VarName ":=" ExprSingle ";"
852-
853- The RHS of the assignment must be a non-updating expr.
854-
855- var_set_expr is used to assign a value to a prolog or block-local var. During
856- runtime, the function computes theExpr and stores the resulting value inside
857- the appropriate dynamic ctx (global or local), at the location that is identified
858- by the variable id.
859-********************************************************************************/
860-class var_set_expr : public expr
861-{
862- friend class ExprManager;
863- friend class ExprIterator;
864- friend class expr;
865-
866-protected:
867- var_expr * theVarExpr;
868- expr * theExpr;
869-
870-protected:
871- var_set_expr(
872- CompilerCB* ccb,
873- static_context* sctx,
874- user_function* udf,
875- const QueryLoc& loc,
876- var_expr* varExpr,
877- expr* setExpr);
878-
879-public:
880- ~var_set_expr();
881-
882- var_expr* get_var_expr() const { return theVarExpr; }
883-
884- expr* get_expr() const { return theExpr; }
885+ expr* get_init_expr() const { return theExpr; }
886
887 void compute_scripting_kind();
888
889
890=== modified file 'src/compiler/expression/var_expr.cpp'
891--- src/compiler/expression/var_expr.cpp 2012-10-31 08:02:16 +0000
892+++ src/compiler/expression/var_expr.cpp 2012-12-06 22:51:20 +0000
893@@ -18,6 +18,7 @@
894 #include "functions/udf.h"
895
896 #include "compiler/expression/var_expr.h"
897+#include "compiler/expression/script_exprs.h"
898 #include "compiler/expression/update_exprs.h"
899 #include "compiler/expression/flwor_expr.h"
900 #include "compiler/expression/expr_visitor.h"
901@@ -300,13 +301,25 @@
902 /*******************************************************************************
903
904 ********************************************************************************/
905+void var_expr::add_set_expr(expr* e)
906+{
907+ assert(e->get_expr_kind() == var_decl_expr_kind ||
908+ e->get_expr_kind() == var_set_expr_kind);
909+
910+ theSetExprs.push_back(static_cast<var_set_expr*>(e));
911+}
912+
913+
914+/*******************************************************************************
915+
916+********************************************************************************/
917 void var_expr::remove_set_expr(expr* e)
918 {
919 assert(theVarKind == local_var || theVarKind == prolog_var);
920
921 bool found = false;
922- std::vector<expr*>::iterator ite = theSetExprs.begin();
923- std::vector<expr*>::iterator end = theSetExprs.end();
924+ VarSetExprs::iterator ite = theSetExprs.begin();
925+ VarSetExprs::iterator end = theSetExprs.end();
926 for (; ite != end; ++ite)
927 {
928 if (*ite == e)
929
930=== modified file 'src/compiler/expression/var_expr.h'
931--- src/compiler/expression/var_expr.h 2012-10-26 07:13:42 +0000
932+++ src/compiler/expression/var_expr.h 2012-12-06 22:51:20 +0000
933@@ -28,6 +28,8 @@
934 class copy_clause;
935 class var_expr;
936 class VarInfo;
937+class var_set_expr;
938+
939
940 /******************************************************************************
941
942@@ -116,6 +118,8 @@
943 friend class ExprManager;
944
945 public:
946+ typedef std::vector<var_set_expr*> VarSetExprs;
947+
948 enum var_kind
949 {
950 unknown_var = 0,
951@@ -161,7 +165,7 @@
952
953 csize theParamPos;
954
955- std::vector<expr*> theSetExprs;
956+ VarSetExprs theSetExprs;
957
958 VarInfo * theVarInfo;
959
960@@ -244,17 +248,17 @@
961
962 void set_param_pos(csize pos) { theParamPos = pos; }
963
964- void add_set_expr(expr* e) { theSetExprs.push_back(e); }
965+ void add_set_expr(expr* e);
966
967 void remove_set_expr(expr* e);
968
969 csize num_set_exprs() const { return theSetExprs.size(); }
970
971- expr* get_set_expr(csize i) const { return theSetExprs[i]; }
972-
973- std::vector<expr*>::const_iterator setExprsBegin() const { return theSetExprs.begin(); }
974-
975- std::vector<expr*>::const_iterator setExprsEnd() const { return theSetExprs.end(); }
976+ var_set_expr* get_set_expr(csize i) const { return theSetExprs[i]; }
977+
978+ VarSetExprs::const_iterator setExprsBegin() const { return theSetExprs.begin(); }
979+
980+ VarSetExprs::const_iterator setExprsEnd() const { return theSetExprs.end(); }
981
982 bool is_context_item() const;
983
984
985=== modified file 'src/compiler/rewriter/rules/hoist_rules.cpp'
986--- src/compiler/rewriter/rules/hoist_rules.cpp 2012-10-29 11:41:36 +0000
987+++ src/compiler/rewriter/rules/hoist_rules.cpp 2012-12-06 22:51:20 +0000
988@@ -484,7 +484,7 @@
989 expr* hoisted = rCtx.theEM->
990 create_fo_expr(sctx, udf, loc, BUILTIN_FUNC(OP_HOIST_1), e);
991
992- hoisted->setFlags(e->getFlags());
993+ hoisted->setAnnotationFlags(e->getAnnotationFlags());
994 //letvar->setFlags(e->getFlags());
995
996 let_clause* flref(rCtx.theEM->create_let_clause(sctx, loc, letvar, hoisted));
997@@ -523,7 +523,7 @@
998 loc,
999 BUILTIN_FUNC(OP_UNHOIST_1),
1000 rCtx.theEM->create_wrapper_expr(sctx, udf, loc, letvar));
1001- unhoisted->setFlags(e->getFlags());
1002+ unhoisted->setAnnotationFlags(e->getAnnotationFlags());
1003
1004 return unhoisted;
1005 }
1006
1007=== modified file 'src/compiler/rewriter/rules/index_join_rule.cpp'
1008--- src/compiler/rewriter/rules/index_join_rule.cpp 2012-11-02 20:00:13 +0000
1009+++ src/compiler/rewriter/rules/index_join_rule.cpp 2012-12-06 22:51:20 +0000
1010@@ -309,7 +309,7 @@
1011 {
1012 // Normally, other rewrite rules should have added the necessary casting
1013 // to the eq operands so that their static types have quantifiers ONE
1014- // or QUESTION and the associated prime types are not xs:untypedAtomic.
1015+ // or QUESTION and the associated prime types are not xs:anyAtomicType.
1016 // But just in case those rules have been disabled, we check again here
1017 // and reject the hashjoin rewrite if these condition are violated.
1018
1019@@ -323,10 +323,11 @@
1020
1021 // The type of the outer/inner operands in the join predicate must not be
1022 // xs:untypedAtomic or xs:anyAtomic.
1023+ /*
1024 if (TypeOps::is_equal(tm, *primeOuterType, *rtm.UNTYPED_ATOMIC_TYPE_ONE, outerLoc) ||
1025 TypeOps::is_equal(tm, *primeInnerType, *rtm.UNTYPED_ATOMIC_TYPE_ONE, innerLoc))
1026 return false;
1027-
1028+ */
1029 if (TypeOps::is_equal(tm, *primeOuterType, *rtm.ANY_ATOMIC_TYPE_ONE, outerLoc) ||
1030 TypeOps::is_equal(tm, *primeInnerType, *rtm.ANY_ATOMIC_TYPE_ONE, innerLoc))
1031 return false;
1032
1033=== modified file 'src/compiler/rewriter/rules/nodeid_rules.cpp'
1034--- src/compiler/rewriter/rules/nodeid_rules.cpp 2012-10-31 08:02:16 +0000
1035+++ src/compiler/rewriter/rules/nodeid_rules.cpp 2012-12-06 22:51:20 +0000
1036@@ -1161,24 +1161,12 @@
1037 {
1038 e->setVisitId(1);
1039
1040- std::vector<expr*>::const_iterator ite = e->setExprsBegin();
1041- std::vector<expr*>::const_iterator end = e->setExprsEnd();
1042+ var_expr::VarSetExprs::const_iterator ite = e->setExprsBegin();
1043+ var_expr::VarSetExprs::const_iterator end = e->setExprsEnd();
1044
1045 for (; ite != end; ++ite)
1046 {
1047- expr* setExpr = *ite;
1048- expr* valueExpr;
1049-
1050- if (setExpr->get_expr_kind() == var_decl_expr_kind)
1051- {
1052- valueExpr = static_cast<var_decl_expr*>(setExpr)->get_init_expr();
1053- }
1054- else
1055- {
1056- assert(setExpr->get_expr_kind() == var_set_expr_kind);
1057-
1058- valueExpr = static_cast<var_set_expr*>(setExpr)->get_expr();
1059- }
1060+ expr* valueExpr = (*ite)->get_expr();
1061
1062 findSourcesForNodeExtractors(valueExpr);
1063 }
1064
1065=== modified file 'src/compiler/rewriter/rules/type_rules.cpp'
1066--- src/compiler/rewriter/rules/type_rules.cpp 2012-10-31 08:02:16 +0000
1067+++ src/compiler/rewriter/rules/type_rules.cpp 2012-12-06 22:51:20 +0000
1068@@ -235,12 +235,10 @@
1069
1070 RULE_REWRITE_POST(SpecializeOperations)
1071 {
1072- const Properties& props = *Properties::instance();
1073-
1074 RootTypeManager& rtm = GENV_TYPESYSTEM;
1075 TypeManager* tm = node->get_type_manager();
1076-
1077 static_context* sctx = node->get_sctx();
1078+ user_function* udf = node->get_udf();
1079
1080 if (node->get_expr_kind() == fo_expr_kind)
1081 {
1082@@ -255,7 +253,9 @@
1083 fnKind == FunctionConsts::FN_SUM_2)
1084 {
1085 expr* argExpr = fo->get_arg(0);
1086+ const QueryLoc& argLoc = argExpr->get_loc();
1087 xqtref_t argType = argExpr->get_return_type();
1088+
1089 std::vector<xqtref_t> argTypes;
1090 argTypes.push_back(argType);
1091
1092@@ -264,14 +264,11 @@
1093 {
1094 fo->set_func(replacement);
1095
1096- if (TypeOps::is_subtype(tm,
1097- *argType,
1098- *rtm.UNTYPED_ATOMIC_TYPE_STAR,
1099- argExpr->get_loc()))
1100+ if (TypeOps::is_subtype(tm, *argType, *rtm.UNTYPED_ATOMIC_TYPE_STAR, argLoc))
1101 {
1102 expr* promoteExpr = rCtx.theEM->
1103- create_promote_expr(argExpr->get_sctx(),
1104- argExpr->get_udf(),
1105+ create_promote_expr(sctx,
1106+ udf,
1107 argExpr->get_loc(),
1108 argExpr,
1109 rtm.DOUBLE_TYPE_STAR,
1110@@ -359,7 +356,7 @@
1111 if (t0->max_card() > 1 || t1->max_card() > 1)
1112 return NULL;
1113
1114- if (props.specializeNum() && fn->isArithmeticFunction())
1115+ if (fn->isArithmeticFunction())
1116 {
1117 if (! TypeOps::is_numeric_or_untyped(tm, *t0) ||
1118 ! TypeOps::is_numeric_or_untyped(tm, *t1))
1119@@ -368,13 +365,38 @@
1120 if (specialize_numeric(fo, sctx, rCtx) != NULL)
1121 return node;
1122 }
1123- else if (props.specializeCmp() && fn->isComparisonFunction())
1124- {
1125- if (fn->isGeneralComparisonFunction())
1126+ else if (fn->isGeneralComparisonFunction())
1127+ {
1128+ std::vector<xqtref_t> argTypes;
1129+ argTypes.push_back(t0);
1130+ argTypes.push_back(t1);
1131+ function* replacement = fn->specialize(sctx, argTypes);
1132+ if (replacement != NULL)
1133+ {
1134+ fo->set_func(replacement);
1135+ return node;
1136+ }
1137+ }
1138+ else if (fn->isValueComparisonFunction())
1139+ {
1140+ xqtref_t stringType = rtm.STRING_TYPE_QUESTION;
1141+ xqtref_t untypedType = rtm.UNTYPED_ATOMIC_TYPE_QUESTION;
1142+
1143+ const QueryLoc& loc0 = arg0->get_loc();
1144+ const QueryLoc& loc1 = arg1->get_loc();
1145+
1146+ bool atomicORstring0 = (TypeOps::is_subtype(tm, *t0, *untypedType, loc0) ||
1147+ TypeOps::is_subtype(tm, *t0, *stringType, loc0));
1148+
1149+ bool atomicORstring1 = (TypeOps::is_subtype(tm, *t1, *untypedType, loc1) ||
1150+ TypeOps::is_subtype(tm, *t1, *stringType, loc1));
1151+
1152+ if (atomicORstring0 && atomicORstring1)
1153 {
1154 std::vector<xqtref_t> argTypes;
1155- argTypes.push_back(t0);
1156- argTypes.push_back(t1);
1157+ argTypes.push_back(stringType);
1158+ argTypes.push_back(stringType);
1159+
1160 function* replacement = fn->specialize(sctx, argTypes);
1161 if (replacement != NULL)
1162 {
1163@@ -382,72 +404,24 @@
1164 return node;
1165 }
1166 }
1167- else if (fn->isValueComparisonFunction())
1168+ else if (TypeOps::is_numeric(tm, *t0) && TypeOps::is_numeric(tm, *t1))
1169 {
1170- xqtref_t string_type = rtm.STRING_TYPE_QUESTION;
1171- bool string_cmp = true;
1172- expr* nargs[2];
1173-
1174- for (int i = 0; i < 2; ++i)
1175- {
1176- nargs[i] = NULL;
1177-
1178- expr* arg = (i == 0 ? arg0 : arg1);
1179- xqtref_t type = (i == 0 ? t0 : t1);
1180- const QueryLoc& loc = arg->get_loc();
1181-
1182- if (TypeOps::is_subtype(tm, *type, *rtm.UNTYPED_ATOMIC_TYPE_QUESTION, loc))
1183- {
1184- nargs[i] = rCtx.theEM->create_cast_expr(arg->get_sctx(),
1185- arg->get_udf(),
1186- arg->get_loc(),
1187- arg,
1188- string_type);
1189- }
1190- else if (! TypeOps::is_subtype(tm, *type, *string_type, loc))
1191- {
1192- string_cmp = false;
1193- break;
1194- }
1195- }
1196-
1197- if (string_cmp)
1198- {
1199- for (int i = 0; i < 2; i++)
1200- {
1201- if (nargs[i] != NULL)
1202- fo->set_arg(i, nargs[i]);
1203- }
1204-
1205- std::vector<xqtref_t> argTypes;
1206- argTypes.push_back(string_type);
1207- argTypes.push_back(string_type);
1208- function* replacement = fn->specialize(sctx, argTypes);
1209- if (replacement != NULL)
1210- {
1211- fo->set_func(replacement);
1212- return node;
1213- }
1214- }
1215- else if (TypeOps::is_numeric(tm, *t0) && TypeOps::is_numeric(tm, *t1))
1216- {
1217- xqtref_t aType = specialize_numeric(fo, sctx, rCtx);
1218- if (aType != NULL)
1219- {
1220- if (TypeOps::is_equal(tm,
1221- *TypeOps::prime_type(tm, *aType),
1222- *rtm.DECIMAL_TYPE_ONE,
1223- fo->get_loc()) &&
1224- TypeOps::is_subtype(tm, *t0, *rtm.INTEGER_TYPE_ONE, fo->get_loc()))
1225- {
1226- expr* tmp = fo->get_arg(0);
1227- fo->set_arg(0, fo->get_arg(1));
1228- fo->set_arg(1, tmp);
1229- fo->set_func(flip_value_cmp(fo->get_func()->getKind()));
1230- }
1231-
1232- return node;
1233- }
1234+ xqtref_t aType = specialize_numeric(fo, sctx, rCtx);
1235+ if (aType != NULL)
1236+ {
1237+ if (TypeOps::is_equal(tm,
1238+ *TypeOps::prime_type(tm, *aType),
1239+ *rtm.DECIMAL_TYPE_ONE,
1240+ fo->get_loc()) &&
1241+ TypeOps::is_subtype(tm, *t0, *rtm.INTEGER_TYPE_ONE, fo->get_loc()))
1242+ {
1243+ expr* tmp = fo->get_arg(0);
1244+ fo->set_arg(0, fo->get_arg(1));
1245+ fo->set_arg(1, tmp);
1246+ fo->set_func(flip_value_cmp(fo->get_func()->getKind()));
1247+ }
1248+
1249+ return node;
1250 }
1251 }
1252 }
1253@@ -456,7 +430,7 @@
1254 else if (node->get_expr_kind() == flwor_expr_kind ||
1255 node->get_expr_kind() == gflwor_expr_kind)
1256 {
1257- flwor_expr* flworExpr = reinterpret_cast<flwor_expr*>(node);
1258+ flwor_expr* flworExpr = static_cast<flwor_expr*>(node);
1259
1260 bool modified = false;
1261
1262@@ -465,8 +439,8 @@
1263 {
1264 if (flworExpr->get_clause(i)->get_kind() == flwor_clause::order_clause)
1265 {
1266- orderby_clause* obc = reinterpret_cast<orderby_clause*>
1267- (flworExpr->get_clause(i));
1268+ orderby_clause* obc =
1269+ static_cast<orderby_clause*>(flworExpr->get_clause(i));
1270
1271 csize numColumns = obc->num_columns();
1272 for (csize j = 0; j < numColumns; ++j)
1273@@ -479,11 +453,7 @@
1274 TypeOps::is_subtype(tm, *colType, *rtm.UNTYPED_ATOMIC_TYPE_STAR, colLoc))
1275 {
1276 expr* castExpr = rCtx.theEM->
1277- create_cast_expr(colExpr->get_sctx(),
1278- colExpr->get_udf(),
1279- colExpr->get_loc(),
1280- colExpr,
1281- rtm.STRING_TYPE_QUESTION);
1282+ create_cast_expr(sctx, udf, colLoc, colExpr, rtm.STRING_TYPE_QUESTION);
1283
1284 obc->set_column_expr(j, castExpr);
1285 modified = true;
1286
1287=== modified file 'src/compiler/rewriter/tools/dataflow_annotations.cpp'
1288--- src/compiler/rewriter/tools/dataflow_annotations.cpp 2012-11-02 20:00:13 +0000
1289+++ src/compiler/rewriter/tools/dataflow_annotations.cpp 2012-12-06 22:51:20 +0000
1290@@ -880,30 +880,17 @@
1291 varSources = new std::vector<expr*>;;
1292 theVarSourcesMap.insert(VarSourcesPair(e, varSources));
1293
1294- std::vector<expr*>::const_iterator ite2 = e->setExprsBegin();
1295- std::vector<expr*>::const_iterator end2 = e->setExprsEnd();
1296+ var_expr::VarSetExprs::const_iterator ite2 = e->setExprsBegin();
1297+ var_expr::VarSetExprs::const_iterator end2 = e->setExprsEnd();
1298
1299 for (; ite2 != end2; ++ite2)
1300 {
1301- expr* setExpr = *ite2;
1302+ var_set_expr* setExpr = *ite2;
1303
1304 if (setExpr->get_udf() != NULL && !setExpr->get_udf()->isOptimized())
1305 continue;
1306
1307- if (setExpr->get_expr_kind() == var_decl_expr_kind)
1308- {
1309- findNodeSourcesRec(static_cast<var_decl_expr*>(setExpr)->get_init_expr(),
1310- *varSources,
1311- currentUdf);
1312- }
1313- else
1314- {
1315- assert(setExpr->get_expr_kind() == var_set_expr_kind);
1316-
1317- findNodeSourcesRec(static_cast<var_set_expr*>(setExpr)->get_expr(),
1318- *varSources,
1319- currentUdf);
1320- }
1321+ findNodeSourcesRec(setExpr->get_expr(), *varSources, currentUdf);
1322 }
1323 }
1324 else
1325@@ -1323,25 +1310,14 @@
1326 varSources = new std::vector<expr*>;;
1327 theVarSourcesMap.insert(VarSourcesPair(e, varSources));
1328
1329- std::vector<expr*>::const_iterator ite2 = e->setExprsBegin();
1330- std::vector<expr*>::const_iterator end2 = e->setExprsEnd();
1331+ var_expr::VarSetExprs::const_iterator ite2 = e->setExprsBegin();
1332+ var_expr::VarSetExprs::const_iterator end2 = e->setExprsEnd();
1333
1334 for (; ite2 != end2; ++ite2)
1335 {
1336- expr* setExpr = *ite2;
1337-
1338- if (setExpr->get_expr_kind() == var_decl_expr_kind)
1339- {
1340- findLocalNodeSources(static_cast<var_decl_expr*>(setExpr)->get_init_expr(),
1341- *varSources);
1342- }
1343- else
1344- {
1345- assert(setExpr->get_expr_kind() == var_set_expr_kind);
1346-
1347- findLocalNodeSources(static_cast<var_set_expr*>(setExpr)->get_expr(),
1348- *varSources);
1349- }
1350+ var_set_expr* setExpr = *ite2;
1351+
1352+ findLocalNodeSources(setExpr->get_expr(), *varSources);
1353 }
1354 }
1355 else
1356
1357=== modified file 'test/parser/CMakeLists.txt'
1358--- test/parser/CMakeLists.txt 2012-09-19 21:16:15 +0000
1359+++ test/parser/CMakeLists.txt 2012-12-06 22:51:20 +0000
1360@@ -15,12 +15,12 @@
1361 CONFIGURE_FILE(parsertestdriverconfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/parsertestdriverconfig.h)
1362 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
1363
1364-ZORBA_GENERATE_EXE("parsertestdriver" "parsertestdriver.cpp" "" "" "")
1365+#ZORBA_GENERATE_EXE("parsertestdriver" "parsertestdriver.cpp" "" "" "")
1366
1367 # collect all queries (suffix .xq) in all subdirectories of the Queries dir
1368-FILE(GLOB_RECURSE TESTFILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/Queries/ *.xq)
1369+#FILE(GLOB_RECURSE TESTFILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/Queries/ *.xq)
1370
1371-MESSAGE(STATUS "Adding parser tests for CTest")
1372+#MESSAGE(STATUS "Adding parser tests for CTest")
1373
1374 FOREACH(TESTFILE ${TESTFILES})
1375 STRING(LENGTH ${TESTFILE} TESTFILELENGTH)
1376
1377=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/collections/count_dynamic_zorba_collection.iter'
1378--- test/rbkt/ExpCompilerResults/IterPlan/zorba/collections/count_dynamic_zorba_collection.iter 2012-10-08 12:09:36 +0000
1379+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/collections/count_dynamic_zorba_collection.iter 2012-12-06 22:51:20 +0000
1380@@ -6,19 +6,11 @@
1381 <SequentialIterator>
1382 <ApplyIterator>
1383 <ZorbaCreateCollectionIterator>
1384- <PromoteIterator type="xs:QName">
1385- <FnDataIterator>
1386- <CtxVarIterator varid="4" varname="coll" varkind="global"/>
1387- </FnDataIterator>
1388- </PromoteIterator>
1389+ <CtxVarIterator varid="4" varname="coll" varkind="global"/>
1390 </ZorbaCreateCollectionIterator>
1391 </ApplyIterator>
1392 <CountCollectionIterator>
1393- <PromoteIterator type="xs:QName">
1394- <FnDataIterator>
1395- <CtxVarIterator varid="4" varname="coll" varkind="global"/>
1396- </FnDataIterator>
1397- </PromoteIterator>
1398+ <CtxVarIterator varid="4" varname="coll" varkind="global"/>
1399 </CountCollectionIterator>
1400 </SequentialIterator>
1401 </SequentialIterator>
1402
1403=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/collections/count_static_zorba_collection.iter'
1404--- test/rbkt/ExpCompilerResults/IterPlan/zorba/collections/count_static_zorba_collection.iter 2012-10-08 12:09:36 +0000
1405+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/collections/count_static_zorba_collection.iter 2012-12-06 22:51:20 +0000
1406@@ -24,19 +24,11 @@
1407 <SequentialIterator>
1408 <ApplyIterator>
1409 <ZorbaCreateCollectionIterator>
1410- <PromoteIterator type="xs:QName">
1411- <FnDataIterator>
1412- <CtxVarIterator varid="10" varname="coll" varkind="global"/>
1413- </FnDataIterator>
1414- </PromoteIterator>
1415+ <CtxVarIterator varid="10" varname="coll" varkind="global"/>
1416 </ZorbaCreateCollectionIterator>
1417 </ApplyIterator>
1418 <CountCollectionIterator>
1419- <PromoteIterator type="xs:QName">
1420- <FnDataIterator>
1421- <CtxVarIterator varid="10" varname="coll" varkind="global"/>
1422- </FnDataIterator>
1423- </PromoteIterator>
1424+ <CtxVarIterator varid="10" varname="coll" varkind="global"/>
1425 </CountCollectionIterator>
1426 </SequentialIterator>
1427 </SequentialIterator>
1428
1429=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/collections/count_w3c_collection.iter'
1430--- test/rbkt/ExpCompilerResults/IterPlan/zorba/collections/count_w3c_collection.iter 2012-10-08 12:09:36 +0000
1431+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/collections/count_w3c_collection.iter 2012-12-06 22:51:20 +0000
1432@@ -6,19 +6,11 @@
1433 <SequentialIterator>
1434 <ApplyIterator>
1435 <UDFunctionCallIterator>
1436- <PromoteIterator type="xs:string">
1437- <FnDataIterator>
1438- <CtxVarIterator varid="4" varname="coll" varkind="global"/>
1439- </FnDataIterator>
1440- </PromoteIterator>
1441+ <CtxVarIterator varid="4" varname="coll" varkind="global"/>
1442 </UDFunctionCallIterator>
1443 </ApplyIterator>
1444 <CountCollectionIterator>
1445- <PromoteIterator type="xs:string">
1446- <FnDataIterator>
1447- <CtxVarIterator varid="4" varname="coll" varkind="global"/>
1448- </FnDataIterator>
1449- </PromoteIterator>
1450+ <CtxVarIterator varid="4" varname="coll" varkind="global"/>
1451 </CountCollectionIterator>
1452 </SequentialIterator>
1453 </SequentialIterator>
1454
1455=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/idx1.iter'
1456--- test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/idx1.iter 2012-09-19 21:16:15 +0000
1457+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/idx1.iter 2012-12-06 22:51:20 +0000
1458@@ -28,17 +28,15 @@
1459 <ReturnClause>
1460 <ValueIndexEntryBuilderIterator>
1461 <ForVarIterator varname="$$opt_temp_3"/>
1462- <CastIterator type="xs:string">
1463- <PromoteIterator type="xs:anyAtomicType">
1464- <FnDataIterator>
1465- <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,person)" typename="*" nill allowed="0">
1466- <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,buyer)" typename="*" nill allowed="0">
1467- <ForVarIterator varname="$$opt_temp_3"/>
1468- </ChildAxisIterator>
1469- </AttributeAxisIterator>
1470- </FnDataIterator>
1471- </PromoteIterator>
1472- </CastIterator>
1473+ <PromoteIterator type="xs:anyAtomicType">
1474+ <FnDataIterator>
1475+ <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,person)" typename="*" nill allowed="0">
1476+ <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,buyer)" typename="*" nill allowed="0">
1477+ <ForVarIterator varname="$$opt_temp_3"/>
1478+ </ChildAxisIterator>
1479+ </AttributeAxisIterator>
1480+ </FnDataIterator>
1481+ </PromoteIterator>
1482 </ValueIndexEntryBuilderIterator>
1483 </ReturnClause>
1484 </flwor::FLWORIterator>
1485@@ -66,13 +64,11 @@
1486 </LetVariable>
1487 <LetVariable name="$$opt_temp_1" materialize="true">
1488 <HoistIterator>
1489- <CastIterator type="xs:string">
1490- <FnDataIterator>
1491- <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,id)" typename="*" nill allowed="0">
1492- <ForVarIterator varname="p"/>
1493- </AttributeAxisIterator>
1494- </FnDataIterator>
1495- </CastIterator>
1496+ <FnDataIterator>
1497+ <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,id)" typename="*" nill allowed="0">
1498+ <ForVarIterator varname="p"/>
1499+ </AttributeAxisIterator>
1500+ </FnDataIterator>
1501 </HoistIterator>
1502 </LetVariable>
1503 <ForVariable name="a">
1504
1505=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/idx2.iter'
1506--- test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/idx2.iter 2012-09-19 21:16:15 +0000
1507+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/idx2.iter 2012-12-06 22:51:20 +0000
1508@@ -36,13 +36,11 @@
1509 </LetVariable>
1510 <LetVariable name="$$opt_temp_1" materialize="true">
1511 <HoistIterator>
1512- <CastIterator type="xs:string">
1513- <FnDataIterator>
1514- <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,id)" typename="*" nill allowed="0">
1515- <ForVarIterator varname="p"/>
1516- </AttributeAxisIterator>
1517- </FnDataIterator>
1518- </CastIterator>
1519+ <FnDataIterator>
1520+ <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,id)" typename="*" nill allowed="0">
1521+ <ForVarIterator varname="p"/>
1522+ </AttributeAxisIterator>
1523+ </FnDataIterator>
1524 </HoistIterator>
1525 </LetVariable>
1526 <ForVariable name="a">
1527@@ -58,17 +56,15 @@
1528 <WhereClause>
1529 <FnBooleanIterator>
1530 <TypedValueCompareIterator_STRING>
1531- <CastIterator type="xs:string">
1532- <PromoteIterator type="xs:anyAtomicType">
1533- <FnDataIterator>
1534- <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,person)" typename="*" nill allowed="0">
1535- <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,buyer)" typename="*" nill allowed="0">
1536- <ForVarIterator varname="t"/>
1537- </ChildAxisIterator>
1538- </AttributeAxisIterator>
1539- </FnDataIterator>
1540- </PromoteIterator>
1541- </CastIterator>
1542+ <PromoteIterator type="xs:anyAtomicType">
1543+ <FnDataIterator>
1544+ <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,person)" typename="*" nill allowed="0">
1545+ <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,buyer)" typename="*" nill allowed="0">
1546+ <ForVarIterator varname="t"/>
1547+ </ChildAxisIterator>
1548+ </AttributeAxisIterator>
1549+ </FnDataIterator>
1550+ </PromoteIterator>
1551 <UnhoistIterator>
1552 <LetVarIterator varname="$$opt_temp_1"/>
1553 </UnhoistIterator>
1554
1555=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/idx5.iter'
1556--- test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/idx5.iter 2012-10-08 12:09:36 +0000
1557+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/idx5.iter 2012-12-06 22:51:20 +0000
1558@@ -19,94 +19,40 @@
1559 <SingletonIterator value="xs:QName(,,tests)"/>
1560 </ElementIterator>
1561 </CtxVarDeclareIterator>
1562- <SequentialIterator>
1563- <CreateInternalIndexIterator name="xs:QName(,,tempIndex0)">
1564+ <flwor::FLWORIterator>
1565+ <LetVariable name="test_old" materialize="true">
1566 <flwor::FLWORIterator>
1567- <ForVariable name="$$opt_temp_2">
1568+ <ForVariable name="$$context-item">
1569 <CtxVarIterator varid="4" varname="tests" varkind="global"/>
1570 </ForVariable>
1571+ <WhereClause>
1572+ <FnBooleanIterator>
1573+ <TypedValueCompareIterator_STRING>
1574+ <PromoteIterator type="xs:anyAtomicType">
1575+ <FnDataIterator>
1576+ <ChildAxisIterator test kind="match_text_test" qname="*" typename="*" nill allowed="0">
1577+ <ForVarIterator varname="$$context-item"/>
1578+ </ChildAxisIterator>
1579+ </FnDataIterator>
1580+ </PromoteIterator>
1581+ <PromoteIterator type="xs:anyAtomicType">
1582+ <FnDataIterator>
1583+ <ChildAxisIterator test kind="match_text_test" qname="*" typename="*" nill allowed="0">
1584+ <CtxVarIterator varid="4" varname="tests" varkind="global"/>
1585+ </ChildAxisIterator>
1586+ </FnDataIterator>
1587+ </PromoteIterator>
1588+ </TypedValueCompareIterator_STRING>
1589+ </FnBooleanIterator>
1590+ </WhereClause>
1591 <ReturnClause>
1592- <ValueIndexEntryBuilderIterator>
1593- <ForVarIterator varname="$$opt_temp_2"/>
1594- <CastIterator type="xs:string">
1595- <PromoteIterator type="xs:anyAtomicType">
1596- <FnDataIterator>
1597- <ChildAxisIterator test kind="match_text_test" qname="*" typename="*" nill allowed="0">
1598- <TreatIterator type="[NodeXQType anyNode content=[XQType ANY_TYPE_KIND*]]" quant="*">
1599- <ForVarIterator varname="$$opt_temp_2"/>
1600- </TreatIterator>
1601- </ChildAxisIterator>
1602- </FnDataIterator>
1603- </PromoteIterator>
1604- </CastIterator>
1605- </ValueIndexEntryBuilderIterator>
1606+ <ForVarIterator varname="$$context-item"/>
1607 </ReturnClause>
1608 </flwor::FLWORIterator>
1609- </CreateInternalIndexIterator>
1610- <flwor::FLWORIterator>
1611- <LetVariable name="$$opt_temp_1" materialize="true">
1612- <HoistIterator>
1613- <flwor::FLWORIterator>
1614- <ForVariable name="$$context-item">
1615- <CtxVarIterator varid="4" varname="tests" varkind="global"/>
1616- </ForVariable>
1617- <WhereClause>
1618- <FnBooleanIterator>
1619- <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,name)" typename="*" nill allowed="0">
1620- <TreatIterator type="[NodeXQType anyNode content=[XQType ANY_TYPE_KIND*]]" quant="*">
1621- <ForVarIterator varname="$$context-item"/>
1622- </TreatIterator>
1623- </AttributeAxisIterator>
1624- </FnBooleanIterator>
1625- </WhereClause>
1626- <ReturnClause>
1627- <ForVarIterator varname="$$context-item"/>
1628- </ReturnClause>
1629- </flwor::FLWORIterator>
1630- </HoistIterator>
1631- </LetVariable>
1632- <ForVariable name="test">
1633- <CtxVarIterator varid="4" varname="tests" varkind="global"/>
1634- </ForVariable>
1635- <LetVariable name="$$opt_temp_0" materialize="true">
1636- <HoistIterator>
1637- <CastIterator type="xs:string">
1638- <PromoteIterator type="xs:anyAtomicType">
1639- <FnDataIterator>
1640- <ChildAxisIterator test kind="match_text_test" qname="*" typename="*" nill allowed="0">
1641- <TreatIterator type="[NodeXQType anyNode content=[XQType ANY_TYPE_KIND*]]" quant="*">
1642- <ForVarIterator varname="test"/>
1643- </TreatIterator>
1644- </ChildAxisIterator>
1645- </FnDataIterator>
1646- </PromoteIterator>
1647- </CastIterator>
1648- </HoistIterator>
1649- </LetVariable>
1650- <LetVariable name="test_old" materialize="true">
1651- <flwor::FLWORIterator>
1652- <ForVariable name="$$context-item">
1653- <ProbeIndexPointValueIterator>
1654- <SingletonIterator value="xs:QName(,,tempIndex0)"/>
1655- <UnhoistIterator>
1656- <LetVarIterator varname="$$opt_temp_0"/>
1657- </UnhoistIterator>
1658- </ProbeIndexPointValueIterator>
1659- </ForVariable>
1660- <ReturnClause>
1661- <ForVarIterator varname="$$context-item"/>
1662- </ReturnClause>
1663- </flwor::FLWORIterator>
1664- </LetVariable>
1665- <LetVariable name="qt_old" materialize="true">
1666- <UnhoistIterator>
1667- <LetVarIterator varname="$$opt_temp_1"/>
1668- </UnhoistIterator>
1669- </LetVariable>
1670- <ReturnClause>
1671- <SingletonIterator value="xs:integer(1)"/>
1672- </ReturnClause>
1673- </flwor::FLWORIterator>
1674- </SequentialIterator>
1675+ </LetVariable>
1676+ <ReturnClause>
1677+ <SingletonIterator value="xs:integer(1)"/>
1678+ </ReturnClause>
1679+ </flwor::FLWORIterator>
1680 </SequentialIterator>
1681
1682
1683=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/dataguide-c.iter'
1684--- test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/dataguide-c.iter 2012-10-08 12:09:36 +0000
1685+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/dataguide-c.iter 2012-12-06 22:51:20 +0000
1686@@ -46,16 +46,8 @@
1687 <SequentialIterator>
1688 <ApplyIterator>
1689 <MapCreateIterator>
1690- <PromoteIterator type="xs:QName">
1691- <FnDataIterator>
1692- <CtxVarIterator varid="5" varname="map1" varkind="global"/>
1693- </FnDataIterator>
1694- </PromoteIterator>
1695- <PromoteIterator type="xs:QName">
1696- <FnDataIterator>
1697- <CtxVarIterator varid="6" varname="str" varkind="global"/>
1698- </FnDataIterator>
1699- </PromoteIterator>
1700+ <CtxVarIterator varid="5" varname="map1" varkind="global"/>
1701+ <CtxVarIterator varid="6" varname="str" varkind="global"/>
1702 </MapCreateIterator>
1703 </ApplyIterator>
1704 <CtxVarDeclareIterator varid="8" varname="DG">
1705@@ -69,11 +61,7 @@
1706 </CtxVarDeclareIterator>
1707 <ApplyIterator>
1708 <MapDestroyIterator>
1709- <PromoteIterator type="xs:QName">
1710- <FnDataIterator>
1711- <CtxVarIterator varid="5" varname="map1" varkind="global"/>
1712- </FnDataIterator>
1713- </PromoteIterator>
1714+ <CtxVarIterator varid="5" varname="map1" varkind="global"/>
1715 </MapDestroyIterator>
1716 </ApplyIterator>
1717 <CtxVarIterator varid="8" varname="DG" varkind="local"/>
1718@@ -195,11 +183,7 @@
1719 <CtxVarAssignIterator varid="1" varname="label" varkind="local">
1720 <TreatIterator type="xs:integer" quant="?">
1721 <MapGetIterator>
1722- <PromoteIterator type="xs:QName">
1723- <FnDataIterator>
1724- <CtxVarIterator varid="5" varname="map1" varkind="global"/>
1725- </FnDataIterator>
1726- </PromoteIterator>
1727+ <CtxVarIterator varid="5" varname="map1" varkind="global"/>
1728 <PromoteIterator type="xs:anyAtomicType">
1729 <FnDataIterator>
1730 <CtxVarIterator varid="4" varname="s2" varkind="local"/>
1731@@ -224,11 +208,7 @@
1732 </CtxVarAssignIterator>
1733 <ApplyIterator>
1734 <MapInsertIterator>
1735- <PromoteIterator type="xs:QName">
1736- <FnDataIterator>
1737- <CtxVarIterator varid="5" varname="map1" varkind="global"/>
1738- </FnDataIterator>
1739- </PromoteIterator>
1740+ <CtxVarIterator varid="5" varname="map1" varkind="global"/>
1741 <CtxVarIterator varid="4" varname="co" varkind="global"/>
1742 <PromoteIterator type="xs:anyAtomicType">
1743 <FnDataIterator>
1744
1745=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/dataguide-nc.iter'
1746--- test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/dataguide-nc.iter 2012-10-08 12:09:36 +0000
1747+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/dataguide-nc.iter 2012-12-06 22:51:20 +0000
1748@@ -46,16 +46,8 @@
1749 <SequentialIterator>
1750 <ApplyIterator>
1751 <MapCreateIterator>
1752- <PromoteIterator type="xs:QName">
1753- <FnDataIterator>
1754- <CtxVarIterator varid="5" varname="map1" varkind="global"/>
1755- </FnDataIterator>
1756- </PromoteIterator>
1757- <PromoteIterator type="xs:QName">
1758- <FnDataIterator>
1759- <CtxVarIterator varid="6" varname="str" varkind="global"/>
1760- </FnDataIterator>
1761- </PromoteIterator>
1762+ <CtxVarIterator varid="5" varname="map1" varkind="global"/>
1763+ <CtxVarIterator varid="6" varname="str" varkind="global"/>
1764 </MapCreateIterator>
1765 </ApplyIterator>
1766 <CtxVarDeclareIterator varid="8" varname="DG">
1767@@ -69,11 +61,7 @@
1768 </CtxVarDeclareIterator>
1769 <ApplyIterator>
1770 <MapDestroyIterator>
1771- <PromoteIterator type="xs:QName">
1772- <FnDataIterator>
1773- <CtxVarIterator varid="5" varname="map1" varkind="global"/>
1774- </FnDataIterator>
1775- </PromoteIterator>
1776+ <CtxVarIterator varid="5" varname="map1" varkind="global"/>
1777 </MapDestroyIterator>
1778 </ApplyIterator>
1779 <CtxVarIterator varid="8" varname="DG" varkind="local"/>
1780@@ -195,11 +183,7 @@
1781 <CtxVarAssignIterator varid="1" varname="label" varkind="local">
1782 <TreatIterator type="xs:integer" quant="?">
1783 <MapGetIterator>
1784- <PromoteIterator type="xs:QName">
1785- <FnDataIterator>
1786- <CtxVarIterator varid="5" varname="map1" varkind="global"/>
1787- </FnDataIterator>
1788- </PromoteIterator>
1789+ <CtxVarIterator varid="5" varname="map1" varkind="global"/>
1790 <PromoteIterator type="xs:anyAtomicType">
1791 <FnDataIterator>
1792 <CtxVarIterator varid="4" varname="s2" varkind="local"/>
1793@@ -224,11 +208,7 @@
1794 </CtxVarAssignIterator>
1795 <ApplyIterator>
1796 <MapInsertIterator>
1797- <PromoteIterator type="xs:QName">
1798- <FnDataIterator>
1799- <CtxVarIterator varid="5" varname="map1" varkind="global"/>
1800- </FnDataIterator>
1801- </PromoteIterator>
1802+ <CtxVarIterator varid="5" varname="map1" varkind="global"/>
1803 <CtxVarIterator varid="4" varname="co" varkind="global"/>
1804 <PromoteIterator type="xs:anyAtomicType">
1805 <FnDataIterator>
1806
1807=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/hashjoin-idx1.iter'
1808--- test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/hashjoin-idx1.iter 2012-09-19 21:16:15 +0000
1809+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/hashjoin-idx1.iter 2012-12-06 22:51:20 +0000
1810@@ -28,17 +28,15 @@
1811 <ReturnClause>
1812 <ValueIndexEntryBuilderIterator>
1813 <ForVarIterator varname="$$opt_temp_3"/>
1814- <CastIterator type="xs:string">
1815- <PromoteIterator type="xs:anyAtomicType">
1816- <FnDataIterator>
1817- <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,person)" typename="*" nill allowed="0">
1818- <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,buyer)" typename="*" nill allowed="0">
1819- <ForVarIterator varname="$$opt_temp_3"/>
1820- </ChildAxisIterator>
1821- </AttributeAxisIterator>
1822- </FnDataIterator>
1823- </PromoteIterator>
1824- </CastIterator>
1825+ <PromoteIterator type="xs:anyAtomicType">
1826+ <FnDataIterator>
1827+ <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,person)" typename="*" nill allowed="0">
1828+ <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,buyer)" typename="*" nill allowed="0">
1829+ <ForVarIterator varname="$$opt_temp_3"/>
1830+ </ChildAxisIterator>
1831+ </AttributeAxisIterator>
1832+ </FnDataIterator>
1833+ </PromoteIterator>
1834 </ValueIndexEntryBuilderIterator>
1835 </ReturnClause>
1836 </flwor::FLWORIterator>
1837@@ -66,13 +64,11 @@
1838 </LetVariable>
1839 <LetVariable name="$$opt_temp_1" materialize="true">
1840 <HoistIterator>
1841- <CastIterator type="xs:string">
1842- <FnDataIterator>
1843- <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,id)" typename="*" nill allowed="0">
1844- <ForVarIterator varname="p"/>
1845- </AttributeAxisIterator>
1846- </FnDataIterator>
1847- </CastIterator>
1848+ <FnDataIterator>
1849+ <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,id)" typename="*" nill allowed="0">
1850+ <ForVarIterator varname="p"/>
1851+ </AttributeAxisIterator>
1852+ </FnDataIterator>
1853 </HoistIterator>
1854 </LetVariable>
1855 <ForVariable name="a">
1856
1857=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/node-copy-01.iter'
1858--- test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/node-copy-01.iter 2012-10-05 08:48:49 +0000
1859+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/node-copy-01.iter 2012-12-06 22:51:20 +0000
1860@@ -20,13 +20,9 @@
1861 <SingletonIterator value="xs:QName(,,node)"/>
1862 <FnConcatIterator/>
1863 <EnclosedIterator attr_cont="false">
1864- <NodeSortIterator distinct="true" ascending="true">
1865- <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,b)" typename="*" nill allowed="0">
1866- <TreatIterator type="[NodeXQType anyNode content=[XQType ANY_TYPE_KIND*]]" quant="*">
1867- <CtxVarIterator varid="4" varname="doc" varkind="global"/>
1868- </TreatIterator>
1869- </ChildAxisIterator>
1870- </NodeSortIterator>
1871+ <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,b)" typename="*" nill allowed="0">
1872+ <CtxVarIterator varid="4" varname="doc" varkind="global"/>
1873+ </ChildAxisIterator>
1874 </EnclosedIterator>
1875 </ElementIterator>
1876 </ChildAxisIterator>
1877
1878=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/node-copy-02.iter'
1879--- test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/node-copy-02.iter 2012-10-05 08:48:49 +0000
1880+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/node-copy-02.iter 2012-12-06 22:51:20 +0000
1881@@ -1,12 +1,12 @@
1882 Iterator tree for main query:
1883 <SequentialIterator>
1884 <CtxVarDeclareIterator varid="4" varname="doc">
1885- <ElementIterator>
1886+ <ElementIterator copyInputNodes="false">
1887 <SingletonIterator value="xs:QName(,,a)"/>
1888 <FnConcatIterator/>
1889- <ElementIterator>
1890+ <ElementIterator copyInputNodes="false">
1891 <SingletonIterator value="xs:QName(,,b)"/>
1892- <ElementIterator>
1893+ <ElementIterator copyInputNodes="false">
1894 <SingletonIterator value="xs:QName(,,c)"/>
1895 </ElementIterator>
1896 </ElementIterator>
1897@@ -20,13 +20,9 @@
1898 <SingletonIterator value="xs:QName(,,node)"/>
1899 <FnConcatIterator/>
1900 <EnclosedIterator attr_cont="false">
1901- <NodeSortIterator distinct="true" ascending="true">
1902- <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,b)" typename="*" nill allowed="0">
1903- <TreatIterator type="[NodeXQType anyNode content=[XQType ANY_TYPE_KIND*]]" quant="*">
1904- <CtxVarIterator varid="4" varname="doc" varkind="global"/>
1905- </TreatIterator>
1906- </ChildAxisIterator>
1907- </NodeSortIterator>
1908+ <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,b)" typename="*" nill allowed="0">
1909+ <CtxVarIterator varid="4" varname="doc" varkind="global"/>
1910+ </ChildAxisIterator>
1911 </EnclosedIterator>
1912 </ElementIterator>
1913 </ChildAxisIterator>
1914
1915=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/node-copy-03.iter'
1916--- test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/node-copy-03.iter 2012-10-05 08:48:49 +0000
1917+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/node-copy-03.iter 2012-12-06 22:51:20 +0000
1918@@ -1,12 +1,12 @@
1919 Iterator tree for main query:
1920 <SequentialIterator>
1921 <CtxVarDeclareIterator varid="4" varname="doc">
1922- <ElementIterator>
1923+ <ElementIterator copyInputNodes="false">
1924 <SingletonIterator value="xs:QName(,,a)"/>
1925 <FnConcatIterator/>
1926- <ElementIterator>
1927+ <ElementIterator copyInputNodes="false">
1928 <SingletonIterator value="xs:QName(,,b)"/>
1929- <ElementIterator>
1930+ <ElementIterator copyInputNodes="false">
1931 <SingletonIterator value="xs:QName(,,c)"/>
1932 </ElementIterator>
1933 </ElementIterator>
1934@@ -20,13 +20,9 @@
1935 <SingletonIterator value="xs:QName(,,node)"/>
1936 <FnConcatIterator/>
1937 <EnclosedIterator attr_cont="false">
1938- <NodeSortIterator distinct="true" ascending="true">
1939- <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,b)" typename="*" nill allowed="0">
1940- <TreatIterator type="[NodeXQType anyNode content=[XQType ANY_TYPE_KIND*]]" quant="*">
1941- <CtxVarIterator varid="4" varname="doc" varkind="global"/>
1942- </TreatIterator>
1943- </ChildAxisIterator>
1944- </NodeSortIterator>
1945+ <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,b)" typename="*" nill allowed="0">
1946+ <CtxVarIterator varid="4" varname="doc" varkind="global"/>
1947+ </ChildAxisIterator>
1948 </EnclosedIterator>
1949 </ElementIterator>
1950 </ChildAxisIterator>
1951
1952=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/optim/positioned-access.iter'
1953--- test/rbkt/ExpCompilerResults/IterPlan/zorba/optim/positioned-access.iter 2012-10-08 12:09:36 +0000
1954+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/optim/positioned-access.iter 2012-12-06 22:51:20 +0000
1955@@ -17,11 +17,7 @@
1956 <FunctionTraceIterator>
1957 <flwor::FLWORIterator>
1958 <LetVariable name="x" materialize="true">
1959- <PromoteIterator type="xs:integer">
1960- <FnDataIterator>
1961- <CtxVarIterator varid="4" varname="n1" varkind="global"/>
1962- </FnDataIterator>
1963- </PromoteIterator>
1964+ <CtxVarIterator varid="4" varname="n1" varkind="global"/>
1965 </LetVariable>
1966 <ReturnClause>
1967 <LetVarIterator varname="x">
1968@@ -35,11 +31,7 @@
1969 <FunctionTraceIterator>
1970 <flwor::FLWORIterator>
1971 <LetVariable name="x" materialize="true">
1972- <PromoteIterator type="xs:integer">
1973- <FnDataIterator>
1974- <CtxVarIterator varid="5" varname="n2" varkind="global"/>
1975- </FnDataIterator>
1976- </PromoteIterator>
1977+ <CtxVarIterator varid="5" varname="n2" varkind="global"/>
1978 </LetVariable>
1979 <ReturnClause>
1980 <LetVarIterator varname="x">
1981
1982=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/optim/var_inline_01.iter'
1983--- test/rbkt/ExpCompilerResults/IterPlan/zorba/optim/var_inline_01.iter 2012-10-08 12:09:36 +0000
1984+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/optim/var_inline_01.iter 2012-12-06 22:51:20 +0000
1985@@ -17,47 +17,32 @@
1986 <SingletonIterator value="xs:integer(2)"/>
1987 </NumArithIterator_ModOperation>
1988 </ForVariable>
1989- <LetVariable name="foo" materialize="true">
1990+ <ForVariable name="foo">
1991 <CtxVarIterator varid="4" varname="g" varkind="global"/>
1992- </LetVariable>
1993- <LetVariable name="$$opt_temp_0" materialize="true">
1994- <HoistIterator>
1995- <PromoteIterator type="xs:anyAtomicType">
1996- <FnDataIterator>
1997- <LetVarIterator varname="foo"/>
1998- </FnDataIterator>
1999- </PromoteIterator>
2000- </HoistIterator>
2001- </LetVariable>
2002+ </ForVariable>
2003 <WhereClause>
2004- <CompareIterator>
2005- <FnSumIterator>
2006+ <TypedValueCompareIterator_INTEGER>
2007+ <FnSumIntegerIterator>
2008 <flwor::FLWORIterator>
2009 <ForVariable name="z">
2010 <FnConcatIterator>
2011 <SingletonIterator value="xs:integer(5)"/>
2012- <LetVarIterator varname="foo"/>
2013+ <ForVarIterator varname="foo"/>
2014 </FnConcatIterator>
2015 </ForVariable>
2016 <ReturnClause>
2017- <GenericArithIterator_AddOperation>
2018- <GenericArithIterator_MultiplyOperation>
2019- <PromoteIterator type="xs:anyAtomicType">
2020- <FnDataIterator>
2021- <ForVarIterator varname="z"/>
2022- </FnDataIterator>
2023- </PromoteIterator>
2024+ <SpecificNumArithIterator_AddOperation_INTEGER>
2025+ <SpecificNumArithIterator_MultiplyOperation_INTEGER>
2026+ <ForVarIterator varname="z"/>
2027 <ForVarIterator varname="y"/>
2028- </GenericArithIterator_MultiplyOperation>
2029- <UnhoistIterator>
2030- <LetVarIterator varname="$$opt_temp_0"/>
2031- </UnhoistIterator>
2032- </GenericArithIterator_AddOperation>
2033+ </SpecificNumArithIterator_MultiplyOperation_INTEGER>
2034+ <ForVarIterator varname="foo"/>
2035+ </SpecificNumArithIterator_AddOperation_INTEGER>
2036 </ReturnClause>
2037 </flwor::FLWORIterator>
2038- </FnSumIterator>
2039+ </FnSumIntegerIterator>
2040 <SingletonIterator value="xs:integer(8)"/>
2041- </CompareIterator>
2042+ </TypedValueCompareIterator_INTEGER>
2043 </WhereClause>
2044 <ReturnClause>
2045 <ForVarIterator varname="x"/>
2046
2047=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/udf/udf1.iter'
2048--- test/rbkt/ExpCompilerResults/IterPlan/zorba/udf/udf1.iter 2012-10-08 12:09:36 +0000
2049+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/udf/udf1.iter 2012-12-06 22:51:20 +0000
2050@@ -31,11 +31,7 @@
2051 </ElementIterator>
2052 </DescendantAxisIterator>
2053 </ChildAxisIterator>
2054- <PromoteIterator type="xs:integer">
2055- <FnDataIterator>
2056- <CtxVarIterator varid="4" varname="x" varkind="global"/>
2057- </FnDataIterator>
2058- </PromoteIterator>
2059+ <CtxVarIterator varid="4" varname="x" varkind="global"/>
2060 </UDFunctionCallIterator>
2061 </SequentialIterator>
2062
2063
2064=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/windowing/q10.iter'
2065--- test/rbkt/ExpCompilerResults/IterPlan/zorba/windowing/q10.iter 2012-10-08 12:09:36 +0000
2066+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/windowing/q10.iter 2012-12-06 22:51:20 +0000
2067@@ -32,13 +32,9 @@
2068 <NodeSortIterator distinct="true" ascending="true">
2069 <flwor::FLWORIterator>
2070 <ForVariable name="$$context-item">
2071- <NodeDistinctIterator allow-atomics="false" check-only="false">
2072- <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,stream)" typename="*" nill allowed="0">
2073- <TreatIterator type="[NodeXQType anyNode content=[XQType ANY_TYPE_KIND*]]" quant="*">
2074- <CtxVarIterator varid="4" varname="seq" varkind="global"/>
2075- </TreatIterator>
2076- </ChildAxisIterator>
2077- </NodeDistinctIterator>
2078+ <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,stream)" typename="*" nill allowed="0">
2079+ <CtxVarIterator varid="4" varname="seq" varkind="global"/>
2080+ </ChildAxisIterator>
2081 </ForVariable>
2082 <ForVariable name="$$context-item">
2083 <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,event)" typename="*" nill allowed="0">
2084@@ -47,7 +43,7 @@
2085 </ForVariable>
2086 <WhereClause>
2087 <FnBooleanIterator>
2088- <CompareIterator>
2089+ <TypedValueCompareIterator_STRING>
2090 <PromoteIterator type="xs:anyAtomicType">
2091 <FnDataIterator>
2092 <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,direction)" typename="*" nill allowed="0">
2093@@ -56,7 +52,7 @@
2094 </FnDataIterator>
2095 </PromoteIterator>
2096 <SingletonIterator value="xs:string(in)"/>
2097- </CompareIterator>
2098+ </TypedValueCompareIterator_STRING>
2099 </FnBooleanIterator>
2100 </WhereClause>
2101 <ReturnClause>
2102@@ -100,7 +96,7 @@
2103 </ForVariable>
2104 <WhereClause>
2105 <FnBooleanIterator>
2106- <CompareIterator>
2107+ <TypedValueCompareIterator_STRING>
2108 <PromoteIterator type="xs:anyAtomicType">
2109 <FnDataIterator>
2110 <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,person)" typename="*" nill allowed="0">
2111@@ -109,7 +105,7 @@
2112 </FnDataIterator>
2113 </PromoteIterator>
2114 <SingletonIterator value="xs:string(Barbara)"/>
2115- </CompareIterator>
2116+ </TypedValueCompareIterator_STRING>
2117 </FnBooleanIterator>
2118 </WhereClause>
2119 <ReturnClause>
2120
2121=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/windowing/q4.iter'
2122--- test/rbkt/ExpCompilerResults/IterPlan/zorba/windowing/q4.iter 2012-10-08 12:09:36 +0000
2123+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/windowing/q4.iter 2012-12-06 22:51:20 +0000
2124@@ -1,6 +1,11 @@
2125 Iterator tree for const-folded expr:
2126 <SingletonIterator value="xs:integer(2)"/>
2127
2128+Iterator tree for const-folded expr:
2129+<PromoteIterator type="xs:double">
2130+ <SingletonIterator value="xs:integer(2)"/>
2131+</PromoteIterator>
2132+
2133 Iterator tree for main query:
2134 <SequentialIterator>
2135 <CtxVarDeclareIterator varid="4" varname="timesequence">
2136@@ -11,60 +16,52 @@
2137 <flwor::TupleStreamIterator>
2138 <flwor::WindowIterator>
2139 <WindowVariable name="w">
2140- <NodeSortIterator distinct="true" ascending="true">
2141- <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,event)" typename="*" nill allowed="0">
2142- <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,stream)" typename="*" nill allowed="0">
2143- <TreatIterator type="[NodeXQType anyNode content=[XQType ANY_TYPE_KIND*]]" quant="*">
2144- <CtxVarIterator varid="4" varname="timesequence" varkind="global"/>
2145- </TreatIterator>
2146- </ChildAxisIterator>
2147+ <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,event)" typename="*" nill allowed="0">
2148+ <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,stream)" typename="*" nill allowed="0">
2149+ <CtxVarIterator varid="4" varname="timesequence" varkind="global"/>
2150 </ChildAxisIterator>
2151- </NodeSortIterator>
2152+ </ChildAxisIterator>
2153 </WindowVariable>
2154 <WinCondVariable name="start-CurrentIn"/>
2155 <WinCondVariable name="start-CurrentInPrevIn"/>
2156 <OrIterator>
2157- <CompareIterator>
2158- <PromoteIterator type="xs:anyAtomicType">
2159- <FnDataIterator>
2160- <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,time)" typename="*" nill allowed="0">
2161- <ForVarIterator varname="s_curr"/>
2162- </AttributeAxisIterator>
2163- </FnDataIterator>
2164- </PromoteIterator>
2165- <PromoteIterator type="xs:anyAtomicType">
2166- <FnDataIterator>
2167- <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,time)" typename="*" nill allowed="0">
2168- <ForVarIterator varname="s_prev"/>
2169- </AttributeAxisIterator>
2170- </FnDataIterator>
2171- </PromoteIterator>
2172- </CompareIterator>
2173+ <TypedValueCompareIterator_STRING>
2174+ <FnDataIterator>
2175+ <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,time)" typename="*" nill allowed="0">
2176+ <ForVarIterator varname="s_curr"/>
2177+ </AttributeAxisIterator>
2178+ </FnDataIterator>
2179+ <FnDataIterator>
2180+ <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,time)" typename="*" nill allowed="0">
2181+ <ForVarIterator varname="s_prev"/>
2182+ </AttributeAxisIterator>
2183+ </FnDataIterator>
2184+ </TypedValueCompareIterator_STRING>
2185 <FnEmptyIterator>
2186 <ForVarIterator varname="s_prev"/>
2187 </FnEmptyIterator>
2188 </OrIterator>
2189 <WinCondVariable name="end-NextIn"/>
2190 <FnBooleanIterator>
2191- <CompareIterator>
2192- <GenericArithIterator_SubtractOperation>
2193- <PromoteIterator type="xs:anyAtomicType">
2194+ <TypedValueCompareIterator_DOUBLE>
2195+ <SpecificNumArithIterator_SubtractOperation_DOUBLE>
2196+ <PromoteIterator type="xs:double">
2197 <FnDataIterator>
2198 <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,time)" typename="*" nill allowed="0">
2199 <ForVarIterator varname="e_next"/>
2200 </AttributeAxisIterator>
2201 </FnDataIterator>
2202 </PromoteIterator>
2203- <PromoteIterator type="xs:anyAtomicType">
2204+ <PromoteIterator type="xs:double">
2205 <FnDataIterator>
2206 <AttributeAxisIterator test kind="match_name_test" qname="xs:QName(,,time)" typename="*" nill allowed="0">
2207 <ForVarIterator varname="s_curr"/>
2208 </AttributeAxisIterator>
2209 </FnDataIterator>
2210 </PromoteIterator>
2211- </GenericArithIterator_SubtractOperation>
2212- <SingletonIterator value="xs:integer(2)"/>
2213- </CompareIterator>
2214+ </SpecificNumArithIterator_SubtractOperation_DOUBLE>
2215+ <SingletonIterator value="xs:double(2)"/>
2216+ </TypedValueCompareIterator_DOUBLE>
2217 </FnBooleanIterator>
2218 <flwor::TupleSourceIterator/>
2219 </flwor::WindowIterator>
2220
2221=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/windowing/q9.iter'
2222--- test/rbkt/ExpCompilerResults/IterPlan/zorba/windowing/q9.iter 2012-10-08 12:09:36 +0000
2223+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/windowing/q9.iter 2012-12-06 22:51:20 +0000
2224@@ -14,20 +14,16 @@
2225 <LetVariable name="person" materialize="true"/>
2226 <flwor::WindowIterator>
2227 <WindowVariable name="w">
2228- <NodeSortIterator distinct="true" ascending="true">
2229- <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,event)" typename="*" nill allowed="0">
2230- <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,stream)" typename="*" nill allowed="0">
2231- <TreatIterator type="[NodeXQType anyNode content=[XQType ANY_TYPE_KIND*]]" quant="*">
2232- <CtxVarIterator varid="4" varname="seq" varkind="global"/>
2233- </TreatIterator>
2234- </ChildAxisIterator>
2235+ <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,event)" typename="*" nill allowed="0">
2236+ <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,stream)" typename="*" nill allowed="0">
2237+ <CtxVarIterator varid="4" varname="seq" varkind="global"/>
2238 </ChildAxisIterator>
2239- </NodeSortIterator>
2240+ </ChildAxisIterator>
2241 </WindowVariable>
2242 <WinCondVariable name="start-CurrentIn"/>
2243 <WinCondVariable name="start-CurrentInCurrentOut"/>
2244 <FnBooleanIterator>
2245- <CompareIterator>
2246+ <TypedValueCompareIterator_STRING>
2247 <PromoteIterator type="xs:anyAtomicType">
2248 <FnDataIterator>
2249 <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,direction)" typename="*" nill allowed="0">
2250@@ -36,12 +32,12 @@
2251 </FnDataIterator>
2252 </PromoteIterator>
2253 <SingletonIterator value="xs:string(in)"/>
2254- </CompareIterator>
2255+ </TypedValueCompareIterator_STRING>
2256 </FnBooleanIterator>
2257 <WinCondVariable name="end-CurrentIn"/>
2258 <WinCondVariable name="end-CurrentInCurrentOut"/>
2259 <AndIterator>
2260- <CompareIterator>
2261+ <TypedValueCompareIterator_STRING>
2262 <PromoteIterator type="xs:anyAtomicType">
2263 <FnDataIterator>
2264 <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,person)" typename="*" nill allowed="0">
2265@@ -56,8 +52,8 @@
2266 </ChildAxisIterator>
2267 </FnDataIterator>
2268 </PromoteIterator>
2269- </CompareIterator>
2270- <CompareIterator>
2271+ </TypedValueCompareIterator_STRING>
2272+ <TypedValueCompareIterator_STRING>
2273 <PromoteIterator type="xs:anyAtomicType">
2274 <FnDataIterator>
2275 <ChildAxisIterator test kind="match_name_test" qname="xs:QName(,,direction)" typename="*" nill allowed="0">
2276@@ -66,7 +62,7 @@
2277 </FnDataIterator>
2278 </PromoteIterator>
2279 <SingletonIterator value="xs:string(out)"/>
2280- </CompareIterator>
2281+ </TypedValueCompareIterator_STRING>
2282 </AndIterator>
2283 <flwor::TupleSourceIterator/>
2284 </flwor::WindowIterator>
2285
2286=== modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/xray/ppm_10.iter'
2287--- test/rbkt/ExpCompilerResults/IterPlan/zorba/xray/ppm_10.iter 2012-10-08 12:09:36 +0000
2288+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/xray/ppm_10.iter 2012-12-06 22:51:20 +0000
2289@@ -183,13 +183,6 @@
2290 </StringJoinIterator>
2291 <SingletonIterator value="xs:string(255)"/>
2292 <flwor::FLWORIterator>
2293- <LetVariable name="$$opt_temp_1" materialize="true">
2294- <HoistIterator>
2295- <TreatIterator type="[NodeXQType elementNode content=[XQType ANY_TYPE_KIND*]]" quant="">
2296- <CtxVarIterator varid="6" varname="scene" varkind="global"/>
2297- </TreatIterator>
2298- </HoistIterator>
2299- </LetVariable>
2300 <LetVariable name="$$opt_temp_0" materialize="true">
2301 <HoistIterator>
2302 <OpToIterator>
2303@@ -221,7 +214,7 @@
2304 <SingletonIterator value="xs:decimal(0.5)"/>
2305 </SpecificNumArithIterator_AddOperation_DECIMAL>
2306 </ForVariable>
2307- <LetVariable name="$$opt_temp_2" materialize="true">
2308+ <LetVariable name="$$opt_temp_1" materialize="true">
2309 <HoistIterator>
2310 <PromoteIterator type="xs:double">
2311 <ForVarIterator varname="y-recentered"/>
2312@@ -238,9 +231,7 @@
2313 <flwor::FLWORIterator>
2314 <ForVariable name="channel">
2315 <UDFunctionCallIterator>
2316- <UnhoistIterator>
2317- <LetVarIterator varname="$$opt_temp_1"/>
2318- </UnhoistIterator>
2319+ <CtxVarIterator varid="6" varname="scene" varkind="global"/>
2320 <PromoteIterator type="xs:double">
2321 <SpecificNumArithIterator_MultiplyOperation_DECIMAL>
2322 <SpecificNumArithIterator_SubtractOperation_DECIMAL>
2323@@ -254,7 +245,7 @@
2324 </SpecificNumArithIterator_MultiplyOperation_DECIMAL>
2325 </PromoteIterator>
2326 <UnhoistIterator>
2327- <LetVarIterator varname="$$opt_temp_2"/>
2328+ <LetVarIterator varname="$$opt_temp_1"/>
2329 </UnhoistIterator>
2330 </UDFunctionCallIterator>
2331 </ForVariable>
2332
2333=== modified file 'test/rbkt/Queries/zorba/windowing/q4.xq'
2334--- test/rbkt/Queries/zorba/windowing/q4.xq 2012-09-19 21:16:15 +0000
2335+++ test/rbkt/Queries/zorba/windowing/q4.xq 2012-12-06 22:51:20 +0000
2336@@ -4,8 +4,8 @@
2337
2338 for sliding window $w in $timesequence/stream/event
2339 start $s_curr at $s_pos previous $s_prev
2340- when ($s_curr/@time ne $s_prev/@time) or (empty($s_prev))
2341+ when ($s_curr/@time ne $s_prev/@time) or (empty($s_prev))
2342 only end next $e_next
2343- when $e_next/@time - $s_curr/@time gt $MAX_DIFF
2344+ when $e_next/@time - $s_curr/@time gt $MAX_DIFF
2345 return
2346 avg( $w/@temp )

Subscribers

People subscribed via source and target branches