Merge lp:~zorba-coders/zorba/no-copy into lp:zorba

Proposed by Markos Zaharioudakis
Status: Merged
Approved by: Markos Zaharioudakis
Approved revision: 11090
Merged at revision: 11099
Proposed branch: lp:~zorba-coders/zorba/no-copy
Merge into: lp:zorba
Diff against target: 3564 lines (+799/-649)
57 files modified
src/compiler/api/compilercb.cpp (+3/-1)
src/compiler/api/compilercb.h (+2/-0)
src/compiler/expression/expr.cpp (+1/-1)
src/compiler/expression/expr_base.cpp (+3/-26)
src/compiler/expression/expr_base.h (+14/-13)
src/compiler/expression/flwor_expr.cpp (+1/-1)
src/compiler/rewriter/framework/rewriter_context.cpp (+2/-0)
src/compiler/rewriter/framework/rewriter_context.h (+4/-0)
src/compiler/rewriter/rules/flwor_rules.cpp (+9/-9)
src/compiler/rewriter/rules/fold_rules.cpp (+6/-6)
src/compiler/rewriter/rules/hoist_rules.cpp (+2/-2)
src/compiler/rewriter/rules/index_join_rule.cpp (+4/-4)
src/compiler/rewriter/rules/nodeid_rules.cpp (+219/-141)
src/compiler/rewriter/rules/ruleset.h (+2/-2)
src/compiler/rewriter/rules/type_rules.cpp (+4/-4)
src/compiler/rewriter/tools/dataflow_annotations.cpp (+87/-96)
src/compiler/rewriter/tools/dataflow_annotations.h (+4/-9)
src/compiler/translator/translator.cpp (+110/-105)
src/compiler/xqddf/value_index.cpp (+7/-7)
src/functions/func_accessors_impl.cpp (+0/-8)
src/functions/func_arithmetic.cpp (+6/-6)
src/functions/func_booleans_impl.cpp (+12/-12)
src/functions/func_collections_impl.cpp (+1/-0)
src/functions/func_ft_module_impl.h (+18/-10)
src/functions/func_jsoniq_functions_impl.h (+6/-1)
src/functions/func_node_sort_distinct.cpp (+12/-12)
src/functions/func_numerics_impl.cpp (+6/-6)
src/functions/func_schema_impl.cpp (+9/-0)
src/functions/func_sequences_impl.cpp (+20/-10)
src/functions/library.h (+1/-1)
src/functions/pregenerated/func_accessors.h (+5/-5)
src/functions/pregenerated/func_maps.h (+2/-0)
src/functions/pregenerated/func_nodes.h (+2/-0)
src/functions/pregenerated/func_schema.cpp (+0/-22)
src/functions/pregenerated/func_schema.h (+1/-18)
src/functions/pregenerated/func_sequences.h (+1/-1)
src/functions/pregenerated/function_enum.h (+0/-1)
src/functions/udf.cpp (+1/-1)
src/functions/udf.h (+3/-3)
src/runtime/collections/collections_impl.cpp (+4/-0)
src/runtime/eval/eval.cpp (+2/-0)
src/runtime/spec/accessors/accessors.xml (+4/-4)
src/runtime/spec/nodes/nodes.xml (+4/-0)
src/runtime/spec/schema/schema.xml (+1/-13)
src/runtime/spec/sequences/sequences.xml (+1/-1)
src/runtime/spec/store/maps.xml (+1/-0)
src/runtime/store/maps_impl.cpp (+10/-19)
src/store/naive/node_items.cpp (+7/-67)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/test5.iter (+48/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/test6.iter (+50/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/baseuri.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/recursive_01.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/test5.xml.res (+1/-1)
test/rbkt/ExpQueryResults/zorba/no-copy/test6.xml.res (+3/-0)
test/rbkt/Queries/zorba/no-copy/baseuri.xq (+11/-0)
test/rbkt/Queries/zorba/no-copy/recursive_01.xq (+35/-0)
test/rbkt/Queries/zorba/no-copy/test6.xq (+24/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/no-copy
Reviewer Review Type Date Requested Status
Markos Zaharioudakis Approve
Review via email: mp+128923@code.launchpad.net

Commit message

no-copy rule restructuring:
1. make sure index domain nodes are standalone trees
2. make sure tokenize-node and tokenize-nodes function take statndalone trees as inputs
3. fn:data and fn:nilled are type-sensitive, but only for shared nodes
4. fn:base-uri and fn:root are unsafe for shared nodes only
5. jn:object is safe
6. fixes in IndexDecl::analyze() method
7. markInUnsafeContext --> findSourcesForNodeExtractors
8. handling recursive udfs in MarkNodeCopyProps::applyInternal
9. added visit id in expressions
10. fn:deep-equal is type-sensitive
11. map:insert must instert standalone trees in map

Description of the change

no-copy rule restructuring:
1. make sure index domain nodes are standalone trees
2. make sure tokenize-node and tokenize-nodes function take statndalone trees as inputs
3. fn:data and fn:nilled are type-sensitive, but only for shared nodes
4. fn:base-uri and fn:root are unsafe for shared nodes only
5. jn:object is safe
6. fixes in IndexDecl::analyze() method
7. markInUnsafeContext --> findSourcesForNodeExtractors
8. handling recursive udfs in MarkNodeCopyProps::applyInternal
9. added visit id in expressions
10. fn:deep-equal is type-sensitive
11. map:insert must instert standalone trees in map

To post a comment you must log in.
lp:~zorba-coders/zorba/no-copy updated
11087. By Markos Zaharioudakis

more no-copy rework

11088. By Markos Zaharioudakis

more no-copy rework

11089. By Markos Zaharioudakis

markInUnsafeContext --> findSourcesForNodeExtractors + handling recursive udfs in MarkNodeCopyProps::applyInternal

11090. By Markos Zaharioudakis

fixed properies of some functions

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 no-copy-2012-10-15T13-51-59.268Z 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 'src/compiler/api/compilercb.cpp'
2--- src/compiler/api/compilercb.cpp 2012-10-08 12:09:36 +0000
3+++ src/compiler/api/compilercb.cpp 2012-10-15 13:39:25 +0000
4@@ -120,9 +120,9 @@
5 theHaveTimeout(false),
6 theTimeout(timeout),
7 theTempIndexCounter(0),
8+ theNextVisitId(1),
9 theEM(new ExprManager(this))
10 {
11-
12 if (timeout >= 0)
13 theHaveTimeout = true;
14 }
15@@ -148,6 +148,7 @@
16 theHaveTimeout(cb.theHaveTimeout),
17 theTimeout(cb.theTimeout),
18 theTempIndexCounter(0),
19+ theNextVisitId(cb.theNextVisitId+1),
20 theConfig(cb.theConfig),
21 theEM(new ExprManager(this))
22 {
23@@ -167,6 +168,7 @@
24 #endif
25 theHasEval(false),
26 theIsEval(false),
27+ theNextVisitId(1),
28 theEM(new ExprManager(this))
29 {
30 }
31
32=== modified file 'src/compiler/api/compilercb.h'
33--- src/compiler/api/compilercb.h 2012-10-08 12:09:36 +0000
34+++ src/compiler/api/compilercb.h 2012-10-15 13:39:25 +0000
35@@ -195,6 +195,8 @@
36
37 uint32_t theTempIndexCounter;
38
39+ ulong theNextVisitId;
40+
41 config theConfig;
42
43 ExprManager * const theEM;
44
45=== modified file 'src/compiler/expression/expr.cpp'
46--- src/compiler/expression/expr.cpp 2012-10-09 14:06:08 +0000
47+++ src/compiler/expression/expr.cpp 2012-10-15 13:39:25 +0000
48@@ -109,7 +109,7 @@
49 create_fo_expr(sctx,
50 udf,
51 loc,
52- GET_BUILTIN_FUNCTION(FN_BOOLEAN_1),
53+ BUILTIN_FUNC(FN_BOOLEAN_1),
54 condExpr);
55
56 condExpr = boolExpr;
57
58=== modified file 'src/compiler/expression/expr_base.cpp'
59--- src/compiler/expression/expr_base.cpp 2012-10-09 14:06:08 +0000
60+++ src/compiler/expression/expr_base.cpp 2012-10-15 13:39:25 +0000
61@@ -134,7 +134,8 @@
62 theUDF(udf),
63 theLoc(loc),
64 theKind(k),
65- theFlags1(0)
66+ theFlags1(0),
67+ theVisitId(0)
68 {
69 theScriptingKind = UNKNOWN_SCRIPTING_KIND;
70
71@@ -512,30 +513,6 @@
72 /*******************************************************************************
73
74 ********************************************************************************/
75-BoolAnnotationValue expr::getInUnsafeContext() const
76-{
77- return (BoolAnnotationValue)
78- ((theFlags1 & IN_UNSAFE_CONTEXT_MASK) >> IN_UNSAFE_CONTEXT);
79-}
80-
81-
82-void expr::setInUnsafeContext(BoolAnnotationValue v)
83-{
84- theFlags1 &= ~IN_UNSAFE_CONTEXT_MASK;
85- theFlags1 |= (v << IN_UNSAFE_CONTEXT);
86-}
87-
88-
89-bool expr::inUnsafeContext() const
90-{
91- BoolAnnotationValue v = getInUnsafeContext();
92- return (v == ANNOTATION_TRUE || v == ANNOTATION_TRUE_FIXED);
93-}
94-
95-
96-/*******************************************************************************
97-
98-********************************************************************************/
99 BoolAnnotationValue expr::getContainsPragma() const
100 {
101 return (BoolAnnotationValue)
102@@ -1189,7 +1166,7 @@
103 create_fo_expr(input->get_sctx(),
104 theUDF,
105 QueryLoc::null,
106- GET_BUILTIN_FUNCTION(OP_CONCATENATE_N));
107+ BUILTIN_FUNC(OP_CONCATENATE_N));
108
109 expr::substitution_t subst;
110 subst[input] = emptyExpr;
111
112=== modified file 'src/compiler/expression/expr_base.h'
113--- src/compiler/expression/expr_base.h 2012-10-09 14:06:08 +0000
114+++ src/compiler/expression/expr_base.h 2012-10-15 13:39:25 +0000
115@@ -147,9 +147,8 @@
116 UNFOLDABLE = 10,
117 CONTAINS_RECURSIVE_CALL = 12,
118 PROPAGATES_INPUT_NODES = 14,
119- IN_UNSAFE_CONTEXT = 16,
120- MUST_COPY_NODES = 18,
121- CONTAINS_PRAGMA = 20
122+ MUST_COPY_NODES = 16,
123+ CONTAINS_PRAGMA = 18
124 } Annotationkey;
125
126 typedef enum
127@@ -162,9 +161,8 @@
128 UNFOLDABLE_MASK = 0xC00,
129 CONTAINS_RECURSIVE_CALL_MASK = 0x3000,
130 PROPAGATES_INPUT_NODES_MASK = 0xC000,
131- IN_UNSAFE_CONTEXT_MASK = 0x30000,
132- MUST_COPY_NODES_MASK = 0xC0000,
133- CONTAINS_PRAGMA_MASK = 0x300000
134+ MUST_COPY_NODES_MASK = 0x30000,
135+ CONTAINS_PRAGMA_MASK = 0xC0000
136 } AnnotationMask;
137
138
139@@ -182,6 +180,7 @@
140 QueryLoc theLoc;
141
142 unsigned short theKind;
143+
144 unsigned short theScriptingKind;
145
146 xqtref_t theType;
147@@ -190,6 +189,8 @@
148
149 FreeVars theFreeVars;
150
151+ int theVisitId;
152+
153 public:
154 static bool is_sequential(unsigned short theScriptingKind);
155
156@@ -317,13 +318,6 @@
157
158 void setMustCopyNodes(BoolAnnotationValue v);
159
160- // Annotation : inUnsafeContext
161- BoolAnnotationValue getInUnsafeContext() const;
162-
163- void setInUnsafeContext(BoolAnnotationValue v);
164-
165- bool inUnsafeContext() const;
166-
167 // Annotation : containsPragma
168 BoolAnnotationValue getContainsPragma() const;
169
170@@ -338,6 +332,13 @@
171
172 void setFreeVars(FreeVars& s);
173
174+ //
175+ void setVisitId(int id) { theVisitId = id; }
176+
177+ bool isVisited(int id) const { return theVisitId == id; }
178+
179+ int getVisitId() const { return theVisitId; }
180+
181 bool is_constant() const;
182
183 bool is_nondeterministic() const;
184
185=== modified file 'src/compiler/expression/flwor_expr.cpp'
186--- src/compiler/expression/flwor_expr.cpp 2012-10-09 14:06:08 +0000
187+++ src/compiler/expression/flwor_expr.cpp 2012-10-15 13:39:25 +0000
188@@ -510,7 +510,7 @@
189 create_fo_expr(theCondExpr->get_sctx(),
190 theCondExpr->get_udf(),
191 theCondExpr->get_loc(),
192- GET_BUILTIN_FUNCTION(FN_BOOLEAN_1),
193+ BUILTIN_FUNC(FN_BOOLEAN_1),
194 theCondExpr);
195 }
196 }
197
198=== modified file 'src/compiler/rewriter/framework/rewriter_context.cpp'
199--- src/compiler/rewriter/framework/rewriter_context.cpp 2012-10-09 14:06:08 +0000
200+++ src/compiler/rewriter/framework/rewriter_context.cpp 2012-10-15 13:39:25 +0000
201@@ -49,6 +49,8 @@
202 theIdVarMap(NULL),
203 theExprVarsMap(NULL)
204 {
205+ theForSerializationOnly = theCCB->theConfig.for_serialization_only;
206+
207 if (msg.empty())
208 {
209 if (udf != NULL)
210
211=== modified file 'src/compiler/rewriter/framework/rewriter_context.h'
212--- src/compiler/rewriter/framework/rewriter_context.h 2012-10-09 14:22:18 +0000
213+++ src/compiler/rewriter/framework/rewriter_context.h 2012-10-15 13:39:25 +0000
214@@ -85,6 +85,8 @@
215
216 int m_tempvarCounter;
217
218+ bool theForSerializationOnly;
219+
220 bool theIsInOrderedMode;
221
222 VarIdMap * theVarIdMap;
223@@ -109,6 +111,8 @@
224
225 void setRoot(expr* root);
226
227+ void setForSerializationOnly(bool v) { theForSerializationOnly = v; }
228+
229 var_expr* createTempVar(
230 static_context* sctx,
231 const QueryLoc& loc,
232
233=== modified file 'src/compiler/rewriter/rules/flwor_rules.cpp'
234--- src/compiler/rewriter/rules/flwor_rules.cpp 2012-10-09 14:06:08 +0000
235+++ src/compiler/rewriter/rules/flwor_rules.cpp 2012-10-15 13:39:25 +0000
236@@ -540,7 +540,7 @@
237 create_fo_expr(sctx,
238 udf,
239 whereCond->get_loc(),
240- GET_BUILTIN_FUNCTION(OP_AND_N),
241+ BUILTIN_FUNC(OP_AND_N),
242 whereExpr,
243 whereCond);
244 }
245@@ -1383,7 +1383,7 @@
246 create_fo_expr(sctx,
247 udf,
248 whereExpr->get_loc(),
249- GET_BUILTIN_FUNCTION(OP_AND_N),
250+ BUILTIN_FUNC(OP_AND_N),
251 whereExpr,
252 condExpr);
253
254@@ -1512,7 +1512,7 @@
255 create_fo_expr(sctx,
256 udf,
257 domainExpr->get_loc(),
258- GET_BUILTIN_FUNCTION(OP_ZORBA_SEQUENCE_POINT_ACCESS_2),
259+ BUILTIN_FUNC(OP_ZORBA_SEQUENCE_POINT_ACCESS_2),
260 domainExpr,
261 posExpr);
262 break;
263@@ -1532,7 +1532,7 @@
264 create_fo_expr(sctx,
265 udf,
266 domainExpr->get_loc(),
267- GET_BUILTIN_FUNCTION(OP_ZORBA_SUBSEQUENCE_INT_3),
268+ BUILTIN_FUNC(OP_ZORBA_SUBSEQUENCE_INT_3),
269 args);
270 break;
271 }
272@@ -1549,7 +1549,7 @@
273 create_fo_expr(sctx,
274 udf,
275 domainExpr->get_loc(),
276- GET_BUILTIN_FUNCTION(OP_NUMERIC_SUBTRACT_INTEGER_2),
277+ BUILTIN_FUNC(OP_NUMERIC_SUBTRACT_INTEGER_2),
278 posExpr,
279 oneExpr2);
280
281@@ -1562,7 +1562,7 @@
282 create_fo_expr(sctx,
283 udf,
284 domainExpr->get_loc(),
285- GET_BUILTIN_FUNCTION(OP_ZORBA_SUBSEQUENCE_INT_3),
286+ BUILTIN_FUNC(OP_ZORBA_SUBSEQUENCE_INT_3),
287 args);
288 break;
289 }
290@@ -1573,7 +1573,7 @@
291 create_fo_expr(sctx,
292 udf,
293 domainExpr->get_loc(),
294- GET_BUILTIN_FUNCTION(OP_ZORBA_SUBSEQUENCE_INT_2),
295+ BUILTIN_FUNC(OP_ZORBA_SUBSEQUENCE_INT_2),
296 domainExpr,
297 posExpr);
298 break;
299@@ -1588,7 +1588,7 @@
300 create_fo_expr(sctx,
301 udf,
302 domainExpr->get_loc(),
303- GET_BUILTIN_FUNCTION(OP_NUMERIC_ADD_INTEGER_2),
304+ BUILTIN_FUNC(OP_NUMERIC_ADD_INTEGER_2),
305 posExpr,
306 oneExpr);
307
308@@ -1596,7 +1596,7 @@
309 create_fo_expr(sctx,
310 udf,
311 domainExpr->get_loc(),
312- GET_BUILTIN_FUNCTION(OP_ZORBA_SUBSEQUENCE_INT_2),
313+ BUILTIN_FUNC(OP_ZORBA_SUBSEQUENCE_INT_2),
314 domainExpr,
315 posExpr);
316 break;
317
318=== modified file 'src/compiler/rewriter/rules/fold_rules.cpp'
319--- src/compiler/rewriter/rules/fold_rules.cpp 2012-10-09 14:06:08 +0000
320+++ src/compiler/rewriter/rules/fold_rules.cpp 2012-10-15 13:39:25 +0000
321@@ -137,7 +137,7 @@
322 error::ZorbaError::toString(lErrorCode).c_str());
323 expr* err_expr = rCtx.theEM->create_fo_expr(node->get_sctx_id(),
324 loc,
325- GET_BUILTIN_FUNCTION(FN_ERROR_2),
326+ BUILTIN_FUNC(FN_ERROR_2),
327 rCtx.theEM->create_const_expr(node->get_sctx_id(), loc, qname),
328 rCtx.theEM->create_const_expr(node->get_sctx_id(), loc, e.theDescription));
329 err_expr->setUnfoldable(ANNOTATION_TRUE_FIXED);
330@@ -877,7 +877,7 @@
331 arg = rCtx.theEM->create_fo_expr(sctx,
332 udf,
333 LOC(fo),
334- GET_BUILTIN_FUNCTION(FN_BOOLEAN_1),
335+ BUILTIN_FUNC(FN_BOOLEAN_1),
336 arg);
337
338 arg = expr_tools::fix_annotations(arg);
339@@ -947,7 +947,7 @@
340 create_fo_expr(sctx,
341 udf,
342 fo.get_loc(),
343- GET_BUILTIN_FUNCTION(FN_EMPTY_1),
344+ BUILTIN_FUNC(FN_EMPTY_1),
345 count_expr->get_arg(0)));
346 }
347 else if (ival == 1)
348@@ -956,7 +956,7 @@
349 create_fo_expr(sctx,
350 udf,
351 fo.get_loc(),
352- GET_BUILTIN_FUNCTION(OP_EXACTLY_ONE_NORAISE_1),
353+ BUILTIN_FUNC(OP_EXACTLY_ONE_NORAISE_1),
354 count_expr->get_arg(0)));
355 }
356 else
357@@ -970,14 +970,14 @@
358 create_fo_expr(sctx,
359 udf,
360 LOC(count_expr),
361- GET_BUILTIN_FUNCTION(OP_ZORBA_SUBSEQUENCE_INT_3),
362+ BUILTIN_FUNC(OP_ZORBA_SUBSEQUENCE_INT_3),
363 args));
364
365 return expr_tools::fix_annotations(rCtx.theEM->
366 create_fo_expr(sctx,
367 udf,
368 fo.get_loc(),
369- GET_BUILTIN_FUNCTION(OP_EXACTLY_ONE_NORAISE_1),
370+ BUILTIN_FUNC(OP_EXACTLY_ONE_NORAISE_1),
371 subseq_expr));
372 }
373 }
374
375=== modified file 'src/compiler/rewriter/rules/hoist_rules.cpp'
376--- src/compiler/rewriter/rules/hoist_rules.cpp 2012-10-09 14:06:08 +0000
377+++ src/compiler/rewriter/rules/hoist_rules.cpp 2012-10-15 13:39:25 +0000
378@@ -482,7 +482,7 @@
379 var_expr* letvar(rCtx.createTempVar(sctx, loc, var_expr::let_var));
380
381 expr* hoisted = rCtx.theEM->
382- create_fo_expr(sctx, udf, loc, GET_BUILTIN_FUNCTION(OP_HOIST_1), e);
383+ create_fo_expr(sctx, udf, loc, BUILTIN_FUNC(OP_HOIST_1), e);
384
385 hoisted->setFlags(e->getFlags());
386 letvar->setFlags(e->getFlags());
387@@ -521,7 +521,7 @@
388 create_fo_expr(sctx,
389 udf,
390 loc,
391- GET_BUILTIN_FUNCTION(OP_UNHOIST_1),
392+ BUILTIN_FUNC(OP_UNHOIST_1),
393 rCtx.theEM->create_wrapper_expr(sctx, udf, loc, letvar));
394 unhoisted->setFlags(e->getFlags());
395
396
397=== modified file 'src/compiler/rewriter/rules/index_join_rule.cpp'
398--- src/compiler/rewriter/rules/index_join_rule.cpp 2012-10-09 14:06:08 +0000
399+++ src/compiler/rewriter/rules/index_join_rule.cpp 2012-10-15 13:39:25 +0000
400@@ -491,7 +491,7 @@
401 create_fo_expr(sctx,
402 udf,
403 loc,
404- GET_BUILTIN_FUNCTION(OP_CREATE_INTERNAL_INDEX_2),
405+ BUILTIN_FUNC(OP_CREATE_INTERNAL_INDEX_2),
406 qnameExpr,
407 buildExpr);
408
409@@ -637,7 +637,7 @@
410 create_fo_expr(sctx,
411 udf,
412 loc,
413- GET_BUILTIN_FUNCTION(FN_ZORBA_XQDDF_PROBE_INDEX_POINT_GENERAL_N),
414+ BUILTIN_FUNC(FN_ZORBA_XQDDF_PROBE_INDEX_POINT_GENERAL_N),
415 qnameExpr,
416 const_cast<expr*>(predInfo.theOuterOp));
417
418@@ -645,7 +645,7 @@
419 create_fo_expr(sctx,
420 udf,
421 loc,
422- GET_BUILTIN_FUNCTION(OP_SORT_DISTINCT_NODES_ASC_1),
423+ BUILTIN_FUNC(OP_SORT_DISTINCT_NODES_ASC_1),
424 probeExpr);
425 }
426 else
427@@ -654,7 +654,7 @@
428 create_fo_expr(sctx,
429 udf,
430 loc,
431- GET_BUILTIN_FUNCTION(FN_ZORBA_XQDDF_PROBE_INDEX_POINT_VALUE_N),
432+ BUILTIN_FUNC(FN_ZORBA_XQDDF_PROBE_INDEX_POINT_VALUE_N),
433 qnameExpr,
434 const_cast<expr*>(predInfo.theOuterOp));
435 }
436
437=== modified file 'src/compiler/rewriter/rules/nodeid_rules.cpp'
438--- src/compiler/rewriter/rules/nodeid_rules.cpp 2012-10-09 14:22:18 +0000
439+++ src/compiler/rewriter/rules/nodeid_rules.cpp 2012-10-15 13:39:25 +0000
440@@ -585,7 +585,7 @@
441
442 try
443 {
444- if (rCtx.theCCB->theConfig.for_serialization_only)
445+ if (rCtx.theForSerializationOnly)
446 {
447 // Serialization may or may not be a "safe" op.
448 static_context* sctx = node->get_sctx();
449@@ -604,14 +604,14 @@
450 // out of input nodes and (b) may propagate the extracted nodes to the
451 // query result will be considered as unsafe and thus require that
452 // their input trees are standalone.
453- markInUnsafeContext(node);
454+ findSourcesForNodeExtractors(node);
455 }
456 }
457 else
458 {
459 // In this case serialization is always unsafe.
460 std::vector<expr*> sources;
461- theSourceFinder->findNodeSources(rCtx.theRoot, NULL, sources);
462+ theSourceFinder->findNodeSources(rCtx.theRoot, sources);
463 markSources(sources);
464 }
465 }
466@@ -620,11 +620,11 @@
467 // We have to assume that the result of the "node" expr will be used in an
468 // unsafe op, so it must consist of standalone trees.
469 std::vector<expr*> sources;
470- theSourceFinder->findNodeSources(rCtx.theRoot, NULL, sources);
471+ theSourceFinder->findNodeSources(rCtx.theRoot, sources);
472 markSources(sources);
473 }
474
475- applyInternal(rCtx, node, NULL);
476+ applyInternal(node, false);
477 }
478 catch (...)
479 {
480@@ -642,13 +642,13 @@
481
482
483 /*******************************************************************************
484-
485+ If "node" is inside a UDF body, then "udfCaller" is the fo expr that invokes
486+ that UDF.
487 ********************************************************************************/
488-void MarkNodeCopyProps::applyInternal(
489- RewriterContext& rCtx,
490- expr* node,
491- fo_expr* udfCaller)
492+void MarkNodeCopyProps::applyInternal(expr* node, bool deferred)
493 {
494+ static_context* sctx = node->get_sctx();
495+
496 switch (node->get_expr_kind())
497 {
498 case const_expr_kind:
499@@ -663,6 +663,13 @@
500 case text_expr_kind:
501 case pi_expr_kind:
502 {
503+ // If a doc or element constructor needs to copy (and the ns mode is preserve
504+ // and inherit), should it be considered unsafe? The answer is no, because if
505+ // copy is needed, then any other construction done during the "current" one
506+ // will need to copy as well, so the input trees to the current constructor
507+ // will be standalone. This is enforced bhy the findNodeSources() method,
508+ // which drills down inside constructors and will collect as sources any
509+ // nested c onstructors as well.
510 break;
511 }
512
513@@ -673,15 +680,13 @@
514 // TODO improve this
515 json_direct_object_expr* e = static_cast<json_direct_object_expr *>(node);
516
517- static_context* sctx = e->get_sctx();
518-
519 if (sctx->preserve_ns() && sctx->inherit_ns())
520 {
521 csize numPairs = e->num_pairs();
522 for (csize i = 0; i < numPairs; ++i)
523 {
524 std::vector<expr*> sources;
525- theSourceFinder->findNodeSources(e->get_value_expr(i), udfCaller, sources);
526+ theSourceFinder->findNodeSources(e->get_value_expr(i), sources);
527 markSources(sources);
528 }
529 }
530@@ -690,6 +695,9 @@
531 }
532 case json_object_expr_kind:
533 {
534+ // The input to this expr is a sequence of other objects, which if they
535+ // contain any nodes, those nodes are in standalone trees. So, copying
536+ // these nodes when the objects are copied is ok.
537 break;
538 }
539 case json_array_expr_kind:
540@@ -698,12 +706,10 @@
541 // TODO improve this
542 json_array_expr* e = static_cast<json_array_expr *>(node);
543
544- static_context* sctx = e->get_sctx();
545-
546 if (sctx->preserve_ns() && sctx->inherit_ns())
547 {
548 std::vector<expr*> sources;
549- theSourceFinder->findNodeSources(e->get_expr(), udfCaller, sources);
550+ theSourceFinder->findNodeSources(e->get_expr(), sources);
551 markSources(sources);
552 }
553
554@@ -715,89 +721,103 @@
555 {
556 relpath_expr* e = static_cast<relpath_expr *>(node);
557
558- if (e->inUnsafeContext())
559- {
560- std::vector<expr*> sources;
561- theSourceFinder->findNodeSources((*e)[0], udfCaller, sources);
562- markSources(sources);
563- }
564- else
565- {
566- std::vector<expr*>::const_iterator ite = e->begin();
567- std::vector<expr*>::const_iterator end = e->end();
568-
569- for (++ite; ite != end; ++ite)
570- {
571- axis_step_expr* axisExpr = static_cast<axis_step_expr*>((*ite));
572- axis_kind_t axisKind = axisExpr->getAxis();
573-
574- if (axisKind != axis_kind_child &&
575- axisKind != axis_kind_descendant &&
576- axisKind != axis_kind_descendant_or_self &&
577- axisKind != axis_kind_self &&
578- axisKind != axis_kind_attribute)
579+ std::vector<expr*>::const_iterator ite = e->begin();
580+ std::vector<expr*>::const_iterator end = e->end();
581+
582+ for (++ite; ite != end; ++ite)
583+ {
584+ axis_step_expr* axisExpr = static_cast<axis_step_expr*>((*ite));
585+ axis_kind_t axisKind = axisExpr->getAxis();
586+
587+ if (axisKind != axis_kind_child &&
588+ axisKind != axis_kind_descendant &&
589+ axisKind != axis_kind_descendant_or_self &&
590+ axisKind != axis_kind_self &&
591+ axisKind != axis_kind_attribute)
592+ {
593+ std::vector<expr*> sources;
594+ theSourceFinder->findNodeSources((*e)[0], sources);
595+ markSources(sources);
596+ break;
597+ }
598+ else
599+ {
600+ match_expr* matchExpr = axisExpr->getTest();
601+
602+ if (matchExpr->getTypeName() != NULL &&
603+ sctx->construction_mode() == StaticContextConsts::cons_strip)
604 {
605 std::vector<expr*> sources;
606- theSourceFinder->findNodeSources((*e)[0], udfCaller, sources);
607+ theSourceFinder->findNodeSources((*e)[0], sources);
608 markSources(sources);
609 break;
610 }
611- else
612- {
613- match_expr* matchExpr = axisExpr->getTest();
614-
615- if (matchExpr->getTypeName() != NULL &&
616- node->get_sctx()->construction_mode() == StaticContextConsts::cons_strip)
617+ }
618+ }
619+
620+ applyInternal((*e)[0], deferred);
621+
622+ return;
623+ }
624+
625+ case fo_expr_kind:
626+ {
627+ fo_expr* e = static_cast<fo_expr *>(node);
628+ function* f = e->get_func();
629+
630+ if (f->isUdf() && static_cast<user_function*>(f)->getBody() != NULL)
631+ {
632+ user_function* udf = static_cast<user_function*>(f);
633+ user_function* callerUdf = e->get_udf();
634+
635+ bool recursive = (callerUdf ? callerUdf->isMutuallyRecursiveWith(udf) : false);
636+
637+ if (recursive && !deferred)
638+ {
639+ callerUdf->addRecursiveCall(e);
640+ }
641+ else
642+ {
643+ UdfSet::iterator ite = theProcessedUDFs.find(udf);
644+
645+ if (ite == theProcessedUDFs.end())
646+ {
647+ theProcessedUDFs.insert(udf);
648+
649+ applyInternal(udf->getBody(), deferred);
650+
651+ if (udf->isRecursive())
652+ {
653+ std::vector<fo_expr*>::const_iterator ite = udf->getRecursiveCalls().begin();
654+ std::vector<fo_expr*>::const_iterator end = udf->getRecursiveCalls().end();
655+ for (; ite != end; ++ite)
656+ {
657+ user_function* recursiveUdf =
658+ static_cast<user_function*>((*ite)->get_func());
659+
660+ applyInternal(*ite, true);
661+ }
662+ }
663+ }
664+
665+ // if an arg var of this udf has been marked as a source before, it
666+ // means that that var is consumed in some unsafe operation, so we
667+ // now have to find the sources of the arg expr and mark them.
668+ csize numArgs = e->num_args();
669+
670+ for (csize i = 0; i < numArgs; ++i)
671+ {
672+ var_expr* argVar = udf->getArgVar(i);
673+
674+ if (theSourceFinder->theVarSourcesMap.find(argVar) !=
675+ theSourceFinder->theVarSourcesMap.end())
676 {
677 std::vector<expr*> sources;
678- theSourceFinder->findNodeSources((*e)[0], udfCaller, sources);
679+ theSourceFinder->findNodeSources(e->get_arg(i), sources);
680 markSources(sources);
681- break;
682 }
683 }
684 }
685- }
686-
687- applyInternal(rCtx, (*e)[0], udfCaller);
688-
689- return;
690- }
691-
692- case fo_expr_kind:
693- {
694- fo_expr* e = static_cast<fo_expr *>(node);
695- function* f = e->get_func();
696-
697- if (f->isUdf() && static_cast<user_function*>(f)->getBody() != NULL)
698- {
699- user_function* udf = static_cast<user_function*>(f);
700-
701- UdfSet::iterator ite = theProcessedUDFs.find(udf);
702-
703- if (ite == theProcessedUDFs.end())
704- {
705- theProcessedUDFs.insert(udf);
706-
707- applyInternal(rCtx, udf->getBody(), e);
708- }
709-
710- // if an arg var of this udf has been marked as a source before, it
711- // means that that var is consumed in some unsafe operation, so we
712- // now have to find the sources of the arg expr and mark them.
713- csize numArgs = e->num_args();
714-
715- for (csize i = 0; i < numArgs; ++i)
716- {
717- var_expr* argVar = udf->getArgVar(i);
718-
719- if (theSourceFinder->theVarSourcesMap.find(argVar) !=
720- theSourceFinder->theVarSourcesMap.end())
721- {
722- std::vector<expr*> sources;
723- theSourceFinder->findNodeSources(e->get_arg(i), udfCaller, sources);
724- markSources(sources);
725- }
726- }
727 } // f->isUdf()
728 else
729 {
730@@ -807,10 +827,34 @@
731 if (f->mustCopyInputNodes(e, i))
732 {
733 std::vector<expr*> sources;
734- theSourceFinder->findNodeSources(e->get_arg(i), udfCaller, sources);
735+ theSourceFinder->findNodeSources(e->get_arg(i), sources);
736 markSources(sources);
737 }
738 }
739+
740+ FunctionConsts::FunctionKind fkind = f->getKind();
741+
742+ switch (fkind)
743+ {
744+ case FunctionConsts::FN_DATA_1:
745+ case FunctionConsts::FN_NILLED_1:
746+ {
747+ if (sctx->construction_mode() == StaticContextConsts::cons_strip)
748+ {
749+ findSourcesForNodeExtractors(e->get_arg(0));
750+ }
751+ break;
752+ }
753+ case FunctionConsts::FN_BASE_URI_1:
754+ case FunctionConsts::FN_ROOT_1:
755+ // TODO: node-before, node-after
756+ {
757+ findSourcesForNodeExtractors(e->get_arg(0));
758+ break;
759+ }
760+ default:
761+ break;
762+ }
763 }
764
765 break;
766@@ -837,11 +881,11 @@
767 case instanceof_expr_kind:
768 case treat_expr_kind:
769 {
770- if (node->get_sctx()->construction_mode() == StaticContextConsts::cons_strip)
771+ if (sctx->construction_mode() == StaticContextConsts::cons_strip)
772 {
773 cast_or_castable_base_expr* e = static_cast<cast_or_castable_base_expr*>(node);
774
775- markInUnsafeContext(e->get_input());
776+ findSourcesForNodeExtractors(e->get_input());
777 }
778
779 break;
780@@ -851,7 +895,7 @@
781 {
782 validate_expr* e = static_cast<validate_expr *>(node);
783 std::vector<expr*> sources;
784- theSourceFinder->findNodeSources(e->get_expr(), udfCaller, sources);
785+ theSourceFinder->findNodeSources(e->get_expr(), sources);
786 markSources(sources);
787 break;
788 }
789@@ -872,16 +916,14 @@
790 if (kind == replace_expr_kind || kind == delete_expr_kind)
791 {
792 std::vector<expr*> sources;
793- theSourceFinder->findNodeSources(e->getTargetExpr(), udfCaller, sources);
794+ theSourceFinder->findNodeSources(e->getTargetExpr(), sources);
795 markSources(sources);
796 }
797 else
798 {
799- markInUnsafeContext(node);
800+ findSourcesForNodeExtractors(node);
801 }
802
803- static_context* sctx = e->get_sctx();
804-
805 // TODO: apply no-copy rule to insert and replace updates
806 if (e->getSourceExpr() != NULL &&
807 (kind == insert_expr_kind ||
808@@ -891,7 +933,7 @@
809 sctx->preserve_ns())
810 {
811 std::vector<expr*> sources;
812- theSourceFinder->findNodeSources(e->getSourceExpr(), udfCaller, sources);
813+ theSourceFinder->findNodeSources(e->getSourceExpr(), sources);
814 markSources(sources);
815 }
816
817@@ -902,8 +944,6 @@
818 {
819 transform_expr* e = static_cast<transform_expr *>(node);
820
821- static_context* sctx = e->get_sctx();
822-
823 if (sctx->preserve_ns() && sctx->inherit_ns())
824 {
825 std::vector<copy_clause*>::const_iterator ite = e->begin();
826@@ -912,7 +952,7 @@
827 for (; ite != end; ++ite)
828 {
829 std::vector<expr*> sources;
830- theSourceFinder->findNodeSources((*ite)->getExpr(), udfCaller, sources);
831+ theSourceFinder->findNodeSources((*ite)->getExpr(), sources);
832 markSources(sources);
833 }
834 }
835@@ -946,7 +986,7 @@
836 expr* arg = e->get_arg_expr(i);
837
838 std::vector<expr*> sources;
839- theSourceFinder->findNodeSources(arg, udfCaller, sources);
840+ theSourceFinder->findNodeSources(arg, sources);
841 markSources(sources);
842 }
843
844@@ -961,10 +1001,13 @@
845 #ifndef ZORBA_NO_FULL_TEXT
846 case ft_expr_kind:
847 {
848+ // This expr prefrorms whole-tree tokenization. So, its input nodes
849+ // must not be shared nodes. What if the input nodes are not shared?
850+ // if ft_expr safe in that case ????
851 ftcontains_expr* e = static_cast<ftcontains_expr*>(node);
852
853 std::vector<expr*> sources;
854- theSourceFinder->findNodeSources(e->get_range(), udfCaller, sources);
855+ theSourceFinder->findNodeSources(e->get_range(), sources);
856 markSources(sources);
857
858 break;
859@@ -985,7 +1028,7 @@
860 FOR_EACH(std::vector<expr*>, ite, args)
861 {
862 std::vector<expr*> sources;
863- theSourceFinder->findNodeSources((*ite), udfCaller, sources);
864+ theSourceFinder->findNodeSources((*ite), sources);
865 markSources(sources);
866 }
867
868@@ -998,7 +1041,7 @@
869
870 user_function* udf = static_cast<user_function*>(e->get_function());
871
872- applyInternal(rCtx, udf->getBody(), NULL);
873+ applyInternal(udf->getBody(), deferred);
874
875 return;
876 }
877@@ -1015,7 +1058,7 @@
878 expr* child = (**iter);
879 if (child != NULL)
880 {
881- applyInternal(rCtx, child, udfCaller);
882+ applyInternal(child, deferred);
883 }
884 iter.next();
885 }
886@@ -1059,13 +1102,14 @@
887
888
889 /*******************************************************************************
890- This method is called when an expr E1 satisfies a condition that may make a
891- sub-expr E2 of E1 be unsafe, even though E2 by itself is safe.
892-
893- This method marks as being in "unsafe context" any expr that may produce
894- nodes which may be propagated into the result of E1.
895+ Some expressions are safe when applied to a non-shared node (even is that
896+ node contains shared subtrees), but unsafe on shared nodes. Let E1 be such
897+ an expr. Instead of considering E1 as an unsafe expr uncondiftionally, we
898+ "transfer" its conditional unsafeness to each expr E2 such that E2 contributes
899+ nodes into E1's input, and E2 extracts such nodes from other nodes (and as a
900+ result, the nodes that E2 propagates to E1 may be shared nodes).
901 ********************************************************************************/
902-void MarkNodeCopyProps::markInUnsafeContext(expr* node)
903+void MarkNodeCopyProps::findSourcesForNodeExtractors(expr* node)
904 {
905 TypeManager* tm = node->get_type_manager();
906 RootTypeManager& rtm = GENV_TYPESYSTEM;
907@@ -1094,10 +1138,10 @@
908 case var_expr::wincond_in_var:
909 case var_expr::non_groupby_var:
910 {
911- if (!e->inUnsafeContext())
912+ if (!e->isVisited(1))
913 {
914- e->setInUnsafeContext(ANNOTATION_TRUE);
915- markInUnsafeContext(e->get_domain_expr());
916+ e->setVisitId(1);
917+ findSourcesForNodeExtractors(e->get_domain_expr());
918 }
919 return;
920 }
921@@ -1105,22 +1149,21 @@
922 case var_expr::copy_var:
923 case var_expr::catch_var:
924 {
925- e->setInUnsafeContext(ANNOTATION_TRUE);
926 return;
927 }
928
929 case var_expr::arg_var:
930 {
931- e->setInUnsafeContext(ANNOTATION_TRUE);
932+ e->setVisitId(1);
933 return;
934 }
935
936 case var_expr::prolog_var:
937 case var_expr::local_var:
938 {
939- if (!e->inUnsafeContext())
940+ if (!e->isVisited(1))
941 {
942- e->setInUnsafeContext(ANNOTATION_TRUE);
943+ e->setVisitId(1);
944
945 std::vector<expr*>::const_iterator ite = e->setExprsBegin();
946 std::vector<expr*>::const_iterator end = e->setExprsEnd();
947@@ -1128,17 +1171,20 @@
948 for (; ite != end; ++ite)
949 {
950 expr* setExpr = *ite;
951+ expr* valueExpr;
952
953 if (setExpr->get_expr_kind() == var_decl_expr_kind)
954 {
955- markInUnsafeContext(static_cast<var_decl_expr*>(setExpr)->get_init_expr());
956+ valueExpr = static_cast<var_decl_expr*>(setExpr)->get_init_expr();
957 }
958 else
959 {
960 assert(setExpr->get_expr_kind() == var_set_expr_kind);
961
962- markInUnsafeContext(static_cast<var_set_expr*>(setExpr)->get_expr());
963+ valueExpr = static_cast<var_set_expr*>(setExpr)->get_expr();
964 }
965+
966+ findSourcesForNodeExtractors(valueExpr);
967 }
968 }
969 return;
970@@ -1164,7 +1210,7 @@
971 case text_expr_kind:
972 case pi_expr_kind:
973 {
974- break;
975+ return;
976 }
977
978 #ifdef ZORBA_WITH_JSON
979@@ -1172,15 +1218,41 @@
980 case json_direct_object_expr_kind:
981 case json_array_expr_kind:
982 {
983- break;
984+ return;
985 }
986 #endif
987
988 case relpath_expr_kind:
989 {
990 relpath_expr* e = static_cast<relpath_expr *>(node);
991- e->setInUnsafeContext(ANNOTATION_TRUE);
992- markInUnsafeContext((*e)[0]);
993+
994+ e->setVisitId(1);
995+
996+ std::vector<expr*>::const_iterator ite = e->begin();
997+ std::vector<expr*>::const_iterator end = e->end();
998+
999+ for (++ite; ite != end; ++ite)
1000+ {
1001+ axis_step_expr* axisExpr = static_cast<axis_step_expr*>((*ite));
1002+ axis_kind_t axisKind = axisExpr->getAxis();
1003+
1004+ if (axisKind != axis_kind_child &&
1005+ axisKind != axis_kind_descendant &&
1006+ axisKind != axis_kind_descendant_or_self &&
1007+ axisKind != axis_kind_self &&
1008+ axisKind != axis_kind_attribute)
1009+ {
1010+ break;
1011+ }
1012+ }
1013+
1014+ if (ite == end)
1015+ {
1016+ std::vector<expr*> sources;
1017+ theSourceFinder->findNodeSources((*e)[0], sources);
1018+ markSources(sources);
1019+ }
1020+
1021 return;
1022 }
1023
1024@@ -1188,8 +1260,11 @@
1025 case flwor_expr_kind:
1026 {
1027 flwor_expr* e = static_cast<flwor_expr *>(node);
1028- e->setInUnsafeContext(ANNOTATION_TRUE);
1029- markInUnsafeContext(e->get_return_expr());
1030+
1031+ e->setVisitId(1);
1032+
1033+ findSourcesForNodeExtractors(e->get_return_expr());
1034+
1035 return;
1036 }
1037
1038@@ -1204,16 +1279,16 @@
1039 fo_expr* e = static_cast<fo_expr *>(node);
1040 function* f = e->get_func();
1041
1042- e->setInUnsafeContext(ANNOTATION_TRUE);
1043+ e->setVisitId(1);
1044
1045 if (f->isUdf() && static_cast<user_function*>(f)->getBody() != NULL)
1046 {
1047 user_function* udf = static_cast<user_function*>(f);
1048 expr* body = udf->getBody();
1049
1050- if (!body->inUnsafeContext())
1051+ if (!body->isVisited(1))
1052 {
1053- markInUnsafeContext(body);
1054+ findSourcesForNodeExtractors(body);
1055 }
1056
1057 std::vector<var_expr*>::const_iterator ite = udf->getArgVars().begin();
1058@@ -1221,10 +1296,10 @@
1059 for (; ite != end; ++ite)
1060 {
1061 expr* argVar = (*ite);
1062- if (argVar->inUnsafeContext())
1063+ if (argVar->isVisited(1))
1064 {
1065 expr* argExpr = e->get_arg(ite - udf->getArgVars().begin());
1066- markInUnsafeContext(argExpr);
1067+ findSourcesForNodeExtractors(argExpr);
1068 }
1069 }
1070 } // f->isUdf()
1071@@ -1235,7 +1310,7 @@
1072 {
1073 if (f->propagatesInputNodes(e, i))
1074 {
1075- markInUnsafeContext(e->get_arg(i));
1076+ findSourcesForNodeExtractors(e->get_arg(i));
1077 }
1078 }
1079 }
1080@@ -1254,24 +1329,27 @@
1081
1082 case validate_expr_kind:
1083 {
1084- node->setInUnsafeContext(ANNOTATION_TRUE);
1085+ node->setVisitId(1);
1086 return;
1087 }
1088
1089 case transform_expr_kind:
1090 {
1091 transform_expr* e = static_cast<transform_expr *>(node);
1092- e->setInUnsafeContext(ANNOTATION_TRUE);
1093- markInUnsafeContext(e->getReturnExpr());
1094+
1095+ findSourcesForNodeExtractors(e->getReturnExpr());
1096+
1097 return;
1098 }
1099
1100 case block_expr_kind:
1101 {
1102 block_expr* e = static_cast<block_expr *>(node);
1103- e->setInUnsafeContext(ANNOTATION_TRUE);
1104+
1105 expr* lastChild = (*e)[e->size()-1];
1106- markInUnsafeContext(lastChild);
1107+
1108+ findSourcesForNodeExtractors(lastChild);
1109+
1110 return;
1111 }
1112
1113@@ -1297,7 +1375,7 @@
1114 {
1115 exit_expr* ex = static_cast<exit_expr*>(*ite);
1116
1117- markInUnsafeContext(ex->get_expr());
1118+ findSourcesForNodeExtractors(ex->get_expr());
1119 }
1120
1121 break;
1122@@ -1325,7 +1403,7 @@
1123
1124 user_function* udf = static_cast<user_function*>(e->get_function());
1125
1126- markInUnsafeContext(udf->getBody());
1127+ findSourcesForNodeExtractors(udf->getBody());
1128
1129 return;
1130 }
1131@@ -1351,7 +1429,7 @@
1132 ZORBA_ASSERT(false);
1133 }
1134
1135- node->setInUnsafeContext(ANNOTATION_TRUE);
1136+ node->setVisitId(1);
1137
1138 ExprIterator iter(node);
1139 while(!iter.done())
1140@@ -1359,7 +1437,7 @@
1141 expr* child = (**iter);
1142 if (child != NULL)
1143 {
1144- markInUnsafeContext(child);
1145+ findSourcesForNodeExtractors(child);
1146 }
1147 iter.next();
1148 }
1149
1150=== modified file 'src/compiler/rewriter/rules/ruleset.h'
1151--- src/compiler/rewriter/rules/ruleset.h 2012-10-09 14:22:18 +0000
1152+++ src/compiler/rewriter/rules/ruleset.h 2012-10-15 13:39:25 +0000
1153@@ -145,11 +145,11 @@
1154 expr* apply(RewriterContext& rCtx, expr* node, bool& modified);
1155
1156 protected:
1157- void applyInternal(RewriterContext& rCtx, expr* node, fo_expr* udfCaller);
1158+ void applyInternal(expr* node, bool deferred);
1159
1160 void markSources(const std::vector<expr*>& sources);
1161
1162- void markInUnsafeContext(expr* node);
1163+ void findSourcesForNodeExtractors(expr* node);
1164 };
1165
1166
1167
1168=== modified file 'src/compiler/rewriter/rules/type_rules.cpp'
1169--- src/compiler/rewriter/rules/type_rules.cpp 2012-10-09 14:06:08 +0000
1170+++ src/compiler/rewriter/rules/type_rules.cpp 2012-10-15 13:39:25 +0000
1171@@ -323,9 +323,9 @@
1172 TypeOps::is_subtype(tm, *lenType, *rtm.INTEGER_TYPE_ONE, lenLoc))
1173 {
1174 if (fnKind == FunctionConsts::FN_SUBSTRING_3)
1175- fo->set_func(GET_BUILTIN_FUNCTION(OP_SUBSTRING_INT_3));
1176+ fo->set_func(BUILTIN_FUNC(OP_SUBSTRING_INT_3));
1177 else
1178- fo->set_func(GET_BUILTIN_FUNCTION(OP_ZORBA_SUBSEQUENCE_INT_3));
1179+ fo->set_func(BUILTIN_FUNC(OP_ZORBA_SUBSEQUENCE_INT_3));
1180
1181 fo->set_arg(1, posExpr);
1182 fo->set_arg(1, lenExpr);
1183@@ -334,9 +334,9 @@
1184 else if (TypeOps::is_subtype(tm, *posType, *rtm.INTEGER_TYPE_ONE, posLoc))
1185 {
1186 if (fnKind == FunctionConsts::FN_SUBSTRING_2)
1187- fo->set_func(GET_BUILTIN_FUNCTION(OP_SUBSTRING_INT_2));
1188+ fo->set_func(BUILTIN_FUNC(OP_SUBSTRING_INT_2));
1189 else
1190- fo->set_func(GET_BUILTIN_FUNCTION(OP_ZORBA_SUBSEQUENCE_INT_2));
1191+ fo->set_func(BUILTIN_FUNC(OP_ZORBA_SUBSEQUENCE_INT_2));
1192
1193 fo->set_arg(1, posExpr);
1194 }
1195
1196=== modified file 'src/compiler/rewriter/tools/dataflow_annotations.cpp'
1197--- src/compiler/rewriter/tools/dataflow_annotations.cpp 2012-10-09 16:33:56 +0000
1198+++ src/compiler/rewriter/tools/dataflow_annotations.cpp 2012-10-15 13:39:25 +0000
1199@@ -806,15 +806,9 @@
1200 If "node" is inside a UDF, "udfCaller" contains the fo expr that invoked that
1201 UDF.
1202 ********************************************************************************/
1203-void SourceFinder::findNodeSources(
1204- expr* node,
1205- fo_expr* udfCaller,
1206- std::vector<expr*>& sources)
1207+void SourceFinder::findNodeSources(expr* node, std::vector<expr*>& sources)
1208 {
1209- user_function* startingUdf = NULL;
1210-
1211- if (udfCaller)
1212- startingUdf = static_cast<user_function*>(udfCaller->get_func());
1213+ user_function* startingUdf = node->get_udf();
1214
1215 findNodeSourcesRec(node, sources, startingUdf);
1216
1217@@ -914,16 +908,6 @@
1218 return;
1219 }
1220
1221- case var_expr::arg_var:
1222- {
1223- std::vector<expr*>* varSources = new std::vector<expr*>;
1224-
1225- if (theVarSourcesMap.insert(VarSourcesPair(e, varSources)).second == false)
1226- delete varSources;
1227-
1228- return;
1229- }
1230-
1231 case var_expr::prolog_var:
1232 case var_expr::local_var:
1233 {
1234@@ -986,6 +970,13 @@
1235 return;
1236 }
1237
1238+ case var_expr::arg_var:
1239+ {
1240+ theVarSourcesMap.insert(VarSourcesPair(e, NULL));
1241+
1242+ return;
1243+ }
1244+
1245 case var_expr::eval_var:
1246 default:
1247 {
1248@@ -996,80 +987,6 @@
1249 break;
1250 }
1251
1252- case doc_expr_kind:
1253- case elem_expr_kind:
1254- {
1255- if (std::find(sources.begin(), sources.end(), node) == sources.end())
1256- {
1257- sources.push_back(node);
1258- }
1259-
1260- std::vector<expr*> enclosedExprs;
1261- node->get_fo_exprs_of_kind(FunctionConsts::OP_ENCLOSED_1, false, enclosedExprs);
1262-
1263- std::vector<expr*>::const_iterator ite = enclosedExprs.begin();
1264- std::vector<expr*>::const_iterator end = enclosedExprs.end();
1265- for (; ite != end; ++ite)
1266- {
1267- fo_expr* fo = static_cast<fo_expr*>(*ite);
1268-
1269- assert(fo->get_func()->getKind() == FunctionConsts::OP_ENCLOSED_1);
1270-
1271- findNodeSourcesRec(fo, sources, currentUdf);
1272- }
1273-
1274- return;
1275- }
1276-
1277- case attr_expr_kind:
1278- case text_expr_kind:
1279- case pi_expr_kind:
1280- {
1281- return;
1282- }
1283-
1284-#ifdef ZORBA_WITH_JSON
1285- case json_direct_object_expr_kind:
1286- case json_object_expr_kind:
1287- case json_array_expr_kind:
1288- {
1289- // TODO? We need to drill inside a json pair or array constructor only
1290- // if we are coming from an unbox or flatten call ????
1291- break;
1292- }
1293-#endif
1294-
1295- case relpath_expr_kind:
1296- {
1297- relpath_expr* e = static_cast<relpath_expr *>(node);
1298- findNodeSourcesRec((*e)[0], sources, currentUdf);
1299- return;
1300- }
1301-
1302- case gflwor_expr_kind:
1303- case flwor_expr_kind:
1304- {
1305- flwor_expr* e = static_cast<flwor_expr *>(node);
1306-
1307- // We don't need to drill down to the domain exprs of variables that
1308- // are not referenced in the return clause.
1309- findNodeSourcesRec(e->get_return_expr(), sources, currentUdf);
1310- return;
1311- }
1312-
1313- case if_expr_kind:
1314- {
1315- if_expr* e = static_cast<if_expr *>(node);
1316- findNodeSourcesRec(e->get_then_expr(), sources, currentUdf);
1317- findNodeSourcesRec(e->get_else_expr(), sources, currentUdf);
1318- return;
1319- }
1320-
1321- case trycatch_expr_kind:
1322- {
1323- break;
1324- }
1325-
1326 case fo_expr_kind:
1327 {
1328 fo_expr* e = static_cast<fo_expr *>(node);
1329@@ -1083,7 +1000,7 @@
1330
1331 if (recursive)
1332 {
1333- currentUdf->addRecursiveCall(node);
1334+ currentUdf->addRecursiveCall(e);
1335 }
1336 else
1337 {
1338@@ -1102,8 +1019,8 @@
1339
1340 if (udf->isRecursive())
1341 {
1342- std::vector<expr*>::const_iterator ite = udf->getRecursiveCalls().begin();
1343- std::vector<expr*>::const_iterator end = udf->getRecursiveCalls().end();
1344+ std::vector<fo_expr*>::const_iterator ite = udf->getRecursiveCalls().begin();
1345+ std::vector<fo_expr*>::const_iterator end = udf->getRecursiveCalls().end();
1346 for (; ite != end; ++ite)
1347 {
1348 findNodeSourcesRec((*ite), *udfSources, NULL);
1349@@ -1127,7 +1044,7 @@
1350
1351 // if an arg var of this udf has been marked as a source before, it
1352 // means that that var is consumed in some unsafe operation, so we
1353- // now have to find the sources of the arg expr and mark them.
1354+ // now have to find the sources of the arg exprs and mark them.
1355 csize numArgs = e->num_args();
1356
1357 for (csize i = 0; i < numArgs; ++i)
1358@@ -1156,6 +1073,80 @@
1359 return;
1360 }
1361
1362+ case doc_expr_kind:
1363+ case elem_expr_kind:
1364+ {
1365+ if (std::find(sources.begin(), sources.end(), node) == sources.end())
1366+ {
1367+ sources.push_back(node);
1368+ }
1369+
1370+ std::vector<expr*> enclosedExprs;
1371+ node->get_fo_exprs_of_kind(FunctionConsts::OP_ENCLOSED_1, false, enclosedExprs);
1372+
1373+ std::vector<expr*>::const_iterator ite = enclosedExprs.begin();
1374+ std::vector<expr*>::const_iterator end = enclosedExprs.end();
1375+ for (; ite != end; ++ite)
1376+ {
1377+ fo_expr* fo = static_cast<fo_expr*>(*ite);
1378+
1379+ assert(fo->get_func()->getKind() == FunctionConsts::OP_ENCLOSED_1);
1380+
1381+ findNodeSourcesRec(fo, sources, currentUdf);
1382+ }
1383+
1384+ return;
1385+ }
1386+
1387+ case attr_expr_kind:
1388+ case text_expr_kind:
1389+ case pi_expr_kind:
1390+ {
1391+ return;
1392+ }
1393+
1394+#ifdef ZORBA_WITH_JSON
1395+ case json_direct_object_expr_kind:
1396+ case json_object_expr_kind:
1397+ case json_array_expr_kind:
1398+ {
1399+ // TODO? We need to drill inside a json pair or array constructor only
1400+ // if we are coming from an unbox or flatten call ????
1401+ break;
1402+ }
1403+#endif
1404+
1405+ case relpath_expr_kind:
1406+ {
1407+ relpath_expr* e = static_cast<relpath_expr *>(node);
1408+ findNodeSourcesRec((*e)[0], sources, currentUdf);
1409+ return;
1410+ }
1411+
1412+ case gflwor_expr_kind:
1413+ case flwor_expr_kind:
1414+ {
1415+ flwor_expr* e = static_cast<flwor_expr *>(node);
1416+
1417+ // We don't need to drill down to the domain exprs of variables that
1418+ // are not referenced in the return clause.
1419+ findNodeSourcesRec(e->get_return_expr(), sources, currentUdf);
1420+ return;
1421+ }
1422+
1423+ case if_expr_kind:
1424+ {
1425+ if_expr* e = static_cast<if_expr *>(node);
1426+ findNodeSourcesRec(e->get_then_expr(), sources, currentUdf);
1427+ findNodeSourcesRec(e->get_else_expr(), sources, currentUdf);
1428+ return;
1429+ }
1430+
1431+ case trycatch_expr_kind:
1432+ {
1433+ break;
1434+ }
1435+
1436 case promote_expr_kind:
1437 case treat_expr_kind:
1438 case order_expr_kind:
1439
1440=== modified file 'src/compiler/rewriter/tools/dataflow_annotations.h'
1441--- src/compiler/rewriter/tools/dataflow_annotations.h 2012-10-09 14:22:18 +0000
1442+++ src/compiler/rewriter/tools/dataflow_annotations.h 2012-10-15 13:39:25 +0000
1443@@ -83,8 +83,8 @@
1444 typedef std::pair<user_function*, std::vector<expr*>* > UdfSourcesPair;
1445
1446 protected:
1447- VarSourcesMap theVarSourcesMap;
1448- UdfSourcesMap theUdfSourcesMap;
1449+ VarSourcesMap theVarSourcesMap;
1450+ UdfSourcesMap theUdfSourcesMap;
1451
1452 protected:
1453 void findNodeSourcesRec(
1454@@ -95,14 +95,9 @@
1455 public:
1456 ~SourceFinder();
1457
1458- void findNodeSources(
1459- expr* inExpr,
1460- fo_expr* udfCaller,
1461- std::vector<expr*>& sources);
1462+ void findNodeSources(expr* inExpr, std::vector<expr*>& sources);
1463
1464- void findLocalNodeSources(
1465- expr* inExpr,
1466- std::vector<expr*>& sources);
1467+ void findLocalNodeSources(expr* inExpr, std::vector<expr*>& sources);
1468 };
1469
1470
1471
1472=== modified file 'src/compiler/translator/translator.cpp'
1473--- src/compiler/translator/translator.cpp 2012-10-09 15:28:45 +0000
1474+++ src/compiler/translator/translator.cpp 2012-10-15 13:39:25 +0000
1475@@ -717,7 +717,7 @@
1476 xquery_fns_def_dot.set(FunctionConsts::FN_PATH_0);
1477
1478
1479- op_concatenate = GET_BUILTIN_FUNCTION(OP_CONCATENATE_N);
1480+ op_concatenate = BUILTIN_FUNC(OP_CONCATENATE_N);
1481 assert(op_concatenate != NULL);
1482
1483 if (rootTranslator == NULL)
1484@@ -1489,7 +1489,7 @@
1485 return theExprManager->create_fo_expr(theRootSctx,
1486 theUDF,
1487 e->get_loc(),
1488- GET_BUILTIN_FUNCTION(FN_DATA_1),
1489+ BUILTIN_FUNC(FN_DATA_1),
1490 e);
1491 }
1492
1493@@ -1555,7 +1555,7 @@
1494 return theExprManager->create_fo_expr(theRootSctx,
1495 theUDF,
1496 loc,
1497- GET_BUILTIN_FUNCTION(OP_ENCLOSED_1),
1498+ BUILTIN_FUNC(OP_ENCLOSED_1),
1499 contentExpr);
1500 }
1501
1502@@ -1568,7 +1568,7 @@
1503 fo_expr* fo = theExprManager->create_fo_expr(theRootSctx,
1504 theUDF,
1505 e->get_loc(),
1506- GET_BUILTIN_FUNCTION(FN_BOOLEAN_1),
1507+ BUILTIN_FUNC(FN_BOOLEAN_1),
1508 e);
1509 return fo;
1510 }
1511@@ -1764,7 +1764,7 @@
1512 create_fo_expr(theRootSctx,
1513 theUDF,
1514 loc,
1515- GET_BUILTIN_FUNCTION(FN_COUNT_1),
1516+ BUILTIN_FUNC(FN_COUNT_1),
1517 lcInputSeq->get_var());
1518
1519 normalize_fo(countExpr);
1520@@ -2030,7 +2030,7 @@
1521 ********************************************************************************/
1522 void declare_var(const GlobalBinding& b, std::vector<expr*>& stmts)
1523 {
1524- function* varGet = GET_BUILTIN_FUNCTION(OP_VAR_GET_1);
1525+ function* varGet = BUILTIN_FUNC(OP_VAR_GET_1);
1526
1527 expr* initExpr = b.theExpr;
1528 var_expr* varExpr = b.theVar;
1529@@ -4588,7 +4588,7 @@
1530 create_fo_expr(theRootSctx,
1531 theUDF,
1532 domainExpr->get_loc(),
1533- GET_BUILTIN_FUNCTION(OP_CHECK_DISTINCT_NODES_1),
1534+ BUILTIN_FUNC(OP_CHECK_DISTINCT_NODES_1),
1535 domainExpr);
1536 }
1537
1538@@ -4601,7 +4601,10 @@
1539 // if (theCCB->theConfig.opt_level == CompilerCB::config::O1)
1540 {
1541 RewriterContext rCtx(theCCB, domainExpr, NULL, msg, false);
1542+ rCtx.setForSerializationOnly(false);
1543+
1544 GENV_COMPILERSUBSYS.getDefaultOptimizingRewriter()->rewrite(rCtx);
1545+
1546 domainExpr = rCtx.getRoot();
1547
1548 if (theCCB->theConfig.optimize_cb != NULL)
1549@@ -4730,7 +4733,7 @@
1550 create_fo_expr(theRootSctx,
1551 theUDF,
1552 keyExpr->get_loc(),
1553- GET_BUILTIN_FUNCTION(FN_DISTINCT_VALUES_1),
1554+ BUILTIN_FUNC(FN_DISTINCT_VALUES_1),
1555 keyExpr);
1556 }
1557
1558@@ -4764,7 +4767,9 @@
1559 // if (theCCB->theConfig.opt_level == CompilerCB::config::O1)
1560 {
1561 RewriterContext rCtx(theCCB, keyExpr, NULL, msg.str(), false);
1562+
1563 GENV_COMPILERSUBSYS.getDefaultOptimizingRewriter()->rewrite(rCtx);
1564+
1565 keyExpr = rCtx.getRoot();
1566
1567 if (theCCB->theConfig.optimize_cb != NULL)
1568@@ -4874,12 +4879,12 @@
1569 create_fo_expr(theRootSctx,
1570 theUDF,
1571 loc,
1572- GET_BUILTIN_FUNCTION(FN_QNAME_2),
1573+ BUILTIN_FUNC(FN_QNAME_2),
1574 uriStrExpr,
1575 qnameStrExpr);
1576
1577 // dc:collection(xs:QName("example:coll1"))
1578- function* fn_collection = GET_BUILTIN_FUNCTION(STATIC_COLLECTIONS_DML_COLLECTION_1);
1579+ function* fn_collection = BUILTIN_FUNC(STATIC_COLLECTIONS_DML_COLLECTION_1);
1580 ZORBA_ASSERT(fn_collection != NULL);
1581 std::vector<expr*> argColl;
1582 argColl.push_back(qnameExpr);
1583@@ -4956,11 +4961,11 @@
1584 create_fo_expr(theRootSctx,
1585 theUDF,
1586 loc,
1587- GET_BUILTIN_FUNCTION(FN_QNAME_2),
1588+ BUILTIN_FUNC(FN_QNAME_2),
1589 uriStrExpr, qnameStrExpr);
1590
1591 // dc:collection(xs:QName("org:employees"))
1592- function* fn_collection = GET_BUILTIN_FUNCTION(STATIC_COLLECTIONS_DML_COLLECTION_1);
1593+ function* fn_collection = BUILTIN_FUNC(STATIC_COLLECTIONS_DML_COLLECTION_1);
1594 ZORBA_ASSERT(fn_collection != NULL);
1595 std::vector<expr*> argColl;
1596 argColl.push_back(qnameExpr);
1597@@ -5057,12 +5062,12 @@
1598 create_fo_expr(theRootSctx,
1599 theUDF,
1600 loc,
1601- GET_BUILTIN_FUNCTION(FN_QNAME_2),
1602+ BUILTIN_FUNC(FN_QNAME_2),
1603 uriStrExpr,
1604 qnameStrExpr);
1605
1606 // dc:collection(xs:QName("org:transactions"))
1607- function* fn_collection = GET_BUILTIN_FUNCTION(STATIC_COLLECTIONS_DML_COLLECTION_1);
1608+ function* fn_collection = BUILTIN_FUNC(STATIC_COLLECTIONS_DML_COLLECTION_1);
1609 ZORBA_ASSERT(fn_collection != NULL);
1610 std::vector<expr*> argColl;
1611 argColl.push_back(qnameExpr);
1612@@ -5139,12 +5144,12 @@
1613 create_fo_expr(theRootSctx,
1614 theUDF,
1615 loc,
1616- GET_BUILTIN_FUNCTION(FN_QNAME_2),
1617+ BUILTIN_FUNC(FN_QNAME_2),
1618 toUriStrExpr,
1619 toQnameStrExpr);
1620
1621 // dc:collection(xs:QName("org:employees"))
1622- function* toFnCollection = GET_BUILTIN_FUNCTION(STATIC_COLLECTIONS_DML_COLLECTION_1);
1623+ function* toFnCollection = BUILTIN_FUNC(STATIC_COLLECTIONS_DML_COLLECTION_1);
1624 ZORBA_ASSERT(toFnCollection != NULL);
1625 std::vector<expr*> toArgColl;
1626 toArgColl.push_back(toQnameExpr);
1627@@ -5188,12 +5193,12 @@
1628 create_fo_expr(theRootSctx,
1629 theUDF,
1630 loc,
1631- GET_BUILTIN_FUNCTION(FN_QNAME_2),
1632+ BUILTIN_FUNC(FN_QNAME_2),
1633 fromUriStrExpr,
1634 fromQnameStrExpr);
1635
1636 // dc:collection(xs:QName("org:transactions"))
1637- function* fromFnCollection = GET_BUILTIN_FUNCTION(STATIC_COLLECTIONS_DML_COLLECTION_1);
1638+ function* fromFnCollection = BUILTIN_FUNC(STATIC_COLLECTIONS_DML_COLLECTION_1);
1639 ZORBA_ASSERT(fromFnCollection != NULL);
1640 std::vector<expr*> fromArgColl;
1641 fromArgColl.push_back(fromQnameExpr);
1642@@ -5318,7 +5323,7 @@
1643 create_fo_expr(theRootSctx,
1644 theUDF,
1645 loc,
1646- GET_BUILTIN_FUNCTION(FN_EXISTS_1),
1647+ BUILTIN_FUNC(FN_EXISTS_1),
1648 uniKeyExpr);
1649
1650 // every ... satisfies evTestExpr
1651@@ -5326,7 +5331,7 @@
1652 create_fo_expr(theRootSctx,
1653 theUDF,
1654 loc,
1655- GET_BUILTIN_FUNCTION(FN_NOT_1),
1656+ BUILTIN_FUNC(FN_NOT_1),
1657 existsExpr);
1658
1659 evFlworExpr->add_where(fnNotExpr);
1660@@ -5335,7 +5340,7 @@
1661 create_fo_expr(theRootSctx,
1662 theUDF,
1663 loc,
1664- GET_BUILTIN_FUNCTION(FN_EMPTY_1),
1665+ BUILTIN_FUNC(FN_EMPTY_1),
1666 evFlworExpr);
1667
1668 // functx:are-distinct-values( $x/@id )
1669@@ -5345,7 +5350,7 @@
1670 create_fo_expr(theRootSctx,
1671 theUDF,
1672 loc,
1673- GET_BUILTIN_FUNCTION(FN_DISTINCT_VALUES_1),
1674+ BUILTIN_FUNC(FN_DISTINCT_VALUES_1),
1675 atomizedUniKeyExpr);
1676
1677 // count($sec)
1678@@ -5353,7 +5358,7 @@
1679 create_fo_expr(theRootSctx,
1680 theUDF,
1681 loc,
1682- GET_BUILTIN_FUNCTION(FN_COUNT_1),
1683+ BUILTIN_FUNC(FN_COUNT_1),
1684 atomizedUniKeyExpr);
1685
1686 // count(distinct-values($sec))
1687@@ -5361,7 +5366,7 @@
1688 create_fo_expr(theRootSctx,
1689 theUDF,
1690 loc,
1691- GET_BUILTIN_FUNCTION(FN_COUNT_1),
1692+ BUILTIN_FUNC(FN_COUNT_1),
1693 distinctValuesExpr);
1694
1695 // countDV = countSec
1696@@ -5369,7 +5374,7 @@
1697 create_fo_expr(theRootSctx,
1698 theUDF,
1699 loc,
1700- GET_BUILTIN_FUNCTION(OP_EQUAL_2),
1701+ BUILTIN_FUNC(OP_EQUAL_2),
1702 countDVExpr,
1703 countSecExpr);
1704
1705@@ -5378,7 +5383,7 @@
1706 create_fo_expr(theRootSctx,
1707 theUDF,
1708 loc,
1709- GET_BUILTIN_FUNCTION(OP_AND_N),
1710+ BUILTIN_FUNC(OP_AND_N),
1711 everyExpr,
1712 equalExpr);
1713
1714@@ -5418,7 +5423,7 @@
1715 create_fo_expr(theRootSctx,
1716 theUDF,
1717 loc,
1718- GET_BUILTIN_FUNCTION(FN_NOT_1),
1719+ BUILTIN_FUNC(FN_NOT_1),
1720 evTestExpr);
1721
1722 // where not( exists($x/sale gt 0) )
1723@@ -5429,7 +5434,7 @@
1724 create_fo_expr(theRootSctx,
1725 theUDF,
1726 loc,
1727- GET_BUILTIN_FUNCTION(FN_EMPTY_1),
1728+ BUILTIN_FUNC(FN_EMPTY_1),
1729 evFlworExpr);
1730
1731 body = emptyExpr;
1732@@ -5458,7 +5463,7 @@
1733 create_fo_expr(theRootSctx,
1734 theUDF,
1735 loc,
1736- GET_BUILTIN_FUNCTION(OP_VALUE_EQUAL_2),
1737+ BUILTIN_FUNC(OP_VALUE_EQUAL_2),
1738 toKeyExpr,
1739 fromKeyExpr);
1740
1741@@ -5473,14 +5478,14 @@
1742 create_fo_expr(theRootSctx,
1743 theUDF,
1744 loc,
1745- GET_BUILTIN_FUNCTION(FN_EXISTS_1),
1746+ BUILTIN_FUNC(FN_EXISTS_1),
1747 someFlworExpr);
1748 // fn:not()
1749 fo_expr* evFnNotExpr = theExprManager->
1750 create_fo_expr(theRootSctx,
1751 theUDF,
1752 loc,
1753- GET_BUILTIN_FUNCTION(FN_NOT_1),
1754+ BUILTIN_FUNC(FN_NOT_1),
1755 fnExistsExpr);
1756
1757 evFlworExpr->add_where(evFnNotExpr);
1758@@ -5490,7 +5495,7 @@
1759 create_fo_expr(theRootSctx,
1760 theUDF,
1761 loc,
1762- GET_BUILTIN_FUNCTION(FN_EMPTY_1),
1763+ BUILTIN_FUNC(FN_EMPTY_1),
1764 evFlworExpr);
1765
1766
1767@@ -7388,7 +7393,7 @@
1768 create_fo_expr(theRootSctx,
1769 theUDF,
1770 loc,
1771- GET_BUILTIN_FUNCTION(OP_ATOMIC_VALUES_EQUIVALENT_2),
1772+ BUILTIN_FUNC(OP_ATOMIC_VALUES_EQUIVALENT_2),
1773 sv,
1774 operandExpr);
1775
1776@@ -7405,7 +7410,7 @@
1777 create_fo_expr(theRootSctx,
1778 theUDF,
1779 loc,
1780- GET_BUILTIN_FUNCTION(OP_OR_N),
1781+ BUILTIN_FUNC(OP_OR_N),
1782 condOperands);
1783 }
1784
1785@@ -7879,7 +7884,7 @@
1786 {
1787 fo_expr* uw = theExprManager->create_fo_expr(theRootSctx, theUDF,
1788 v.get_expr()->get_location(),
1789- GET_BUILTIN_FUNCTION(FN_NOT_1),
1790+ BUILTIN_FUNC(FN_NOT_1),
1791 testExpr);
1792 testExpr = uw;
1793 }
1794@@ -7901,8 +7906,8 @@
1795 fo_expr* quant = theExprManager->create_fo_expr(theRootSctx, theUDF,
1796 loc,
1797 v.get_qmode() == ParseConstants::quant_every ?
1798- GET_BUILTIN_FUNCTION(FN_EMPTY_1) :
1799- GET_BUILTIN_FUNCTION(FN_EXISTS_1),
1800+ BUILTIN_FUNC(FN_EMPTY_1) :
1801+ BUILTIN_FUNC(FN_EXISTS_1),
1802 flworExpr);
1803 push_nodestack(quant);
1804 }
1805@@ -8017,7 +8022,7 @@
1806 args.push_back(e1);
1807 }
1808
1809- fo_expr* fo = theExprManager->create_fo_expr(theRootSctx, theUDF, loc, GET_BUILTIN_FUNCTION(OP_OR_N), args);
1810+ fo_expr* fo = theExprManager->create_fo_expr(theRootSctx, theUDF, loc, BUILTIN_FUNC(OP_OR_N), args);
1811
1812 push_nodestack(fo);
1813 }
1814@@ -8082,7 +8087,7 @@
1815 args.push_back(e1);
1816 }
1817
1818- fo_expr* fo = theExprManager->create_fo_expr(theRootSctx, theUDF, loc, GET_BUILTIN_FUNCTION(OP_AND_N), args);
1819+ fo_expr* fo = CREATE(fo)(theRootSctx, theUDF, loc, BUILTIN_FUNC(OP_AND_N), args);
1820
1821 push_nodestack(fo);
1822 }
1823@@ -8114,22 +8119,22 @@
1824 switch (v.get_gencomp()->get_type())
1825 {
1826 case ParseConstants::op_eq:
1827- f = GET_BUILTIN_FUNCTION(OP_EQUAL_2);
1828+ f = BUILTIN_FUNC(OP_EQUAL_2);
1829 break;
1830 case ParseConstants::op_ne:
1831- f = GET_BUILTIN_FUNCTION(OP_NOT_EQUAL_2);
1832+ f = BUILTIN_FUNC(OP_NOT_EQUAL_2);
1833 break;
1834 case ParseConstants::op_lt:
1835- f = GET_BUILTIN_FUNCTION(OP_LESS_2);
1836+ f = BUILTIN_FUNC(OP_LESS_2);
1837 break;
1838 case ParseConstants::op_le:
1839- f = GET_BUILTIN_FUNCTION(OP_LESS_EQUAL_2);
1840+ f = BUILTIN_FUNC(OP_LESS_EQUAL_2);
1841 break;
1842 case ParseConstants::op_gt:
1843- f = GET_BUILTIN_FUNCTION(OP_GREATER_2);
1844+ f = BUILTIN_FUNC(OP_GREATER_2);
1845 break;
1846 case ParseConstants::op_ge:
1847- f = GET_BUILTIN_FUNCTION(OP_GREATER_EQUAL_2);
1848+ f = BUILTIN_FUNC(OP_GREATER_EQUAL_2);
1849 break;
1850 }
1851 }
1852@@ -8138,22 +8143,22 @@
1853 switch (v.get_valcomp()->get_type())
1854 {
1855 case ParseConstants::op_val_eq:
1856- f = GET_BUILTIN_FUNCTION(OP_VALUE_EQUAL_2);
1857+ f = BUILTIN_FUNC(OP_VALUE_EQUAL_2);
1858 break;
1859 case ParseConstants::op_val_ne:
1860- f = GET_BUILTIN_FUNCTION(OP_VALUE_NOT_EQUAL_2);
1861+ f = BUILTIN_FUNC(OP_VALUE_NOT_EQUAL_2);
1862 break;
1863 case ParseConstants::op_val_lt:
1864- f = GET_BUILTIN_FUNCTION(OP_VALUE_LESS_2);
1865+ f = BUILTIN_FUNC(OP_VALUE_LESS_2);
1866 break;
1867 case ParseConstants::op_val_le:
1868- f = GET_BUILTIN_FUNCTION(OP_VALUE_LESS_EQUAL_2);
1869+ f = BUILTIN_FUNC(OP_VALUE_LESS_EQUAL_2);
1870 break;
1871 case ParseConstants::op_val_gt:
1872- f = GET_BUILTIN_FUNCTION(OP_VALUE_GREATER_2);
1873+ f = BUILTIN_FUNC(OP_VALUE_GREATER_2);
1874 break;
1875 case ParseConstants::op_val_ge:
1876- f = GET_BUILTIN_FUNCTION(OP_VALUE_GREATER_EQUAL_2);
1877+ f = BUILTIN_FUNC(OP_VALUE_GREATER_EQUAL_2);
1878 break;
1879 }
1880 }
1881@@ -8162,13 +8167,13 @@
1882 switch (v.get_nodecomp()->get_type())
1883 {
1884 case ParseConstants::op_is:
1885- f = GET_BUILTIN_FUNCTION(OP_IS_SAME_NODE_2);
1886+ f = BUILTIN_FUNC(OP_IS_SAME_NODE_2);
1887 break;
1888 case ParseConstants::op_precedes:
1889- f = GET_BUILTIN_FUNCTION(OP_NODE_BEFORE_2);
1890+ f = BUILTIN_FUNC(OP_NODE_BEFORE_2);
1891 break;
1892 case ParseConstants::op_follows:
1893- f = GET_BUILTIN_FUNCTION(OP_NODE_AFTER_2);
1894+ f = BUILTIN_FUNC(OP_NODE_AFTER_2);
1895 break;
1896 }
1897 }
1898@@ -8247,7 +8252,7 @@
1899 expr* e1 = pop_nodestack();
1900 expr* e2 = pop_nodestack();
1901
1902- fo_expr* e = theExprManager->create_fo_expr(theRootSctx, theUDF, loc, GET_BUILTIN_FUNCTION(OP_TO_2), e2, e1);
1903+ fo_expr* e = theExprManager->create_fo_expr(theRootSctx, theUDF, loc, BUILTIN_FUNC(OP_TO_2), e2, e1);
1904
1905 normalize_fo(e);
1906
1907@@ -8276,10 +8281,10 @@
1908 switch (v.get_add_op())
1909 {
1910 case ParseConstants::op_plus:
1911- func = GET_BUILTIN_FUNCTION(OP_ADD_2);
1912+ func = BUILTIN_FUNC(OP_ADD_2);
1913 break;
1914 case ParseConstants::op_minus:
1915- func = GET_BUILTIN_FUNCTION(OP_SUBTRACT_2);
1916+ func = BUILTIN_FUNC(OP_SUBTRACT_2);
1917 break;
1918 }
1919
1920@@ -8311,16 +8316,16 @@
1921 switch (v.get_mult_op())
1922 {
1923 case ParseConstants::op_mul:
1924- f = GET_BUILTIN_FUNCTION(OP_MULTIPLY_2);
1925+ f = BUILTIN_FUNC(OP_MULTIPLY_2);
1926 break;
1927 case ParseConstants::op_div:
1928- f = GET_BUILTIN_FUNCTION(OP_DIVIDE_2);
1929+ f = BUILTIN_FUNC(OP_DIVIDE_2);
1930 break;
1931 case ParseConstants::op_idiv:
1932- f = GET_BUILTIN_FUNCTION(OP_INTEGER_DIVIDE_2);
1933+ f = BUILTIN_FUNC(OP_INTEGER_DIVIDE_2);
1934 break;
1935 case ParseConstants::op_mod:
1936- f = GET_BUILTIN_FUNCTION(OP_MOD_2);
1937+ f = BUILTIN_FUNC(OP_MOD_2);
1938 break;
1939 }
1940
1941@@ -8350,7 +8355,7 @@
1942
1943 fo_expr* foExpr = theExprManager->create_fo_expr(theRootSctx, theUDF,
1944 loc,
1945- GET_BUILTIN_FUNCTION(OP_UNION_2),
1946+ BUILTIN_FUNC(OP_UNION_2),
1947 e2,
1948 e1);
1949
1950@@ -8360,7 +8365,7 @@
1951 // and duplicate elimi
1952 push_nodestack(theExprManager->create_fo_expr(theRootSctx, theUDF,
1953 loc,
1954- GET_BUILTIN_FUNCTION(OP_SORT_DISTINCT_NODES_ASC_1),
1955+ BUILTIN_FUNC(OP_SORT_DISTINCT_NODES_ASC_1),
1956 foExpr));
1957 }
1958
1959@@ -8386,10 +8391,10 @@
1960 switch (v.get_intex_op())
1961 {
1962 case ParseConstants::op_intersect:
1963- f = GET_BUILTIN_FUNCTION(OP_INTERSECT_2);
1964+ f = BUILTIN_FUNC(OP_INTERSECT_2);
1965 break;
1966 case ParseConstants::op_except:
1967- f = GET_BUILTIN_FUNCTION(OP_EXCEPT_2);
1968+ f = BUILTIN_FUNC(OP_EXCEPT_2);
1969 break;
1970 }
1971
1972@@ -8399,7 +8404,7 @@
1973
1974 push_nodestack(theExprManager->create_fo_expr(theRootSctx, theUDF,
1975 loc,
1976- GET_BUILTIN_FUNCTION(OP_SORT_DISTINCT_NODES_ASC_1),
1977+ BUILTIN_FUNC(OP_SORT_DISTINCT_NODES_ASC_1),
1978 foExpr));
1979 }
1980
1981@@ -8583,8 +8588,8 @@
1982 fo_expr* foExpr = theExprManager->create_fo_expr(theRootSctx, theUDF,
1983 loc,
1984 (v.get_signlist()->get_sign() ?
1985- GET_BUILTIN_FUNCTION(OP_UNARY_PLUS_1) :
1986- GET_BUILTIN_FUNCTION(OP_UNARY_MINUS_1)),
1987+ BUILTIN_FUNC(OP_UNARY_PLUS_1) :
1988+ BUILTIN_FUNC(OP_UNARY_MINUS_1)),
1989 e1);
1990 normalize_fo(foExpr);
1991
1992@@ -9013,7 +9018,7 @@
1993
1994 fo_expr* fnroot = theExprManager->create_fo_expr(theRootSctx, theUDF,
1995 loc,
1996- GET_BUILTIN_FUNCTION(FN_ROOT_1),
1997+ BUILTIN_FUNC(FN_ROOT_1),
1998 ctx_path_expr);
1999 normalize_fo(fnroot);
2000
2001@@ -9070,7 +9075,7 @@
2002 fo_expr* checkExpr =
2003 theExprManager->create_fo_expr(theRootSctx, theUDF,
2004 arg2->get_loc(),
2005- GET_BUILTIN_FUNCTION(OP_EITHER_NODES_OR_ATOMICS_1),
2006+ BUILTIN_FUNC(OP_EITHER_NODES_OR_ATOMICS_1),
2007 arg2);
2008
2009 push_nodestack(checkExpr);
2010@@ -9934,7 +9939,7 @@
2011 create_fo_expr(sourceExpr->get_sctx(),
2012 theUDF,
2013 sourceExpr->get_loc(),
2014- GET_BUILTIN_FUNCTION(OP_ZORBA_SEQUENCE_POINT_ACCESS_2),
2015+ BUILTIN_FUNC(OP_ZORBA_SEQUENCE_POINT_ACCESS_2),
2016 sourceExpr,
2017 predExpr);
2018
2019@@ -9948,7 +9953,7 @@
2020 create_fo_expr(sourceExpr->get_sctx(),
2021 theUDF,
2022 sourceExpr->get_loc(),
2023- GET_BUILTIN_FUNCTION(OP_ZORBA_SEQUENCE_POINT_ACCESS_2),
2024+ BUILTIN_FUNC(OP_ZORBA_SEQUENCE_POINT_ACCESS_2),
2025 sourceExpr,
2026 predExpr);
2027
2028@@ -9970,7 +9975,7 @@
2029 create_fo_expr(theRootSctx,
2030 theUDF,
2031 loc,
2032- GET_BUILTIN_FUNCTION(OP_VALUE_EQUAL_2),
2033+ BUILTIN_FUNC(OP_VALUE_EQUAL_2),
2034 lookup_ctx_var(DOT_POS_VARNAME, loc),
2035 predvar);
2036
2037@@ -10019,7 +10024,7 @@
2038 create_instanceof_expr(theRootSctx, theUDF, loc, predvar, rtm.FLOAT_TYPE_QUESTION, true);
2039
2040 condExpr = theExprManager->
2041- create_fo_expr(theRootSctx, theUDF, loc, GET_BUILTIN_FUNCTION(OP_OR_N), condOperands);
2042+ create_fo_expr(theRootSctx, theUDF, loc, BUILTIN_FUNC(OP_OR_N), condOperands);
2043
2044 // If so: return $dot if the value of the pred expr is equal to the value
2045 // of $dot_pos var, otherwise return the empty seq.
2046@@ -10027,7 +10032,7 @@
2047 create_fo_expr(theRootSctx,
2048 theUDF,
2049 loc,
2050- GET_BUILTIN_FUNCTION(OP_VALUE_EQUAL_2),
2051+ BUILTIN_FUNC(OP_VALUE_EQUAL_2),
2052 lookup_ctx_var(DOT_POS_VARNAME, loc),
2053 predvar);
2054
2055@@ -10184,7 +10189,7 @@
2056 if(right->get_expr_kind() == fo_expr_kind)
2057 {
2058 fo_expr* lFoExpr = dynamic_cast<fo_expr*>(right);
2059- if(lFoExpr->get_func() == GET_BUILTIN_FUNCTION(FN_CONCAT_N))
2060+ if(lFoExpr->get_func() == BUILTIN_FUNC(FN_CONCAT_N))
2061 {
2062 rightLeafIsConcatExpr = true;
2063 csize i = 0;
2064@@ -10204,7 +10209,7 @@
2065 theExprManager->create_fo_expr(theRootSctx,
2066 theUDF,
2067 loc,
2068- GET_BUILTIN_FUNCTION(FN_CONCAT_N),
2069+ BUILTIN_FUNC(FN_CONCAT_N),
2070 concat_args);
2071 push_nodestack(concat);
2072 }
2073@@ -10543,7 +10548,7 @@
2074 arguments.push_back(theExprManager->
2075 create_const_expr(theRootSctx, theUDF, loc, xs_integer::one()));
2076
2077- function* f = GET_BUILTIN_FUNCTION(OP_ZORBA_SUBSEQUENCE_INT_3);
2078+ function* f = BUILTIN_FUNC(OP_ZORBA_SUBSEQUENCE_INT_3);
2079
2080 fo_expr* foExpr = theExprManager->
2081 create_fo_expr(theRootSctx, theUDF, loc, f, arguments);
2082@@ -10558,7 +10563,7 @@
2083 arguments.push_back(theExprManager->
2084 create_const_expr(theRootSctx, theUDF, loc, xs_integer(2)));
2085
2086- function* f = GET_BUILTIN_FUNCTION(OP_ZORBA_SUBSEQUENCE_INT_2);
2087+ function* f = BUILTIN_FUNC(OP_ZORBA_SUBSEQUENCE_INT_2);
2088
2089 fo_expr* foExpr = theExprManager->
2090 create_fo_expr(theRootSctx, theUDF, loc, f, arguments);
2091@@ -10582,9 +10587,9 @@
2092 if (TypeOps::is_subtype(tm, *posType, *theRTM.INTEGER_TYPE_STAR, loc))
2093 {
2094 if (f->getKind() == FunctionConsts::FN_SUBSTRING_2)
2095- f = GET_BUILTIN_FUNCTION(OP_SUBSTRING_INT_2);
2096+ f = BUILTIN_FUNC(OP_SUBSTRING_INT_2);
2097 else
2098- f = GET_BUILTIN_FUNCTION(OP_ZORBA_SUBSEQUENCE_INT_2);
2099+ f = BUILTIN_FUNC(OP_ZORBA_SUBSEQUENCE_INT_2);
2100 }
2101 }
2102 else
2103@@ -10595,9 +10600,9 @@
2104 TypeOps::is_subtype(tm, *lenType, *theRTM.INTEGER_TYPE_STAR, loc))
2105 {
2106 if (f->getKind() == FunctionConsts::FN_SUBSTRING_3)
2107- f = GET_BUILTIN_FUNCTION(OP_SUBSTRING_INT_3);
2108+ f = BUILTIN_FUNC(OP_SUBSTRING_INT_3);
2109 else
2110- f = GET_BUILTIN_FUNCTION(OP_ZORBA_SUBSEQUENCE_INT_3);
2111+ f = BUILTIN_FUNC(OP_ZORBA_SUBSEQUENCE_INT_3);
2112 }
2113 }
2114
2115@@ -10626,7 +10631,7 @@
2116 case 0:
2117 {
2118 arguments.push_back(DOT_REF);
2119- f = GET_BUILTIN_FUNCTION(FN_NUMBER_1);
2120+ f = BUILTIN_FUNC(FN_NUMBER_1);
2121 break;
2122 }
2123 case 1:
2124@@ -10701,13 +10706,13 @@
2125
2126 normExpr = theExprManager->create_fo_expr(theRootSctx, theUDF,
2127 loc,
2128- GET_BUILTIN_FUNCTION(FN_NORMALIZE_SPACE_1),
2129+ BUILTIN_FUNC(FN_NORMALIZE_SPACE_1),
2130 flworVarExpr);
2131 normalize_fo(normExpr);
2132
2133 tokenExpr = theExprManager->create_fo_expr(theRootSctx, theUDF,
2134 loc,
2135- GET_BUILTIN_FUNCTION(FN_TOKENIZE_2),
2136+ BUILTIN_FUNC(FN_TOKENIZE_2),
2137 normExpr,
2138 constExpr);
2139 normalize_fo(tokenExpr);
2140@@ -10722,20 +10727,20 @@
2141 case FunctionConsts::FN_IDREF_1:
2142 {
2143 arguments.insert(arguments.begin(), DOT_REF);
2144- f = GET_BUILTIN_FUNCTION(FN_IDREF_2);
2145+ f = BUILTIN_FUNC(FN_IDREF_2);
2146 break;
2147 }
2148 case FunctionConsts::FN_LANG_1:
2149 {
2150 arguments.insert(arguments.begin(), DOT_REF);
2151- f = GET_BUILTIN_FUNCTION(FN_LANG_2);
2152+ f = BUILTIN_FUNC(FN_LANG_2);
2153 break;
2154 }
2155 case FunctionConsts::FN_RESOLVE_URI_1:
2156 {
2157 zstring baseUri = theSctx->get_base_uri();
2158 arguments.insert(arguments.begin(), theExprManager->create_const_expr(theRootSctx, theUDF, loc, baseUri));
2159- f = GET_BUILTIN_FUNCTION(FN_RESOLVE_URI_2);
2160+ f = BUILTIN_FUNC(FN_RESOLVE_URI_2);
2161 break;
2162 }
2163 case FunctionConsts::FN_CONCAT_N:
2164@@ -11060,24 +11065,24 @@
2165 expr* namespaceExpr =
2166 theExprManager->create_fo_expr(theRootSctx, theUDF,
2167 loc,
2168- GET_BUILTIN_FUNCTION(FN_NAMESPACE_URI_FROM_QNAME_1),
2169+ BUILTIN_FUNC(FN_NAMESPACE_URI_FROM_QNAME_1),
2170 temp_vars[0]);
2171
2172 namespaceExpr =
2173 theExprManager->create_fo_expr(theRootSctx, theUDF,
2174 loc,
2175- GET_BUILTIN_FUNCTION(FN_STRING_1),
2176+ BUILTIN_FUNC(FN_STRING_1),
2177 namespaceExpr);
2178
2179 // Expanded QName's local name
2180 expr* localExpr =
2181 theExprManager->create_fo_expr(theRootSctx, theUDF,
2182 loc,
2183- GET_BUILTIN_FUNCTION(FN_LOCAL_NAME_FROM_QNAME_1),
2184+ BUILTIN_FUNC(FN_LOCAL_NAME_FROM_QNAME_1),
2185 temp_vars[0]);
2186
2187 localExpr = theExprManager->
2188- create_fo_expr(theRootSctx, theUDF, loc, GET_BUILTIN_FUNCTION(FN_STRING_1), localExpr);
2189+ create_fo_expr(theRootSctx, theUDF, loc, BUILTIN_FUNC(FN_STRING_1), localExpr);
2190
2191 // qnameExpr := concat("Q{",
2192 // namespaceExpr,
2193@@ -11094,7 +11099,7 @@
2194 qnameExpr = theExprManager->
2195 create_fo_expr(theRootSctx, theUDF,
2196 loc,
2197- GET_BUILTIN_FUNCTION(FN_CONCAT_N),
2198+ BUILTIN_FUNC(FN_CONCAT_N),
2199 concat_args);
2200
2201 eval_expr* evalExpr = theExprManager->
2202@@ -11204,15 +11209,15 @@
2203
2204 if (TypeOps::is_subtype(tm, *srcType, *theRTM.JSON_ARRAY_TYPE_STAR))
2205 {
2206- func = GET_BUILTIN_FUNCTION(FN_JSONIQ_MEMBER_2);
2207+ func = BUILTIN_FUNC(FN_JSONIQ_MEMBER_2);
2208 }
2209 else if (TypeOps::is_subtype(tm, *srcType, *theRTM.JSON_OBJECT_TYPE_STAR))
2210 {
2211- func = GET_BUILTIN_FUNCTION(FN_JSONIQ_VALUE_2);
2212+ func = BUILTIN_FUNC(FN_JSONIQ_VALUE_2);
2213 }
2214 else
2215 {
2216- func = GET_BUILTIN_FUNCTION(OP_ZORBA_JSON_ITEM_ACCESSOR_2);
2217+ func = BUILTIN_FUNC(OP_ZORBA_JSON_ITEM_ACCESSOR_2);
2218 }
2219
2220 accessorExpr = theExprManager->create_fo_expr(theRootSctx, theUDF,
2221@@ -11718,7 +11723,7 @@
2222 create_fo_expr(theRootSctx,
2223 theUDF,
2224 valueExpr->get_loc(),
2225- GET_BUILTIN_FUNCTION(OP_ZORBA_JSON_BOX_1),
2226+ BUILTIN_FUNC(OP_ZORBA_JSON_BOX_1),
2227 valueExpr);
2228
2229 push_nodestack(valueExpr);
2230@@ -13471,7 +13476,7 @@
2231 expr* updExpr = theExprManager->
2232 create_fo_expr(theRootSctx, theUDF,
2233 loc,
2234- GET_BUILTIN_FUNCTION(OP_ZORBA_JSON_OBJECT_INSERT_2),
2235+ BUILTIN_FUNC(OP_ZORBA_JSON_OBJECT_INSERT_2),
2236 args);
2237
2238 push_nodestack(updExpr);
2239@@ -13522,7 +13527,7 @@
2240 fo_expr* updExpr = theExprManager->
2241 create_fo_expr(theRootSctx, theUDF,
2242 loc,
2243- GET_BUILTIN_FUNCTION(OP_ZORBA_JSON_ARRAY_INSERT_3),
2244+ BUILTIN_FUNC(OP_ZORBA_JSON_ARRAY_INSERT_3),
2245 args);
2246
2247 normalize_fo(updExpr);
2248@@ -13562,7 +13567,7 @@
2249 fo_expr* updExpr = theExprManager->
2250 create_fo_expr(theRootSctx, theUDF,
2251 loc,
2252- GET_BUILTIN_FUNCTION(OP_ZORBA_JSON_ARRAY_APPEND_2),
2253+ BUILTIN_FUNC(OP_ZORBA_JSON_ARRAY_APPEND_2),
2254 targetExpr,
2255 contentExpr);
2256
2257@@ -13618,7 +13623,7 @@
2258 fo_expr* updExpr = theExprManager->
2259 create_fo_expr(theRootSctx, theUDF,
2260 loc,
2261- GET_BUILTIN_FUNCTION(OP_ZORBA_JSON_DELETE_2),
2262+ BUILTIN_FUNC(OP_ZORBA_JSON_DELETE_2),
2263 targetExpr,
2264 selExpr);
2265
2266@@ -13664,13 +13669,13 @@
2267
2268 args[2] = theExprManager->create_fo_expr(theRootSctx, theUDF,
2269 valueExpr->get_loc(),
2270- GET_BUILTIN_FUNCTION(OP_ZORBA_JSON_BOX_1),
2271+ BUILTIN_FUNC(OP_ZORBA_JSON_BOX_1),
2272 valueExpr);
2273
2274 fo_expr* updExpr = theExprManager->
2275 create_fo_expr(theRootSctx, theUDF,
2276 loc,
2277- GET_BUILTIN_FUNCTION(OP_ZORBA_JSON_REPLACE_VALUE_3),
2278+ BUILTIN_FUNC(OP_ZORBA_JSON_REPLACE_VALUE_3),
2279 args);
2280
2281 push_nodestack(updExpr);
2282@@ -13719,7 +13724,7 @@
2283 fo_expr* updExpr = theExprManager->
2284 create_fo_expr(theRootSctx, theUDF,
2285 loc,
2286- GET_BUILTIN_FUNCTION(OP_ZORBA_JSON_RENAME_3),
2287+ BUILTIN_FUNC(OP_ZORBA_JSON_RENAME_3),
2288 args);
2289
2290 push_nodestack(updExpr);
2291
2292=== modified file 'src/compiler/xqddf/value_index.cpp'
2293--- src/compiler/xqddf/value_index.cpp 2012-10-09 14:06:08 +0000
2294+++ src/compiler/xqddf/value_index.cpp 2012-10-15 13:39:25 +0000
2295@@ -275,7 +275,7 @@
2296 void IndexDecl::analyze(CompilerCB* ccb)
2297 {
2298 store::Item_t dotQName;
2299- GENV_ITEMFACTORY->createQName(dotQName, "", "", "$$dot");
2300+ GENV_ITEMFACTORY->createQName(dotQName, "", "", static_context::DOT_VAR_NAME);
2301 expr* dotVar = NULL;
2302
2303 // Get the var_expr representing the context item, if it is defined
2304@@ -293,8 +293,6 @@
2305 varExprs,
2306 dotVar);
2307
2308- varExprs.clear();
2309-
2310 std::vector<expr*> keySources;
2311
2312 csize numKeys = theKeyExprs.size();
2313@@ -308,6 +306,8 @@
2314 // Check constraints on the key exprs
2315 for (csize i = 0; i < numKeys; ++i)
2316 {
2317+ varExprs.clear();
2318+
2319 analyzeExprInternal(theKeyExprs[i],
2320 theSourceNames,
2321 keySources,
2322@@ -530,9 +530,9 @@
2323 function* f = NULL;
2324
2325 if (theIsGeneral)
2326- f = GET_BUILTIN_FUNCTION(OP_GENERAL_INDEX_ENTRY_BUILDER_N);
2327+ f = BUILTIN_FUNC(OP_GENERAL_INDEX_ENTRY_BUILDER_N);
2328 else
2329- f = GET_BUILTIN_FUNCTION(OP_VALUE_INDEX_ENTRY_BUILDER_N);
2330+ f = BUILTIN_FUNC(OP_VALUE_INDEX_ENTRY_BUILDER_N);
2331
2332 ZORBA_ASSERT(f != NULL);
2333
2334@@ -684,9 +684,9 @@
2335 function* f = NULL;
2336
2337 if (theIsGeneral)
2338- f = GET_BUILTIN_FUNCTION(OP_GENERAL_INDEX_ENTRY_BUILDER_N);
2339+ f = BUILTIN_FUNC(OP_GENERAL_INDEX_ENTRY_BUILDER_N);
2340 else
2341- f = GET_BUILTIN_FUNCTION(OP_VALUE_INDEX_ENTRY_BUILDER_N);
2342+ f = BUILTIN_FUNC(OP_VALUE_INDEX_ENTRY_BUILDER_N);
2343
2344 ZORBA_ASSERT(f != NULL);
2345
2346
2347=== modified file 'src/functions/func_accessors_impl.cpp'
2348--- src/functions/func_accessors_impl.cpp 2012-09-19 21:16:15 +0000
2349+++ src/functions/func_accessors_impl.cpp 2012-10-15 13:39:25 +0000
2350@@ -64,14 +64,6 @@
2351 }
2352
2353
2354-bool fn_data::mustCopyInputNodes(expr* fo, csize input) const
2355-{
2356- static_context* sctx = fo->get_sctx();
2357-
2358- return (sctx->construction_mode() != StaticContextConsts::cons_preserve);
2359-}
2360-
2361-
2362 xqtref_t fn_data::getReturnType(const fo_expr* caller) const
2363 {
2364 const QueryLoc& loc = caller->get_loc();
2365
2366=== modified file 'src/functions/func_arithmetic.cpp'
2367--- src/functions/func_arithmetic.cpp 2012-09-19 21:16:15 +0000
2368+++ src/functions/func_arithmetic.cpp 2012-10-15 13:39:25 +0000
2369@@ -126,22 +126,22 @@
2370 switch (theKind)
2371 {
2372 case FunctionConsts::OP_ADD_2:
2373- f1 = GET_BUILTIN_FUNCTION(OP_NUMERIC_ADD_2);
2374+ f1 = BUILTIN_FUNC(OP_NUMERIC_ADD_2);
2375 break;
2376 case FunctionConsts::OP_SUBTRACT_2:
2377- f1 = GET_BUILTIN_FUNCTION(OP_NUMERIC_SUBTRACT_2);
2378+ f1 = BUILTIN_FUNC(OP_NUMERIC_SUBTRACT_2);
2379 break;
2380 case FunctionConsts::OP_MULTIPLY_2:
2381- f1 = GET_BUILTIN_FUNCTION(OP_NUMERIC_MULTIPLY_2);
2382+ f1 = BUILTIN_FUNC(OP_NUMERIC_MULTIPLY_2);
2383 break;
2384 case FunctionConsts::OP_DIVIDE_2:
2385- f1 = GET_BUILTIN_FUNCTION(OP_NUMERIC_DIVIDE_2);
2386+ f1 = BUILTIN_FUNC(OP_NUMERIC_DIVIDE_2);
2387 break;
2388 case FunctionConsts::OP_INTEGER_DIVIDE_2:
2389- f1 = GET_BUILTIN_FUNCTION(OP_NUMERIC_INTEGER_DIVIDE_2);
2390+ f1 = BUILTIN_FUNC(OP_NUMERIC_INTEGER_DIVIDE_2);
2391 break;
2392 case FunctionConsts::OP_MOD_2:
2393- f1 = GET_BUILTIN_FUNCTION(OP_NUMERIC_MOD_2);
2394+ f1 = BUILTIN_FUNC(OP_NUMERIC_MOD_2);
2395 break;
2396 default:
2397 ZORBA_ASSERT(false);
2398
2399=== modified file 'src/functions/func_booleans_impl.cpp'
2400--- src/functions/func_booleans_impl.cpp 2012-09-19 21:16:15 +0000
2401+++ src/functions/func_booleans_impl.cpp 2012-10-15 13:39:25 +0000
2402@@ -168,22 +168,22 @@
2403 switch (kind) \
2404 { \
2405 case FunctionConsts::OP_VALUE_EQUAL_2: \
2406- return GET_BUILTIN_FUNCTION(OP_VALUE_EQUAL_##type##_2); \
2407+ return BUILTIN_FUNC(OP_VALUE_EQUAL_##type##_2); \
2408 \
2409 case FunctionConsts::OP_VALUE_NOT_EQUAL_2: \
2410- return GET_BUILTIN_FUNCTION(OP_VALUE_NOT_EQUAL_##type##_2); \
2411+ return BUILTIN_FUNC(OP_VALUE_NOT_EQUAL_##type##_2); \
2412 \
2413 case FunctionConsts::OP_VALUE_LESS_EQUAL_2: \
2414- return GET_BUILTIN_FUNCTION(OP_VALUE_LESS_EQUAL_##type##_2); \
2415+ return BUILTIN_FUNC(OP_VALUE_LESS_EQUAL_##type##_2); \
2416 \
2417 case FunctionConsts::OP_VALUE_LESS_2: \
2418- return GET_BUILTIN_FUNCTION(OP_VALUE_LESS_##type##_2); \
2419+ return BUILTIN_FUNC(OP_VALUE_LESS_##type##_2); \
2420 \
2421 case FunctionConsts::OP_VALUE_GREATER_EQUAL_2: \
2422- return GET_BUILTIN_FUNCTION(OP_VALUE_GREATER_EQUAL_##type##_2); \
2423+ return BUILTIN_FUNC(OP_VALUE_GREATER_EQUAL_##type##_2); \
2424 \
2425 case FunctionConsts::OP_VALUE_GREATER_2: \
2426- return GET_BUILTIN_FUNCTION(OP_VALUE_GREATER_##type##_2); \
2427+ return BUILTIN_FUNC(OP_VALUE_GREATER_##type##_2); \
2428 \
2429 default: \
2430 ZORBA_ASSERT(false); \
2431@@ -389,7 +389,7 @@
2432
2433 function* toValueComp(static_context* sctx) const
2434 {
2435- return GET_BUILTIN_FUNCTION(OP_VALUE_EQUAL_2);
2436+ return BUILTIN_FUNC(OP_VALUE_EQUAL_2);
2437 }
2438
2439 CompareConsts::CompareType comparisonKind() const
2440@@ -427,7 +427,7 @@
2441
2442 function* toValueComp(static_context* sctx) const
2443 {
2444- return GET_BUILTIN_FUNCTION(OP_VALUE_NOT_EQUAL_2);
2445+ return BUILTIN_FUNC(OP_VALUE_NOT_EQUAL_2);
2446 }
2447 };
2448
2449@@ -460,7 +460,7 @@
2450
2451 function* toValueComp(static_context* sctx) const
2452 {
2453- return GET_BUILTIN_FUNCTION(OP_VALUE_LESS_EQUAL_2);
2454+ return BUILTIN_FUNC(OP_VALUE_LESS_EQUAL_2);
2455 }
2456 };
2457
2458@@ -493,7 +493,7 @@
2459
2460 function* toValueComp(static_context* sctx) const
2461 {
2462- return GET_BUILTIN_FUNCTION(OP_VALUE_LESS_2);
2463+ return BUILTIN_FUNC(OP_VALUE_LESS_2);
2464 }
2465 };
2466
2467@@ -526,7 +526,7 @@
2468
2469 function* toValueComp(static_context* sctx) const
2470 {
2471- return GET_BUILTIN_FUNCTION(OP_VALUE_GREATER_EQUAL_2);
2472+ return BUILTIN_FUNC(OP_VALUE_GREATER_EQUAL_2);
2473 }
2474 };
2475
2476@@ -559,7 +559,7 @@
2477
2478 function* toValueComp(static_context* sctx) const
2479 {
2480- return GET_BUILTIN_FUNCTION(OP_VALUE_GREATER_2);
2481+ return BUILTIN_FUNC(OP_VALUE_GREATER_2);
2482 }
2483 };
2484
2485
2486=== modified file 'src/functions/func_collections_impl.cpp'
2487--- src/functions/func_collections_impl.cpp 2012-10-08 12:09:36 +0000
2488+++ src/functions/func_collections_impl.cpp 2012-10-15 13:39:25 +0000
2489@@ -366,6 +366,7 @@
2490 processPragmaInternal(e, p);
2491 }
2492
2493+
2494 PlanIter_t static_collections_dml_apply_insert_nodes_last::codegen(
2495 CompilerCB* cb,
2496 static_context* sctx,
2497
2498=== modified file 'src/functions/func_ft_module_impl.h'
2499--- src/functions/func_ft_module_impl.h 2012-09-19 21:16:15 +0000
2500+++ src/functions/func_ft_module_impl.h 2012-10-15 13:39:25 +0000
2501@@ -33,11 +33,12 @@
2502 class full_text_tokenize_node : public function
2503 {
2504 public:
2505- full_text_tokenize_node(const signature& sig,
2506- FunctionConsts::FunctionKind kind) :
2507+ full_text_tokenize_node(
2508+ const signature& sig,
2509+ FunctionConsts::FunctionKind kind)
2510+ :
2511 function(sig, kind)
2512 {
2513-
2514 }
2515
2516 // Mark the function as accessing the dyn ctx so that it won't be
2517@@ -45,6 +46,8 @@
2518 // uses the store to get access to the tokenizer provider.
2519 bool accessesDynCtx() const { return true; }
2520
2521+ bool mustCopyInputNodes(expr* fo, csize producer) const { return producer == 0; }
2522+
2523 CODEGEN_DECL();
2524 };
2525
2526@@ -53,11 +56,12 @@
2527 class full_text_tokenize_nodes : public function
2528 {
2529 public:
2530- full_text_tokenize_nodes(const signature& sig,
2531- FunctionConsts::FunctionKind kind) :
2532+ full_text_tokenize_nodes(
2533+ const signature& sig,
2534+ FunctionConsts::FunctionKind kind)
2535+ :
2536 function(sig, kind)
2537 {
2538-
2539 }
2540
2541 // Mark the function as accessing the dyn ctx so that it won't be
2542@@ -65,6 +69,8 @@
2543 // uses the store to get access to the tokenizer provider.
2544 bool accessesDynCtx() const { return true; }
2545
2546+ bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
2547+
2548 CODEGEN_DECL();
2549 };
2550
2551@@ -73,11 +79,12 @@
2552 class full_text_tokenizer_properties : public function
2553 {
2554 public:
2555- full_text_tokenizer_properties(const signature& sig, FunctionConsts::FunctionKind kind)
2556+ full_text_tokenizer_properties(
2557+ const signature& sig,
2558+ FunctionConsts::FunctionKind kind)
2559 :
2560 function(sig, kind)
2561 {
2562-
2563 }
2564
2565 // Mark the function as accessing the dyn ctx so that it won't be
2566@@ -93,11 +100,12 @@
2567 class full_text_current_compare_options : public function
2568 {
2569 public:
2570- full_text_current_compare_options(const signature& sig, FunctionConsts::FunctionKind kind)
2571+ full_text_current_compare_options(
2572+ const signature& sig,
2573+ FunctionConsts::FunctionKind kind)
2574 :
2575 function(sig, kind)
2576 {
2577-
2578 }
2579
2580 CODEGEN_DECL();
2581
2582=== modified file 'src/functions/func_jsoniq_functions_impl.h'
2583--- src/functions/func_jsoniq_functions_impl.h 2012-09-12 14:05:46 +0000
2584+++ src/functions/func_jsoniq_functions_impl.h 2012-10-15 13:39:25 +0000
2585@@ -30,6 +30,11 @@
2586 void populate_context_jsoniq_functions_impl(static_context* sctx);
2587
2588
2589+/*******************************************************************************
2590+ jn:object($objs as object()*) as object()
2591+
2592+ It performs object construction by unioning the input objects.
2593+********************************************************************************/
2594 class jn_object : public function
2595 {
2596 public:
2597@@ -39,7 +44,7 @@
2598 {
2599 }
2600
2601- bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
2602+ bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
2603
2604 CODEGEN_DECL();
2605 };
2606
2607=== modified file 'src/functions/func_node_sort_distinct.cpp'
2608--- src/functions/func_node_sort_distinct.cpp 2012-09-19 21:16:15 +0000
2609+++ src/functions/func_node_sort_distinct.cpp 2012-10-15 13:39:25 +0000
2610@@ -115,17 +115,17 @@
2611 {
2612 if (distinct && noa)
2613 {
2614- return GET_BUILTIN_FUNCTION(OP_DISTINCT_NODES_OR_ATOMICS_1);
2615+ return BUILTIN_FUNC(OP_DISTINCT_NODES_OR_ATOMICS_1);
2616 }
2617 else if (distinct)
2618 {
2619 return (getKind() == FunctionConsts::OP_CHECK_DISTINCT_NODES_1 ?
2620- GET_BUILTIN_FUNCTION(OP_CHECK_DISTINCT_NODES_1) :
2621- GET_BUILTIN_FUNCTION(OP_DISTINCT_NODES_1));
2622+ BUILTIN_FUNC(OP_CHECK_DISTINCT_NODES_1) :
2623+ BUILTIN_FUNC(OP_DISTINCT_NODES_1));
2624 }
2625 else if (noa)
2626 {
2627- return GET_BUILTIN_FUNCTION(OP_EITHER_NODES_OR_ATOMICS_1);
2628+ return BUILTIN_FUNC(OP_EITHER_NODES_OR_ATOMICS_1);
2629 }
2630 else
2631 {
2632@@ -135,26 +135,26 @@
2633 else if (distinct && noa)
2634 {
2635 return (myActions[SORT_ASC] ?
2636- GET_BUILTIN_FUNCTION(OP_SORT_DISTINCT_NODES_ASC_OR_ATOMICS_1) :
2637- GET_BUILTIN_FUNCTION(OP_SORT_DISTINCT_NODES_DESC_OR_ATOMICS_1));
2638+ BUILTIN_FUNC(OP_SORT_DISTINCT_NODES_ASC_OR_ATOMICS_1) :
2639+ BUILTIN_FUNC(OP_SORT_DISTINCT_NODES_DESC_OR_ATOMICS_1));
2640 }
2641 else if (distinct)
2642 {
2643 return (myActions[SORT_ASC] ?
2644- GET_BUILTIN_FUNCTION(OP_SORT_DISTINCT_NODES_ASC_1) :
2645- GET_BUILTIN_FUNCTION(OP_SORT_DISTINCT_NODES_DESC_1));
2646+ BUILTIN_FUNC(OP_SORT_DISTINCT_NODES_ASC_1) :
2647+ BUILTIN_FUNC(OP_SORT_DISTINCT_NODES_DESC_1));
2648 }
2649 else if (noa)
2650 {
2651 return (myActions[SORT_ASC] ?
2652- GET_BUILTIN_FUNCTION(OP_SORT_NODES_ASC_OR_ATOMICS_1) :
2653- GET_BUILTIN_FUNCTION(OP_SORT_NODES_DESC_OR_ATOMICS_1));
2654+ BUILTIN_FUNC(OP_SORT_NODES_ASC_OR_ATOMICS_1) :
2655+ BUILTIN_FUNC(OP_SORT_NODES_DESC_OR_ATOMICS_1));
2656 }
2657 else
2658 {
2659 return (myActions[SORT_ASC] ?
2660- GET_BUILTIN_FUNCTION(OP_SORT_NODES_ASC_1) :
2661- GET_BUILTIN_FUNCTION(OP_SORT_NODES_DESC_1));
2662+ BUILTIN_FUNC(OP_SORT_NODES_ASC_1) :
2663+ BUILTIN_FUNC(OP_SORT_NODES_DESC_1));
2664 }
2665 }
2666
2667
2668=== modified file 'src/functions/func_numerics_impl.cpp'
2669--- src/functions/func_numerics_impl.cpp 2012-09-19 21:16:15 +0000
2670+++ src/functions/func_numerics_impl.cpp 2012-10-15 13:39:25 +0000
2671@@ -34,16 +34,16 @@
2672 switch (kind) \
2673 { \
2674 case FunctionConsts::OP_NUMERIC_ADD_2: \
2675- return GET_BUILTIN_FUNCTION(OP_NUMERIC_ADD_##type##_2); \
2676+ return BUILTIN_FUNC(OP_NUMERIC_ADD_##type##_2); \
2677 \
2678 case FunctionConsts::OP_NUMERIC_SUBTRACT_2: \
2679- return GET_BUILTIN_FUNCTION(OP_NUMERIC_SUBTRACT_##type##_2); \
2680+ return BUILTIN_FUNC(OP_NUMERIC_SUBTRACT_##type##_2); \
2681 \
2682 case FunctionConsts::OP_NUMERIC_MULTIPLY_2: \
2683- return GET_BUILTIN_FUNCTION(OP_NUMERIC_MULTIPLY_##type##_2); \
2684+ return BUILTIN_FUNC(OP_NUMERIC_MULTIPLY_##type##_2); \
2685 \
2686 case FunctionConsts::OP_NUMERIC_DIVIDE_2: \
2687- return GET_BUILTIN_FUNCTION(OP_NUMERIC_DIVIDE_##type##_2); \
2688+ return BUILTIN_FUNC(OP_NUMERIC_DIVIDE_##type##_2); \
2689 \
2690 default: \
2691 ZORBA_ASSERT(false); \
2692@@ -586,14 +586,14 @@
2693 {
2694 if (TypeOps::is_subtype(tm, *argType, *rtm.DOUBLE_TYPE_ONE))
2695 {
2696- return GET_BUILTIN_FUNCTION(OP_DOUBLE_UNARY_PLUS_1);
2697+ return BUILTIN_FUNC(OP_DOUBLE_UNARY_PLUS_1);
2698 }
2699 }
2700 else if (getKind() == FunctionConsts::OP_UNARY_MINUS_1)
2701 {
2702 if (TypeOps::is_subtype(tm, *argType, *rtm.DOUBLE_TYPE_ONE))
2703 {
2704- return GET_BUILTIN_FUNCTION(OP_DOUBLE_UNARY_MINUS_1);
2705+ return BUILTIN_FUNC(OP_DOUBLE_UNARY_MINUS_1);
2706 }
2707 }
2708
2709
2710=== modified file 'src/functions/func_schema_impl.cpp'
2711--- src/functions/func_schema_impl.cpp 2012-09-30 09:46:56 +0000
2712+++ src/functions/func_schema_impl.cpp 2012-10-15 13:39:25 +0000
2713@@ -33,4 +33,13 @@
2714 }
2715
2716
2717+/*******************************************************************************
2718+
2719+********************************************************************************/
2720+bool fn_zorba_schema_is_validated::mustCopyInputNodes(expr* fo, csize producer) const
2721+{
2722+ return (fo->get_sctx()->construction_mode() == StaticContextConsts::cons_strip);
2723+}
2724+
2725+
2726 }
2727
2728=== modified file 'src/functions/func_sequences_impl.cpp'
2729--- src/functions/func_sequences_impl.cpp 2012-09-19 21:16:15 +0000
2730+++ src/functions/func_sequences_impl.cpp 2012-10-15 13:39:25 +0000
2731@@ -724,6 +724,16 @@
2732 /*******************************************************************************
2733
2734 ********************************************************************************/
2735+bool fn_deep_equal::mustCopyInputNodes(expr* fo, csize producer) const
2736+{
2737+ return (producer < 2 &&
2738+ fo->get_sctx()->construction_mode() == StaticContextConsts::cons_strip);
2739+}
2740+
2741+
2742+/*******************************************************************************
2743+
2744+********************************************************************************/
2745 PlanIter_t fn_union::codegen(
2746 CompilerCB* /*cb*/,
2747 static_context* sctx,
2748@@ -845,32 +855,32 @@
2749 if (TypeOps::is_subtype(tm, *argType, *rtm.UNTYPED_ATOMIC_TYPE_STAR))
2750 {
2751 return (getArity() == 1 ?
2752- GET_BUILTIN_FUNCTION(OP_SUM_DOUBLE_1) :
2753- GET_BUILTIN_FUNCTION(OP_SUM_DOUBLE_2));
2754+ BUILTIN_FUNC(OP_SUM_DOUBLE_1) :
2755+ BUILTIN_FUNC(OP_SUM_DOUBLE_2));
2756 }
2757 else if (TypeOps::is_subtype(tm, *argType, *rtm.DOUBLE_TYPE_STAR))
2758 {
2759 return (getArity() == 1 ?
2760- GET_BUILTIN_FUNCTION(OP_SUM_DOUBLE_1) :
2761- GET_BUILTIN_FUNCTION(OP_SUM_DOUBLE_2));
2762+ BUILTIN_FUNC(OP_SUM_DOUBLE_1) :
2763+ BUILTIN_FUNC(OP_SUM_DOUBLE_2));
2764 }
2765 else if (TypeOps::is_subtype(tm, *argType, *rtm.FLOAT_TYPE_STAR))
2766 {
2767 return (getArity() == 1 ?
2768- GET_BUILTIN_FUNCTION(OP_SUM_FLOAT_1) :
2769- GET_BUILTIN_FUNCTION(OP_SUM_FLOAT_2));
2770+ BUILTIN_FUNC(OP_SUM_FLOAT_1) :
2771+ BUILTIN_FUNC(OP_SUM_FLOAT_2));
2772 }
2773 else if (TypeOps::is_subtype(tm, *argType, *rtm.INTEGER_TYPE_STAR))
2774 {
2775 return (getArity() == 1 ?
2776- GET_BUILTIN_FUNCTION(OP_SUM_INTEGER_1) :
2777- GET_BUILTIN_FUNCTION(OP_SUM_INTEGER_2));
2778+ BUILTIN_FUNC(OP_SUM_INTEGER_1) :
2779+ BUILTIN_FUNC(OP_SUM_INTEGER_2));
2780 }
2781 else if (TypeOps::is_subtype(tm, *argType, *rtm.DECIMAL_TYPE_STAR))
2782 {
2783 return (getArity() == 1 ?
2784- GET_BUILTIN_FUNCTION(OP_SUM_DECIMAL_1) :
2785- GET_BUILTIN_FUNCTION(OP_SUM_DECIMAL_2));
2786+ BUILTIN_FUNC(OP_SUM_DECIMAL_1) :
2787+ BUILTIN_FUNC(OP_SUM_DECIMAL_2));
2788 }
2789 else
2790 {
2791
2792=== modified file 'src/functions/library.h'
2793--- src/functions/library.h 2012-09-19 21:16:15 +0000
2794+++ src/functions/library.h 2012-10-15 13:39:25 +0000
2795@@ -48,7 +48,7 @@
2796
2797
2798
2799-#define GET_BUILTIN_FUNCTION(func_code) \
2800+#define BUILTIN_FUNC(func_code) \
2801 BuiltinFunctionLibrary::getFunction(FunctionConsts::func_code)
2802
2803
2804
2805=== modified file 'src/functions/pregenerated/func_accessors.h'
2806--- src/functions/pregenerated/func_accessors.h 2012-10-08 12:09:36 +0000
2807+++ src/functions/pregenerated/func_accessors.h 2012-10-15 13:39:25 +0000
2808@@ -82,7 +82,7 @@
2809 theXQueryVersion = StaticContextConsts::xquery_version_3_0;
2810 }
2811
2812- bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
2813+ bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
2814
2815 CODEGEN_DECL();
2816 };
2817@@ -98,7 +98,7 @@
2818
2819 }
2820
2821- bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
2822+ bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
2823
2824 CODEGEN_DECL();
2825 };
2826@@ -140,7 +140,7 @@
2827
2828 BoolAnnotationValue ignoresDuplicateNodes(expr* fo, csize producer) const;
2829
2830- bool mustCopyInputNodes(expr* fo, csize producer) const;
2831+ bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
2832
2833 CODEGEN_DECL();
2834 };
2835@@ -157,7 +157,7 @@
2836
2837 }
2838
2839- bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
2840+ bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
2841
2842 CODEGEN_DECL();
2843 };
2844@@ -207,7 +207,7 @@
2845
2846 }
2847
2848- bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
2849+ bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
2850
2851 CODEGEN_DECL();
2852 };
2853
2854=== modified file 'src/functions/pregenerated/func_maps.h'
2855--- src/functions/pregenerated/func_maps.h 2012-10-08 12:09:36 +0000
2856+++ src/functions/pregenerated/func_maps.h 2012-10-15 13:39:25 +0000
2857@@ -127,6 +127,8 @@
2858
2859 bool accessesDynCtx() const { return true; }
2860
2861+ bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
2862+
2863 CODEGEN_DECL();
2864 };
2865
2866
2867=== modified file 'src/functions/pregenerated/func_nodes.h'
2868--- src/functions/pregenerated/func_nodes.h 2012-10-08 12:09:36 +0000
2869+++ src/functions/pregenerated/func_nodes.h 2012-10-15 13:39:25 +0000
2870@@ -179,6 +179,8 @@
2871 theXQueryVersion = StaticContextConsts::xquery_version_3_0;
2872 }
2873
2874+ bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
2875+
2876 CODEGEN_DECL();
2877 };
2878
2879
2880=== modified file 'src/functions/pregenerated/func_schema.cpp'
2881--- src/functions/pregenerated/func_schema.cpp 2012-10-08 12:09:36 +0000
2882+++ src/functions/pregenerated/func_schema.cpp 2012-10-15 13:39:25 +0000
2883@@ -41,16 +41,6 @@
2884 return new ZorbaValidateInPlaceIterator(sctx, loc, argv[0]);
2885 }
2886
2887-PlanIter_t fn_zorba_util_schema_type::codegen(
2888- CompilerCB*,
2889- static_context* sctx,
2890- const QueryLoc& loc,
2891- std::vector<PlanIter_t>& argv,
2892- expr& ann) const
2893-{
2894- return new ZorbaSchemaTypeIterator(sctx, loc, argv);
2895-}
2896-
2897 PlanIter_t fn_zorba_schema_schema_type::codegen(
2898 CompilerCB*,
2899 static_context* sctx,
2900@@ -88,18 +78,6 @@
2901
2902
2903 {
2904- DECL_WITH_KIND(sctx, fn_zorba_util_schema_type,
2905- (createQName("http://www.zorba-xquery.com/zorba/util-functions","","schema-type"),
2906- GENV_TYPESYSTEM.ITEM_TYPE_ONE,
2907- GENV_TYPESYSTEM.QNAME_TYPE_QUESTION),
2908- FunctionConsts::FN_ZORBA_UTIL_SCHEMA_TYPE_1);
2909-
2910- }
2911-
2912-
2913-
2914-
2915- {
2916 DECL_WITH_KIND(sctx, fn_zorba_schema_schema_type,
2917 (createQName("http://www.zorba-xquery.com/modules/schema","","schema-type"),
2918 GENV_TYPESYSTEM.ITEM_TYPE_ONE,
2919
2920=== modified file 'src/functions/pregenerated/func_schema.h'
2921--- src/functions/pregenerated/func_schema.h 2012-10-08 12:09:36 +0000
2922+++ src/functions/pregenerated/func_schema.h 2012-10-15 13:39:25 +0000
2923@@ -59,23 +59,6 @@
2924 };
2925
2926
2927-//fn-zorba-util:schema-type
2928-class fn_zorba_util_schema_type : public function
2929-{
2930-public:
2931- fn_zorba_util_schema_type(const signature& sig, FunctionConsts::FunctionKind kind)
2932- :
2933- function(sig, kind)
2934- {
2935-
2936- }
2937-
2938- bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
2939-
2940- CODEGEN_DECL();
2941-};
2942-
2943-
2944 //fn-zorba-schema:schema-type
2945 class fn_zorba_schema_schema_type : public function
2946 {
2947@@ -104,7 +87,7 @@
2948
2949 }
2950
2951- bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
2952+ bool mustCopyInputNodes(expr* fo, csize producer) const;
2953
2954 CODEGEN_DECL();
2955 };
2956
2957=== modified file 'src/functions/pregenerated/func_sequences.h'
2958--- src/functions/pregenerated/func_sequences.h 2012-10-08 12:09:36 +0000
2959+++ src/functions/pregenerated/func_sequences.h 2012-10-15 13:39:25 +0000
2960@@ -348,7 +348,7 @@
2961
2962 bool accessesDynCtx() const { return true; }
2963
2964- bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
2965+ bool mustCopyInputNodes(expr* fo, csize producer) const;
2966
2967 CODEGEN_DECL();
2968 };
2969
2970=== modified file 'src/functions/pregenerated/function_enum.h'
2971--- src/functions/pregenerated/function_enum.h 2012-10-08 12:09:36 +0000
2972+++ src/functions/pregenerated/function_enum.h 2012-10-15 13:39:25 +0000
2973@@ -360,7 +360,6 @@
2974 FN_ZORBA_UTIL_UUID_0,
2975 FN_ZORBA_RANDOM_UUID_0,
2976 FN_ZORBA_SCHEMA_VALIDATE_IN_PLACE_1,
2977- FN_ZORBA_UTIL_SCHEMA_TYPE_1,
2978 FN_ZORBA_SCHEMA_SCHEMA_TYPE_1,
2979 FN_ZORBA_SCHEMA_IS_VALIDATED_1,
2980 OP_CONCATENATE_N,
2981
2982=== modified file 'src/functions/udf.cpp'
2983--- src/functions/udf.cpp 2012-10-09 14:06:08 +0000
2984+++ src/functions/udf.cpp 2012-10-15 13:39:25 +0000
2985@@ -280,7 +280,7 @@
2986 /*******************************************************************************
2987
2988 ********************************************************************************/
2989-void user_function::addRecursiveCall(expr* call)
2990+void user_function::addRecursiveCall(fo_expr* call)
2991 {
2992 assert(theBodyExpr != NULL);
2993
2994
2995=== modified file 'src/functions/udf.h'
2996--- src/functions/udf.h 2012-10-09 14:06:08 +0000
2997+++ src/functions/udf.h 2012-10-15 13:39:25 +0000
2998@@ -128,7 +128,7 @@
2999 bool theIsLeaf;
3000
3001 std::vector<user_function*> theMutuallyRecursiveUDFs;
3002- std::vector<expr*> theRecursiveCalls;
3003+ std::vector<fo_expr*> theRecursiveCalls;
3004
3005 bool theIsOptimized;
3006
3007@@ -183,9 +183,9 @@
3008 const std::vector<user_function*>& udfs,
3009 const std::vector<user_function*>::const_iterator& cycle);
3010
3011- void addRecursiveCall(expr* call);
3012+ void addRecursiveCall(fo_expr* call);
3013
3014- const std::vector<expr*>& getRecursiveCalls() const { return theRecursiveCalls; }
3015+ const std::vector<fo_expr*>& getRecursiveCalls() const { return theRecursiveCalls; }
3016
3017 bool isMutuallyRecursiveWith(const user_function* udf);
3018
3019
3020=== modified file 'src/runtime/collections/collections_impl.cpp'
3021--- src/runtime/collections/collections_impl.cpp 2012-09-19 21:16:15 +0000
3022+++ src/runtime/collections/collections_impl.cpp 2012-10-15 13:39:25 +0000
3023@@ -367,6 +367,7 @@
3024 }
3025 }
3026
3027+
3028 bool ZorbaCollectionIterator::isCountOptimizable() const
3029 {
3030 // if ref is passed to the collections function, count cannot be
3031@@ -374,6 +375,7 @@
3032 return theChildren.size() <= 2;
3033 }
3034
3035+
3036 bool ZorbaCollectionIterator::nextImpl(
3037 store::Item_t& result,
3038 PlanState& planState) const
3039@@ -402,11 +404,13 @@
3040 store::Item_t lSkipItem;
3041 consumeNext(lSkipItem, theChildren[(lRefPassed ? 2 : 1)].getp(), planState);
3042 lSkip = lSkipItem->getIntegerValue();
3043+
3044 // negative skip is not allowed
3045 if (lSkip < xs_integer::zero())
3046 {
3047 lSkip = xs_integer::zero();
3048 }
3049+
3050 if (!lRefPassed)
3051 {
3052 state->theIterator = collection->getIterator(lSkip);
3053
3054=== modified file 'src/runtime/eval/eval.cpp'
3055--- src/runtime/eval/eval.cpp 2012-10-09 14:06:08 +0000
3056+++ src/runtime/eval/eval.cpp 2012-10-15 13:39:25 +0000
3057@@ -166,6 +166,8 @@
3058 // Compile
3059 state->thePlan = compile(evalCCB, item->getStringValue(), maxOuterVarId);
3060
3061+ planState.theCompilerCB->theNextVisitId = evalCCB->theNextVisitId + 1;
3062+
3063 // Set the values for the (explicit) external vars of the eval query
3064 setExternalVariables(evalCCB, importSctx, evalSctx, evalDctx);
3065
3066
3067=== modified file 'src/runtime/spec/accessors/accessors.xml'
3068--- src/runtime/spec/accessors/accessors.xml 2012-09-19 21:16:15 +0000
3069+++ src/runtime/spec/accessors/accessors.xml 2012-10-15 13:39:25 +0000
3070@@ -71,7 +71,7 @@
3071 </zorba:signature>
3072
3073 <zorba:methods>
3074- <zorba:mustCopyInputNodes value="true"/>
3075+ <zorba:mustCopyInputNodes value="false"/>
3076 </zorba:methods>
3077
3078 </zorba:function>
3079@@ -140,7 +140,7 @@
3080 <zorba:isMap producer="0"/>
3081 <zorba:ignoresSortedNodes/>
3082 <zorba:ignoresDuplicateNodes/>
3083- <zorba:mustCopyInputNodes/>
3084+ <zorba:mustCopyInputNodes value="false"/>
3085 </zorba:methods>
3086
3087 </zorba:function>
3088@@ -173,7 +173,7 @@
3089 </zorba:signature>
3090
3091 <zorba:methods>
3092- <zorba:mustCopyInputNodes value="true"/>
3093+ <zorba:mustCopyInputNodes value="false"/>
3094 </zorba:methods>
3095
3096 </zorba:function>
3097@@ -236,7 +236,7 @@
3098 </zorba:signature>
3099
3100 <zorba:methods>
3101- <zorba:mustCopyInputNodes value="true"/>
3102+ <zorba:mustCopyInputNodes value="false"/>
3103 </zorba:methods>
3104
3105 </zorba:function>
3106
3107=== modified file 'src/runtime/spec/nodes/nodes.xml'
3108--- src/runtime/spec/nodes/nodes.xml 2012-09-19 21:16:15 +0000
3109+++ src/runtime/spec/nodes/nodes.xml 2012-10-15 13:39:25 +0000
3110@@ -243,6 +243,10 @@
3111 <zorba:output>xs:boolean</zorba:output>
3112 </zorba:signature>
3113
3114+ <zorba:methods>
3115+ <zorba:mustCopyInputNodes value="false"/>
3116+ </zorba:methods>
3117+
3118 </zorba:function>
3119
3120 </zorba:iterator>
3121
3122=== modified file 'src/runtime/spec/schema/schema.xml'
3123--- src/runtime/spec/schema/schema.xml 2012-10-08 12:09:36 +0000
3124+++ src/runtime/spec/schema/schema.xml 2012-10-15 13:39:25 +0000
3125@@ -81,18 +81,6 @@
3126 <zorba:description author="Zorba Team">iterator backing the schema-type function</zorba:description>
3127
3128 <zorba:function>
3129- <zorba:signature localname="schema-type" prefix="fn-zorba-util">
3130- <zorba:param>item()</zorba:param>
3131- <zorba:output>xs:QName?</zorba:output>
3132- </zorba:signature>
3133-
3134- <zorba:methods>
3135- <zorba:mustCopyInputNodes value="false"/>
3136- </zorba:methods>
3137-
3138- </zorba:function>
3139-
3140- <zorba:function>
3141 <zorba:signature localname="schema-type" prefix="fn-zorba-schema">
3142 <zorba:param>item()</zorba:param>
3143 <zorba:output>xs:QName?</zorba:output>
3144@@ -121,7 +109,7 @@
3145 </zorba:signature>
3146
3147 <zorba:methods>
3148- <zorba:mustCopyInputNodes value="false"/>
3149+ <zorba:mustCopyInputNodes/>
3150 </zorba:methods>
3151
3152 </zorba:function>
3153
3154=== modified file 'src/runtime/spec/sequences/sequences.xml'
3155--- src/runtime/spec/sequences/sequences.xml 2012-09-19 21:16:15 +0000
3156+++ src/runtime/spec/sequences/sequences.xml 2012-10-15 13:39:25 +0000
3157@@ -636,7 +636,7 @@
3158
3159 <zorba:methods>
3160 <zorba:accessesDynCtx returnValue="true"/>
3161- <zorba:mustCopyInputNodes value="false"/>
3162+ <zorba:mustCopyInputNodes/>
3163 </zorba:methods>
3164
3165 </zorba:function>
3166
3167=== modified file 'src/runtime/spec/store/maps.xml'
3168--- src/runtime/spec/store/maps.xml 2012-09-19 21:16:15 +0000
3169+++ src/runtime/spec/store/maps.xml 2012-10-15 13:39:25 +0000
3170@@ -156,6 +156,7 @@
3171 <zorba:methods>
3172 <zorba:getScriptingKind returnValue="SEQUENTIAL_FUNC_EXPR"/>
3173 <zorba:accessesDynCtx returnValue="true"/>
3174+ <zorba:mustCopyInputNodes value="true"/>
3175 </zorba:methods>
3176
3177 </zorba:function>
3178
3179=== modified file 'src/runtime/store/maps_impl.cpp'
3180--- src/runtime/store/maps_impl.cpp 2012-09-19 21:16:15 +0000
3181+++ src/runtime/store/maps_impl.cpp 2012-10-15 13:39:25 +0000
3182@@ -399,15 +399,11 @@
3183
3184 if (lSpec.getNumColumns() != theChildren.size() - 2)
3185 {
3186- RAISE_ERROR(
3187- zerr::ZDDY0025_INDEX_WRONG_NUMBER_OF_PROBE_ARGS,
3188- loc,
3189- ERROR_PARAMS(
3190- lQName->getStringValue(),
3191- "map",
3192- theChildren.size() - 2,
3193- lSpec.getNumColumns() )
3194- );
3195+ RAISE_ERROR(zerr::ZDDY0025_INDEX_WRONG_NUMBER_OF_PROBE_ARGS, loc,
3196+ ERROR_PARAMS(lQName->getStringValue(),
3197+ "map",
3198+ theChildren.size() - 2,
3199+ lSpec.getNumColumns()));
3200 }
3201
3202 lKey.resize(theChildren.size() - 2);
3203@@ -497,16 +493,11 @@
3204
3205 if (lSpec.getNumColumns() != theChildren.size() - 1)
3206 {
3207- RAISE_ERROR(
3208- zerr::ZDDY0025_INDEX_WRONG_NUMBER_OF_PROBE_ARGS,
3209- loc,
3210- ERROR_PARAMS(
3211- lQName->getStringValue(),
3212- "map",
3213- theChildren.size() - 1,
3214- lSpec.getNumColumns()
3215- )
3216- );
3217+ RAISE_ERROR(zerr::ZDDY0025_INDEX_WRONG_NUMBER_OF_PROBE_ARGS, loc,
3218+ ERROR_PARAMS(lQName->getStringValue(),
3219+ "map",
3220+ theChildren.size() - 1,
3221+ lSpec.getNumColumns()));
3222 }
3223
3224 lKey.resize(theChildren.size()-1);
3225
3226=== modified file 'src/store/naive/node_items.cpp'
3227--- src/store/naive/node_items.cpp 2012-09-19 21:16:15 +0000
3228+++ src/store/naive/node_items.cpp 2012-10-15 13:39:25 +0000
3229@@ -623,6 +623,9 @@
3230 const store::CopyMode& copymode) const
3231 {
3232 assert(!isConnectorNode());
3233+ store::StoreConsts::NodeKind kind = getNodeKind();
3234+
3235+ bool copy = (copymode.theDoCopy || kind == store::StoreConsts::attributeNode);
3236
3237 InternalNode* parent = NULL;
3238 csize pos = 0;
3239@@ -634,9 +637,9 @@
3240
3241 parent = reinterpret_cast<InternalNode*>(inParent);
3242
3243- if (copymode.theDoCopy == false)
3244+ if (!copy)
3245 {
3246- if (getNodeKind() == store::StoreConsts::textNode)
3247+ if (kind == store::StoreConsts::textNode)
3248 {
3249 pos = parent->numChildren();
3250
3251@@ -670,28 +673,12 @@
3252 }
3253 }
3254 }
3255- else if (getNodeKind() == store::StoreConsts::attributeNode)
3256- {
3257- ElementNode* pnode = reinterpret_cast<ElementNode*>(parent);
3258- store::Item_t attrName = getNodeName();
3259- pnode->checkUniqueAttr(attrName);
3260-
3261- try
3262- {
3263- pnode->addBindingForQName(attrName, true, false);
3264- }
3265- catch (...)
3266- {
3267- goto doCopy;
3268- }
3269- }
3270
3271 new ConnectorNode(parent->getTree(), parent, this);
3272 return const_cast<XmlNode*>(this);
3273 }
3274
3275- doCopy:
3276- if (getNodeKind() == store::StoreConsts::attributeNode)
3277+ if (kind == store::StoreConsts::attributeNode)
3278 {
3279 ElementNode* pnode = reinterpret_cast<ElementNode*>(parent);
3280 pnode->checkUniqueAttr(getNodeName());
3281@@ -703,7 +690,7 @@
3282 }
3283 } // have parent
3284
3285- if (copymode.theDoCopy)
3286+ if (copy)
3287 {
3288 return copyInternal(parent, parent, pos, NULL, copymode);
3289 }
3290@@ -714,53 +701,6 @@
3291 }
3292
3293
3294-#if 0
3295-/*******************************************************************************
3296- Make a copy of the xml tree rooted at this node and place the copied tree at
3297- a given position under a given node. Return a pointer to the root node of the
3298- copied tree.
3299-
3300- parent : The node P under which the copied tree is to be placed. P may be
3301- NULL, in which case the copied tree becomes a new standalone tree.
3302- pos : The position under P where the copied tree is to be placed. If
3303- "this" is an attribute node, pos is a position among the attributes
3304- of P; otherwise it is a position among the children of P. If pos
3305- is greater or equal to the current number of attrs/children in P,
3306- then the copied tree is appended to P's attributes/children.
3307- copymode : Encapsulates the construction-mode and copy-namespace-mode
3308- components of the query's static context.
3309-********************************************************************************/
3310-store::Item* XmlNode::copy(
3311- store::Item* inParent,
3312- csize pos,
3313- const store::CopyMode& copymode) const
3314-{
3315- assert(!isConnectorNode());
3316- assert(copymode.theDoCopy == true);
3317-
3318- InternalNode* parent = NULL;
3319-
3320- if (inParent)
3321- {
3322- parent = reinterpret_cast<InternalNode*>(inParent);
3323- ZORBA_ASSERT(inParent->getNodeKind() == store::StoreConsts::elementNode ||
3324- inParent->getNodeKind() == store::StoreConsts::documentNode);
3325- }
3326-
3327- if (getNodeKind() == store::StoreConsts::attributeNode)
3328- {
3329- if (parent)
3330- {
3331- ElementNode* pnode = reinterpret_cast<ElementNode*>(parent);
3332- pnode->checkUniqueAttr(getNodeName());
3333- }
3334- }
3335-
3336- return copyInternal(parent, parent, pos, NULL, copymode);
3337-}
3338-#endif
3339-
3340-
3341 /*******************************************************************************
3342 Connect "this" to the given parent at the given position.
3343 ********************************************************************************/
3344
3345=== added file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/test5.iter'
3346--- test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/test5.iter 1970-01-01 00:00:00 +0000
3347+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/test5.iter 2012-10-15 13:39:25 +0000
3348@@ -0,0 +1,48 @@
3349+Iterator tree for main query:
3350+<SequentialIterator>
3351+ <CtxVarDeclareIterator varid="4" varname="doc">
3352+ <ElementIterator>
3353+ <SingletonIterator value="xs:QName(http://www.zorba-xquery.org/simple,s,person)"/>
3354+ <FnConcatIterator>
3355+ <ElementIterator>
3356+ <SingletonIterator value="xs:QName(http://www.zorba-xquery.org/simple,s,name)"/>
3357+ <TextIterator>
3358+ <SingletonIterator value="xs:string(foo)"/>
3359+ </TextIterator>
3360+ </ElementIterator>
3361+ <ElementIterator>
3362+ <SingletonIterator value="xs:QName(http://www.zorba-xquery.org/simple,s,age)"/>
3363+ <TextIterator>
3364+ <SingletonIterator value="xs:string(25)"/>
3365+ </TextIterator>
3366+ </ElementIterator>
3367+ </FnConcatIterator>
3368+ </ElementIterator>
3369+ </CtxVarDeclareIterator>
3370+ <flwor::FLWORIterator>
3371+ <LetVariable name="copyname" materialize="true">
3372+ <ChildAxisIterator test kind="match_name_test" qname="xs:QName(http://www.zorba-xquery.org/simple,s,name)" typename="*" nill allowed="0">
3373+ <ElementIterator>
3374+ <SingletonIterator value="xs:QName(,,root)"/>
3375+ <EnclosedIterator attr_cont="false">
3376+ <ChildAxisIterator test kind="match_name_test" qname="xs:QName(http://www.zorba-xquery.org/simple,s,name)" typename="*" nill allowed="0">
3377+ <ValidateIterator>
3378+ <CtxVarIterator varid="4" varname="doc" varkind="global"/>
3379+ </ValidateIterator>
3380+ </ChildAxisIterator>
3381+ </EnclosedIterator>
3382+ </ElementIterator>
3383+ </ChildAxisIterator>
3384+ </LetVariable>
3385+ <ReturnClause>
3386+ <FnConcatIterator>
3387+ <LetVarIterator varname="copyname"/>
3388+ <SingletonIterator value="xs:string( )"/>
3389+ <InstanceOfIterator>
3390+ <LetVarIterator varname="copyname"/>
3391+ </InstanceOfIterator>
3392+ </FnConcatIterator>
3393+ </ReturnClause>
3394+ </flwor::FLWORIterator>
3395+</SequentialIterator>
3396+
3397
3398=== added file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/test6.iter'
3399--- test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/test6.iter 1970-01-01 00:00:00 +0000
3400+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/test6.iter 2012-10-15 13:39:25 +0000
3401@@ -0,0 +1,50 @@
3402+Iterator tree for main query:
3403+<SequentialIterator>
3404+ <CtxVarDeclareIterator varid="4" varname="doc">
3405+ <ElementIterator>
3406+ <SingletonIterator value="xs:QName(http://www.zorba-xquery.org/simple,s,person)"/>
3407+ <FnConcatIterator>
3408+ <ElementIterator>
3409+ <SingletonIterator value="xs:QName(http://www.zorba-xquery.org/simple,s,name)"/>
3410+ <TextIterator>
3411+ <SingletonIterator value="xs:string(foo)"/>
3412+ </TextIterator>
3413+ </ElementIterator>
3414+ <ElementIterator>
3415+ <SingletonIterator value="xs:QName(http://www.zorba-xquery.org/simple,s,age)"/>
3416+ <TextIterator>
3417+ <SingletonIterator value="xs:string(25)"/>
3418+ </TextIterator>
3419+ </ElementIterator>
3420+ </FnConcatIterator>
3421+ </ElementIterator>
3422+ </CtxVarDeclareIterator>
3423+ <FnConcatIterator>
3424+ <FnDataIterator>
3425+ <ChildAxisIterator test kind="match_name_test" qname="xs:QName(http://www.zorba-xquery.org/simple,s,person)" typename="*" nill allowed="0">
3426+ <ElementIterator>
3427+ <SingletonIterator value="xs:QName(,,root)"/>
3428+ <EnclosedIterator attr_cont="false">
3429+ <ValidateIterator>
3430+ <CtxVarIterator varid="4" varname="doc" varkind="global"/>
3431+ </ValidateIterator>
3432+ </EnclosedIterator>
3433+ </ElementIterator>
3434+ </ChildAxisIterator>
3435+ </FnDataIterator>
3436+ <SingletonIterator value="xs:string(
3437+
3438+)"/>
3439+ <FnDataIterator>
3440+ <ElementIterator copyInputNodes="false">
3441+ <SingletonIterator value="xs:QName(,,root)"/>
3442+ <EnclosedIterator attr_cont="false">
3443+ <ValidateIterator>
3444+ <CtxVarIterator varid="4" varname="doc" varkind="global"/>
3445+ </ValidateIterator>
3446+ </EnclosedIterator>
3447+ </ElementIterator>
3448+ </FnDataIterator>
3449+ </FnConcatIterator>
3450+</SequentialIterator>
3451+
3452
3453=== added file 'test/rbkt/ExpQueryResults/zorba/no-copy/baseuri.xml.res'
3454--- test/rbkt/ExpQueryResults/zorba/no-copy/baseuri.xml.res 1970-01-01 00:00:00 +0000
3455+++ test/rbkt/ExpQueryResults/zorba/no-copy/baseuri.xml.res 2012-10-15 13:39:25 +0000
3456@@ -0,0 +1,1 @@
3457+http://x.com/root http://x.com/b http://x.com/b http://y.com/ http://y.com/
3458
3459=== added file 'test/rbkt/ExpQueryResults/zorba/no-copy/recursive_01.xml.res'
3460--- test/rbkt/ExpQueryResults/zorba/no-copy/recursive_01.xml.res 1970-01-01 00:00:00 +0000
3461+++ test/rbkt/ExpQueryResults/zorba/no-copy/recursive_01.xml.res 2012-10-15 13:39:25 +0000
3462@@ -0,0 +1,2 @@
3463+<book><author/><title/></book>
3464+
3465
3466=== modified file 'test/rbkt/ExpQueryResults/zorba/no-copy/test5.xml.res'
3467--- test/rbkt/ExpQueryResults/zorba/no-copy/test5.xml.res 2012-10-02 22:10:55 +0000
3468+++ test/rbkt/ExpQueryResults/zorba/no-copy/test5.xml.res 2012-10-15 13:39:25 +0000
3469@@ -1,1 +1,1 @@
3470-<s:name xmlns:s="http://www.zorba-xquery.org/simple">foo</s:name> true
3471+<s:name xmlns:s="http://www.zorba-xquery.org/simple">foo</s:name> false
3472
3473=== added file 'test/rbkt/ExpQueryResults/zorba/no-copy/test6.xml.res'
3474--- test/rbkt/ExpQueryResults/zorba/no-copy/test6.xml.res 1970-01-01 00:00:00 +0000
3475+++ test/rbkt/ExpQueryResults/zorba/no-copy/test6.xml.res 2012-10-15 13:39:25 +0000
3476@@ -0,0 +1,3 @@
3477+foo25
3478+
3479+ foo25
3480
3481=== added file 'test/rbkt/Queries/zorba/no-copy/baseuri.xq'
3482--- test/rbkt/Queries/zorba/no-copy/baseuri.xq 1970-01-01 00:00:00 +0000
3483+++ test/rbkt/Queries/zorba/no-copy/baseuri.xq 2012-10-15 13:39:25 +0000
3484@@ -0,0 +1,11 @@
3485+
3486+declare namespace opt = "http://www.zorba-xquery.com/options/optimizer";
3487+
3488+declare base-uri "http://x.com/root";
3489+
3490+declare option opt:enable "for-serialization-only";
3491+
3492+
3493+let $t0 := <t/>
3494+let $t := <a><b xml:base="b"><c><d xml:base="http://y.com/">{$t0}</d></c></b></a>
3495+for $n in ($t, $t//*) return base-uri ($n)
3496
3497=== added file 'test/rbkt/Queries/zorba/no-copy/recursive_01.xq'
3498--- test/rbkt/Queries/zorba/no-copy/recursive_01.xq 1970-01-01 00:00:00 +0000
3499+++ test/rbkt/Queries/zorba/no-copy/recursive_01.xq 2012-10-15 13:39:25 +0000
3500@@ -0,0 +1,35 @@
3501+declare namespace ann = "http://www.zorba-xquery.com/annotations";
3502+
3503+
3504+declare namespace opt = "http://www.zorba-xquery.com/options/optimizer";
3505+
3506+declare option opt:enable "for-serialization-only";
3507+
3508+
3509+declare function local:collapseNodes($x as node()*) as node()*
3510+{
3511+ for $y in $x
3512+ let $n := node-name($y)
3513+ group by $n
3514+ order by string($n)
3515+ return local:collapseNodesSameName(element {$n} {$y})
3516+};
3517+
3518+
3519+declare function local:collapseNodesSameName($x as node()) as node()+
3520+{
3521+ variable $f := $x/*[1];
3522+ variable $c := $x/*/*;
3523+ variable $cc := local:collapseNodes($c);
3524+
3525+ element { node-name($x/*/..) } { $cc }
3526+};
3527+
3528+
3529+declare variable $input as element()* := <book>{doc('books.xml')/*/*}</book>;
3530+
3531+local:collapseNodesSameName($input)
3532+,
3533+"
3534+
3535+"
3536
3537=== added file 'test/rbkt/Queries/zorba/no-copy/test6.xq'
3538--- test/rbkt/Queries/zorba/no-copy/test6.xq 1970-01-01 00:00:00 +0000
3539+++ test/rbkt/Queries/zorba/no-copy/test6.xq 2012-10-15 13:39:25 +0000
3540@@ -0,0 +1,24 @@
3541+declare namespace opt = "http://www.zorba-xquery.com/options/optimizer";
3542+
3543+declare construction strip;
3544+
3545+import schema namespace s="http://www.zorba-xquery.org/simple" at "simple.xsd";
3546+
3547+declare option opt:enable "for-serialization-only";
3548+
3549+declare variable $doc := <s:person><s:name>foo</s:name><s:age>25</s:age></s:person>;
3550+
3551+let $vdoc := validate { $doc }
3552+let $copy := <root>{$vdoc}</root>
3553+return fn:data($copy/s:person)
3554+,
3555+"
3556+
3557+"
3558+,
3559+let $vdoc := validate { $doc }
3560+let $copy := <root>{$vdoc}</root>
3561+return fn:data($copy)
3562+
3563+
3564+

Subscribers

People subscribed via source and target branches