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

Proposed by Markos Zaharioudakis
Status: Merged
Approved by: Markos Zaharioudakis
Approved revision: 10961
Merged at revision: 11092
Proposed branch: lp:~zorba-coders/zorba/markos-scratch
Merge into: lp:zorba
Diff against target: 11065 lines (+2844/-2065)
44 files modified
src/compiler/expression/CMakeLists.txt (+1/-0)
src/compiler/expression/expr.cpp (+130/-300)
src/compiler/expression/expr.h (+197/-132)
src/compiler/expression/expr_base.cpp (+18/-42)
src/compiler/expression/expr_base.h (+16/-14)
src/compiler/expression/expr_clone.cpp (+790/-0)
src/compiler/expression/expr_manager.cpp (+174/-140)
src/compiler/expression/expr_manager.h (+85/-8)
src/compiler/expression/flwor_expr.cpp (+107/-98)
src/compiler/expression/flwor_expr.h (+25/-14)
src/compiler/expression/fo_expr.cpp (+14/-29)
src/compiler/expression/fo_expr.h (+15/-3)
src/compiler/expression/ft_expr.cpp (+5/-10)
src/compiler/expression/ft_expr.h (+2/-2)
src/compiler/expression/ftnode.cpp (+95/-75)
src/compiler/expression/ftnode.h (+31/-28)
src/compiler/expression/function_item_expr.cpp (+13/-42)
src/compiler/expression/function_item_expr.h (+7/-8)
src/compiler/expression/json_exprs.cpp (+6/-50)
src/compiler/expression/json_exprs.h (+6/-6)
src/compiler/expression/path_expr.cpp (+18/-44)
src/compiler/expression/path_expr.h (+15/-9)
src/compiler/expression/script_exprs.cpp (+26/-93)
src/compiler/expression/script_exprs.h (+18/-18)
src/compiler/expression/update_exprs.cpp (+19/-67)
src/compiler/expression/update_exprs.h (+53/-48)
src/compiler/expression/var_expr.cpp (+4/-18)
src/compiler/expression/var_expr.h (+2/-13)
src/compiler/parsetree/parsenodes.cpp (+1/-1)
src/compiler/rewriter/framework/rewriter_context.cpp (+1/-1)
src/compiler/rewriter/rules/flwor_rules.cpp (+32/-12)
src/compiler/rewriter/rules/fold_rules.cpp (+139/-107)
src/compiler/rewriter/rules/hoist_rules.cpp (+19/-16)
src/compiler/rewriter/rules/index_join_rule.cpp (+46/-33)
src/compiler/rewriter/rules/type_rules.cpp (+23/-17)
src/compiler/rewriter/tools/dataflow_annotations.cpp (+4/-6)
src/compiler/rewriter/tools/dataflow_annotations.h (+0/-6)
src/compiler/translator/translator.cpp (+644/-477)
src/compiler/xqddf/value_index.cpp (+30/-23)
src/functions/udf.cpp (+9/-0)
src/functions/udf.h (+2/-0)
src/runtime/eval/eval.cpp (+1/-0)
src/runtime/function_item/function_item.cpp (+1/-1)
test/rbkt/Queries/zorba/no-copy/q21.xq (+0/-54)
To merge this branch: bzr merge lp:~zorba-coders/zorba/markos-scratch
Reviewer Review Type Date Requested Status
Markos Zaharioudakis Approve
Review via email: mp+128675@code.launchpad.net

Commit message

Associated expressions with UDFs

Description of the change

Associated expressions with UDFs

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

associating exprs with udfs

Revision history for this message
Markos Zaharioudakis (markos-za) :
review: Approve
10961. By Markos Zaharioudakis

cleaning up no-copy rule

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job markos-scratch-2012-10-09T13-39-57.923Z 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/expression/CMakeLists.txt'
2--- src/compiler/expression/CMakeLists.txt 2012-10-08 12:09:36 +0000
3+++ src/compiler/expression/CMakeLists.txt 2012-10-09 13:35:26 +0000
4@@ -14,6 +14,7 @@
5 SET(EXPRESSION_SRCS
6 expr_consts.cpp
7 expr_base.cpp
8+ expr_clone.cpp
9 expr_iter.cpp
10 expr_type.cpp
11 expr.cpp
12
13=== modified file 'src/compiler/expression/expr.cpp'
14--- src/compiler/expression/expr.cpp 2012-10-08 12:09:36 +0000
15+++ src/compiler/expression/expr.cpp 2012-10-09 13:35:26 +0000
16@@ -83,22 +83,19 @@
17 DEF_EXPR_ACCEPT (pi_expr)
18
19
20-#define CLONE( e, s ) ((e) == NULL ? NULL : (e)->clone(s))
21-
22-
23-
24 /*******************************************************************************
25 [68] IfExpr ::= "if" "(" Expr ")" "then" ExprSingle "else" ExprSingle
26 ********************************************************************************/
27 if_expr::if_expr(
28 CompilerCB* ccb,
29 static_context* sctx,
30+ user_function* udf,
31 const QueryLoc& loc,
32 expr* condExpr,
33 expr* thenExpr,
34 expr* elseExpr)
35 :
36- expr(ccb, sctx, loc, if_expr_kind),
37+ expr(ccb, sctx, udf, loc, if_expr_kind),
38 theThenExpr(thenExpr),
39 theElseExpr(elseExpr)
40 {
41@@ -108,10 +105,13 @@
42 *GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE,
43 loc))
44 {
45- fo_expr* boolExpr = theCCB->theEM->create_fo_expr(sctx,
46- loc,
47- GET_BUILTIN_FUNCTION(FN_BOOLEAN_1),
48- condExpr);
49+ fo_expr* boolExpr = theCCB->theEM->
50+ create_fo_expr(sctx,
51+ udf,
52+ loc,
53+ GET_BUILTIN_FUNCTION(FN_BOOLEAN_1),
54+ condExpr);
55+
56 condExpr = boolExpr;
57 }
58
59@@ -166,27 +166,18 @@
60 }
61
62
63-expr* if_expr::cloneImpl(substitution_t& subst) const
64-{
65- return theCCB->theEM->create_if_expr(theSctx,
66- get_loc(),
67- get_cond_expr()->clone(subst),
68- get_then_expr()->clone(subst),
69- get_else_expr()->clone(subst));
70-}
71-
72-
73 /***************************************************************************//**
74
75 ********************************************************************************/
76 order_expr::order_expr(
77 CompilerCB* ccb,
78 static_context* sctx,
79+ user_function* udf,
80 const QueryLoc& loc,
81 order_type_t type,
82 expr* inExpr)
83 :
84- expr(ccb, sctx, loc, order_expr_kind),
85+ expr(ccb, sctx, udf, loc, order_expr_kind),
86 theType(type),
87 theExpr(inExpr)
88 {
89@@ -203,25 +194,20 @@
90 }
91
92
93-expr* order_expr::cloneImpl(substitution_t& subst) const
94-{
95- return theCCB->theEM->create_order_expr(theSctx, get_loc(), get_type(), get_expr()->clone(subst));
96-}
97-
98-
99 /***************************************************************************//**
100
101 ********************************************************************************/
102 validate_expr::validate_expr(
103 CompilerCB* ccb,
104 static_context* sctx,
105+ user_function* udf,
106 const QueryLoc& loc,
107 enum ParseConstants::validation_mode_t mode,
108 const store::Item_t& typeName,
109 expr* inExpr,
110 rchandle<TypeManager> typemgr)
111 :
112- expr(ccb, sctx, loc, validate_expr_kind),
113+ expr(ccb, sctx, udf, loc, validate_expr_kind),
114 theMode(mode),
115 theTypeName(typeName),
116 theTypeMgr(typemgr),
117@@ -242,16 +228,6 @@
118 }
119
120
121-expr* validate_expr::cloneImpl(substitution_t& subst) const
122-{
123- return theCCB->theEM->create_validate_expr(theSctx,
124- get_loc(),
125- get_valmode(),
126- const_cast<store::Item*>(get_type_name()),
127- get_expr()->clone(subst),
128- get_typemgr());
129-}
130-
131
132 /***************************************************************************//**
133 Base for expression classes that require a namespace context
134@@ -259,11 +235,12 @@
135 namespace_context_base_expr::namespace_context_base_expr(
136 CompilerCB* ccb,
137 static_context* sctx,
138+ user_function* udf,
139 const QueryLoc& loc,
140 expr_kind_t kind,
141 const namespace_context* aNSCtx)
142 :
143- expr(ccb, sctx, loc, kind),
144+ expr(ccb, sctx, udf, loc, kind),
145 theNSCtx(const_cast<namespace_context*>(aNSCtx))
146 {
147 }
148@@ -282,12 +259,13 @@
149 cast_or_castable_base_expr::cast_or_castable_base_expr(
150 CompilerCB* ccb,
151 static_context* sctx,
152+ user_function* udf,
153 const QueryLoc& loc,
154 expr_kind_t kind,
155 expr* input,
156 const xqtref_t& type)
157 :
158- expr(ccb, sctx, loc, kind),
159+ expr(ccb, sctx, udf, loc, kind),
160 theInputExpr(input),
161 theTargetType(type)
162 {
163@@ -327,12 +305,13 @@
164 cast_base_expr::cast_base_expr(
165 CompilerCB* ccb,
166 static_context* sctx,
167+ user_function* udf,
168 const QueryLoc& loc,
169 expr_kind_t kind,
170 expr* input,
171 const xqtref_t& type)
172 :
173- cast_or_castable_base_expr(ccb, sctx, loc, kind, input, type)
174+ cast_or_castable_base_expr(ccb, sctx, udf, loc, kind, input, type)
175 {
176 setNonDiscardable(ANNOTATION_TRUE_FIXED);
177 }
178@@ -346,11 +325,12 @@
179 cast_expr::cast_expr(
180 CompilerCB* ccb,
181 static_context* sctx,
182+ user_function* udf,
183 const QueryLoc& loc,
184 expr* inputExpr,
185 const xqtref_t& type)
186 :
187- cast_base_expr(ccb, sctx, loc, cast_expr_kind, inputExpr, type)
188+ cast_base_expr(ccb, sctx, udf, loc, cast_expr_kind, inputExpr, type)
189 {
190 assert(type->get_quantifier() == TypeConstants::QUANT_ONE ||
191 type->get_quantifier() == TypeConstants::QUANT_QUESTION);
192@@ -363,21 +343,13 @@
193 }
194
195
196-expr* cast_expr::cloneImpl(substitution_t& subst) const
197-{
198- return theCCB->theEM->create_cast_expr(theSctx,
199- get_loc(),
200- get_input()->clone(subst),
201- get_target_type());
202-}
203-
204-
205 /***************************************************************************//**
206 TreatExpr ::= CastableExpr ( "treat" "as" SequenceType )?
207 ********************************************************************************/
208 treat_expr::treat_expr(
209 CompilerCB* ccb,
210 static_context* sctx,
211+ user_function* udf,
212 const QueryLoc& loc,
213 expr* inputExpr,
214 const xqtref_t& type,
215@@ -385,7 +357,7 @@
216 bool check_prime,
217 store::Item* qname)
218 :
219- cast_base_expr(ccb, sctx, loc, treat_expr_kind, inputExpr, type),
220+ cast_base_expr(ccb, sctx, udf, loc, treat_expr_kind, inputExpr, type),
221 theErrorKind(err),
222 theCheckPrime(check_prime),
223 theQName(qname)
224@@ -393,31 +365,20 @@
225 }
226
227
228-expr* treat_expr::cloneImpl(substitution_t& subst) const
229-{
230- return theCCB->theEM->create_treat_expr(theSctx,
231- get_loc(),
232- get_input()->clone(subst),
233- get_target_type(),
234- get_err(),
235- get_check_prime(),
236- get_qname());
237-}
238-
239-
240 /***************************************************************************//**
241
242 ********************************************************************************/
243 promote_expr::promote_expr(
244 CompilerCB* ccb,
245 static_context* sctx,
246+ user_function* udf,
247 const QueryLoc& loc,
248 expr* input,
249 const xqtref_t& type,
250 PromoteIterator::ErrorKind err,
251 store::Item* qname)
252 :
253- cast_base_expr(ccb, sctx, loc, promote_expr_kind, input, type),
254+ cast_base_expr(ccb, sctx, udf, loc, promote_expr_kind, input, type),
255 theErrorKind(err),
256 theQName(qname)
257 {
258@@ -427,29 +388,19 @@
259 }
260
261
262-expr* promote_expr::cloneImpl(substitution_t& subst) const
263-{
264- return theCCB->theEM->create_promote_expr(theSctx,
265- get_loc(),
266- get_input()->clone(subst),
267- get_target_type(),
268- theErrorKind,
269- theQName.getp());
270-}
271-
272-
273 /***************************************************************************//**
274 Base for castable, instanceof
275 ********************************************************************************/
276 castable_base_expr::castable_base_expr(
277 CompilerCB* ccb,
278 static_context* sctx,
279+ user_function* udf,
280 const QueryLoc& loc,
281 expr_kind_t kind,
282 expr* input,
283 const xqtref_t& type)
284 :
285- cast_or_castable_base_expr(ccb, sctx, loc, kind, input, type)
286+ cast_or_castable_base_expr(ccb, sctx, udf, loc, kind, input, type)
287 {
288 }
289
290@@ -462,11 +413,12 @@
291 castable_expr::castable_expr(
292 CompilerCB* ccb,
293 static_context* sctx,
294+ user_function* udf,
295 const QueryLoc& loc,
296 expr* inputExpr,
297 const xqtref_t& type)
298 :
299- castable_base_expr (ccb, sctx, loc, castable_expr_kind, inputExpr, type)
300+ castable_base_expr(ccb, sctx, udf, loc, castable_expr_kind, inputExpr, type)
301 {
302 }
303
304@@ -477,53 +429,37 @@
305 }
306
307
308-expr* castable_expr::cloneImpl(substitution_t& subst) const
309-{
310- return theCCB->theEM->create_castable_expr(theSctx,
311- get_loc(),
312- get_input()->clone(subst),
313- get_target_type());
314-}
315-
316-
317 /***************************************************************************//**
318 InstanceofExpr ::= TreatExpr ( "instance" "of" SequenceType )?
319 ********************************************************************************/
320 instanceof_expr::instanceof_expr(
321 CompilerCB* ccb,
322 static_context* sctx,
323+ user_function* udf,
324 const QueryLoc& loc,
325 expr* inputExpr,
326 const xqtref_t& type,
327 bool checkPrimeOnly)
328 :
329- castable_base_expr(ccb, sctx, loc, instanceof_expr_kind, inputExpr, type),
330+ castable_base_expr(ccb, sctx, udf, loc, instanceof_expr_kind, inputExpr, type),
331 theCheckPrimeOnly(checkPrimeOnly)
332 {
333 }
334
335
336-expr* instanceof_expr::cloneImpl(substitution_t& subst) const
337-{
338- return theCCB->theEM->create_instanceof_expr(theSctx,
339- get_loc(),
340- get_input()->clone(subst),
341- get_target_type());
342-}
343-
344-
345 /***************************************************************************//**
346
347 ********************************************************************************/
348 name_cast_expr::name_cast_expr(
349 CompilerCB* ccb,
350 static_context* sctx,
351+ user_function* udf,
352 const QueryLoc& loc,
353 expr* inputExpr,
354 const namespace_context* aNSCtx,
355 bool isAttrName)
356 :
357- namespace_context_base_expr(ccb, sctx, loc, name_cast_expr_kind, aNSCtx),
358+ namespace_context_base_expr(ccb, sctx, udf, loc, name_cast_expr_kind, aNSCtx),
359 theInputExpr(inputExpr),
360 theIsAttrName(isAttrName)
361 {
362@@ -542,27 +478,18 @@
363 }
364
365
366-expr* name_cast_expr::cloneImpl(substitution_t& subst) const
367-{
368- return theCCB->theEM->create_name_cast_expr(theSctx,
369- get_loc(),
370- get_input()->clone(subst),
371- getNSCtx(),
372- theIsAttrName);
373-}
374-
375-
376 /***************************************************************************//**
377 CompDocConstructor ::= "document" "{" Expr "}"
378 ********************************************************************************/
379 doc_expr::doc_expr(
380 CompilerCB* ccb,
381 static_context* sctx,
382+ user_function* udf,
383 const QueryLoc& loc,
384 expr* aContent,
385 bool copyNodes)
386 :
387- expr(ccb, sctx, loc, doc_expr_kind),
388+ expr(ccb, sctx, udf, loc, doc_expr_kind),
389 theContent(aContent),
390 theCopyInputNodes(copyNodes)
391 {
392@@ -581,22 +508,13 @@
393 }
394
395
396-expr* doc_expr::cloneImpl(substitution_t& subst) const
397-{
398- doc_expr* clone = theCCB->theEM->create_doc_expr(theSctx,
399- get_loc(),
400- CLONE(getContent(), subst),
401- theCopyInputNodes);
402- return clone;
403-}
404-
405-
406 /***************************************************************************//**
407
408 ********************************************************************************/
409 elem_expr::elem_expr(
410 CompilerCB* ccb,
411 static_context* sctx,
412+ user_function* udf,
413 const QueryLoc& aLoc,
414 expr* aQNameExpr,
415 expr* attrs,
416@@ -604,7 +522,7 @@
417 const namespace_context* aNSCtx,
418 bool copyNodes)
419 :
420- namespace_context_base_expr(ccb, sctx, aLoc, elem_expr_kind, aNSCtx),
421+ namespace_context_base_expr(ccb, sctx, udf, aLoc, elem_expr_kind, aNSCtx),
422 theQNameExpr(aQNameExpr),
423 theAttrs(attrs),
424 theContent(content),
425@@ -619,13 +537,14 @@
426 elem_expr::elem_expr(
427 CompilerCB* ccb,
428 static_context* sctx,
429+ user_function* udf,
430 const QueryLoc& aLoc,
431 expr* aQNameExpr,
432 expr* content,
433 const namespace_context* aNSCtx,
434 bool copyNodes)
435 :
436- namespace_context_base_expr(ccb, sctx, aLoc, elem_expr_kind, aNSCtx),
437+ namespace_context_base_expr(ccb, sctx, udf, aLoc, elem_expr_kind, aNSCtx),
438 theQNameExpr(aQNameExpr),
439 theAttrs(0),
440 theContent(content),
441@@ -663,30 +582,18 @@
442 }
443
444
445-expr* elem_expr::cloneImpl(substitution_t& subst) const
446-{
447- elem_expr* clone = theCCB->theEM->create_elem_expr(theSctx,
448- get_loc(),
449- CLONE(getQNameExpr(), subst),
450- CLONE(getAttrs(), subst),
451- CLONE(getContent(), subst),
452- getNSCtx(),
453- theCopyInputNodes);
454- return clone;
455-}
456-
457-
458 /***************************************************************************//**
459
460 ********************************************************************************/
461 attr_expr::attr_expr(
462 CompilerCB* ccb,
463 static_context* sctx,
464+ user_function* udf,
465 const QueryLoc& loc,
466 expr* aQNameExpr,
467 expr* aValueExpr)
468 :
469- expr(ccb, sctx, loc, attr_expr_kind),
470+ expr(ccb, sctx, udf, loc, attr_expr_kind),
471 theQNameExpr(aQNameExpr),
472 theValueExpr(aValueExpr)
473 {
474@@ -730,15 +637,6 @@
475 }
476
477
478-expr* attr_expr::cloneImpl(substitution_t& subst) const
479-{
480- return theCCB->theEM->create_attr_expr(theSctx,
481- get_loc(),
482- CLONE(getQNameExpr(), subst),
483- CLONE(getValueExpr(), subst));
484-}
485-
486-
487 DEF_EXPR_ACCEPT(attr_expr)
488
489
490@@ -748,11 +646,12 @@
491 text_expr::text_expr(
492 CompilerCB* ccb,
493 static_context* sctx,
494+ user_function* udf,
495 const QueryLoc& loc,
496 text_constructor_type type_arg,
497 expr* content)
498 :
499- expr(ccb, sctx, loc, text_expr_kind),
500+ expr(ccb, sctx, udf, loc, text_expr_kind),
501 type(type_arg),
502 theContentExpr(content)
503 {
504@@ -773,23 +672,18 @@
505 }
506
507
508-expr* text_expr::cloneImpl(substitution_t& subst) const
509-{
510- return theCCB->theEM->create_text_expr(theSctx, get_loc(), get_type(), CLONE(get_text(), subst));
511-}
512-
513-
514 /***************************************************************************//**
515
516 ********************************************************************************/
517 pi_expr::pi_expr(
518 CompilerCB* ccb,
519 static_context* sctx,
520+ user_function* udf,
521 const QueryLoc& loc,
522 expr* targetExpr,
523 expr* contentExpr)
524 :
525- expr(ccb, sctx, loc, pi_expr_kind),
526+ expr(ccb, sctx, udf, loc, pi_expr_kind),
527 theTargetExpr(targetExpr),
528 theContentExpr(contentExpr)
529 {
530@@ -823,23 +717,18 @@
531 }
532
533
534-expr* pi_expr::cloneImpl(substitution_t& subst) const
535-{
536- return theCCB->theEM->create_pi_expr(theSctx,
537- get_loc(),
538- CLONE(get_target_expr(), subst),
539- CLONE(get_content_expr(), subst));
540-}
541-
542-
543-
544 /*******************************************************************************
545 Normally, it is used to wrap a var_expr in order to represent a var reference
546 (see var_expr.h). But it may wrap any other kind of expr as well.
547 ********************************************************************************/
548-wrapper_expr::wrapper_expr(CompilerCB* ccb, static_context* sctx, const QueryLoc& loc, expr* wrapped)
549+wrapper_expr::wrapper_expr(
550+ CompilerCB* ccb,
551+ static_context* sctx,
552+ user_function* udf,
553+ const QueryLoc& loc,
554+ expr* wrapped)
555 :
556- expr(ccb, sctx, loc, wrapper_expr_kind),
557+ expr(ccb, sctx, udf, loc, wrapper_expr_kind),
558 theWrappedExpr(wrapped)
559 {
560 compute_scripting_kind();
561@@ -852,77 +741,89 @@
562 }
563
564
565-expr* wrapper_expr::cloneImpl(substitution_t& subst) const
566-{
567- expr* e = theWrappedExpr->clone(subst);
568-
569- if (theWrappedExpr->get_expr_kind() == var_expr_kind &&
570- e->get_expr_kind() != var_expr_kind)
571- return e;
572- else
573- return theCCB->theEM->create_wrapper_expr(theSctx, get_loc(), e);
574-}
575-
576-
577 /***************************************************************************//**
578
579 ********************************************************************************/
580-const_expr::const_expr(CompilerCB* ccb, static_context* sctx, const QueryLoc& loc, zstring& v)
581+const_expr::const_expr(
582+ CompilerCB* ccb,
583+ static_context* sctx,
584+ user_function* udf,
585+ const QueryLoc& loc,
586+ zstring& v)
587 :
588- expr(ccb, sctx, loc, const_expr_kind)
589+ expr(ccb, sctx, udf, loc, const_expr_kind)
590 {
591 GENV_ITEMFACTORY->createString(theValue, v);
592 theScriptingKind = SIMPLE_EXPR;
593 }
594
595
596-const_expr::const_expr(CompilerCB* ccb, static_context* sctx, const QueryLoc& loc, const std::string& v)
597- :
598- expr(ccb, sctx, loc, const_expr_kind)
599-{
600- zstring tmp(v);
601- GENV_ITEMFACTORY->createString(theValue, tmp);
602- theScriptingKind = SIMPLE_EXPR;
603-}
604-
605-
606-const_expr::const_expr(CompilerCB* ccb, static_context* sctx, const QueryLoc& loc, const char* v)
607- :
608- expr(ccb, sctx, loc, const_expr_kind)
609-{
610- zstring tmp(v);
611- GENV_ITEMFACTORY->createString(theValue, tmp);
612- theScriptingKind = SIMPLE_EXPR;
613-}
614-
615-
616-const_expr::const_expr(CompilerCB* ccb, static_context* sctx, const QueryLoc& loc, xs_integer v)
617- :
618- expr(ccb, sctx, loc, const_expr_kind)
619+const_expr::const_expr(
620+ CompilerCB* ccb,
621+ static_context* sctx,
622+ user_function* udf,
623+ const QueryLoc& loc,
624+ const std::string& v)
625+ :
626+ expr(ccb, sctx, udf, loc, const_expr_kind)
627+{
628+ zstring tmp(v);
629+ GENV_ITEMFACTORY->createString(theValue, tmp);
630+ theScriptingKind = SIMPLE_EXPR;
631+}
632+
633+
634+const_expr::const_expr(
635+ CompilerCB* ccb,
636+ static_context* sctx,
637+ user_function* udf,
638+ const QueryLoc& loc,
639+ const char* v)
640+ :
641+ expr(ccb, sctx, udf, loc, const_expr_kind)
642+{
643+ zstring tmp(v);
644+ GENV_ITEMFACTORY->createString(theValue, tmp);
645+ theScriptingKind = SIMPLE_EXPR;
646+}
647+
648+
649+const_expr::const_expr(
650+ CompilerCB* ccb,
651+ static_context* sctx,
652+ user_function* udf,
653+ const QueryLoc& loc,
654+ xs_integer v)
655+ :
656+ expr(ccb, sctx, udf, loc, const_expr_kind)
657 {
658 GENV_ITEMFACTORY->createInteger(theValue, v);
659 theScriptingKind = SIMPLE_EXPR;
660 }
661
662+
663 const_expr::const_expr(
664 CompilerCB* ccb,
665 static_context* sctx,
666+ user_function* udf,
667 const QueryLoc& loc,
668 xs_decimal v)
669 :
670- expr(ccb, sctx, loc, const_expr_kind)
671+ expr(ccb, sctx, udf, loc, const_expr_kind)
672 {
673 GENV_ITEMFACTORY->createDecimal(theValue, v);
674 theScriptingKind = SIMPLE_EXPR;
675 }
676
677+
678 const_expr::const_expr(
679 CompilerCB* ccb,
680 static_context* sctx,
681+ user_function* udf,
682 const QueryLoc& loc,
683 xs_double v)
684 :
685- expr(ccb, sctx, loc, const_expr_kind)
686+ expr(ccb, sctx, udf, loc, const_expr_kind)
687 {
688 GENV_ITEMFACTORY->createDouble(theValue, v);
689 theScriptingKind = SIMPLE_EXPR;
690@@ -932,10 +833,11 @@
691 const_expr::const_expr(
692 CompilerCB* ccb,
693 static_context* sctx,
694+ user_function* udf,
695 const QueryLoc& loc,
696 xs_boolean v)
697 :
698- expr(ccb, sctx, loc, const_expr_kind)
699+ expr(ccb, sctx, udf, loc, const_expr_kind)
700 {
701 GENV_ITEMFACTORY->createBoolean(theValue, v);
702 theScriptingKind = SIMPLE_EXPR;
703@@ -945,10 +847,11 @@
704 const_expr::const_expr(
705 CompilerCB* ccb,
706 static_context* sctx,
707+ user_function* udf,
708 const QueryLoc& loc,
709 const store::Item_t& v)
710 :
711- expr(ccb, sctx, loc, const_expr_kind),
712+ expr(ccb, sctx, udf, loc, const_expr_kind),
713 theValue(v)
714 {
715 theScriptingKind = SIMPLE_EXPR;
716@@ -958,12 +861,13 @@
717 const_expr::const_expr(
718 CompilerCB* ccb,
719 static_context* sctx,
720+ user_function* udf,
721 const QueryLoc& aLoc,
722 const char* aNamespace,
723 const char* aPrefix,
724 const char* aLocal)
725 :
726- expr(ccb, sctx, aLoc, const_expr_kind)
727+ expr(ccb, sctx, udf, aLoc, const_expr_kind)
728 {
729 GENV_ITEMFACTORY->createQName(theValue, aNamespace, aPrefix, aLocal);
730 theScriptingKind = SIMPLE_EXPR;
731@@ -976,21 +880,16 @@
732 }
733
734
735-expr* const_expr::cloneImpl(substitution_t&) const
736-{
737- return theCCB->theEM->create_const_expr(theSctx, get_loc(), theValue);
738-}
739-
740-
741 /*******************************************************************************
742
743 ********************************************************************************/
744 extension_expr::extension_expr(
745 CompilerCB* ccb,
746 static_context* sctx,
747+ user_function* udf,
748 const QueryLoc& loc)
749 :
750- expr(ccb, sctx, loc, extension_expr_kind)
751+ expr(ccb, sctx, udf, loc, extension_expr_kind)
752 {
753 compute_scripting_kind();
754 }
755@@ -999,10 +898,11 @@
756 extension_expr::extension_expr(
757 CompilerCB* ccb,
758 static_context* sctx,
759+ user_function* udf,
760 const QueryLoc& loc,
761 expr* e)
762 :
763- expr(ccb, sctx, loc, extension_expr_kind),
764+ expr(ccb, sctx, udf, loc, extension_expr_kind),
765 theExpr(e)
766 {
767 compute_scripting_kind();
768@@ -1020,23 +920,6 @@
769 }
770
771
772-expr* extension_expr::cloneImpl(substitution_t& subst) const
773-{
774- extension_expr* lClone(0);
775- lClone = (
776- theExpr == 0 ? theCCB->theEM->create_extension_expr(theSctx, get_loc())
777- : theCCB->theEM->create_extension_expr(theSctx, get_loc(), theExpr->clone()) );
778- // pragm doesn't contain expressions. Thus, it is not cloned.
779- for ( std::vector<pragma*>::const_iterator lIter = thePragmas.begin();
780- lIter != thePragmas.end();
781- ++lIter )
782- {
783- lClone->add(*lIter);
784- }
785- return lClone;
786-}
787-
788-
789 /////////////////////////////////////////////////////////////////////////
790 // //
791 // XQuery 3.0 expressions //
792@@ -1049,7 +932,8 @@
793
794 ********************************************************************************/
795 catch_clause::catch_clause(CompilerCB* ccb)
796-:theCCB(ccb)
797+ :
798+ theCCB(ccb)
799 {
800 }
801
802@@ -1057,10 +941,11 @@
803 trycatch_expr::trycatch_expr(
804 CompilerCB* ccb,
805 static_context* sctx,
806+ user_function* udf,
807 const QueryLoc& loc,
808 expr* tryExpr)
809 :
810- expr(ccb, sctx, loc, trycatch_expr_kind),
811+ expr(ccb, sctx, udf, loc, trycatch_expr_kind),
812 theTryExpr(tryExpr)
813 {
814 compute_scripting_kind();
815@@ -1145,6 +1030,7 @@
816 {
817 lClause->add_nametest_h(lIter->getp());
818 }
819+
820 for (var_map_t::const_iterator lIter = theVarMap.begin();
821 lIter != theVarMap.end();
822 ++lIter)
823@@ -1156,39 +1042,19 @@
824 }
825
826
827-expr* trycatch_expr::cloneImpl(substitution_t& subst) const
828-{
829- std::auto_ptr<trycatch_expr> lTryCatch(
830- theCCB->theEM->create_trycatch_expr(theSctx, get_loc(), theTryExpr->clone(subst)));
831-
832- for (std::vector<expr*>::const_iterator lIter = theCatchExprs.begin();
833- lIter != theCatchExprs.end();
834- ++lIter)
835- {
836- lTryCatch->add_catch_expr((*lIter)->clone(subst));
837- }
838-
839- for (csize i = 0; i < clause_count(); ++i)
840- {
841- lTryCatch->add_clause(theCatchClauses[i]->clone(subst));
842- }
843-
844- return lTryCatch.release();
845-}
846-
847-
848 /*******************************************************************************
849
850 ********************************************************************************/
851 eval_expr::eval_expr(
852 CompilerCB* ccb,
853 static_context* sctx,
854+ user_function* udf,
855 const QueryLoc& loc,
856 expr* e,
857 expr_script_kind_t scriptingKind,
858 namespace_context* nsCtx)
859 :
860- namespace_context_base_expr(ccb, sctx, loc, eval_expr_kind, nsCtx),
861+ namespace_context_base_expr(ccb, sctx, udf, loc, eval_expr_kind, nsCtx),
862 theExpr(e),
863 theInnerScriptingKind(scriptingKind),
864 theDoNodeCopy(false)
865@@ -1222,33 +1088,6 @@
866 }
867
868
869-expr* eval_expr::cloneImpl(substitution_t& s) const
870-{
871- eval_expr* new_eval = theCCB->theEM->
872- create_eval_expr(theSctx,
873- theLoc,
874- theExpr->clone(s),
875- theInnerScriptingKind,
876- theNSCtx.getp());
877-
878- new_eval->setNodeCopy(theDoNodeCopy);
879-
880- new_eval->theOuterVarNames = theOuterVarNames;
881- new_eval->theOuterVarTypes = theOuterVarTypes;
882-
883- csize numVars = theOuterVarNames.size();
884-
885- new_eval->theArgs.resize(numVars);
886-
887- for (csize i = 0; i < numVars; ++i)
888- {
889- new_eval->theArgs[i] = theArgs[i]->clone(s);
890- }
891-
892- return new_eval;
893-}
894-
895-
896 #ifdef ZORBA_WITH_DEBUGGER
897 /*******************************************************************************
898
899@@ -1256,12 +1095,13 @@
900 debugger_expr::debugger_expr(
901 CompilerCB* ccb,
902 static_context* sctx,
903+ user_function* udf,
904 const QueryLoc& loc,
905 expr* aChild,
906 namespace_context* nsCtx,
907 bool aIsVarDeclaration)
908 :
909- namespace_context_base_expr(ccb, sctx, loc, debugger_expr_kind, nsCtx),
910+ namespace_context_base_expr(ccb, sctx, udf, loc, debugger_expr_kind, nsCtx),
911 theExpr(aChild),
912 theIsVarDeclaration(aIsVarDeclaration)
913 {
914@@ -1283,10 +1123,11 @@
915 function_trace_expr::function_trace_expr(
916 CompilerCB* ccb,
917 static_context* sctx,
918+ user_function* udf,
919 const QueryLoc& loc,
920 expr* aChild)
921 :
922- expr(ccb, sctx, loc, aChild->get_expr_kind()),
923+ expr(ccb, sctx, udf, loc, aChild->get_expr_kind()),
924 theExpr(aChild),
925 theFunctionArity(0)
926 {
927@@ -1296,9 +1137,13 @@
928 }
929
930
931-function_trace_expr::function_trace_expr(expr* aExpr)
932+function_trace_expr::function_trace_expr(user_function* udf, expr* aExpr)
933 :
934- expr(aExpr->get_ccb(), aExpr->get_sctx(), aExpr->get_loc(), function_trace_expr_kind),
935+ expr(aExpr->get_ccb(),
936+ aExpr->get_sctx(),
937+ udf,
938+ aExpr->get_loc(),
939+ function_trace_expr_kind),
940 theExpr(aExpr),
941 theFunctionArity(0)
942 {
943@@ -1319,20 +1164,5 @@
944 }
945
946
947-expr* function_trace_expr::cloneImpl(substitution_t& s) const
948-{
949- function_trace_expr* clone = theCCB->theEM->
950- create_function_trace_expr(theExpr->clone(s));
951-
952- clone->theFunctionName = theFunctionName;
953- clone->theFunctionLocation = theFunctionLocation;
954- clone->theFunctionCallLocation = theFunctionCallLocation;
955- clone->theFunctionArity = theFunctionArity;
956-
957- return clone;
958-}
959-
960-
961-
962 } /* namespace zorba */
963 /* vim:set et sw=2 ts=2: */
964
965=== modified file 'src/compiler/expression/expr.h'
966--- src/compiler/expression/expr.h 2012-10-08 12:09:36 +0000
967+++ src/compiler/expression/expr.h 2012-10-09 13:35:26 +0000
968@@ -58,14 +58,15 @@
969 friend class expr;
970
971 protected:
972- expr* theCondExpr;
973- expr* theThenExpr;
974- expr* theElseExpr;
975+ expr * theCondExpr;
976+ expr * theThenExpr;
977+ expr * theElseExpr;
978
979 protected:
980 if_expr(
981 CompilerCB* ccb,
982 static_context* sctx,
983+ user_function* udf,
984 const QueryLoc& loc,
985 expr* c,
986 expr* t,
987@@ -80,8 +81,6 @@
988
989 void compute_scripting_kind();
990
991- expr* cloneImpl(substitution_t& s) const;
992-
993 void accept(expr_visitor&);
994
995 std::ostream& put(std::ostream&) const;
996@@ -105,11 +104,17 @@
997 };
998
999 protected:
1000- order_type_t theType;
1001- expr* theExpr;
1002+ order_type_t theType;
1003+ expr * theExpr;
1004
1005 protected:
1006- order_expr(CompilerCB* ccb, static_context* sctx, const QueryLoc&, order_type_t, expr*);
1007+ order_expr(
1008+ CompilerCB* ccb,
1009+ static_context* sctx,
1010+ user_function* udf,
1011+ const QueryLoc&,
1012+ order_type_t,
1013+ expr*);
1014
1015 public:
1016 order_type_t get_type() const { return theType; }
1017@@ -118,8 +123,6 @@
1018
1019 void compute_scripting_kind();
1020
1021- expr* cloneImpl(substitution_t& s) const;
1022-
1023 void accept(expr_visitor&);
1024
1025 std::ostream& put(std::ostream&) const;
1026@@ -139,17 +142,18 @@
1027 ParseConstants::validation_mode_t theMode;
1028 store::Item_t theTypeName;
1029 rchandle<TypeManager> theTypeMgr;
1030- expr* theExpr;
1031+ expr * theExpr;
1032
1033 protected:
1034 validate_expr(
1035- CompilerCB* ccb,
1036- static_context* sctx,
1037- const QueryLoc&,
1038- ParseConstants::validation_mode_t,
1039- const store::Item_t& aTypeName,
1040- expr*,
1041- rchandle<TypeManager>);
1042+ CompilerCB* ccb,
1043+ static_context* sctx,
1044+ user_function* udf,
1045+ const QueryLoc&,
1046+ ParseConstants::validation_mode_t,
1047+ const store::Item_t& aTypeName,
1048+ expr*,
1049+ rchandle<TypeManager>);
1050
1051 public:
1052 expr* get_expr() const { return theExpr; }
1053@@ -162,8 +166,6 @@
1054
1055 void compute_scripting_kind();
1056
1057- expr* cloneImpl(substitution_t& s) const;
1058-
1059 void accept(expr_visitor&);
1060
1061 std::ostream& put(std::ostream&) const;
1062@@ -184,6 +186,7 @@
1063 namespace_context_base_expr(
1064 CompilerCB* ccb,
1065 static_context* sctx,
1066+ user_function* udf,
1067 const QueryLoc& loc,
1068 expr_kind_t kind,
1069 const namespace_context* aNSCtx);
1070@@ -207,12 +210,13 @@
1071
1072 protected:
1073 cast_or_castable_base_expr(
1074- CompilerCB* ccb,
1075- static_context* sctx,
1076- const QueryLoc& loc,
1077- expr_kind_t kind,
1078- expr* input,
1079- const xqtref_t& type);
1080+ CompilerCB* ccb,
1081+ static_context* sctx,
1082+ user_function* udf,
1083+ const QueryLoc& loc,
1084+ expr_kind_t kind,
1085+ expr* input,
1086+ const xqtref_t& type);
1087
1088 public:
1089 expr* get_input() const { return theInputExpr; }
1090@@ -234,12 +238,13 @@
1091
1092 protected:
1093 cast_base_expr(
1094- CompilerCB* ccb,
1095- static_context* sctx,
1096- const QueryLoc& loc,
1097- expr_kind_t kind,
1098- expr* input,
1099- const xqtref_t& type);
1100+ CompilerCB* ccb,
1101+ static_context* sctx,
1102+ user_function* udf,
1103+ const QueryLoc& loc,
1104+ expr_kind_t kind,
1105+ expr* input,
1106+ const xqtref_t& type);
1107 };
1108
1109
1110@@ -258,6 +263,7 @@
1111 cast_expr(
1112 CompilerCB* ccb,
1113 static_context* sctx,
1114+ user_function* udf,
1115 const QueryLoc&,
1116 expr*,
1117 const xqtref_t&);
1118@@ -265,8 +271,6 @@
1119 public:
1120 bool is_optional() const;
1121
1122- expr* cloneImpl(substitution_t& s) const;
1123-
1124 void accept(expr_visitor&);
1125
1126 std::ostream& put(std::ostream&) const;
1127@@ -299,14 +303,15 @@
1128
1129 protected:
1130 treat_expr(
1131- CompilerCB* ccb,
1132- static_context* sctx,
1133- const QueryLoc&,
1134- expr*,
1135- const xqtref_t&,
1136- TreatIterator::ErrorKind err,
1137- bool check_prime = true,
1138- store::Item* qname = NULL);
1139+ CompilerCB* ccb,
1140+ static_context* sctx,
1141+ user_function* udf,
1142+ const QueryLoc&,
1143+ expr*,
1144+ const xqtref_t&,
1145+ TreatIterator::ErrorKind err,
1146+ bool check_prime = true,
1147+ store::Item* qname = NULL);
1148
1149 public:
1150 TreatIterator::ErrorKind get_err() const { return theErrorKind; }
1151@@ -319,8 +324,6 @@
1152
1153 store::Item_t get_qname() const { return theQName; }
1154
1155- expr* cloneImpl(substitution_t& s) const;
1156-
1157 void accept(expr_visitor&);
1158
1159 std::ostream& put(std::ostream&) const;
1160@@ -379,6 +382,7 @@
1161 promote_expr(
1162 CompilerCB* ccb,
1163 static_context* sctx,
1164+ user_function* udf,
1165 const QueryLoc& loc,
1166 expr* input,
1167 const xqtref_t& type,
1168@@ -386,8 +390,6 @@
1169 store::Item* qname);
1170
1171 public:
1172- expr* cloneImpl(substitution_t& s) const;
1173-
1174 PromoteIterator::ErrorKind get_err() const { return theErrorKind; }
1175
1176 void set_qname(const store::Item_t& qname) { theQName = qname; }
1177@@ -409,12 +411,13 @@
1178
1179 protected:
1180 castable_base_expr(
1181- CompilerCB* ccb,
1182- static_context* sctx,
1183- const QueryLoc&,
1184- expr_kind_t kind,
1185- expr*,
1186- const xqtref_t&);
1187+ CompilerCB* ccb,
1188+ static_context* sctx,
1189+ user_function* udf,
1190+ const QueryLoc&,
1191+ expr_kind_t kind,
1192+ expr*,
1193+ const xqtref_t&);
1194 };
1195
1196
1197@@ -433,6 +436,7 @@
1198 castable_expr(
1199 CompilerCB* ccb,
1200 static_context* sctx,
1201+ user_function* udf,
1202 const QueryLoc&,
1203 expr*,
1204 const xqtref_t&);
1205@@ -440,8 +444,6 @@
1206 public:
1207 bool is_optional() const;
1208
1209- expr* cloneImpl(substitution_t& s) const;
1210-
1211 void accept(expr_visitor&);
1212
1213 std::ostream& put(std::ostream&) const;
1214@@ -470,6 +472,7 @@
1215 instanceof_expr(
1216 CompilerCB* ccb,
1217 static_context* sctx,
1218+ user_function* udf,
1219 const QueryLoc&,
1220 expr*,
1221 const xqtref_t&,
1222@@ -478,8 +481,6 @@
1223 public:
1224 bool getCheckPrimeOnly() const { return theCheckPrimeOnly; }
1225
1226- expr* cloneImpl(substitution_t& s) const;
1227-
1228 void accept(expr_visitor&);
1229
1230 std::ostream& put(std::ostream&) const;
1231@@ -510,6 +511,7 @@
1232 name_cast_expr(
1233 CompilerCB* ccb,
1234 static_context* sctx,
1235+ user_function* udf,
1236 const QueryLoc&,
1237 expr*,
1238 const namespace_context*,
1239@@ -522,8 +524,6 @@
1240
1241 void compute_scripting_kind();
1242
1243- expr* cloneImpl(substitution_t& s) const;
1244-
1245 void accept(expr_visitor&);
1246
1247 std::ostream& put(std::ostream&) const;
1248@@ -540,11 +540,17 @@
1249 friend class expr;
1250
1251 protected:
1252- expr* theContent;
1253- bool theCopyInputNodes;
1254+ expr * theContent;
1255+ bool theCopyInputNodes;
1256
1257 protected:
1258- doc_expr(CompilerCB* ccb, static_context* sctx, const QueryLoc&, expr* content, bool copyNodes);
1259+ doc_expr(
1260+ CompilerCB* ccb,
1261+ static_context* sctx,
1262+ user_function* udf,
1263+ const QueryLoc&,
1264+ expr* content,
1265+ bool copyNodes);
1266
1267 public:
1268 expr* getContent() const { return theContent; }
1269@@ -555,8 +561,6 @@
1270
1271 void compute_scripting_kind();
1272
1273- expr* cloneImpl(substitution_t& s) const;
1274-
1275 void accept(expr_visitor&);
1276
1277 std::ostream& put(std::ostream&) const;
1278@@ -596,25 +600,27 @@
1279 friend class expr;
1280
1281 protected:
1282- expr* theQNameExpr;
1283- expr* theAttrs;
1284- expr* theContent;
1285- bool theCopyInputNodes;
1286+ expr * theQNameExpr;
1287+ expr * theAttrs;
1288+ expr * theContent;
1289+ bool theCopyInputNodes;
1290
1291 protected:
1292 elem_expr(
1293- CompilerCB* ccb,
1294- static_context* sctx,
1295- const QueryLoc&,
1296- expr* qnameExpr,
1297- expr* attrs,
1298- expr* content,
1299- const namespace_context* nsCtx,
1300- bool copyNodes);
1301+ CompilerCB* ccb,
1302+ static_context* sctx,
1303+ user_function* udf,
1304+ const QueryLoc&,
1305+ expr* qnameExpr,
1306+ expr* attrs,
1307+ expr* content,
1308+ const namespace_context* nsCtx,
1309+ bool copyNodes);
1310
1311 elem_expr(
1312 CompilerCB* ccb,
1313 static_context* sctx,
1314+ user_function* udf,
1315 const QueryLoc&,
1316 expr* qnameExpr,
1317 expr* content,
1318@@ -634,8 +640,6 @@
1319
1320 void compute_scripting_kind();
1321
1322- expr* cloneImpl(substitution_t& s) const;
1323-
1324 void accept(expr_visitor&);
1325
1326 std::ostream& put(std::ostream&) const;
1327@@ -673,16 +677,17 @@
1328 friend class expr;
1329
1330 protected:
1331- expr* theQNameExpr;
1332- expr* theValueExpr;
1333+ expr * theQNameExpr;
1334+ expr * theValueExpr;
1335
1336 protected:
1337 attr_expr(
1338- CompilerCB* ccb,
1339- static_context* sctx,
1340- const QueryLoc& loc,
1341- expr* aQNameExpr,
1342- expr* aValueExpr);
1343+ CompilerCB* ccb,
1344+ static_context* sctx,
1345+ user_function* udf,
1346+ const QueryLoc& loc,
1347+ expr* aQNameExpr,
1348+ expr* aValueExpr);
1349
1350 public:
1351 expr* getQNameExpr() const { return theQNameExpr; }
1352@@ -693,8 +698,6 @@
1353
1354 void compute_scripting_kind();
1355
1356- expr* cloneImpl(substitution_t& s) const;
1357-
1358 void accept(expr_visitor&);
1359
1360 std::ostream& put(std::ostream&) const;
1361@@ -718,13 +721,14 @@
1362 } text_constructor_type;
1363
1364 protected:
1365- text_constructor_type type;
1366- expr* theContentExpr;
1367+ text_constructor_type type;
1368+ expr * theContentExpr;
1369
1370 protected:
1371 text_expr(
1372 CompilerCB* ccb,
1373 static_context* sctx,
1374+ user_function* udf,
1375 const QueryLoc&,
1376 text_constructor_type,
1377 expr*);
1378@@ -736,8 +740,6 @@
1379
1380 void compute_scripting_kind();
1381
1382- expr* cloneImpl(substitution_t& s) const;
1383-
1384 void accept(expr_visitor&);
1385
1386 std::ostream& put(std::ostream&) const;
1387@@ -754,11 +756,17 @@
1388 friend class expr;
1389
1390 protected:
1391- expr* theTargetExpr;
1392- expr* theContentExpr;
1393+ expr * theTargetExpr;
1394+ expr * theContentExpr;
1395
1396 protected:
1397- pi_expr(CompilerCB* ccb, static_context* sctx, const QueryLoc&, expr*, expr*);
1398+ pi_expr(
1399+ CompilerCB* ccb,
1400+ static_context* sctx,
1401+ user_function* udf,
1402+ const QueryLoc&,
1403+ expr*,
1404+ expr*);
1405
1406 public:
1407 expr* get_target_expr() const { return theTargetExpr; }
1408@@ -767,8 +775,6 @@
1409
1410 void compute_scripting_kind();
1411
1412- expr* cloneImpl(substitution_t& s) const;
1413-
1414 void accept(expr_visitor&);
1415
1416 std::ostream& put(std::ostream&) const;
1417@@ -788,31 +794,76 @@
1418 store::Item_t theValue;
1419
1420 protected:
1421- const_expr(CompilerCB*, static_context*, const QueryLoc&, zstring& sval);
1422-
1423- const_expr(CompilerCB*, static_context*, const QueryLoc&, const std::string& sval);
1424-
1425- const_expr(CompilerCB*, static_context*, const QueryLoc&, const char* sval);
1426-
1427- const_expr(CompilerCB*, static_context*, const QueryLoc&, xs_integer);
1428-
1429- const_expr(CompilerCB*, static_context*, const QueryLoc&, xs_decimal);
1430-
1431- const_expr(CompilerCB*, static_context*, const QueryLoc&, xs_double);
1432-
1433- const_expr(CompilerCB*, static_context*, const QueryLoc&, xs_boolean);
1434-
1435- const_expr(CompilerCB*, static_context*, const QueryLoc&, const store::Item_t&);
1436-
1437- const_expr(CompilerCB*, static_context*, const QueryLoc&, const char* ns, const char* pre, const char* local);
1438+ const_expr(
1439+ CompilerCB*,
1440+ static_context*,
1441+ user_function* udf,
1442+ const QueryLoc&,
1443+ zstring& sval);
1444+
1445+ const_expr(
1446+ CompilerCB*,
1447+ static_context*,
1448+ user_function* udf,
1449+ const QueryLoc&,
1450+ const std::string& sval);
1451+
1452+ const_expr(
1453+ CompilerCB*,
1454+ static_context*,
1455+ user_function* udf,
1456+ const QueryLoc&,
1457+ const char* sval);
1458+
1459+ const_expr(
1460+ CompilerCB*,
1461+ static_context*,
1462+ user_function* udf,
1463+ const QueryLoc&,
1464+ xs_integer);
1465+
1466+ const_expr(
1467+ CompilerCB*,
1468+ static_context*,
1469+ user_function* udf,
1470+ const QueryLoc&,
1471+ xs_decimal);
1472+
1473+ const_expr(
1474+ CompilerCB*,
1475+ static_context*,
1476+ user_function* udf,
1477+ const QueryLoc&,
1478+ xs_double);
1479+
1480+ const_expr(
1481+ CompilerCB*,
1482+ static_context*,
1483+ user_function* udf,
1484+ const QueryLoc&,
1485+ xs_boolean);
1486+
1487+ const_expr(
1488+ CompilerCB*,
1489+ static_context*,
1490+ user_function* udf,
1491+ const QueryLoc&,
1492+ const store::Item_t&);
1493+
1494+ const_expr(
1495+ CompilerCB*,
1496+ static_context*,
1497+ user_function* udf,
1498+ const QueryLoc&,
1499+ const char* ns,
1500+ const char* pre,
1501+ const char* local);
1502
1503 public:
1504 store::Item* get_val() const { return theValue.getp(); }
1505
1506 void compute_scripting_kind();
1507
1508- expr* cloneImpl(substitution_t& s) const;
1509-
1510 void accept(expr_visitor&);
1511
1512 std::ostream& put(std::ostream&) const;
1513@@ -829,13 +880,22 @@
1514 friend class expr;
1515
1516 protected:
1517- std::vector<pragma*> thePragmas;
1518- expr* theExpr;
1519+ std::vector<pragma*> thePragmas;
1520+ expr * theExpr;
1521
1522 protected:
1523- extension_expr(CompilerCB* ccb, static_context* sctx, const QueryLoc&);
1524+ extension_expr(
1525+ CompilerCB* ccb,
1526+ static_context* sctx,
1527+ user_function* udf,
1528+ const QueryLoc&);
1529
1530- extension_expr(CompilerCB* ccb, static_context* sctx, const QueryLoc&, expr*);
1531+ extension_expr(
1532+ CompilerCB* ccb,
1533+ static_context* sctx,
1534+ user_function* udf,
1535+ const QueryLoc&,
1536+ expr*);
1537
1538 public:
1539 void add(pragma* p) { thePragmas.push_back(p); }
1540@@ -844,8 +904,6 @@
1541
1542 void compute_scripting_kind();
1543
1544- expr* cloneImpl(substitution_t& subst) const;
1545-
1546 void accept(expr_visitor&);
1547
1548 std::ostream& put(std::ostream&) const;
1549@@ -934,7 +992,12 @@
1550 std::vector<catch_clause*> theCatchClauses;
1551
1552 protected:
1553- trycatch_expr(CompilerCB* ccb, static_context* sctx, const QueryLoc&, expr* tryExpr);
1554+ trycatch_expr(
1555+ CompilerCB* ccb,
1556+ static_context* sctx,
1557+ user_function* udf,
1558+ const QueryLoc&,
1559+ expr* tryExpr);
1560
1561 public:
1562 expr* get_try_expr() const { return theTryExpr; }
1563@@ -953,8 +1016,6 @@
1564
1565 void compute_scripting_kind();
1566
1567- expr* cloneImpl(substitution_t& subst) const;
1568-
1569 void accept(expr_visitor&);
1570
1571 std::ostream& put(std::ostream&) const;
1572@@ -979,10 +1040,15 @@
1573 friend class ExprManager;
1574
1575 protected:
1576- expr* theWrappedExpr;
1577+ expr * theWrappedExpr;
1578
1579 protected:
1580- wrapper_expr(CompilerCB* ccb, static_context* sctx, const QueryLoc& loc, expr* wrapped);
1581+ wrapper_expr(
1582+ CompilerCB* ccb,
1583+ static_context* sctx,
1584+ user_function* udf,
1585+ const QueryLoc& loc,
1586+ expr* wrapped);
1587
1588 public:
1589 expr* get_expr() const { return theWrappedExpr; }
1590@@ -993,8 +1059,6 @@
1591
1592 void accept(expr_visitor&);
1593
1594- expr* cloneImpl(substitution_t& s) const;
1595-
1596 std::ostream& put(std::ostream&) const;
1597 };
1598
1599@@ -1019,10 +1083,13 @@
1600 function_trace_expr(
1601 CompilerCB* ccb,
1602 static_context* sctx,
1603+ user_function* udf,
1604 const QueryLoc& loc,
1605 expr* aChild);
1606
1607- function_trace_expr(expr* aExpr);
1608+ function_trace_expr(
1609+ user_function* udf,
1610+ expr* aExpr);
1611
1612 public:
1613 virtual ~function_trace_expr();
1614@@ -1031,8 +1098,6 @@
1615
1616 void accept(expr_visitor&);
1617
1618- expr* cloneImpl(substitution_t& s) const;
1619-
1620 std::ostream& put(std::ostream&) const;
1621
1622 expr* get_expr() const { return theExpr; }
1623@@ -1133,6 +1198,7 @@
1624 eval_expr(
1625 CompilerCB* ccb,
1626 static_context* sctx,
1627+ user_function* udf,
1628 const QueryLoc& loc,
1629 expr* e,
1630 expr_script_kind_t scriptingKind,
1631@@ -1166,8 +1232,6 @@
1632
1633 void accept(expr_visitor&);
1634
1635- expr* cloneImpl(substitution_t& s) const;
1636-
1637 std::ostream& put(std::ostream&) const;
1638 };
1639
1640@@ -1205,6 +1269,7 @@
1641 debugger_expr(
1642 CompilerCB* ccb,
1643 static_context* sctx,
1644+ user_function* udf,
1645 const QueryLoc& loc,
1646 expr* aChild,
1647 namespace_context* nsCtx,
1648
1649=== modified file 'src/compiler/expression/expr_base.cpp'
1650--- src/compiler/expression/expr_base.cpp 2012-10-08 12:09:36 +0000
1651+++ src/compiler/expression/expr_base.cpp 2012-10-09 13:35:26 +0000
1652@@ -19,7 +19,6 @@
1653 #include "compiler/expression/expr.h"
1654 #include "compiler/expression/fo_expr.h"
1655 #include "compiler/expression/flwor_expr.h"
1656-#include "compiler/expression/script_exprs.h"
1657 #include "compiler/expression/path_expr.h"
1658 #include "compiler/expression/expr_iter.h"
1659 #include "compiler/expression/expr_visitor.h"
1660@@ -123,13 +122,19 @@
1661 /*******************************************************************************
1662
1663 ********************************************************************************/
1664-expr::expr(CompilerCB* ccb, static_context* sctx, const QueryLoc& loc, expr_kind_t k)
1665+expr::expr(
1666+ CompilerCB* ccb,
1667+ static_context* sctx,
1668+ user_function* udf,
1669+ const QueryLoc& loc,
1670+ expr_kind_t k)
1671 :
1672+ theCCB(ccb),
1673 theSctx(sctx),
1674+ theUDF(udf),
1675 theLoc(loc),
1676 theKind(k),
1677- theFlags1(0),
1678- theCCB(ccb)
1679+ theFlags1(0)
1680 {
1681 theScriptingKind = UNKNOWN_SCRIPTING_KIND;
1682
1683@@ -239,40 +244,6 @@
1684 /*******************************************************************************
1685
1686 ********************************************************************************/
1687-expr* expr::clone() const
1688-{
1689- substitution_t subst;
1690- return clone(subst);
1691-}
1692-
1693-
1694-expr* expr::clone(substitution_t& subst) const
1695-{
1696- expr* lNewExpr = cloneImpl(subst);
1697-
1698- if (containsPragma())
1699- {
1700- lNewExpr->setContainsPragma(ANNOTATION_TRUE);
1701- std::vector<pragma*> lPragmas;
1702- theCCB->lookup_pragmas(this, lPragmas);
1703- for (size_t i = 0; i < lPragmas.size(); ++i)
1704- {
1705- theCCB->add_pragma(lNewExpr, lPragmas[i]);
1706- }
1707- }
1708- return lNewExpr;
1709-}
1710-
1711-
1712-expr* expr::cloneImpl(substitution_t& subst) const
1713-{
1714- throw XQUERY_EXCEPTION(zerr::ZXQP0003_INTERNAL_ERROR, ERROR_LOC(get_loc()));
1715-}
1716-
1717-
1718-/*******************************************************************************
1719-
1720-********************************************************************************/
1721 void expr::accept_children(expr_visitor& v)
1722 {
1723 ExprIterator iter(this);
1724@@ -1212,13 +1183,18 @@
1725 ********************************************************************************/
1726 xqtref_t expr::get_return_type_with_empty_input(const expr* input) const
1727 {
1728- expr* emptyExpr = theCCB->theEM->create_fo_expr(input->get_sctx(),
1729- QueryLoc::null,
1730- GET_BUILTIN_FUNCTION(OP_CONCATENATE_N));
1731+ assert(input->get_udf() == theUDF);
1732+
1733+ expr* emptyExpr = theCCB->theEM->
1734+ create_fo_expr(input->get_sctx(),
1735+ theUDF,
1736+ QueryLoc::null,
1737+ GET_BUILTIN_FUNCTION(OP_CONCATENATE_N));
1738+
1739 expr::substitution_t subst;
1740 subst[input] = emptyExpr;
1741
1742- expr* cloneExpr = clone(subst);
1743+ expr* cloneExpr = clone(theUDF, subst);
1744
1745 return cloneExpr->get_return_type();
1746 }
1747
1748=== modified file 'src/compiler/expression/expr_base.h'
1749--- src/compiler/expression/expr_base.h 2012-10-08 12:09:36 +0000
1750+++ src/compiler/expression/expr_base.h 2012-10-09 13:35:26 +0000
1751@@ -173,8 +173,12 @@
1752 static expr* * iter_done;
1753
1754 protected:
1755+ CompilerCB * const theCCB;
1756+
1757 static_context * theSctx;
1758
1759+ user_function * theUDF;
1760+
1761 QueryLoc theLoc;
1762
1763 unsigned short theKind;
1764@@ -186,8 +190,6 @@
1765
1766 FreeVars theFreeVars;
1767
1768- CompilerCB *const theCCB;
1769-
1770 public:
1771 static bool is_sequential(unsigned short theScriptingKind);
1772
1773@@ -196,14 +198,20 @@
1774 static void checkNonUpdating(const expr* e);
1775
1776 protected:
1777- expr(CompilerCB*, static_context*, const QueryLoc&, expr_kind_t);
1778+ expr(CompilerCB*, static_context*, user_function*, const QueryLoc&, expr_kind_t);
1779
1780- expr() : theSctx(NULL), theFlags1(0), theCCB(NULL) {}
1781+ expr() : theCCB(NULL), theSctx(NULL), theUDF(NULL), theFlags1(0) {}
1782
1783 public:
1784 virtual ~expr();
1785
1786- CompilerCB* get_ccb() {return theCCB;}
1787+ CompilerCB* get_ccb() { return theCCB; }
1788+
1789+ static_context* get_sctx() const { return theSctx; }
1790+
1791+ TypeManager* get_type_manager() const;
1792+
1793+ user_function* get_udf() const { return theUDF; }
1794
1795 expr_kind_t get_expr_kind() const { return static_cast<expr_kind_t>(theKind); }
1796
1797@@ -211,10 +219,6 @@
1798
1799 void set_loc(const QueryLoc& loc) { theLoc = loc; }
1800
1801- static_context* get_sctx() const { return theSctx; }
1802-
1803- TypeManager* get_type_manager() const;
1804-
1805 uint32_t getFlags() const { return theFlags1; }
1806
1807 void setFlags(uint32_t flags) { theFlags1 = flags; }
1808@@ -241,11 +245,9 @@
1809
1810 xqtref_t get_return_type();
1811
1812- expr* clone() const;
1813-
1814- expr* clone(substitution_t&) const;
1815-
1816- virtual expr* cloneImpl(substitution_t& substitution) const;
1817+ expr* clone(user_function* udf) const;
1818+
1819+ expr* clone(user_function* udf, substitution_t& subst) const;
1820
1821 virtual void accept(expr_visitor& v) = 0;
1822
1823
1824=== added file 'src/compiler/expression/expr_clone.cpp'
1825--- src/compiler/expression/expr_clone.cpp 1970-01-01 00:00:00 +0000
1826+++ src/compiler/expression/expr_clone.cpp 2012-10-09 13:35:26 +0000
1827@@ -0,0 +1,790 @@
1828+/*
1829+ * Copyright 2006-2008 The FLWOR Foundation.
1830+ *
1831+ * Licensed under the Apache License, Version 2.0 (the "License");
1832+ * you may not use this file except in compliance with the License.
1833+ * You may obtain a copy of the License at
1834+ *
1835+ * http://www.apache.org/licenses/LICENSE-2.0
1836+ *
1837+ * Unless required by applicable law or agreed to in writing, software
1838+ * distributed under the License is distributed on an "AS IS" BASIS,
1839+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1840+ * See the License for the specific language governing permissions and
1841+ * limitations under the License.
1842+ */
1843+
1844+#include "compiler/expression/expr_base.h"
1845+#include "compiler/expression/update_exprs.h"
1846+#include "compiler/expression/expr.h"
1847+#include "compiler/expression/fo_expr.h"
1848+#include "compiler/expression/flwor_expr.h"
1849+#include "compiler/expression/script_exprs.h"
1850+#include "compiler/expression/path_expr.h"
1851+#include "compiler/expression/json_exprs.h"
1852+#include "compiler/expression/function_item_expr.h"
1853+#include "compiler/expression/ft_expr.h"
1854+#include "compiler/expression/expr_manager.h"
1855+
1856+#include "compiler/api/compilercb.h"
1857+
1858+#include "functions/function.h"
1859+
1860+#include "diagnostics/xquery_diagnostics.h"
1861+#include "diagnostics/util_macros.h"
1862+
1863+namespace zorba
1864+{
1865+
1866+#define CLONE(e, udf, subst) ((e) == NULL ? NULL : (e)->clone(udf, subst))
1867+
1868+
1869+/*******************************************************************************
1870+
1871+********************************************************************************/
1872+expr* expr::clone(user_function* udf) const
1873+{
1874+ substitution_t subst;
1875+ return clone(udf, subst);
1876+}
1877+
1878+
1879+expr* expr::clone(user_function* udf, substitution_t& subst) const
1880+{
1881+ expr* newExpr = NULL;
1882+
1883+ switch (get_expr_kind())
1884+ {
1885+ case const_expr_kind:
1886+ {
1887+ const const_expr* e = static_cast<const const_expr*>(this);
1888+
1889+ newExpr = theCCB->theEM->
1890+ create_const_expr(theSctx, udf, theLoc, e->theValue);
1891+
1892+ break;
1893+ }
1894+ case var_expr_kind:
1895+ {
1896+ expr::subst_iter_t i = subst.find(this);
1897+
1898+ if (i == subst.end())
1899+ newExpr = const_cast<expr*>(this);
1900+ else
1901+ newExpr = i->second;
1902+
1903+ break;
1904+ }
1905+ case doc_expr_kind:
1906+ {
1907+ const doc_expr* e = static_cast<const doc_expr*>(this);
1908+
1909+ newExpr = theCCB->theEM->
1910+ create_doc_expr(theSctx,
1911+ udf,
1912+ theLoc,
1913+ CLONE(e->getContent(), udf, subst),
1914+ e->theCopyInputNodes);
1915+ break;
1916+ }
1917+ case elem_expr_kind:
1918+ {
1919+ const elem_expr* e = static_cast<const elem_expr*>(this);
1920+
1921+ newExpr = theCCB->theEM->
1922+ create_elem_expr(theSctx,
1923+ udf,
1924+ theLoc,
1925+ CLONE(e->getQNameExpr(), udf, subst),
1926+ CLONE(e->getAttrs(), udf, subst),
1927+ CLONE(e->getContent(), udf, subst),
1928+ e->getNSCtx(),
1929+ e->theCopyInputNodes);
1930+ break;
1931+ }
1932+ case attr_expr_kind:
1933+ {
1934+ const attr_expr* e = static_cast<const attr_expr*>(this);
1935+
1936+ newExpr = theCCB->theEM->
1937+ create_attr_expr(theSctx,
1938+ udf,
1939+ theLoc,
1940+ CLONE(e->getQNameExpr(), udf, subst),
1941+ CLONE(e->getValueExpr(), udf, subst));
1942+ break;
1943+ }
1944+ case text_expr_kind:
1945+ {
1946+ const text_expr* e = static_cast<const text_expr*>(this);
1947+
1948+ newExpr = theCCB->theEM->
1949+ create_text_expr(theSctx,
1950+ udf,
1951+ theLoc,
1952+ e->get_type(),
1953+ CLONE(e->get_text(), udf, subst));
1954+ break;
1955+ }
1956+ case pi_expr_kind:
1957+ {
1958+ const pi_expr* e = static_cast<const pi_expr*>(this);
1959+
1960+ newExpr = theCCB->theEM->
1961+ create_pi_expr(theSctx,
1962+ udf,
1963+ theLoc,
1964+ CLONE(e->get_target_expr(), udf, subst),
1965+ CLONE(e->get_content_expr(), udf, subst));
1966+ break;
1967+ }
1968+#ifdef ZORBA_WITH_JSON
1969+ case json_direct_object_expr_kind:
1970+ {
1971+ const json_direct_object_expr* e = static_cast<const json_direct_object_expr*>(this);
1972+
1973+ std::vector<expr*> names;
1974+ std::vector<expr*> values;
1975+
1976+ names.reserve(e->theNames.size());
1977+ values.reserve(e->theValues.size());
1978+
1979+ std::vector<expr*>::const_iterator ite = e->theNames.begin();
1980+ std::vector<expr*>::const_iterator end = e->theNames.end();
1981+ for (; ite != end; ++ite)
1982+ {
1983+ names.push_back((*ite)->clone(udf, subst));
1984+ }
1985+
1986+ ite = e->theValues.begin();
1987+ end = e->theValues.end();
1988+ for (; ite != end; ++ite)
1989+ {
1990+ values.push_back((*ite)->clone(udf, subst));
1991+ }
1992+
1993+ newExpr = theCCB->theEM->
1994+ create_json_direct_object_expr(theSctx, udf, theLoc, names, values);
1995+
1996+ break;
1997+ }
1998+ case json_object_expr_kind:
1999+ {
2000+ const json_object_expr* e = static_cast<const json_object_expr*>(this);
2001+
2002+ newExpr = theCCB->theEM->
2003+ create_json_object_expr(theSctx,
2004+ udf,
2005+ theLoc,
2006+ (e->theContentExpr ?
2007+ e->theContentExpr->clone(udf, subst) : NULL),
2008+ e->theAccumulate);
2009+
2010+ break;
2011+ }
2012+ case json_array_expr_kind:
2013+ {
2014+ const json_array_expr* e = static_cast<const json_array_expr*>(this);
2015+
2016+ newExpr = theCCB->theEM->
2017+ create_json_array_expr(theSctx,
2018+ udf,
2019+ theLoc,
2020+ e->theContentExpr->clone(udf, subst));
2021+
2022+ break;
2023+ }
2024+#endif
2025+
2026+ case relpath_expr_kind:
2027+ {
2028+ const relpath_expr* e = static_cast<const relpath_expr*>(this);
2029+
2030+ relpath_expr* cloneExpr = theCCB->theEM->
2031+ create_relpath_expr(theSctx, udf, theLoc);
2032+
2033+ for (csize i = 0; i < e->size(); ++i)
2034+ {
2035+ cloneExpr->add_back((*e)[i]->clone(udf, subst));
2036+ }
2037+
2038+ newExpr = cloneExpr;
2039+ break;
2040+ }
2041+ case axis_step_expr_kind:
2042+ {
2043+ const axis_step_expr* e = static_cast<const axis_step_expr*>(this);
2044+
2045+ axis_step_expr* cloneExpr = theCCB->theEM->
2046+ create_axis_step_expr(theSctx, udf, theLoc);
2047+
2048+ cloneExpr->setAxis(e->getAxis());
2049+ cloneExpr->setTest(static_cast<match_expr*>(CLONE(e->getTest(), udf, subst)));
2050+ cloneExpr->theReverseOrder = e->theReverseOrder;
2051+
2052+ newExpr = cloneExpr;
2053+ break;
2054+ }
2055+ case match_expr_kind:
2056+ {
2057+ const match_expr* e = static_cast<const match_expr*>(this);
2058+
2059+ match_expr* cloneExpr = theCCB->theEM->
2060+ create_match_expr(theSctx, udf, theLoc);
2061+
2062+ cloneExpr->setTestKind(e->getTestKind());
2063+ cloneExpr->setDocTestKind(e->getDocTestKind());
2064+ cloneExpr->setWildName(e->getWildName());
2065+ cloneExpr->setWildKind(e->getWildKind());
2066+ cloneExpr->setQName(e->getQName());
2067+ cloneExpr->setTypeName(e->getTypeName());
2068+ cloneExpr->setNilledAllowed(e->getNilledAllowed());
2069+
2070+ newExpr = cloneExpr;
2071+ break;
2072+ }
2073+
2074+ case flwor_expr_kind:
2075+ case gflwor_expr_kind:
2076+ {
2077+ const flwor_expr* e = static_cast<const flwor_expr*>(this);
2078+
2079+ flwor_expr* cloneExpr = theCCB->theEM->
2080+ create_flwor_expr(theSctx, udf, theLoc, e->theIsGeneral);
2081+
2082+ csize numClauses = e->num_clauses();
2083+
2084+ for (csize i = 0; i < numClauses; ++i)
2085+ {
2086+ flwor_clause* cloneClause = e->theClauses[i]->clone(udf, subst);
2087+
2088+ cloneExpr->add_clause(cloneClause, false);
2089+ }
2090+
2091+ cloneExpr->set_return_expr(e->theReturnExpr->clone(udf, subst));
2092+
2093+ newExpr = cloneExpr;
2094+ break;
2095+ }
2096+ case if_expr_kind:
2097+ {
2098+ const if_expr* e = static_cast<const if_expr*>(this);
2099+
2100+ newExpr = theCCB->theEM->
2101+ create_if_expr(theSctx,
2102+ udf,
2103+ theLoc,
2104+ e->get_cond_expr()->clone(udf, subst),
2105+ e->get_then_expr()->clone(udf, subst),
2106+ e->get_else_expr()->clone(udf, subst));
2107+ break;
2108+ }
2109+ case trycatch_expr_kind:
2110+ {
2111+ const trycatch_expr* e = static_cast<const trycatch_expr*>(this);
2112+
2113+ trycatch_expr* cloneExpr = theCCB->theEM->
2114+ create_trycatch_expr(theSctx, udf, theLoc, e->theTryExpr->clone(udf, subst));
2115+
2116+ for (std::vector<expr*>::const_iterator ite = e->theCatchExprs.begin();
2117+ ite != e->theCatchExprs.end();
2118+ ++ite)
2119+ {
2120+ cloneExpr->add_catch_expr((*ite)->clone(udf, subst));
2121+ }
2122+
2123+ for (csize i = 0; i < e->clause_count(); ++i)
2124+ {
2125+ cloneExpr->add_clause(e->theCatchClauses[i]->clone(subst));
2126+ }
2127+
2128+ newExpr = cloneExpr;
2129+ break;
2130+ }
2131+ case fo_expr_kind:
2132+ {
2133+ const fo_expr* e = static_cast<const fo_expr*>(this);
2134+
2135+ if (e->get_func()->getKind() == FunctionConsts::STATIC_COLLECTIONS_DML_COLLECTION_1)
2136+ {
2137+ expr::subst_iter_t i = subst.find(this);
2138+
2139+ if (i != subst.end())
2140+ {
2141+ newExpr = i->second;
2142+ break;
2143+ }
2144+ }
2145+
2146+ fo_expr* cloneExpr = theCCB->theEM->
2147+ create_fo_expr(theSctx, udf, theLoc, e->get_func());
2148+
2149+ cloneExpr->theArgs.reserve(e->theArgs.size());
2150+
2151+ for (csize i = 0; i < e->theArgs.size(); ++i)
2152+ cloneExpr->theArgs.push_back(e->theArgs[i]->clone(udf, subst));
2153+
2154+ cloneExpr->theScriptingKind = e->theScriptingKind;
2155+
2156+ newExpr = cloneExpr;
2157+ break;
2158+ }
2159+ case dynamic_function_invocation_expr_kind:
2160+ {
2161+ const dynamic_function_invocation_expr* e =
2162+ static_cast<const dynamic_function_invocation_expr*>(this);
2163+
2164+ checked_vector<expr*> newArgs;
2165+ for (checked_vector<expr*>::const_iterator ite = e->theArgs.begin();
2166+ ite != e->theArgs.end();
2167+ ++ite)
2168+ {
2169+ newArgs.push_back((*ite)->clone(udf, subst));
2170+ }
2171+
2172+ newExpr = theCCB->theEM->
2173+ create_dynamic_function_invocation_expr(theSctx,
2174+ udf,
2175+ theLoc,
2176+ e->theExpr->clone(udf, subst),
2177+ newArgs);
2178+ break;
2179+ }
2180+ case function_item_expr_kind:
2181+ {
2182+ const function_item_expr* e = static_cast<const function_item_expr*>(this);
2183+
2184+ function_item_expr* cloneExpr = theCCB->theEM->
2185+ create_function_item_expr(theSctx,
2186+ udf,
2187+ theLoc,
2188+ e->theFunction->getName(),
2189+ e->theFunction.getp(),
2190+ e->theArity);
2191+
2192+ std::vector<expr*> lNewVariables;
2193+ for (std::vector<expr*>::const_iterator ite = e->theScopedVariables.begin();
2194+ ite != e->theScopedVariables.end();
2195+ ++ite)
2196+ {
2197+ cloneExpr->add_variable((*ite)->clone(udf, subst));
2198+ }
2199+
2200+ newExpr = cloneExpr;
2201+ break;
2202+ }
2203+ case castable_expr_kind:
2204+ {
2205+ const castable_expr* e = static_cast<const castable_expr*>(this);
2206+
2207+ newExpr = theCCB->theEM->
2208+ create_castable_expr(theSctx,
2209+ udf,
2210+ theLoc,
2211+ e->get_input()->clone(udf, subst),
2212+ e->get_target_type());
2213+
2214+ break;
2215+ }
2216+ case cast_expr_kind:
2217+ {
2218+ const cast_expr* e = static_cast<const cast_expr*>(this);
2219+
2220+ newExpr = theCCB->theEM->
2221+ create_cast_expr(theSctx,
2222+ udf,
2223+ theLoc,
2224+ e->get_input()->clone(udf, subst),
2225+ e->get_target_type());
2226+ break;
2227+ }
2228+ case instanceof_expr_kind:
2229+ {
2230+ const instanceof_expr* e = static_cast<const instanceof_expr*>(this);
2231+
2232+ newExpr = theCCB->theEM->
2233+ create_instanceof_expr(theSctx,
2234+ udf,
2235+ theLoc,
2236+ e->get_input()->clone(udf, subst),
2237+ e->get_target_type());
2238+ break;
2239+ }
2240+ case treat_expr_kind:
2241+ {
2242+ const treat_expr* e = static_cast<const treat_expr*>(this);
2243+
2244+ newExpr = theCCB->theEM->
2245+ create_treat_expr(theSctx,
2246+ udf,
2247+ theLoc,
2248+ e->get_input()->clone(udf, subst),
2249+ e->get_target_type(),
2250+ e->get_err(),
2251+ e->get_check_prime(),
2252+ e->get_qname());
2253+ break;
2254+ }
2255+ case promote_expr_kind:
2256+ {
2257+ const promote_expr* e = static_cast<const promote_expr*>(this);
2258+
2259+ newExpr = theCCB->theEM->
2260+ create_promote_expr(theSctx,
2261+ udf,
2262+ theLoc,
2263+ e->get_input()->clone(udf, subst),
2264+ e->get_target_type(),
2265+ e->theErrorKind,
2266+ e->theQName.getp());
2267+ break;
2268+ }
2269+ case name_cast_expr_kind:
2270+ {
2271+ const name_cast_expr* e = static_cast<const name_cast_expr*>(this);
2272+
2273+ newExpr = theCCB->theEM->
2274+ create_name_cast_expr(theSctx,
2275+ udf,
2276+ theLoc,
2277+ e->get_input()->clone(udf, subst),
2278+ e->getNSCtx(),
2279+ e->theIsAttrName);
2280+ break;
2281+ }
2282+ case validate_expr_kind:
2283+ {
2284+ const validate_expr* e = static_cast<const validate_expr*>(this);
2285+
2286+ newExpr = theCCB->theEM->
2287+ create_validate_expr(theSctx,
2288+ udf,
2289+ theLoc,
2290+ e->get_valmode(),
2291+ const_cast<store::Item*>(e->get_type_name()),
2292+ e->get_expr()->clone(udf, subst),
2293+ e->get_typemgr());
2294+
2295+ break;
2296+ }
2297+ case extension_expr_kind:
2298+ {
2299+ const extension_expr* e = static_cast<const extension_expr*>(this);
2300+
2301+ extension_expr* cloneExpr;
2302+ if(e->theExpr == 0)
2303+ {
2304+ cloneExpr = theCCB->theEM->create_extension_expr(theSctx, udf, theLoc);
2305+ }
2306+ else
2307+ {
2308+ cloneExpr = theCCB->theEM->
2309+ create_extension_expr(theSctx, udf, theLoc, e->theExpr->clone(udf, subst));
2310+ }
2311+
2312+ // pragma doesn't contain expressions. Thus, it is not cloned.
2313+ for (std::vector<pragma*>::const_iterator lIter = e->thePragmas.begin();
2314+ lIter != e->thePragmas.end();
2315+ ++lIter)
2316+ {
2317+ cloneExpr->add(*lIter);
2318+ }
2319+
2320+ newExpr = cloneExpr;
2321+ break;
2322+ }
2323+ case order_expr_kind:
2324+ {
2325+ const order_expr* e = static_cast<const order_expr*>(this);
2326+
2327+ newExpr = theCCB->theEM->
2328+ create_order_expr(theSctx,
2329+ udf,
2330+ theLoc,
2331+ e->get_type(),
2332+ e->get_expr()->clone(udf, subst));
2333+ break;
2334+ }
2335+#ifndef ZORBA_NO_FULL_TEXT
2336+ case ft_expr_kind:
2337+ {
2338+ const ftcontains_expr* e = static_cast<const ftcontains_expr*>(this);
2339+
2340+ newExpr = theCCB->theEM->
2341+ create_ftcontains_expr(theSctx,
2342+ udf,
2343+ theLoc,
2344+ e->range_->clone(udf, subst),
2345+ e->ftselection_->clone(udf, subst).release(),
2346+ (e->ftignore_ == NULL ? 0 : e->ftignore_->clone(udf, subst)));
2347+
2348+ break;
2349+ }
2350+#endif /* ZORBA_NO_FULL_TEXT */
2351+
2352+ case delete_expr_kind:
2353+ {
2354+ const delete_expr* e = static_cast<const delete_expr*>(this);
2355+
2356+ newExpr = theCCB->theEM->
2357+ create_delete_expr(theSctx, udf, theLoc, e->getTargetExpr()->clone(udf, subst));
2358+
2359+ break;
2360+ }
2361+ case insert_expr_kind:
2362+ {
2363+ const insert_expr* e = static_cast<const insert_expr*>(this);
2364+
2365+ newExpr = theCCB->theEM->
2366+ create_insert_expr(theSctx,
2367+ udf,
2368+ theLoc,
2369+ e->getType(),
2370+ e->getSourceExpr()->clone(udf, subst),
2371+ e->getTargetExpr()->clone(udf, subst));
2372+ break;
2373+ }
2374+ case rename_expr_kind:
2375+ {
2376+ const rename_expr* e = static_cast<const rename_expr*>(this);
2377+
2378+ newExpr = theCCB->theEM->
2379+ create_rename_expr(theSctx,
2380+ udf,
2381+ theLoc,
2382+ e->getTargetExpr()->clone(udf, subst),
2383+ e->getNameExpr()->clone(udf, subst));
2384+ break;
2385+ }
2386+ case replace_expr_kind:
2387+ {
2388+ const zorba::replace_expr* e = static_cast<const zorba::replace_expr*>(this);
2389+
2390+ newExpr = theCCB->theEM->
2391+ create_replace_expr(theSctx,
2392+ udf,
2393+ theLoc,
2394+ e->getType(),
2395+ e->getTargetExpr()->clone(udf, subst),
2396+ e->getReplaceExpr()->clone(udf, subst));
2397+ break;
2398+ }
2399+ case transform_expr_kind:
2400+ {
2401+ const transform_expr* e = static_cast<const transform_expr*>(this);
2402+
2403+ ZORBA_ASSERT(e->theModifyExpr && e->theReturnExpr);
2404+
2405+ transform_expr* cloneExpr = theCCB->theEM->
2406+ create_transform_expr(theSctx, udf, theLoc);
2407+
2408+ for (std::vector<copy_clause*>::const_iterator ite = e->theCopyClauses.begin();
2409+ ite != e->theCopyClauses.end();
2410+ ++ite)
2411+ {
2412+ cloneExpr->add_back((*ite)->clone(udf, subst));
2413+ }
2414+
2415+ cloneExpr->setModifyExpr(e->theModifyExpr->clone(udf, subst));
2416+ cloneExpr->setReturnExpr(e->theReturnExpr->clone(udf, subst));
2417+
2418+ newExpr = cloneExpr;
2419+ break;
2420+ }
2421+
2422+ case block_expr_kind:
2423+ {
2424+ const block_expr* e = static_cast<const block_expr*>(this);
2425+
2426+ checked_vector<expr*> seq2;
2427+ for (csize i = 0; i < e->theArgs.size(); ++i)
2428+ seq2.push_back(e->theArgs[i]->clone(udf, subst));
2429+
2430+ newExpr = theCCB->theEM->
2431+ create_block_expr(theSctx, udf, theLoc, true, seq2, NULL);
2432+
2433+ break;
2434+ }
2435+ case var_decl_expr_kind:
2436+ {
2437+ const var_decl_expr* e = static_cast<const var_decl_expr*>(this);
2438+
2439+ var_expr* varCopy = theCCB->theEM->create_var_expr(udf, *e->theVarExpr);
2440+ subst[e->theVarExpr] = varCopy;
2441+
2442+ newExpr = theCCB->theEM->
2443+ create_var_decl_expr(theSctx,
2444+ udf,
2445+ theLoc,
2446+ varCopy,
2447+ (e->theInitExpr ? e->theInitExpr->clone(udf, subst) : NULL));
2448+
2449+ break;
2450+ }
2451+ case var_set_expr_kind:
2452+ {
2453+ const var_set_expr* e = static_cast<const var_set_expr*>(this);
2454+
2455+ expr* varClone = e->theVarExpr->clone(udf, subst);
2456+
2457+ ZORBA_ASSERT(varClone->get_expr_kind() == var_expr_kind);
2458+
2459+ newExpr = theCCB->theEM->
2460+ create_var_set_expr(theSctx,
2461+ udf,
2462+ theLoc,
2463+ static_cast<var_expr*>(varClone),
2464+ e->theExpr->clone(udf, subst));
2465+ break;
2466+ }
2467+ case apply_expr_kind:
2468+ {
2469+ const apply_expr* e = static_cast<const apply_expr*>(this);
2470+
2471+ newExpr = theCCB->theEM->
2472+ create_apply_expr(theSctx,
2473+ udf,
2474+ theLoc,
2475+ e->theExpr->clone(udf, subst),
2476+ e->theDiscardXDM);
2477+
2478+ break;
2479+ }
2480+ case exit_expr_kind:
2481+ {
2482+ const exit_expr* e = static_cast<const exit_expr*>(this);
2483+
2484+ newExpr = theCCB->theEM->
2485+ create_exit_expr(theSctx, udf, theLoc, e->get_expr()->clone(udf, subst));
2486+
2487+ subst[this] = newExpr;
2488+
2489+ break;
2490+ }
2491+ case exit_catcher_expr_kind:
2492+ {
2493+ const exit_catcher_expr* e = static_cast<const exit_catcher_expr*>(this);
2494+
2495+ expr* clonedInput = e->get_expr()->clone(udf, subst);
2496+
2497+ std::vector<expr*> clonedExits;
2498+ std::vector<expr*>::const_iterator ite = e->theExitExprs.begin();
2499+ std::vector<expr*>::const_iterator end = e->theExitExprs.end();
2500+ for (; ite != end; ++ite)
2501+ {
2502+ assert(subst.find(*ite) != subst.end());
2503+
2504+ clonedExits.push_back(subst[*ite]);
2505+ }
2506+
2507+ newExpr = theCCB->theEM->
2508+ create_exit_catcher_expr(theSctx, udf, theLoc, clonedInput, clonedExits);
2509+
2510+ break;
2511+ }
2512+ case flowctl_expr_kind:
2513+ {
2514+ const flowctl_expr* e = static_cast<const flowctl_expr*>(this);
2515+
2516+ newExpr = theCCB->theEM->
2517+ create_flowctl_expr(theSctx, udf, theLoc, e->get_action());
2518+
2519+ break;
2520+ }
2521+ case while_expr_kind:
2522+ {
2523+ const while_expr* e = static_cast<const while_expr*>(this);
2524+
2525+ newExpr = theCCB->theEM->
2526+ create_while_expr(theSctx, udf, theLoc, e->get_body()->clone(udf, subst));
2527+
2528+ break;
2529+ }
2530+ case eval_expr_kind:
2531+ {
2532+ const eval_expr* e = static_cast<const eval_expr*>(this);
2533+
2534+ newExpr = theCCB->theEM->
2535+ create_eval_expr(theSctx,
2536+ udf,
2537+ theLoc,
2538+ e->theExpr->clone(udf, subst),
2539+ e->theInnerScriptingKind,
2540+ e->theNSCtx.getp());
2541+
2542+ eval_expr* newEval = static_cast<eval_expr*>(newExpr);
2543+
2544+ newEval->setNodeCopy(e->theDoNodeCopy);
2545+
2546+ newEval->theOuterVarNames = e->theOuterVarNames;
2547+ newEval->theOuterVarTypes = e->theOuterVarTypes;
2548+
2549+ csize numVars = e->theOuterVarNames.size();
2550+
2551+ newEval->theArgs.resize(numVars);
2552+
2553+ for (csize i = 0; i < numVars; ++i)
2554+ {
2555+ newEval->theArgs[i] = e->theArgs[i]->clone(udf, subst);
2556+ }
2557+
2558+ break;
2559+ }
2560+ case wrapper_expr_kind:
2561+ {
2562+ const wrapper_expr* e = static_cast<const wrapper_expr*>(this);
2563+
2564+ expr* wrappedClone = e->theWrappedExpr->clone(udf, subst);
2565+
2566+ if (e->theWrappedExpr->get_expr_kind() == var_expr_kind &&
2567+ wrappedClone->get_expr_kind() != var_expr_kind)
2568+ {
2569+ newExpr = wrappedClone;
2570+ }
2571+ else
2572+ {
2573+ newExpr = theCCB->theEM->create_wrapper_expr(theSctx, udf, theLoc, wrappedClone);
2574+ }
2575+
2576+ break;
2577+ }
2578+ case function_trace_expr_kind:
2579+ {
2580+ const function_trace_expr* e = static_cast<const function_trace_expr*>(this);
2581+
2582+ function_trace_expr* cloneExpr = theCCB->theEM->
2583+ create_function_trace_expr(udf, e->theExpr->clone(udf, subst));
2584+
2585+ cloneExpr->theFunctionName = e->theFunctionName;
2586+ cloneExpr->theFunctionLocation = e->theFunctionLocation;
2587+ cloneExpr->theFunctionCallLocation = e->theFunctionCallLocation;
2588+ cloneExpr->theFunctionArity = e->theFunctionArity;
2589+
2590+ newExpr = cloneExpr;
2591+ break;
2592+ }
2593+ case debugger_expr_kind:
2594+ default:
2595+ {
2596+ RAISE_ERROR(zerr::ZXQP0003_INTERNAL_ERROR, theLoc,
2597+ ERROR_PARAMS(ZED(CloneNotImplemented)));
2598+ }
2599+ }
2600+
2601+ if (containsPragma())
2602+ {
2603+ newExpr->setContainsPragma(ANNOTATION_TRUE);
2604+
2605+ std::vector<pragma*> pragmas;
2606+ theCCB->lookup_pragmas(this, pragmas);
2607+
2608+ for (csize i = 0; i < pragmas.size(); ++i)
2609+ {
2610+ theCCB->add_pragma(newExpr, pragmas[i]);
2611+ }
2612+ }
2613+
2614+ return newExpr;
2615+}
2616+
2617+}
2618
2619=== modified file 'src/compiler/expression/expr_manager.cpp'
2620--- src/compiler/expression/expr_manager.cpp 2012-10-08 12:09:36 +0000
2621+++ src/compiler/expression/expr_manager.cpp 2012-10-09 13:35:26 +0000
2622@@ -35,60 +35,6 @@
2623 namespace zorba
2624 {
2625
2626-#if 0
2627-//A simple expression that can just be deallocated without calling the
2628-//destructor.
2629-class NullExpr : public expr
2630-{
2631-public:
2632- NullExpr() : expr(NULL, NULL, QueryLoc(), unknown_expr_kind) {}
2633-
2634- void accept(expr_visitor& v) {}
2635-
2636- void compute_scripting_kind() {}
2637-
2638- std::ostream& put(std::ostream& stream) const { return stream; }
2639-};
2640-
2641-
2642-class NullFlworClause : public flwor_clause
2643-{
2644-public:
2645- //it being a let clause is arbitrary, it doesn't matter what type it is.
2646- NullFlworClause() :flwor_clause(NULL, NULL, QueryLoc(), flwor_clause::let_clause) {}
2647-
2648- std::ostream& put(std::ostream& stream) const { return stream; }
2649-
2650- flwor_clause* clone(expr::substitution_t &) const { return NULL; }
2651-};
2652-
2653-
2654-class NullWincond : public flwor_wincond
2655-{
2656-public:
2657- NullWincond() : flwor_wincond(NULL, NULL, false, vars(), vars(), NULL) {}
2658-
2659- std::ostream& put(std::ostream& stream) const { return stream; }
2660-};
2661-
2662-
2663-class NullCatchClause : public catch_clause
2664-{
2665-public:
2666- NullCatchClause() : catch_clause(NULL) {}
2667-
2668- std::ostream& put(std::ostream& stream) const{return stream;}
2669-};
2670-
2671-
2672-class NullCopyClause : public copy_clause
2673-{
2674-public:
2675- NullCopyClause() : copy_clause(NULL, NULL, NULL) {}
2676-};
2677-#endif
2678-
2679-
2680 ExprManager::ExprManager(CompilerCB* ccb)
2681 :
2682 theCCB(ccb)
2683@@ -219,49 +165,54 @@
2684
2685 if_expr* ExprManager::create_if_expr(
2686 static_context* sctx,
2687+ user_function* udf,
2688 const QueryLoc& loc,
2689 expr* cond_expr,
2690 expr* then_expr,
2691 expr* else_expr)
2692 {
2693- CREATE_AND_RETURN_EXPR(if_expr, sctx, loc, cond_expr, then_expr, else_expr);
2694+ CREATE_AND_RETURN_EXPR(if_expr, sctx, udf, loc, cond_expr, then_expr, else_expr);
2695 }
2696
2697
2698 order_expr* ExprManager::create_order_expr(
2699 static_context* sctx,
2700+ user_function* udf,
2701 const QueryLoc& loc,
2702 order_expr::order_type_t order,
2703 expr* exp)
2704 {
2705- CREATE_AND_RETURN_EXPR(order_expr, sctx, loc, order, exp);
2706+ CREATE_AND_RETURN_EXPR(order_expr, sctx, udf, loc, order, exp);
2707 }
2708
2709
2710 validate_expr* ExprManager::create_validate_expr(
2711 static_context* sctx,
2712+ user_function* udf,
2713 const QueryLoc& loc,
2714 ParseConstants::validation_mode_t mode,
2715 const store::Item_t& aTypeName,
2716 expr* validated,
2717 rchandle<TypeManager> tm)
2718 {
2719- CREATE_AND_RETURN_EXPR(validate_expr, sctx, loc, mode, aTypeName, validated, tm);
2720+ CREATE_AND_RETURN_EXPR(validate_expr, sctx, udf, loc, mode, aTypeName, validated, tm);
2721 }
2722
2723
2724 cast_expr* ExprManager::create_cast_expr(
2725 static_context* sctx,
2726+ user_function* udf,
2727 const QueryLoc& loc,
2728 expr* casted,
2729 xqtref_t type)
2730 {
2731- CREATE_AND_RETURN_EXPR(cast_expr, sctx, loc, casted, type);
2732+ CREATE_AND_RETURN_EXPR(cast_expr, sctx, udf, loc, casted, type);
2733 }
2734
2735
2736 treat_expr* ExprManager::create_treat_expr(
2737 static_context* sctx,
2738+ user_function* udf,
2739 const QueryLoc& loc,
2740 expr* treated,
2741 const xqtref_t& type,
2742@@ -270,67 +221,73 @@
2743 store::Item* qname)
2744 {
2745 CREATE_AND_RETURN_EXPR(treat_expr,
2746- sctx, loc, treated, type, err, check_prime, qname);
2747+ sctx, udf, loc, treated, type, err, check_prime, qname);
2748 }
2749
2750
2751 promote_expr* ExprManager::create_promote_expr(
2752 static_context* sctx,
2753+ user_function* udf,
2754 const QueryLoc& loc,
2755 expr* promoted,
2756 const xqtref_t& type,
2757 PromoteIterator::ErrorKind err,
2758 store::Item* qname)
2759 {
2760- CREATE_AND_RETURN_EXPR(promote_expr, sctx, loc, promoted, type, err, qname);
2761+ CREATE_AND_RETURN_EXPR(promote_expr, sctx, udf, loc, promoted, type, err, qname);
2762 }
2763
2764
2765 castable_expr* ExprManager::create_castable_expr(
2766 static_context* sctx,
2767+ user_function* udf,
2768 const QueryLoc& loc,
2769 expr* castable,
2770 xqtref_t type)
2771 {
2772- CREATE_AND_RETURN_EXPR(castable_expr, sctx, loc, castable, type);
2773+ CREATE_AND_RETURN_EXPR(castable_expr, sctx, udf, loc, castable, type);
2774 }
2775
2776
2777 instanceof_expr* ExprManager::create_instanceof_expr(
2778 static_context* sctx,
2779+ user_function* udf,
2780 const QueryLoc& loc,
2781 expr* instanced,
2782 xqtref_t type,
2783 bool checkPrimeOnly)
2784 {
2785 CREATE_AND_RETURN_EXPR(instanceof_expr,
2786- sctx, loc, instanced, type, checkPrimeOnly);
2787+ sctx, udf, loc, instanced, type, checkPrimeOnly);
2788 }
2789
2790
2791 name_cast_expr* ExprManager::create_name_cast_expr(
2792 static_context* sctx,
2793+ user_function* udf,
2794 const QueryLoc& loc,
2795 expr* casted,
2796 const namespace_context* ns,
2797 bool isAttr)
2798 {
2799- CREATE_AND_RETURN_EXPR(name_cast_expr, sctx, loc, casted, ns, isAttr);
2800+ CREATE_AND_RETURN_EXPR(name_cast_expr, sctx, udf, loc, casted, ns, isAttr);
2801 }
2802
2803
2804 doc_expr* ExprManager::create_doc_expr(
2805 static_context* sctx,
2806+ user_function* udf,
2807 const QueryLoc& loc,
2808 expr* content,
2809 bool copyNodes)
2810 {
2811- CREATE_AND_RETURN_EXPR(doc_expr, sctx, loc, content, copyNodes);
2812+ CREATE_AND_RETURN_EXPR(doc_expr, sctx, udf, loc, content, copyNodes);
2813 }
2814
2815
2816 elem_expr* ExprManager::create_elem_expr(
2817 static_context* sctx,
2818+ user_function* udf,
2819 const QueryLoc& loc,
2820 expr* qnameExpr,
2821 expr* attrs,
2822@@ -339,12 +296,13 @@
2823 bool copyNodes)
2824 {
2825 CREATE_AND_RETURN_EXPR(elem_expr,
2826- sctx, loc, qnameExpr, attrs, content, nsCtx, copyNodes);
2827+ sctx, udf, loc, qnameExpr, attrs, content, nsCtx, copyNodes);
2828 }
2829
2830
2831 elem_expr* ExprManager::create_elem_expr(
2832 static_context* sctx,
2833+ user_function* udf,
2834 const QueryLoc& loc,
2835 expr* qnameExpr,
2836 expr* content,
2837@@ -352,137 +310,151 @@
2838 bool copyNodes)
2839 {
2840 CREATE_AND_RETURN_EXPR(elem_expr,
2841- sctx, loc, qnameExpr, content, nsCtx, copyNodes);
2842+ sctx, udf, loc, qnameExpr, content, nsCtx, copyNodes);
2843 }
2844
2845
2846 attr_expr* ExprManager::create_attr_expr(
2847 static_context* sctx,
2848+ user_function* udf,
2849 const QueryLoc& loc,
2850 expr* aQNameExpr,
2851 expr* aValueExpr)
2852 {
2853- CREATE_AND_RETURN_EXPR(attr_expr, sctx, loc, aQNameExpr, aValueExpr);
2854+ CREATE_AND_RETURN_EXPR(attr_expr, sctx, udf, loc, aQNameExpr, aValueExpr);
2855 }
2856
2857
2858 text_expr* ExprManager::create_text_expr(
2859 static_context* sctx,
2860+ user_function* udf,
2861 const QueryLoc& loc,
2862 text_expr::text_constructor_type textType,
2863 expr* text)
2864 {
2865- CREATE_AND_RETURN_EXPR(text_expr, sctx, loc, textType, text);
2866+ CREATE_AND_RETURN_EXPR(text_expr, sctx, udf, loc, textType, text);
2867 }
2868
2869
2870 pi_expr* ExprManager::create_pi_expr(
2871 static_context* sctx,
2872+ user_function* udf,
2873 const QueryLoc& loc,
2874 expr* targetExpr,
2875 expr* contentExpr)
2876 {
2877- CREATE_AND_RETURN_EXPR(pi_expr, sctx, loc, targetExpr, contentExpr);
2878+ CREATE_AND_RETURN_EXPR(pi_expr, sctx, udf, loc, targetExpr, contentExpr);
2879 }
2880
2881
2882 const_expr* ExprManager::create_const_expr(
2883 static_context* sctx,
2884+ user_function* udf,
2885 const QueryLoc& loc,
2886 zstring& sval)
2887 {
2888- CREATE_AND_RETURN_EXPR(const_expr, sctx, loc, sval);
2889+ CREATE_AND_RETURN_EXPR(const_expr, sctx, udf, loc, sval);
2890 }
2891
2892
2893 const_expr* ExprManager::create_const_expr(
2894 static_context* sctx,
2895+ user_function* udf,
2896 const QueryLoc& loc,
2897 const std::string& sval)
2898 {
2899- CREATE_AND_RETURN_EXPR(const_expr, sctx, loc, sval);
2900+ CREATE_AND_RETURN_EXPR(const_expr, sctx, udf, loc, sval);
2901 }
2902
2903
2904 const_expr* ExprManager::create_const_expr(
2905 static_context* sctx,
2906+ user_function* udf,
2907 const QueryLoc& loc,
2908 const char* sval)
2909 {
2910- CREATE_AND_RETURN_EXPR(const_expr, sctx, loc, sval);
2911+ CREATE_AND_RETURN_EXPR(const_expr, sctx, udf, loc, sval);
2912 }
2913
2914
2915 const_expr* ExprManager::create_const_expr(
2916 static_context* sctx,
2917+ user_function* udf,
2918 const QueryLoc& loc,
2919 xs_integer val)
2920 {
2921- CREATE_AND_RETURN_EXPR(const_expr, sctx, loc, val);
2922+ CREATE_AND_RETURN_EXPR(const_expr, sctx, udf, loc, val);
2923 }
2924
2925
2926 const_expr* ExprManager::create_const_expr(
2927 static_context* sctx,
2928+ user_function* udf,
2929 const QueryLoc& loc,
2930 xs_decimal val)
2931 {
2932- CREATE_AND_RETURN_EXPR(const_expr, sctx, loc, val);
2933+ CREATE_AND_RETURN_EXPR(const_expr, sctx, udf, loc, val);
2934 }
2935
2936
2937 const_expr* ExprManager::create_const_expr(
2938 static_context* sctx,
2939+ user_function* udf,
2940 const QueryLoc& loc,
2941 xs_double val)
2942 {
2943- CREATE_AND_RETURN_EXPR(const_expr, sctx, loc, val);
2944+ CREATE_AND_RETURN_EXPR(const_expr, sctx, udf, loc, val);
2945 }
2946
2947
2948 const_expr* ExprManager::create_const_expr(
2949 static_context* sctx,
2950+ user_function* udf,
2951 const QueryLoc& loc,
2952 xs_boolean val)
2953 {
2954- CREATE_AND_RETURN_EXPR(const_expr, sctx, loc, val);
2955+ CREATE_AND_RETURN_EXPR(const_expr, sctx, udf, loc, val);
2956 }
2957
2958
2959 const_expr* ExprManager::create_const_expr(
2960 static_context* sctx,
2961+ user_function* udf,
2962 const QueryLoc& loc,
2963 store::Item_t val)
2964 {
2965- CREATE_AND_RETURN_EXPR(const_expr, sctx, loc, val);
2966+ CREATE_AND_RETURN_EXPR(const_expr, sctx, udf, loc, val);
2967 }
2968
2969
2970 const_expr* ExprManager::create_const_expr(
2971 static_context* sctx,
2972+ user_function* udf,
2973 const QueryLoc& loc,
2974 const char* ns,
2975 const char* pre,
2976 const char* local)
2977 {
2978- CREATE_AND_RETURN_EXPR(const_expr, sctx, loc, ns, pre, local);
2979+ CREATE_AND_RETURN_EXPR(const_expr, sctx, udf, loc, ns, pre, local);
2980 }
2981
2982
2983 extension_expr* ExprManager::create_extension_expr(
2984 static_context* sctx,
2985+ user_function* udf,
2986 const QueryLoc& loc)
2987 {
2988- CREATE_AND_RETURN_EXPR(extension_expr, sctx, loc);
2989+ CREATE_AND_RETURN_EXPR(extension_expr, sctx, udf, loc);
2990 }
2991
2992
2993 extension_expr* ExprManager::create_extension_expr(
2994 static_context* sctx,
2995+ user_function* udf,
2996 const QueryLoc& loc,
2997 expr* extended)
2998 {
2999- CREATE_AND_RETURN_EXPR(extension_expr, sctx, loc, extended);
3000+ CREATE_AND_RETURN_EXPR(extension_expr, sctx, udf, loc, extended);
3001 }
3002
3003
3004@@ -494,35 +466,40 @@
3005
3006 trycatch_expr* ExprManager::create_trycatch_expr(
3007 static_context* sctx,
3008+ user_function* udf,
3009 const QueryLoc& loc,
3010 expr* tryExpr)
3011 {
3012- CREATE_AND_RETURN_EXPR(trycatch_expr, sctx, loc, tryExpr);
3013+ CREATE_AND_RETURN_EXPR(trycatch_expr, sctx, udf, loc, tryExpr);
3014 }
3015
3016
3017 wrapper_expr* ExprManager::create_wrapper_expr(
3018 static_context* sctx,
3019+ user_function* udf,
3020 const QueryLoc& loc,
3021 expr* wrapped)
3022 {
3023- CREATE_AND_RETURN_EXPR(wrapper_expr, sctx, loc, wrapped);
3024+ CREATE_AND_RETURN_EXPR(wrapper_expr, sctx, udf, loc, wrapped);
3025 }
3026
3027-
3028+#if 0
3029 function_trace_expr* ExprManager::create_function_trace_expr(
3030 static_context* sctx,
3031+ user_function* udf,
3032 const QueryLoc& loc,
3033 expr* aChild)
3034 {
3035- CREATE_AND_RETURN_EXPR(function_trace_expr, sctx, loc, aChild);
3036+ CREATE_AND_RETURN_EXPR(function_trace_expr, sctx, udf, loc, aChild);
3037 }
3038-
3039-
3040-function_trace_expr* ExprManager::create_function_trace_expr(expr* aExpr)
3041+#endif
3042+
3043+function_trace_expr* ExprManager::create_function_trace_expr(
3044+ user_function* udf,
3045+ expr* aExpr)
3046 {
3047 //this function gets the ExprManager from the expression it recieves.
3048- function_trace_expr* e = new (theMemoryMgr) function_trace_expr(aExpr);
3049+ function_trace_expr* e = new (theMemoryMgr) function_trace_expr(udf, aExpr);
3050 reg(e);
3051 return e;
3052 }
3053@@ -530,25 +507,27 @@
3054
3055 eval_expr* ExprManager::create_eval_expr(
3056 static_context* sctx,
3057+ user_function* udf,
3058 const QueryLoc& loc,
3059 expr* e,
3060 expr_script_kind_t scriptingKind,
3061 namespace_context* nsCtx)
3062 {
3063- CREATE_AND_RETURN_EXPR(eval_expr, sctx, loc, e, scriptingKind, nsCtx);
3064+ CREATE_AND_RETURN_EXPR(eval_expr, sctx, udf, loc, e, scriptingKind, nsCtx);
3065 }
3066
3067 #ifdef ZORBA_WITH_DEBUGGER
3068
3069 debugger_expr* ExprManager::create_debugger_expr(
3070 static_context* sctx,
3071+ user_function* udf,
3072 const QueryLoc& loc,
3073 expr* aChild,
3074 namespace_context* nsCtx,
3075 bool aIsVarDeclaration)
3076 {
3077 CREATE_AND_RETURN_EXPR(debugger_expr,
3078- sctx, loc, aChild, nsCtx, aIsVarDeclaration);
3079+ sctx, udf, loc, aChild, nsCtx, aIsVarDeclaration);
3080 }
3081
3082 #endif
3083@@ -557,17 +536,20 @@
3084
3085 var_expr* ExprManager::create_var_expr(
3086 static_context* sctx,
3087+ user_function* udf,
3088 const QueryLoc& loc,
3089 var_expr::var_kind k,
3090 store::Item* name)
3091 {
3092- CREATE_AND_RETURN_EXPR(var_expr, sctx, loc, k, name);
3093+ CREATE_AND_RETURN_EXPR(var_expr, sctx, udf, loc, k, name);
3094 }
3095
3096
3097-var_expr* ExprManager::create_var_expr(const var_expr& source)
3098+var_expr* ExprManager::create_var_expr(
3099+ user_function* udf,
3100+ const var_expr& source)
3101 {
3102- var_expr* e = new (theMemoryMgr) var_expr(source);
3103+ var_expr* e = new (theMemoryMgr) var_expr(udf, source);
3104 reg(e);
3105 return e;
3106 }
3107@@ -580,30 +562,33 @@
3108
3109 json_array_expr* ExprManager::create_json_array_expr(
3110 static_context* sctx,
3111+ user_function* udf,
3112 const QueryLoc& loc,
3113 expr* content)
3114 {
3115- CREATE_AND_RETURN_EXPR(json_array_expr, sctx, loc, content);
3116+ CREATE_AND_RETURN_EXPR(json_array_expr, sctx, udf, loc, content);
3117 }
3118
3119
3120 json_object_expr* ExprManager::create_json_object_expr(
3121 static_context* sctx,
3122+ user_function* udf,
3123 const QueryLoc& loc,
3124 expr* content,
3125 bool accumulate)
3126 {
3127- CREATE_AND_RETURN_EXPR(json_object_expr, sctx, loc, content, accumulate);
3128+ CREATE_AND_RETURN_EXPR(json_object_expr, sctx, udf, loc, content, accumulate);
3129 }
3130
3131
3132 json_direct_object_expr* ExprManager::create_json_direct_object_expr(
3133 static_context* sctx,
3134+ user_function* udf,
3135 const QueryLoc& loc,
3136 std::vector<expr*>& names,
3137 std::vector<expr*>& values)
3138 {
3139- CREATE_AND_RETURN_EXPR(json_direct_object_expr, sctx, loc, names, values);
3140+ CREATE_AND_RETURN_EXPR(json_direct_object_expr, sctx, udf, loc, names, values);
3141 }
3142
3143
3144@@ -614,43 +599,47 @@
3145
3146 insert_expr* ExprManager::create_insert_expr(
3147 static_context* sctx,
3148+ user_function* udf,
3149 const QueryLoc& loc,
3150 store::UpdateConsts::InsertType insertType,
3151 expr* aSourceExpr,
3152 expr* aTargetExpr)
3153 {
3154 CREATE_AND_RETURN_EXPR(insert_expr,
3155- sctx, loc, insertType, aSourceExpr, aTargetExpr);
3156+ sctx, udf, loc, insertType, aSourceExpr, aTargetExpr);
3157 }
3158
3159
3160 delete_expr* ExprManager::create_delete_expr(
3161 static_context* sctx,
3162+ user_function* udf,
3163 const QueryLoc& loc,
3164 expr* aTargetExpr)
3165 {
3166- CREATE_AND_RETURN_EXPR(delete_expr, sctx, loc, aTargetExpr);
3167+ CREATE_AND_RETURN_EXPR(delete_expr, sctx, udf, loc, aTargetExpr);
3168 }
3169
3170
3171 replace_expr* ExprManager::create_replace_expr(
3172 static_context* sctx,
3173+ user_function* udf,
3174 const QueryLoc& loc,
3175 store::UpdateConsts::ReplaceType aType,
3176 expr* aSourceExpr,
3177 expr* aTargetExpr)
3178 {
3179- CREATE_AND_RETURN_EXPR(replace_expr, sctx, loc, aType, aSourceExpr, aTargetExpr);
3180+ CREATE_AND_RETURN_EXPR(replace_expr, sctx, udf, loc, aType, aSourceExpr, aTargetExpr);
3181 }
3182
3183
3184 rename_expr* ExprManager::create_rename_expr(
3185 static_context* sctx,
3186+ user_function* udf,
3187 const QueryLoc& loc,
3188 expr* aSourceExpr,
3189 expr* aTargetExpr)
3190 {
3191- CREATE_AND_RETURN_EXPR(rename_expr, sctx, loc, aSourceExpr, aTargetExpr);
3192+ CREATE_AND_RETURN_EXPR(rename_expr, sctx, udf, loc, aSourceExpr, aTargetExpr);
3193 }
3194
3195
3196@@ -662,112 +651,126 @@
3197
3198 transform_expr* ExprManager::create_transform_expr(
3199 static_context* sctx,
3200+ user_function* udf,
3201 const QueryLoc& loc)
3202 {
3203- CREATE_AND_RETURN_EXPR(transform_expr, sctx, loc);
3204+ CREATE_AND_RETURN_EXPR(transform_expr, sctx, udf, loc);
3205 }
3206
3207
3208 block_expr* ExprManager::create_block_expr(
3209 static_context* sctx,
3210+ user_function* udf,
3211 const QueryLoc& loc,
3212 bool allowLastUpdating,
3213 std::vector<expr*>& seq,
3214 std::vector<var_expr*>* assignedVars)
3215 {
3216 CREATE_AND_RETURN_EXPR(block_expr,
3217- sctx, loc, allowLastUpdating, seq, assignedVars);
3218+ sctx, udf, loc, allowLastUpdating, seq, assignedVars);
3219 }
3220
3221
3222 apply_expr* ExprManager::create_apply_expr(
3223 static_context* sctx,
3224+ user_function* udf,
3225 const QueryLoc& loc,
3226 expr* inExpr,
3227 bool discardXDM)
3228 {
3229- CREATE_AND_RETURN_EXPR(apply_expr, sctx, loc, inExpr, discardXDM);
3230+ CREATE_AND_RETURN_EXPR(apply_expr, sctx, udf, loc, inExpr, discardXDM);
3231 }
3232
3233
3234 var_decl_expr* ExprManager::create_var_decl_expr(
3235 static_context* sctx,
3236+ user_function* udf,
3237 const QueryLoc& loc,
3238 var_expr* varExpr,
3239 expr* initExpr)
3240 {
3241- CREATE_AND_RETURN_EXPR(var_decl_expr, sctx, loc, varExpr, initExpr);
3242+ CREATE_AND_RETURN_EXPR(var_decl_expr, sctx, udf, loc, varExpr, initExpr);
3243 }
3244
3245
3246 var_set_expr* ExprManager::create_var_set_expr(
3247 static_context* sctx,
3248+ user_function* udf,
3249 const QueryLoc& loc,
3250 var_expr* varExpr,
3251 expr* setExpr)
3252 {
3253- CREATE_AND_RETURN_EXPR(var_set_expr, sctx, loc, varExpr, setExpr);
3254+ CREATE_AND_RETURN_EXPR(var_set_expr, sctx, udf, loc, varExpr, setExpr);
3255 }
3256
3257
3258 exit_expr* ExprManager::create_exit_expr(
3259 static_context* sctx,
3260+ user_function* udf,
3261 const QueryLoc& loc,
3262 expr* inExpr)
3263 {
3264- CREATE_AND_RETURN_EXPR(exit_expr, sctx, loc, inExpr);
3265+ CREATE_AND_RETURN_EXPR(exit_expr, sctx, udf, loc, inExpr);
3266 }
3267
3268
3269 exit_catcher_expr* ExprManager::create_exit_catcher_expr(
3270 static_context* sctx,
3271+ user_function* udf,
3272 const QueryLoc& loc,
3273 expr* inExpr,
3274 std::vector<expr*>& exitExprs)
3275 {
3276- CREATE_AND_RETURN_EXPR(exit_catcher_expr, sctx, loc, inExpr, exitExprs);
3277+ CREATE_AND_RETURN_EXPR(exit_catcher_expr, sctx, udf, loc, inExpr, exitExprs);
3278 }
3279
3280
3281 flowctl_expr* ExprManager::create_flowctl_expr(
3282 static_context* sctx,
3283+ user_function* udf,
3284 const QueryLoc& loc,
3285 flowctl_expr::action action)
3286 {
3287- CREATE_AND_RETURN_EXPR(flowctl_expr, sctx, loc, action);
3288+ CREATE_AND_RETURN_EXPR(flowctl_expr, sctx, udf, loc, action);
3289 }
3290
3291
3292 while_expr* ExprManager::create_while_expr(
3293- static_context* sctx, const QueryLoc& loc, expr* body)
3294+ static_context* sctx,
3295+ user_function* udf,
3296+ const QueryLoc& loc,
3297+ expr* body)
3298 {
3299- CREATE_AND_RETURN_EXPR(while_expr, sctx, loc, body);
3300+ CREATE_AND_RETURN_EXPR(while_expr, sctx, udf, loc, body);
3301 }
3302
3303
3304 ////////////////////////////////////////////////////////////////////////////////
3305
3306 relpath_expr* ExprManager::create_relpath_expr(
3307- static_context* sctx,
3308- const QueryLoc& loc)
3309+ static_context* sctx,
3310+ user_function* udf,
3311+ const QueryLoc& loc)
3312 {
3313- CREATE_AND_RETURN_EXPR(relpath_expr, sctx, loc);
3314+ CREATE_AND_RETURN_EXPR(relpath_expr, sctx, udf, loc);
3315 }
3316
3317
3318 axis_step_expr* ExprManager::create_axis_step_expr(
3319 static_context* sctx,
3320+ user_function* udf,
3321 const QueryLoc& loc)
3322 {
3323- CREATE_AND_RETURN_EXPR(axis_step_expr, sctx, loc);
3324+ CREATE_AND_RETURN_EXPR(axis_step_expr, sctx, udf, loc);
3325 }
3326
3327
3328 match_expr* ExprManager::create_match_expr(
3329 static_context* sctx,
3330+ user_function* udf,
3331 const QueryLoc& loc)
3332 {
3333- CREATE_AND_RETURN_EXPR(match_expr, sctx, loc);
3334+ CREATE_AND_RETURN_EXPR(match_expr, sctx, udf, loc);
3335 }
3336
3337
3338@@ -776,92 +779,105 @@
3339 dynamic_function_invocation_expr*
3340 ExprManager::create_dynamic_function_invocation_expr(
3341 static_context* sctx,
3342+ user_function* udf,
3343 const QueryLoc& loc,
3344 expr* anExpr,
3345 const std::vector<expr*>& args)
3346 {
3347- CREATE_AND_RETURN_EXPR(dynamic_function_invocation_expr, sctx, loc, anExpr, args);
3348+ CREATE_AND_RETURN_EXPR(dynamic_function_invocation_expr, sctx, udf, loc, anExpr, args);
3349 }
3350
3351
3352 function_item_expr* ExprManager::create_function_item_expr(
3353 static_context* sctx,
3354+ user_function* udf,
3355 const QueryLoc& loc,
3356 const store::Item* aQName,
3357 function* f,
3358 uint32_t aArity)
3359 {
3360- CREATE_AND_RETURN_EXPR(function_item_expr, sctx, loc, aQName, f, aArity);
3361+ CREATE_AND_RETURN_EXPR(function_item_expr, sctx, udf, loc, aQName, f, aArity);
3362 }
3363
3364
3365 function_item_expr* ExprManager::create_function_item_expr(
3366 static_context* sctx,
3367+ user_function* udf,
3368 const QueryLoc& loc)
3369 {
3370- CREATE_AND_RETURN_EXPR(function_item_expr, sctx, loc);
3371+ CREATE_AND_RETURN_EXPR(function_item_expr, sctx, udf, loc);
3372 }
3373
3374
3375 ftcontains_expr* ExprManager::create_ftcontains_expr(
3376 static_context* sctx,
3377+ user_function* udf,
3378 QueryLoc const& loc,
3379 expr* range,
3380 ftnode *ftselection,
3381 expr* ftignore)
3382 {
3383- CREATE_AND_RETURN_EXPR(ftcontains_expr, sctx, loc, range, ftselection, ftignore);
3384+ CREATE_AND_RETURN_EXPR(ftcontains_expr, sctx, udf, loc, range, ftselection, ftignore);
3385 }
3386
3387
3388 ////////////////////////////////////////////////////////////////////////////////
3389
3390 //this calls the static create_seq within fo_expr
3391-fo_expr* ExprManager::create_seq(static_context* sctx, const QueryLoc& loc)
3392+fo_expr* ExprManager::create_seq(
3393+ static_context* sctx,
3394+ user_function* udf,
3395+ const QueryLoc& loc)
3396 {
3397 //TODO make fo_expr use this factory to generate everything
3398- return fo_expr::create_seq(theCCB, sctx, loc);
3399+ return fo_expr::create_seq(theCCB, sctx, udf, loc);
3400 }
3401
3402
3403 fo_expr* ExprManager::create_fo_expr(
3404 static_context* sctx,
3405+ user_function* udf,
3406 const QueryLoc& loc,
3407 const function* f,
3408 expr* arg)
3409 {
3410- CREATE_AND_RETURN_EXPR(fo_expr, sctx, loc, f, arg);
3411+ CREATE_AND_RETURN_EXPR(fo_expr, sctx, udf, loc, f, arg);
3412 }
3413
3414
3415 fo_expr* ExprManager::create_fo_expr(
3416 static_context* sctx,
3417+ user_function* udf,
3418 const QueryLoc& loc,
3419 const function* f,
3420 expr* arg1,
3421 expr* arg2)
3422 {
3423- CREATE_AND_RETURN_EXPR(fo_expr, sctx, loc, f, arg1, arg2);
3424+ CREATE_AND_RETURN_EXPR(fo_expr, sctx, udf, loc, f, arg1, arg2);
3425 }
3426
3427
3428 fo_expr* ExprManager::create_fo_expr(
3429 static_context* sctx,
3430+ user_function* udf,
3431 const QueryLoc& loc,
3432 const function* f,
3433 const std::vector<expr*>& args)
3434 {
3435- CREATE_AND_RETURN_EXPR(fo_expr, sctx, loc, f, args);
3436+ CREATE_AND_RETURN_EXPR(fo_expr, sctx, udf, loc, f, args);
3437 }
3438
3439+
3440 fo_expr* ExprManager::create_fo_expr(
3441 static_context* sctx,
3442+ user_function* udf,
3443 const QueryLoc& loc,
3444 const function* f)
3445 {
3446
3447- CREATE_AND_RETURN_EXPR(fo_expr, sctx, loc, f);
3448+ CREATE_AND_RETURN_EXPR(fo_expr, sctx, udf, loc, f);
3449 }
3450+
3451 ////////////////////////////////////////////////////////////////////////////////
3452
3453 for_clause* ExprManager::create_for_clause(
3454@@ -877,6 +893,7 @@
3455 sctx, theCCB, loc, varExpr, domainExpr, posVarExpr, scoreVarExpr, isOuter);
3456 }
3457
3458+
3459 let_clause* ExprManager::create_let_clause(
3460 static_context* sctx,
3461 const QueryLoc& loc,
3462@@ -887,6 +904,7 @@
3463 CREATE_AND_RETURN(let_clause, sctx, theCCB, loc, varExpr, domainExpr, lazy);
3464 }
3465
3466+
3467 window_clause* ExprManager::create_window_clause(
3468 static_context* sctx,
3469 const QueryLoc& loc,
3470@@ -901,16 +919,18 @@
3471 sctx, theCCB, loc, winKind, varExpr, domainExpr, winStart, winStop, lazy);
3472 }
3473
3474+
3475 flwor_wincond* ExprManager::create_flwor_wincond(
3476- static_context* sctx,
3477- bool isOnly,
3478- const flwor_wincond::vars& in_vars,
3479- const flwor_wincond::vars& out_vars,
3480- expr* cond)
3481+ static_context* sctx,
3482+ bool isOnly,
3483+ const flwor_wincond::vars& in_vars,
3484+ const flwor_wincond::vars& out_vars,
3485+ expr* cond)
3486 {
3487 CREATE_AND_RETURN(flwor_wincond, theCCB, sctx, isOnly, in_vars, out_vars, cond);
3488 }
3489
3490+
3491 group_clause* ExprManager::create_group_clause(
3492 static_context* sctx,
3493 const QueryLoc& loc,
3494@@ -921,40 +941,54 @@
3495 CREATE_AND_RETURN(group_clause, sctx, theCCB, loc, gvars, ngvars, collations);
3496 }
3497
3498+
3499 orderby_clause* ExprManager::create_orderby_clause(
3500- static_context* sctx,
3501- const QueryLoc& loc,
3502- bool stable,
3503- const std::vector<OrderModifier>& modifiers,
3504- const std::vector<expr*>& orderingExprs)
3505+ static_context* sctx,
3506+ const QueryLoc& loc,
3507+ bool stable,
3508+ const std::vector<OrderModifier>& modifiers,
3509+ const std::vector<expr*>& orderingExprs)
3510 {
3511 CREATE_AND_RETURN(orderby_clause, sctx, theCCB, loc, stable, modifiers, orderingExprs);
3512 }
3513
3514+
3515 materialize_clause* ExprManager::create_materialize_clause(
3516- static_context* sctx, const QueryLoc& loc)
3517+ static_context* sctx,
3518+ const QueryLoc& loc)
3519 {
3520 CREATE_AND_RETURN(materialize_clause, sctx, theCCB, loc);
3521 }
3522
3523+
3524 count_clause* ExprManager::create_count_clause(
3525- static_context* sctx, const QueryLoc& loc, var_expr* var)
3526+ static_context* sctx,
3527+ const QueryLoc& loc,
3528+ var_expr* var)
3529 {
3530 CREATE_AND_RETURN(count_clause, sctx, theCCB, loc, var);
3531 }
3532
3533+
3534 where_clause* ExprManager::create_where_clause(
3535- static_context* sctx, const QueryLoc& loc, expr* where)
3536+ static_context* sctx,
3537+ const QueryLoc& loc,
3538+ expr* where)
3539 {
3540 CREATE_AND_RETURN(where_clause, sctx, theCCB, loc, where);
3541 }
3542
3543+
3544 flwor_expr* ExprManager::create_flwor_expr(
3545- static_context* sctx, const QueryLoc& loc, bool general)
3546+ static_context* sctx,
3547+ user_function* udf,
3548+ const QueryLoc& loc,
3549+ bool general)
3550 {
3551- CREATE_AND_RETURN_EXPR(flwor_expr, sctx, loc, general);
3552+ CREATE_AND_RETURN_EXPR(flwor_expr, sctx, udf, loc, general);
3553 }
3554
3555+
3556 pragma* ExprManager::create_pragma(
3557 const store::Item_t& name,
3558 const zstring& lit)
3559
3560=== modified file 'src/compiler/expression/expr_manager.h'
3561--- src/compiler/expression/expr_manager.h 2012-10-08 12:09:36 +0000
3562+++ src/compiler/expression/expr_manager.h 2012-10-09 13:35:26 +0000
3563@@ -31,6 +31,7 @@
3564
3565 class CompilerCB;
3566
3567+
3568 class ExprManager
3569 {
3570 private:
3571@@ -75,6 +76,7 @@
3572 public:
3573 if_expr* create_if_expr(
3574 static_context* sctx,
3575+ user_function* udf,
3576 const QueryLoc& loc,
3577 expr* cond_expr,
3578 expr* then_expr,
3579@@ -82,12 +84,14 @@
3580
3581 order_expr* create_order_expr(
3582 static_context* sctx,
3583+ user_function* udf,
3584 const QueryLoc& loc,
3585 order_expr::order_type_t,
3586 expr*);
3587
3588 validate_expr* create_validate_expr(
3589 static_context*,
3590+ user_function* udf,
3591 const QueryLoc&,
3592 ParseConstants::validation_mode_t,
3593 const store::Item_t& aTypeName,
3594@@ -96,12 +100,14 @@
3595
3596 cast_expr* create_cast_expr(
3597 static_context* sctx,
3598+ user_function* udf,
3599 const QueryLoc&,
3600 expr*,
3601 xqtref_t);
3602
3603 treat_expr* create_treat_expr(
3604 static_context* sctx,
3605+ user_function* udf,
3606 const QueryLoc& loc,
3607 expr* input,
3608 const xqtref_t& type,
3609@@ -112,6 +118,7 @@
3610
3611 promote_expr* create_promote_expr(
3612 static_context* sctx,
3613+ user_function* udf,
3614 const QueryLoc& loc,
3615 expr* input,
3616 const xqtref_t& type,
3617@@ -120,12 +127,14 @@
3618
3619 castable_expr* create_castable_expr(
3620 static_context* sctx,
3621+ user_function* udf,
3622 const QueryLoc&,
3623 expr*,
3624 xqtref_t);
3625
3626 instanceof_expr* create_instanceof_expr(
3627 static_context* sctx,
3628+ user_function* udf,
3629 const QueryLoc&,
3630 expr*,
3631 xqtref_t,
3632@@ -133,6 +142,7 @@
3633
3634 name_cast_expr* create_name_cast_expr(
3635 static_context* sctx,
3636+ user_function* udf,
3637 const QueryLoc&,
3638 expr*,
3639 const namespace_context*,
3640@@ -140,12 +150,14 @@
3641
3642 doc_expr* create_doc_expr(
3643 static_context* sctx,
3644+ user_function* udf,
3645 const QueryLoc&,
3646 expr* content,
3647 bool copyNodes);
3648
3649 elem_expr* create_elem_expr(
3650 static_context* sctx,
3651+ user_function* udf,
3652 const QueryLoc&,
3653 expr* qnameExpr,
3654 expr* attrs,
3655@@ -155,6 +167,7 @@
3656
3657 elem_expr* create_elem_expr(
3658 static_context* sctx,
3659+ user_function* udf,
3660 const QueryLoc&,
3661 expr* qnameExpr,
3662 expr* content,
3663@@ -163,64 +176,76 @@
3664
3665 attr_expr* create_attr_expr(
3666 static_context* sctx,
3667+ user_function* udf,
3668 const QueryLoc& loc,
3669 expr* aQNameExpr,
3670 expr* aValueExpr);
3671
3672 text_expr* create_text_expr(
3673 static_context* sctx,
3674+ user_function* udf,
3675 const QueryLoc&,
3676 text_expr::text_constructor_type,
3677 expr*);
3678
3679 pi_expr* create_pi_expr(
3680 static_context* sctx,
3681+ user_function* udf,
3682 const QueryLoc&,
3683 expr*,
3684 expr*);
3685
3686 const_expr* create_const_expr(
3687 static_context* sctx,
3688+ user_function* udf,
3689 const QueryLoc&,
3690 zstring& sval);
3691
3692 const_expr* create_const_expr(
3693 static_context* sctx,
3694+ user_function* udf,
3695 const QueryLoc&,
3696 const std::string& sval);
3697
3698 const_expr* create_const_expr(
3699 static_context* sctx,
3700+ user_function* udf,
3701 const QueryLoc&,
3702 const char* sval);
3703
3704 const_expr* create_const_expr(
3705 static_context* sctx,
3706+ user_function* udf,
3707 const QueryLoc&,
3708 xs_integer);
3709
3710 const_expr* create_const_expr(
3711 static_context* sctx,
3712+ user_function* udf,
3713 const QueryLoc&,
3714 xs_decimal);
3715
3716 const_expr* create_const_expr(
3717 static_context* sctx,
3718+ user_function* udf,
3719 const QueryLoc&,
3720 xs_double);
3721
3722 const_expr* create_const_expr(
3723 static_context* sctx,
3724+ user_function* udf,
3725 const QueryLoc&,
3726 xs_boolean);
3727
3728 const_expr* create_const_expr(
3729 static_context* sctx,
3730+ user_function* udf,
3731 const QueryLoc&,
3732 store::Item_t);
3733
3734 const_expr* create_const_expr(
3735 static_context* sctx,
3736+ user_function* udf,
3737 const QueryLoc&,
3738 const char* ns,
3739 const char* pre,
3740@@ -228,10 +253,12 @@
3741
3742 extension_expr* create_extension_expr(
3743 static_context* sctx,
3744+ user_function* udf,
3745 const QueryLoc&);
3746
3747 extension_expr* create_extension_expr(
3748 static_context* sctx,
3749+ user_function* udf,
3750 const QueryLoc&,
3751 expr*);
3752
3753@@ -239,23 +266,31 @@
3754
3755 trycatch_expr* create_trycatch_expr(
3756 static_context* sctx,
3757+ user_function* udf,
3758 const QueryLoc&,
3759 expr* tryExpr);
3760
3761 wrapper_expr* create_wrapper_expr(
3762 static_context* sctx,
3763+ user_function* udf,
3764 const QueryLoc& loc,
3765 expr* wrapped);
3766
3767+#if 0
3768 function_trace_expr* create_function_trace_expr(
3769 static_context* sctx,
3770+ user_function* udf,
3771 const QueryLoc& loc,
3772 expr* aChild);
3773+#endif
3774
3775- function_trace_expr* create_function_trace_expr(expr* aExpr);
3776+ function_trace_expr* create_function_trace_expr(
3777+ user_function* udf,
3778+ expr* aExpr);
3779
3780 eval_expr* create_eval_expr(
3781 static_context* sctx,
3782+ user_function* udf,
3783 const QueryLoc& loc,
3784 expr* e,
3785 expr_script_kind_t scriptingKind,
3786@@ -264,6 +299,7 @@
3787 #ifdef ZORBA_WITH_DEBUGGER
3788 debugger_expr* create_debugger_expr(
3789 static_context* sctx,
3790+ user_function* udf,
3791 const QueryLoc& loc,
3792 expr* aChild,
3793 namespace_context* nsCtx,
3794@@ -274,11 +310,12 @@
3795
3796 var_expr* create_var_expr(
3797 static_context* sctx,
3798+ user_function* udf,
3799 const QueryLoc& loc,
3800 var_expr::var_kind k,
3801 store::Item* name);
3802
3803- var_expr* create_var_expr(const var_expr& source);
3804+ var_expr* create_var_expr(user_function* udf, const var_expr& source);
3805
3806 ////////////////////////////////////////////////////////////////////////////////
3807
3808@@ -286,17 +323,20 @@
3809
3810 json_array_expr* create_json_array_expr(
3811 static_context* sctx,
3812+ user_function* udf,
3813 const QueryLoc& loc,
3814 expr* content);
3815
3816 json_object_expr* create_json_object_expr(
3817 static_context* sctx,
3818+ user_function* udf,
3819 const QueryLoc& loc,
3820 expr* content,
3821 bool accumulate);
3822
3823 json_direct_object_expr* create_json_direct_object_expr(
3824 static_context* sctx,
3825+ user_function* udf,
3826 const QueryLoc&,
3827 std::vector<expr*>& names,
3828 std::vector<expr*>& values);
3829@@ -307,6 +347,7 @@
3830
3831 insert_expr* create_insert_expr(
3832 static_context* sctx,
3833+ user_function* udf,
3834 const QueryLoc&,
3835 store::UpdateConsts::InsertType,
3836 expr* aSourceExpr,
3837@@ -314,11 +355,13 @@
3838
3839 delete_expr* create_delete_expr(
3840 static_context* sctx,
3841+ user_function* udf,
3842 const QueryLoc&,
3843 expr*);
3844
3845 replace_expr* create_replace_expr(
3846 static_context* sctx,
3847+ user_function* udf,
3848 const QueryLoc&,
3849 store::UpdateConsts::ReplaceType aType,
3850 expr*,
3851@@ -326,6 +369,7 @@
3852
3853 rename_expr* create_rename_expr(
3854 static_context* sctx,
3855+ user_function* udf,
3856 const QueryLoc&,
3857 expr*,
3858 expr*);
3859@@ -334,10 +378,12 @@
3860
3861 transform_expr* create_transform_expr(
3862 static_context* sctx,
3863+ user_function* udf,
3864 const QueryLoc& loc);
3865
3866 block_expr* create_block_expr(
3867 static_context* sctx,
3868+ user_function* udf,
3869 const QueryLoc& loc,
3870 bool allowLastUpdating,
3871 std::vector<expr*>& seq,
3872@@ -345,61 +391,79 @@
3873
3874 apply_expr* create_apply_expr(
3875 static_context* sctx,
3876+ user_function* udf,
3877 const QueryLoc& loc,
3878 expr* inExpr,
3879 bool discardXDM);
3880
3881 var_decl_expr* create_var_decl_expr(
3882 static_context* sctx,
3883+ user_function* udf,
3884 const QueryLoc& loc,
3885 var_expr* varExpr,
3886 expr* initExpr);
3887
3888 var_set_expr* create_var_set_expr(
3889 static_context* sctx,
3890+ user_function* udf,
3891 const QueryLoc& loc,
3892 var_expr* varExpr,
3893 expr* setExpr);
3894
3895 exit_expr* create_exit_expr(
3896 static_context* sctx,
3897+ user_function* udf,
3898 const QueryLoc& loc,
3899 expr* inExpr);
3900
3901 exit_catcher_expr* create_exit_catcher_expr(
3902 static_context* sctx,
3903+ user_function* udf,
3904 const QueryLoc& loc,
3905 expr* inExpr,
3906 std::vector<expr*>& exitExprs);
3907
3908 flowctl_expr* create_flowctl_expr(
3909 static_context* sctx,
3910+ user_function* udf,
3911 const QueryLoc& loc,
3912 flowctl_expr::action action);
3913
3914 while_expr* create_while_expr(
3915 static_context* sctx,
3916+ user_function* udf,
3917 const QueryLoc& loc,
3918 expr* body);
3919
3920 ////////////////////////////////////////////////////////////////////////////////
3921
3922- relpath_expr* create_relpath_expr(static_context* sctx, const QueryLoc& loc);
3923-
3924- axis_step_expr* create_axis_step_expr(static_context* sctx, const QueryLoc&);
3925-
3926- match_expr* create_match_expr(static_context* sctx, const QueryLoc&);
3927+ relpath_expr* create_relpath_expr(
3928+ static_context* sctx,
3929+ user_function* udf,
3930+ const QueryLoc& loc);
3931+
3932+ axis_step_expr* create_axis_step_expr(
3933+ static_context* sctx,
3934+ user_function* udf,
3935+ const QueryLoc&);
3936+
3937+ match_expr* create_match_expr(
3938+ static_context* sctx,
3939+ user_function* udf,
3940+ const QueryLoc&);
3941
3942 ////////////////////////////////////////////////////////////////////////////////
3943
3944 dynamic_function_invocation_expr* create_dynamic_function_invocation_expr(
3945 static_context* sctx,
3946+ user_function* udf,
3947 const QueryLoc& loc,
3948 expr* anExpr,
3949 const std::vector<expr*>& args);
3950
3951 function_item_expr* create_function_item_expr(
3952 static_context* sctx,
3953+ user_function* udf,
3954 const QueryLoc& loc,
3955 const store::Item* aQName,
3956 function* f,
3957@@ -407,10 +471,12 @@
3958
3959 function_item_expr* create_function_item_expr(
3960 static_context* sctx,
3961+ user_function* udf,
3962 const QueryLoc& loc);
3963
3964 ftcontains_expr* create_ftcontains_expr(
3965 static_context*,
3966+ user_function* udf,
3967 QueryLoc const&,
3968 expr* range,
3969 ftnode *ftselection,
3970@@ -419,16 +485,21 @@
3971 ////////////////////////////////////////////////////////////////////////////////
3972
3973 //this calls the static create_seq within fo_expr
3974- fo_expr* create_seq(static_context* sctx, const QueryLoc &);
3975+ fo_expr* create_seq(
3976+ static_context* sctx,
3977+ user_function* udf,
3978+ const QueryLoc &);
3979
3980 fo_expr* create_fo_expr(
3981 static_context* sctx,
3982+ user_function* udf,
3983 const QueryLoc& loc,
3984 const function* f,
3985 expr* arg);
3986
3987 fo_expr* create_fo_expr(
3988 static_context* sctx,
3989+ user_function* udf,
3990 const QueryLoc& loc,
3991 const function* f,
3992 expr* arg1,
3993@@ -436,12 +507,14 @@
3994
3995 fo_expr* create_fo_expr(
3996 static_context* sctx,
3997+ user_function* udf,
3998 const QueryLoc& loc,
3999 const function* f,
4000 const std::vector<expr*>& args);
4001
4002 fo_expr* create_fo_expr(
4003 static_context* sctx,
4004+ user_function* udf,
4005 const QueryLoc& loc,
4006 const function* f);
4007
4008@@ -510,6 +583,7 @@
4009
4010 flwor_expr* create_flwor_expr(
4011 static_context* sctx,
4012+ user_function* udf,
4013 const QueryLoc& loc,
4014 bool general);
4015
4016@@ -524,17 +598,20 @@
4017
4018 json_array_expr* create_json_array_expr(
4019 static_context* sctx,
4020+ user_function* udf,
4021 const QueryLoc& loc,
4022 expr* content);
4023
4024 json_object_expr* create_json_object_expr(
4025 static_context* sctx,
4026+ user_function* udf,
4027 const QueryLoc& loc,
4028 expr* content,
4029 bool accumulate);
4030
4031 json_direct_object_expr* create_json_direct_object_expr(
4032 static_context* sctx,
4033+ user_function* udf,
4034 const QueryLoc& loc,
4035 std::vector<expr*>& names,
4036 std::vector<expr*>& values);
4037
4038=== modified file 'src/compiler/expression/flwor_expr.cpp'
4039--- src/compiler/expression/flwor_expr.cpp 2012-10-08 12:09:36 +0000
4040+++ src/compiler/expression/flwor_expr.cpp 2012-10-09 13:35:26 +0000
4041@@ -107,6 +107,7 @@
4042 {
4043 theDomainExpr = theCCB->theEM->
4044 create_treat_expr(theDomainExpr->get_sctx(),
4045+ theDomainExpr->get_udf(),
4046 theDomainExpr->get_loc(),
4047 theDomainExpr,
4048 varType,
4049@@ -173,11 +174,13 @@
4050 *declaredType));
4051 }
4052
4053- domainExpr = theCCB->theEM->create_treat_expr(sctx,
4054- loc,
4055- domainExpr,
4056- declaredType,
4057- TreatIterator::TYPE_MATCH);
4058+ domainExpr = theCCB->theEM->
4059+ create_treat_expr(sctx,
4060+ domainExpr->get_udf(),
4061+ loc,
4062+ domainExpr,
4063+ declaredType,
4064+ TreatIterator::TYPE_MATCH);
4065
4066 set_expr(domainExpr);
4067 }
4068@@ -225,18 +228,18 @@
4069 }
4070
4071
4072-flwor_clause* for_clause::clone(expr::substitution_t& subst) const
4073+flwor_clause* for_clause::clone(user_function* udf, expr::substitution_t& subst) const
4074 {
4075- expr* domainCopy = theDomainExpr->clone(subst);
4076+ expr* domainCopy = theDomainExpr->clone(udf, subst);
4077
4078- var_expr* varCopy = theCCB->theEM->create_var_expr(*theVarExpr);
4079+ var_expr* varCopy = theCCB->theEM->create_var_expr(udf, *theVarExpr);
4080 subst[theVarExpr] = varCopy;
4081
4082 var_expr* posvarCopy = NULL;
4083 var_expr* pos_var_ptr = thePosVarExpr;
4084 if (pos_var_ptr)
4085 {
4086- posvarCopy = theCCB->theEM->create_var_expr(*pos_var_ptr);
4087+ posvarCopy = theCCB->theEM->create_var_expr(udf, *pos_var_ptr);
4088 subst[pos_var_ptr] = posvarCopy;
4089 }
4090
4091@@ -244,17 +247,17 @@
4092 var_expr* score_var_ptr = theScoreVarExpr;
4093 if (score_var_ptr)
4094 {
4095- scorevarCopy = theCCB->theEM->create_var_expr(*score_var_ptr);
4096+ scorevarCopy = theCCB->theEM->create_var_expr(udf, *score_var_ptr);
4097 subst[score_var_ptr] = scorevarCopy;
4098 }
4099
4100 return theCCB->theEM->create_for_clause(theContext,
4101- get_loc(),
4102- varCopy,
4103- domainCopy,
4104- posvarCopy,
4105- scorevarCopy,
4106- theAllowingEmpty);
4107+ get_loc(),
4108+ varCopy,
4109+ domainCopy,
4110+ posvarCopy,
4111+ scorevarCopy,
4112+ theAllowingEmpty);
4113 }
4114
4115
4116@@ -298,11 +301,13 @@
4117 ERROR_PARAMS(ZED(BadType_23o), *domainType, ZED(NoTreatAs_4), *declaredType));
4118 }
4119
4120- domainExpr = theCCB->theEM->create_treat_expr(sctx,
4121- loc,
4122- domainExpr,
4123- declaredType,
4124- TreatIterator::TYPE_MATCH);
4125+ domainExpr = theCCB->theEM->
4126+ create_treat_expr(sctx,
4127+ domainExpr->get_udf(),
4128+ loc,
4129+ domainExpr,
4130+ declaredType,
4131+ TreatIterator::TYPE_MATCH);
4132
4133 set_expr(domainExpr);
4134 }
4135@@ -332,11 +337,11 @@
4136 }
4137
4138
4139-flwor_clause* let_clause::clone(expr::substitution_t& subst) const
4140+flwor_clause* let_clause::clone(user_function* udf, expr::substitution_t& subst) const
4141 {
4142- expr* domainCopy = theDomainExpr->clone(subst);
4143+ expr* domainCopy = theDomainExpr->clone(udf, subst);
4144
4145- var_expr* varCopy = theCCB->theEM->create_var_expr(*theVarExpr);
4146+ var_expr* varCopy = theCCB->theEM->create_var_expr(udf, *theVarExpr);
4147 subst[theVarExpr] = varCopy;
4148
4149 #if 0
4150@@ -350,10 +355,10 @@
4151 #endif
4152
4153 return theCCB->theEM->create_let_clause(theContext,
4154- get_loc(),
4155- varCopy,
4156- domainCopy,
4157- theLazyEval);
4158+ get_loc(),
4159+ varCopy,
4160+ domainCopy,
4161+ theLazyEval);
4162 }
4163
4164
4165@@ -403,6 +408,7 @@
4166 {
4167 domainExpr = theCCB->theEM->
4168 create_treat_expr(sctx,
4169+ domainExpr->get_udf(),
4170 loc,
4171 domainExpr,
4172 varType,
4173@@ -441,21 +447,23 @@
4174 }
4175
4176
4177-flwor_clause* window_clause::clone(expr::substitution_t& subst) const
4178+flwor_clause* window_clause::clone(
4179+ user_function* udf,
4180+ expr::substitution_t& subst) const
4181 {
4182- expr* domainCopy = theDomainExpr->clone(subst);
4183+ expr* domainCopy = theDomainExpr->clone(udf, subst);
4184
4185- var_expr* varCopy = theCCB->theEM->create_var_expr(*theVarExpr);
4186+ var_expr* varCopy = theCCB->theEM->create_var_expr(udf, *theVarExpr);
4187 subst[theVarExpr] = varCopy;
4188
4189 flwor_wincond* cloneStartCond = NULL;
4190 flwor_wincond* cloneStopCond = NULL;
4191
4192 if (theWinStartCond != NULL)
4193- cloneStartCond = theWinStartCond->clone(subst);
4194+ cloneStartCond = theWinStartCond->clone(udf, subst);
4195
4196 if (theWinStopCond != NULL)
4197- cloneStopCond = theWinStopCond->clone(subst);
4198+ cloneStopCond = theWinStopCond->clone(udf, subst);
4199
4200 return theCCB->theEM->create_window_clause(theContext,
4201 get_loc(),
4202@@ -493,15 +501,17 @@
4203
4204 xqtref_t condType = theCondExpr->get_return_type();
4205
4206- if(!TypeOps::is_equal(tm,
4207+ if (!TypeOps::is_equal(tm,
4208 *condType,
4209 *GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE,
4210 theCondExpr->get_loc()))
4211 {
4212- theCondExpr = theCCB->theEM->create_fo_expr(theCondExpr->get_sctx(),
4213- theCondExpr->get_loc(),
4214- GET_BUILTIN_FUNCTION(FN_BOOLEAN_1),
4215- theCondExpr);
4216+ theCondExpr = theCCB->theEM->
4217+ create_fo_expr(theCondExpr->get_sctx(),
4218+ theCondExpr->get_udf(),
4219+ theCondExpr->get_loc(),
4220+ GET_BUILTIN_FUNCTION(FN_BOOLEAN_1),
4221+ theCondExpr);
4222 }
4223 }
4224 }
4225@@ -514,14 +524,15 @@
4226
4227
4228 flwor_wincond::vars::vars()
4229-:
4230-posvar(NULL),
4231-curr(NULL),
4232-prev(NULL),
4233-next(NULL)
4234+ :
4235+ posvar(NULL),
4236+ curr(NULL),
4237+ prev(NULL),
4238+ next(NULL)
4239 {
4240 }
4241
4242+
4243 flwor_wincond::vars::~vars()
4244 {
4245 // set_flwor_clause(NULL);
4246@@ -539,33 +550,34 @@
4247
4248 void flwor_wincond::vars::clone(
4249 ExprManager* mgr,
4250+ user_function* udf,
4251 flwor_wincond::vars& cloneVars,
4252 expr::substitution_t& subst) const
4253 {
4254 if (posvar != NULL)
4255 {
4256- var_expr* varCopy = mgr->create_var_expr(*posvar);
4257+ var_expr* varCopy = mgr->create_var_expr(udf, *posvar);
4258 subst[posvar] = varCopy;
4259 cloneVars.posvar = varCopy;
4260 }
4261
4262 if (curr != NULL)
4263 {
4264- var_expr* varCopy = mgr->create_var_expr(*curr);
4265+ var_expr* varCopy = mgr->create_var_expr(udf, *curr);
4266 subst[curr] = varCopy;
4267 cloneVars.curr = varCopy;
4268 }
4269
4270 if (prev != NULL)
4271 {
4272- var_expr* varCopy = mgr->create_var_expr(*prev);
4273+ var_expr* varCopy = mgr->create_var_expr(udf, *prev);
4274 subst[prev] = varCopy;
4275 cloneVars.prev = varCopy;
4276 }
4277
4278 if (next != NULL)
4279 {
4280- var_expr* varCopy = mgr->create_var_expr(*next);
4281+ var_expr* varCopy = mgr->create_var_expr(udf, *next);
4282 subst[next] = varCopy;
4283 cloneVars.next = varCopy;
4284 }
4285@@ -579,21 +591,23 @@
4286 }
4287
4288
4289-flwor_wincond* flwor_wincond::clone(expr::substitution_t& subst) const
4290+flwor_wincond* flwor_wincond::clone(
4291+ user_function* udf,
4292+ expr::substitution_t& subst) const
4293 {
4294 flwor_wincond::vars cloneInVars;
4295 flwor_wincond::vars cloneOutVars;
4296
4297- theInputVars.clone(theCCB->theEM, cloneInVars, subst);
4298- theOutputVars.clone(theCCB->theEM, cloneOutVars, subst);
4299+ theInputVars.clone(theCCB->theEM, udf, cloneInVars, subst);
4300+ theOutputVars.clone(theCCB->theEM, udf, cloneOutVars, subst);
4301
4302- expr* cloneCondExpr = theCondExpr->clone(subst);
4303+ expr* cloneCondExpr = theCondExpr->clone(udf, subst);
4304
4305 return theCCB->theEM->create_flwor_wincond(NULL,
4306- theIsOnly,
4307- cloneInVars,
4308- cloneOutVars,
4309- cloneCondExpr);
4310+ theIsOnly,
4311+ cloneInVars,
4312+ cloneOutVars,
4313+ cloneCondExpr);
4314 }
4315
4316
4317@@ -663,7 +677,9 @@
4318 }
4319
4320
4321-flwor_clause* group_clause::clone(expr::substitution_t& subst) const
4322+flwor_clause* group_clause::clone(
4323+ user_function* udf,
4324+ expr::substitution_t& subst) const
4325 {
4326 csize numGroupVars = theGroupVars.size();
4327 csize numNonGroupVars = theNonGroupVars.size();
4328@@ -680,23 +696,29 @@
4329
4330 for (csize i = 0; i < numGroupVars; ++i)
4331 {
4332- cloneGroupVars[i].first = theGroupVars[i].first->clone(subst);
4333- cloneGroupVars[i].second = exprMgr->create_var_expr(*theGroupVars[i].second);
4334+ cloneGroupVars[i].first = theGroupVars[i].first->clone(udf, subst);
4335+
4336+ cloneGroupVars[i].second = exprMgr->
4337+ create_var_expr(udf, *theGroupVars[i].second);
4338+
4339 subst[theGroupVars[i].second] = cloneGroupVars[i].second;
4340 }
4341
4342 for (csize i = 0; i < numNonGroupVars; ++i)
4343 {
4344- cloneNonGroupVars[i].first = theNonGroupVars[i].first->clone(subst);
4345- cloneNonGroupVars[i].second = exprMgr->create_var_expr(*theNonGroupVars[i].second);
4346+ cloneNonGroupVars[i].first = theNonGroupVars[i].first->clone(udf, subst);
4347+
4348+ cloneNonGroupVars[i].second = exprMgr->
4349+ create_var_expr(udf, *theNonGroupVars[i].second);
4350+
4351 subst[theNonGroupVars[i].second] = cloneNonGroupVars[i].second;
4352 }
4353
4354 return theCCB->theEM->create_group_clause(theContext,
4355- get_loc(),
4356- cloneGroupVars,
4357- cloneNonGroupVars,
4358- theCollations);
4359+ get_loc(),
4360+ cloneGroupVars,
4361+ cloneNonGroupVars,
4362+ theCollations);
4363 }
4364
4365
4366@@ -726,7 +748,9 @@
4367 }
4368
4369
4370-flwor_clause* orderby_clause::clone(expr::substitution_t& subst) const
4371+flwor_clause* orderby_clause::clone(
4372+ user_function* udf,
4373+ expr::substitution_t& subst) const
4374 {
4375 csize numColumns = num_columns();
4376
4377@@ -734,14 +758,14 @@
4378
4379 for (csize i = 0; i < numColumns; ++i)
4380 {
4381- cloneExprs[i] = theOrderingExprs[i]->clone(subst);
4382+ cloneExprs[i] = theOrderingExprs[i]->clone(udf, subst);
4383 }
4384
4385 return theCCB->theEM->create_orderby_clause(theContext,
4386- get_loc(),
4387- theStableOrder,
4388- theModifiers,
4389- cloneExprs);
4390+ get_loc(),
4391+ theStableOrder,
4392+ theModifiers,
4393+ cloneExprs);
4394 }
4395
4396
4397@@ -758,7 +782,9 @@
4398 }
4399
4400
4401-flwor_clause* materialize_clause::clone(expr::substitution_t& subst) const
4402+flwor_clause* materialize_clause::clone(
4403+ user_function* udf,
4404+ expr::substitution_t& subst) const
4405 {
4406 // we will reach here under the following scenario:
4407 // 1. We do plan seriazation
4408@@ -792,11 +818,13 @@
4409 }
4410
4411
4412-flwor_clause* count_clause::clone(expr::substitution_t& subst) const
4413+flwor_clause* count_clause::clone(
4414+ user_function* udf,
4415+ expr::substitution_t& subst) const
4416 {
4417 ExprManager* exprMgr = theVarExpr->get_ccb()->theEM;
4418
4419- var_expr* cloneVar = exprMgr->create_var_expr(*theVarExpr);
4420+ var_expr* cloneVar = exprMgr->create_var_expr(udf, *theVarExpr);
4421 subst[theVarExpr] = cloneVar;
4422
4423 return theCCB->theEM->create_count_clause(theContext, get_loc(), cloneVar);
4424@@ -825,9 +853,11 @@
4425 }
4426
4427
4428-flwor_clause* where_clause::clone(expr::substitution_t& subst) const
4429+flwor_clause* where_clause::clone(
4430+ user_function* udf,
4431+ expr::substitution_t& subst) const
4432 {
4433- expr* cloneExpr = theWhereExpr->clone(subst);
4434+ expr* cloneExpr = theWhereExpr->clone(udf, subst);
4435
4436 return theCCB->theEM->create_where_clause(theContext, get_loc(), cloneExpr);
4437 }
4438@@ -839,10 +869,11 @@
4439 flwor_expr::flwor_expr(
4440 CompilerCB* ccb,
4441 static_context* sctx,
4442+ user_function* udf,
4443 const QueryLoc& loc,
4444 bool general)
4445 :
4446- expr(ccb, sctx, loc, (general ? gflwor_expr_kind : flwor_expr_kind)),
4447+ expr(ccb, sctx, udf, loc, (general ? gflwor_expr_kind : flwor_expr_kind)),
4448 theIsGeneral(general),
4449 theHasSequentialClauses(false),
4450 theReturnExpr(NULL)
4451@@ -1167,27 +1198,5 @@
4452 }
4453
4454
4455-/*******************************************************************************
4456-
4457-********************************************************************************/
4458-expr* flwor_expr::cloneImpl(substitution_t& subst) const
4459-{
4460- ulong numClauses = num_clauses();
4461-
4462- flwor_expr* cloneFlwor = theCCB->theEM->create_flwor_expr(theSctx, get_loc(), theIsGeneral);
4463-
4464- for (ulong i = 0; i < numClauses; ++i)
4465- {
4466- flwor_clause* cloneClause = theClauses[i]->clone(subst);
4467-
4468- cloneFlwor->add_clause(cloneClause, false);
4469- }
4470-
4471- cloneFlwor->set_return_expr(theReturnExpr->clone(subst));
4472-
4473- return cloneFlwor;
4474-}
4475-
4476-
4477 } // namespace zorba
4478 /* vim:set et sw=2 ts=2: */
4479
4480=== modified file 'src/compiler/expression/flwor_expr.h'
4481--- src/compiler/expression/flwor_expr.h 2012-10-08 12:09:36 +0000
4482+++ src/compiler/expression/flwor_expr.h 2012-10-09 13:35:26 +0000
4483@@ -105,7 +105,9 @@
4484
4485 virtual var_expr* get_score_var() const { return NULL; }
4486
4487- virtual flwor_clause* clone(expr::substitution_t& substitution) const = 0;
4488+ virtual flwor_clause* clone(
4489+ user_function* udf,
4490+ expr::substitution_t& substitution) const = 0;
4491 };
4492
4493
4494@@ -207,7 +209,7 @@
4495
4496 void set_score_var(var_expr* v);
4497
4498- flwor_clause* clone(expr::substitution_t& substitution) const;
4499+ flwor_clause* clone(user_function* udf, expr::substitution_t& substitution) const;
4500
4501 std::ostream& put(std::ostream&) const;
4502 };
4503@@ -247,7 +249,7 @@
4504
4505 bool lazyEval() const { return theLazyEval; }
4506
4507- flwor_clause* clone(expr::substitution_t& substitution) const;
4508+ flwor_clause* clone(user_function* udf, expr::substitution_t& substitution) const;
4509
4510 std::ostream& put(std::ostream&) const;
4511 };
4512@@ -303,7 +305,7 @@
4513
4514 bool lazyEval() const { return theLazyEval; }
4515
4516- flwor_clause* clone(expr::substitution_t& substitution) const;
4517+ flwor_clause* clone(user_function* udf, expr::substitution_t& substitution) const;
4518
4519 std::ostream& put(std::ostream&) const;
4520 };
4521@@ -354,10 +356,16 @@
4522 var_expr* next;
4523
4524 vars();
4525+
4526 ~vars();
4527+
4528 void set_flwor_clause(flwor_clause* c);
4529
4530- void clone(ExprManager* mgr, vars& cloneVars, expr::substitution_t& subst) const;
4531+ void clone(
4532+ ExprManager* mgr,
4533+ user_function* udf,
4534+ vars& cloneVars,
4535+ expr::substitution_t& subst) const;
4536
4537 std::ostream& put(std::ostream&) const;
4538 };
4539@@ -394,7 +402,7 @@
4540
4541 void set_flwor_clause(flwor_clause *);
4542
4543- flwor_wincond* clone(expr::substitution_t& substitution) const;
4544+ flwor_wincond* clone(user_function* udf, expr::substitution_t& substitution) const;
4545
4546 std::ostream& put(std::ostream&) const;
4547 };
4548@@ -484,7 +492,7 @@
4549
4550 expr* get_input_for_nongroup_var(const var_expr* var);
4551
4552- flwor_clause* clone(expr::substitution_t& substitution) const;
4553+ flwor_clause* clone(user_function* udf, expr::substitution_t& substitution) const;
4554
4555 std::ostream& put(std::ostream&) const;
4556 };
4557@@ -552,7 +560,7 @@
4558
4559 void set_column_expr(csize i, expr* e) { theOrderingExprs[i] = e; }
4560
4561- flwor_clause* clone(expr::substitution_t& substitution) const;
4562+ flwor_clause* clone(user_function* udf, expr::substitution_t& substitution) const;
4563
4564 std::ostream& put(std::ostream&) const;
4565 };
4566@@ -572,7 +580,7 @@
4567 materialize_clause(static_context* sctx, CompilerCB* ccb, const QueryLoc& loc);
4568
4569 public:
4570- flwor_clause* clone(expr::substitution_t& substitution) const;
4571+ flwor_clause* clone(user_function* udf, expr::substitution_t& substitution) const;
4572
4573 std::ostream& put(std::ostream&) const;
4574 };
4575@@ -597,7 +605,7 @@
4576
4577 var_expr* get_var() const { return theVarExpr; }
4578
4579- flwor_clause* clone(expr::substitution_t& substitution) const;
4580+ flwor_clause* clone(user_function* udf, expr::substitution_t& substitution) const;
4581 };
4582
4583
4584@@ -619,7 +627,7 @@
4585
4586 void set_expr(expr* where);
4587
4588- flwor_clause* clone(expr::substitution_t& substitution) const;
4589+ flwor_clause* clone(user_function* udf, expr::substitution_t& substitution) const;
4590 };
4591
4592
4593@@ -665,7 +673,12 @@
4594 expr * theReturnExpr;
4595
4596 protected:
4597- flwor_expr(CompilerCB* ccb, static_context* sctx, const QueryLoc& loc, bool general);
4598+ flwor_expr(
4599+ CompilerCB* ccb,
4600+ static_context* sctx,
4601+ user_function* udf,
4602+ const QueryLoc& loc,
4603+ bool general);
4604
4605 public:
4606 bool is_general() const { return theIsGeneral; }
4607@@ -704,8 +717,6 @@
4608
4609 void get_vars_defined(std::vector<var_expr*>& varExprs) const;
4610
4611- expr* cloneImpl(substitution_t& substitution) const;
4612-
4613 // The following 5 methods are for the simple flwor only. They should be
4614 // removed eventually.
4615 expr* get_where() const;
4616
4617=== modified file 'src/compiler/expression/fo_expr.cpp'
4618--- src/compiler/expression/fo_expr.cpp 2012-10-08 12:09:36 +0000
4619+++ src/compiler/expression/fo_expr.cpp 2012-10-09 13:35:26 +0000
4620@@ -55,11 +55,15 @@
4621 UnionExpr, and IntersectExceptExpr.
4622 ********************************************************************************/
4623
4624-fo_expr* fo_expr::create_seq(CompilerCB* ccb, static_context* sctx, const QueryLoc& loc)
4625+fo_expr* fo_expr::create_seq(
4626+ CompilerCB* ccb,
4627+ static_context* sctx,
4628+ user_function* udf,
4629+ const QueryLoc& loc)
4630 {
4631 function* f = BuiltinFunctionLibrary::getFunction(FunctionConsts::OP_CONCATENATE_N);
4632
4633- std::auto_ptr<fo_expr> fo(ccb->theEM->create_fo_expr(sctx, loc, f));
4634+ std::auto_ptr<fo_expr> fo(ccb->theEM->create_fo_expr(sctx, udf, loc, f));
4635
4636 return fo.release();
4637 }
4638@@ -68,10 +72,11 @@
4639 fo_expr::fo_expr(
4640 CompilerCB* ccb,
4641 static_context* sctx,
4642+ user_function* udf,
4643 const QueryLoc& loc,
4644 const function* f)
4645 :
4646- expr(ccb, sctx, loc, fo_expr_kind),
4647+ expr(ccb, sctx, udf, loc, fo_expr_kind),
4648 theFunction(const_cast<function*>(f))
4649 {
4650 // This method is private and it is to be used only by the clone method
4651@@ -83,11 +88,12 @@
4652 fo_expr::fo_expr(
4653 CompilerCB* ccb,
4654 static_context* sctx,
4655+ user_function* udf,
4656 const QueryLoc& loc,
4657 const function* f,
4658 expr* arg)
4659 :
4660- expr(ccb, sctx, loc, fo_expr_kind),
4661+ expr(ccb, sctx, udf, loc, fo_expr_kind),
4662 theFunction(const_cast<function*>(f))
4663 {
4664 assert(f != NULL);
4665@@ -101,12 +107,13 @@
4666 fo_expr::fo_expr(
4667 CompilerCB* ccb,
4668 static_context* sctx,
4669+ user_function* udf,
4670 const QueryLoc& loc,
4671 const function* f,
4672 expr* arg1,
4673 expr* arg2)
4674 :
4675- expr(ccb, sctx, loc, fo_expr_kind),
4676+ expr(ccb, sctx, udf, loc, fo_expr_kind),
4677 theFunction(const_cast<function*>(f))
4678 {
4679 assert(f != NULL);
4680@@ -121,11 +128,12 @@
4681 fo_expr::fo_expr(
4682 CompilerCB* ccb,
4683 static_context* sctx,
4684+ user_function* udf,
4685 const QueryLoc& loc,
4686 const function* f,
4687 const std::vector<expr*>& args)
4688 :
4689- expr(ccb, sctx, loc, fo_expr_kind),
4690+ expr(ccb, sctx, udf, loc, fo_expr_kind),
4691 theArgs(args),
4692 theFunction(const_cast<function*>(f))
4693 {
4694@@ -273,29 +281,6 @@
4695 }
4696
4697
4698-expr* fo_expr::cloneImpl(substitution_t& subst) const
4699-{
4700- if (get_func()->getKind() == FunctionConsts::STATIC_COLLECTIONS_DML_COLLECTION_1)
4701- {
4702- expr::subst_iter_t i = subst.find(this);
4703-
4704- if (i != subst.end())
4705- return i->second;
4706- }
4707-
4708- std::auto_ptr<fo_expr> fo(theCCB->theEM->create_fo_expr(theSctx,
4709- get_loc(),
4710- get_func()));
4711-
4712- for (csize i = 0; i < theArgs.size(); ++i)
4713- fo->theArgs.push_back(theArgs[i]->clone(subst));
4714-
4715- fo->theScriptingKind = theScriptingKind;
4716-
4717- return fo.release();
4718-}
4719-
4720-
4721 }
4722
4723 /* vim:set et sw=2 ts=2: */
4724
4725=== modified file 'src/compiler/expression/fo_expr.h'
4726--- src/compiler/expression/fo_expr.h 2012-10-08 12:09:36 +0000
4727+++ src/compiler/expression/fo_expr.h 2012-10-09 13:35:26 +0000
4728@@ -45,12 +45,24 @@
4729 public:
4730
4731 protected:
4732- static fo_expr* create_seq(CompilerCB* ccb, static_context* sctx, const QueryLoc&);
4733+ static fo_expr* create_seq(
4734+ CompilerCB* ccb,
4735+ static_context* sctx,
4736+ user_function* udf,
4737+ const QueryLoc&);
4738
4739 protected:
4740 fo_expr(
4741 CompilerCB* ccb,
4742 static_context* sctx,
4743+ user_function* udf,
4744+ const QueryLoc& loc,
4745+ const function* f);
4746+
4747+ fo_expr(
4748+ CompilerCB* ccb,
4749+ static_context* sctx,
4750+ user_function* udf,
4751 const QueryLoc& loc,
4752 const function* f,
4753 expr* arg);
4754@@ -58,6 +70,7 @@
4755 fo_expr(
4756 CompilerCB* ccb,
4757 static_context* sctx,
4758+ user_function* udf,
4759 const QueryLoc& loc,
4760 const function* f,
4761 expr* arg1,
4762@@ -66,6 +79,7 @@
4763 fo_expr(
4764 CompilerCB* ccb,
4765 static_context* sctx,
4766+ user_function* udf,
4767 const QueryLoc& loc,
4768 const function* f,
4769 const std::vector<expr*>& args);
4770@@ -95,8 +109,6 @@
4771
4772 void compute_scripting_kind();
4773
4774- expr* cloneImpl(substitution_t& s) const;
4775-
4776 void accept(expr_visitor&);
4777
4778 std::ostream& put(std::ostream&) const;
4779
4780=== modified file 'src/compiler/expression/ft_expr.cpp'
4781--- src/compiler/expression/ft_expr.cpp 2012-10-08 12:09:36 +0000
4782+++ src/compiler/expression/ft_expr.cpp 2012-10-09 13:35:26 +0000
4783@@ -35,12 +35,13 @@
4784 ftcontains_expr::ftcontains_expr(
4785 CompilerCB* ccb,
4786 static_context* sctx,
4787+ user_function* udf,
4788 QueryLoc const &loc,
4789 expr* range,
4790 ftnode *ftselection,
4791 expr* ftignore
4792 ) :
4793- expr(ccb, sctx, loc, ft_expr_kind ),
4794+ expr(ccb, sctx, udf, loc, ft_expr_kind ),
4795 range_( range ),
4796 ftselection_( ftselection ),
4797 ftignore_( ftignore )
4798@@ -50,6 +51,7 @@
4799 compute_scripting_kind();
4800 }
4801
4802+
4803 void ftcontains_expr::accept( expr_visitor &v ) {
4804 if ( v.begin_visit( *this ) ) {
4805 EV_ACCEPT( range_, v );
4806@@ -59,16 +61,9 @@
4807 v.end_visit( *this );
4808 }
4809
4810-expr* ftcontains_expr::cloneImpl( substitution_t &s ) const {
4811- return theCCB->theEM->create_ftcontains_expr(
4812- theSctx, get_loc(),
4813- range_->clone( s ),
4814- ftselection_->clone( s ).release(),
4815- ftignore_ == NULL ? 0 : ftignore_->clone( s )
4816- );
4817-}
4818
4819-void ftcontains_expr::compute_scripting_kind() {
4820+void ftcontains_expr::compute_scripting_kind()
4821+{
4822 checkSimpleExpr(range_);
4823
4824 theScriptingKind = SIMPLE_EXPR;
4825
4826=== modified file 'src/compiler/expression/ft_expr.h'
4827--- src/compiler/expression/ft_expr.h 2012-10-08 12:09:36 +0000
4828+++ src/compiler/expression/ft_expr.h 2012-10-09 13:35:26 +0000
4829@@ -29,6 +29,7 @@
4830 */
4831 class ftcontains_expr : public expr
4832 {
4833+ friend class expr;
4834 friend class ExprIterator;
4835 friend class ExprManager;
4836
4837@@ -36,6 +37,7 @@
4838 ftcontains_expr(
4839 CompilerCB* ccb,
4840 static_context*,
4841+ user_function*,
4842 QueryLoc const&,
4843 expr* range,
4844 ftnode *ftselection,
4845@@ -43,8 +45,6 @@
4846 );
4847
4848 public:
4849- expr* cloneImpl( substitution_t& ) const;
4850-
4851 void compute_scripting_kind();
4852
4853 expr* get_range() const { return range_; }
4854
4855=== modified file 'src/compiler/expression/ftnode.cpp'
4856--- src/compiler/expression/ftnode.cpp 2012-09-19 21:16:15 +0000
4857+++ src/compiler/expression/ftnode.cpp 2012-10-09 13:35:26 +0000
4858@@ -171,37 +171,60 @@
4859 ///////////////////////////////////////////////////////////////////////////////
4860
4861 template<typename PointerType>
4862-inline PointerType clone_ptr( PointerType p, expr::substitution_t &s ) {
4863- return static_cast<PointerType>( p->clone( s ).release() );
4864+inline PointerType clone_ptr(
4865+ PointerType p,
4866+ user_function* udf,
4867+ expr::substitution_t &s )
4868+{
4869+ return static_cast<PointerType>( p->clone( udf, s ).release() );
4870 }
4871
4872+
4873 template<>
4874-inline expr* clone_ptr( expr* p, expr::substitution_t &s ) {
4875- return static_cast<expr*>( p->clone( s ) );
4876+inline expr* clone_ptr( expr* p, user_function* udf, expr::substitution_t &s ) {
4877+ return static_cast<expr*>( p->clone(udf, s) );
4878 }
4879
4880+
4881 template<class RCHandleValueType>
4882-inline RCHandleValueType* clone_ptr( rchandle<RCHandleValueType> const &p,
4883- expr::substitution_t &s ) {
4884- return static_cast<RCHandleValueType*>( p->clone( s ).release() );
4885+inline RCHandleValueType* clone_ptr(
4886+ rchandle<RCHandleValueType> const &p,
4887+ user_function* udf,
4888+ expr::substitution_t &s )
4889+{
4890+ return static_cast<RCHandleValueType*>( p->clone(udf, s).release() );
4891 }
4892
4893+
4894 template<typename PointerType>
4895-inline PointerType clone_ptr_if( PointerType p, expr::substitution_t &s ) {
4896- return p ? clone_ptr( p, s ) : nullptr;
4897+inline PointerType clone_ptr_if(
4898+ PointerType p,
4899+ user_function* udf,
4900+ expr::substitution_t &s )
4901+{
4902+ return p ? clone_ptr( p, udf, s ) : nullptr;
4903 }
4904
4905+
4906 template<class RCHandleValueType>
4907-inline RCHandleValueType* clone_ptr_if( rchandle<RCHandleValueType> const &p,
4908- expr::substitution_t &s ) {
4909- return p.isNull() ? nullptr : clone_ptr( p, s );
4910+inline RCHandleValueType* clone_ptr_if(
4911+ rchandle<RCHandleValueType> const &p,
4912+ user_function* udf,
4913+ expr::substitution_t &s )
4914+{
4915+ return p.isNull() ? nullptr : clone_ptr( p, udf, s );
4916 }
4917
4918+
4919 template<class ContainerType>
4920-void clone_list( ContainerType const &from, ContainerType *to,
4921- expr::substitution_t &s ) {
4922+void clone_list(
4923+ ContainerType const &from,
4924+ ContainerType *to,
4925+ user_function* udf,
4926+ expr::substitution_t &s )
4927+{
4928 FOR_EACH( typename ContainerType, i, from )
4929- to->push_back( clone_ptr( *i, s ) );
4930+ to->push_back( clone_ptr( *i, udf, s ) );
4931 }
4932
4933 ///////////////////////////////////////////////////////////////////////////////
4934@@ -221,9 +244,9 @@
4935 END_VISIT( v );
4936 }
4937
4938-ftnode_t ftand::clone( expr::substitution_t &s ) const {
4939+ftnode_t ftand::clone(user_function* udf, expr::substitution_t &s ) const {
4940 ftnode_list_t copy;
4941- clone_list( get_node_list(), &copy, s );
4942+ clone_list( get_node_list(), &copy, udf, s );
4943 return new ftand( get_loc(), copy );
4944 }
4945
4946@@ -251,7 +274,7 @@
4947 END_VISIT( v );
4948 }
4949
4950-ftnode_t ftcase_option::clone( expr::substitution_t& ) const {
4951+ftnode_t ftcase_option::clone(user_function* udf, expr::substitution_t& ) const {
4952 return new ftcase_option( get_loc(), mode_ );
4953 }
4954
4955@@ -279,7 +302,7 @@
4956 END_VISIT( v );
4957 }
4958
4959-ftnode_t ftcontent_filter::clone( expr::substitution_t &s ) const {
4960+ftnode_t ftcontent_filter::clone(user_function* udf, expr::substitution_t &s ) const {
4961 return new ftcontent_filter( get_loc(), mode_ );
4962 }
4963
4964@@ -308,7 +331,7 @@
4965 END_VISIT( v );
4966 }
4967
4968-ftnode_t ftdiacritics_option::clone( expr::substitution_t& ) const {
4969+ftnode_t ftdiacritics_option::clone(user_function* udf, expr::substitution_t& ) const {
4970 return new ftdiacritics_option( get_loc(), mode_ );
4971 }
4972
4973@@ -345,8 +368,8 @@
4974 END_VISIT( v );
4975 }
4976
4977-ftnode_t ftdistance_filter::clone( expr::substitution_t &s ) const {
4978- return new ftdistance_filter( get_loc(), clone_ptr_if( range_, s ), unit_ );
4979+ftnode_t ftdistance_filter::clone(user_function* udf, expr::substitution_t &s ) const {
4980+ return new ftdistance_filter( get_loc(), clone_ptr_if( range_, udf, s ), unit_ );
4981 }
4982
4983 ostream& ftdistance_filter::put( ostream &o ) const {
4984@@ -384,9 +407,9 @@
4985 END_VISIT( v );
4986 }
4987
4988-ftnode_t ftextension_selection::clone( expr::substitution_t &s ) const {
4989+ftnode_t ftextension_selection::clone(user_function* udf, expr::substitution_t &s ) const {
4990 return new ftextension_selection(
4991- get_loc(), pragmas_, clone_ptr_if( ftselection_, s )
4992+ get_loc(), pragmas_, clone_ptr_if( ftselection_, udf, s )
4993 );
4994 }
4995
4996@@ -418,7 +441,7 @@
4997 END_VISIT( v );
4998 }
4999
5000-ftnode_t ftextension_option::clone( expr::substitution_t& ) const {
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches