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
=== modified file 'src/compiler/expression/CMakeLists.txt'
--- src/compiler/expression/CMakeLists.txt 2012-10-08 12:09:36 +0000
+++ src/compiler/expression/CMakeLists.txt 2012-10-09 13:35:26 +0000
@@ -14,6 +14,7 @@
14SET(EXPRESSION_SRCS14SET(EXPRESSION_SRCS
15 expr_consts.cpp15 expr_consts.cpp
16 expr_base.cpp16 expr_base.cpp
17 expr_clone.cpp
17 expr_iter.cpp18 expr_iter.cpp
18 expr_type.cpp19 expr_type.cpp
19 expr.cpp20 expr.cpp
2021
=== modified file 'src/compiler/expression/expr.cpp'
--- src/compiler/expression/expr.cpp 2012-10-08 12:09:36 +0000
+++ src/compiler/expression/expr.cpp 2012-10-09 13:35:26 +0000
@@ -83,22 +83,19 @@
83DEF_EXPR_ACCEPT (pi_expr)83DEF_EXPR_ACCEPT (pi_expr)
8484
8585
86#define CLONE( e, s ) ((e) == NULL ? NULL : (e)->clone(s))
87
88
89
90/*******************************************************************************86/*******************************************************************************
91 [68] IfExpr ::= "if" "(" Expr ")" "then" ExprSingle "else" ExprSingle87 [68] IfExpr ::= "if" "(" Expr ")" "then" ExprSingle "else" ExprSingle
92********************************************************************************/88********************************************************************************/
93if_expr::if_expr(89if_expr::if_expr(
94 CompilerCB* ccb,90 CompilerCB* ccb,
95 static_context* sctx,91 static_context* sctx,
92 user_function* udf,
96 const QueryLoc& loc,93 const QueryLoc& loc,
97 expr* condExpr,94 expr* condExpr,
98 expr* thenExpr,95 expr* thenExpr,
99 expr* elseExpr)96 expr* elseExpr)
100 :97 :
101 expr(ccb, sctx, loc, if_expr_kind),98 expr(ccb, sctx, udf, loc, if_expr_kind),
102 theThenExpr(thenExpr),99 theThenExpr(thenExpr),
103 theElseExpr(elseExpr)100 theElseExpr(elseExpr)
104{101{
@@ -108,10 +105,13 @@
108 *GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE,105 *GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE,
109 loc))106 loc))
110 {107 {
111 fo_expr* boolExpr = theCCB->theEM->create_fo_expr(sctx,108 fo_expr* boolExpr = theCCB->theEM->
112 loc,109 create_fo_expr(sctx,
113 GET_BUILTIN_FUNCTION(FN_BOOLEAN_1),110 udf,
114 condExpr);111 loc,
112 GET_BUILTIN_FUNCTION(FN_BOOLEAN_1),
113 condExpr);
114
115 condExpr = boolExpr;115 condExpr = boolExpr;
116 }116 }
117117
@@ -166,27 +166,18 @@
166}166}
167167
168168
169expr* if_expr::cloneImpl(substitution_t& subst) const
170{
171 return theCCB->theEM->create_if_expr(theSctx,
172 get_loc(),
173 get_cond_expr()->clone(subst),
174 get_then_expr()->clone(subst),
175 get_else_expr()->clone(subst));
176}
177
178
179/***************************************************************************//**169/***************************************************************************//**
180170
181********************************************************************************/171********************************************************************************/
182order_expr::order_expr(172order_expr::order_expr(
183 CompilerCB* ccb,173 CompilerCB* ccb,
184 static_context* sctx,174 static_context* sctx,
175 user_function* udf,
185 const QueryLoc& loc,176 const QueryLoc& loc,
186 order_type_t type,177 order_type_t type,
187 expr* inExpr)178 expr* inExpr)
188 :179 :
189 expr(ccb, sctx, loc, order_expr_kind),180 expr(ccb, sctx, udf, loc, order_expr_kind),
190 theType(type),181 theType(type),
191 theExpr(inExpr)182 theExpr(inExpr)
192{183{
@@ -203,25 +194,20 @@
203}194}
204195
205196
206expr* order_expr::cloneImpl(substitution_t& subst) const
207{
208 return theCCB->theEM->create_order_expr(theSctx, get_loc(), get_type(), get_expr()->clone(subst));
209}
210
211
212/***************************************************************************//**197/***************************************************************************//**
213198
214********************************************************************************/199********************************************************************************/
215validate_expr::validate_expr(200validate_expr::validate_expr(
216 CompilerCB* ccb,201 CompilerCB* ccb,
217 static_context* sctx,202 static_context* sctx,
203 user_function* udf,
218 const QueryLoc& loc,204 const QueryLoc& loc,
219 enum ParseConstants::validation_mode_t mode,205 enum ParseConstants::validation_mode_t mode,
220 const store::Item_t& typeName,206 const store::Item_t& typeName,
221 expr* inExpr,207 expr* inExpr,
222 rchandle<TypeManager> typemgr)208 rchandle<TypeManager> typemgr)
223 :209 :
224 expr(ccb, sctx, loc, validate_expr_kind),210 expr(ccb, sctx, udf, loc, validate_expr_kind),
225 theMode(mode),211 theMode(mode),
226 theTypeName(typeName),212 theTypeName(typeName),
227 theTypeMgr(typemgr),213 theTypeMgr(typemgr),
@@ -242,16 +228,6 @@
242}228}
243229
244230
245expr* validate_expr::cloneImpl(substitution_t& subst) const
246{
247 return theCCB->theEM->create_validate_expr(theSctx,
248 get_loc(),
249 get_valmode(),
250 const_cast<store::Item*>(get_type_name()),
251 get_expr()->clone(subst),
252 get_typemgr());
253}
254
255231
256/***************************************************************************//**232/***************************************************************************//**
257 Base for expression classes that require a namespace context233 Base for expression classes that require a namespace context
@@ -259,11 +235,12 @@
259namespace_context_base_expr::namespace_context_base_expr(235namespace_context_base_expr::namespace_context_base_expr(
260 CompilerCB* ccb,236 CompilerCB* ccb,
261 static_context* sctx,237 static_context* sctx,
238 user_function* udf,
262 const QueryLoc& loc,239 const QueryLoc& loc,
263 expr_kind_t kind,240 expr_kind_t kind,
264 const namespace_context* aNSCtx)241 const namespace_context* aNSCtx)
265 :242 :
266 expr(ccb, sctx, loc, kind),243 expr(ccb, sctx, udf, loc, kind),
267 theNSCtx(const_cast<namespace_context*>(aNSCtx))244 theNSCtx(const_cast<namespace_context*>(aNSCtx))
268{245{
269}246}
@@ -282,12 +259,13 @@
282cast_or_castable_base_expr::cast_or_castable_base_expr(259cast_or_castable_base_expr::cast_or_castable_base_expr(
283 CompilerCB* ccb,260 CompilerCB* ccb,
284 static_context* sctx,261 static_context* sctx,
262 user_function* udf,
285 const QueryLoc& loc,263 const QueryLoc& loc,
286 expr_kind_t kind,264 expr_kind_t kind,
287 expr* input,265 expr* input,
288 const xqtref_t& type)266 const xqtref_t& type)
289 :267 :
290 expr(ccb, sctx, loc, kind),268 expr(ccb, sctx, udf, loc, kind),
291 theInputExpr(input),269 theInputExpr(input),
292 theTargetType(type)270 theTargetType(type)
293{271{
@@ -327,12 +305,13 @@
327cast_base_expr::cast_base_expr(305cast_base_expr::cast_base_expr(
328 CompilerCB* ccb,306 CompilerCB* ccb,
329 static_context* sctx,307 static_context* sctx,
308 user_function* udf,
330 const QueryLoc& loc,309 const QueryLoc& loc,
331 expr_kind_t kind,310 expr_kind_t kind,
332 expr* input,311 expr* input,
333 const xqtref_t& type)312 const xqtref_t& type)
334 :313 :
335 cast_or_castable_base_expr(ccb, sctx, loc, kind, input, type)314 cast_or_castable_base_expr(ccb, sctx, udf, loc, kind, input, type)
336{315{
337 setNonDiscardable(ANNOTATION_TRUE_FIXED);316 setNonDiscardable(ANNOTATION_TRUE_FIXED);
338}317}
@@ -346,11 +325,12 @@
346cast_expr::cast_expr(325cast_expr::cast_expr(
347 CompilerCB* ccb,326 CompilerCB* ccb,
348 static_context* sctx,327 static_context* sctx,
328 user_function* udf,
349 const QueryLoc& loc,329 const QueryLoc& loc,
350 expr* inputExpr,330 expr* inputExpr,
351 const xqtref_t& type)331 const xqtref_t& type)
352 :332 :
353 cast_base_expr(ccb, sctx, loc, cast_expr_kind, inputExpr, type)333 cast_base_expr(ccb, sctx, udf, loc, cast_expr_kind, inputExpr, type)
354{334{
355 assert(type->get_quantifier() == TypeConstants::QUANT_ONE ||335 assert(type->get_quantifier() == TypeConstants::QUANT_ONE ||
356 type->get_quantifier() == TypeConstants::QUANT_QUESTION);336 type->get_quantifier() == TypeConstants::QUANT_QUESTION);
@@ -363,21 +343,13 @@
363}343}
364344
365345
366expr* cast_expr::cloneImpl(substitution_t& subst) const
367{
368 return theCCB->theEM->create_cast_expr(theSctx,
369 get_loc(),
370 get_input()->clone(subst),
371 get_target_type());
372}
373
374
375/***************************************************************************//**346/***************************************************************************//**
376 TreatExpr ::= CastableExpr ( "treat" "as" SequenceType )?347 TreatExpr ::= CastableExpr ( "treat" "as" SequenceType )?
377********************************************************************************/348********************************************************************************/
378treat_expr::treat_expr(349treat_expr::treat_expr(
379 CompilerCB* ccb,350 CompilerCB* ccb,
380 static_context* sctx,351 static_context* sctx,
352 user_function* udf,
381 const QueryLoc& loc,353 const QueryLoc& loc,
382 expr* inputExpr,354 expr* inputExpr,
383 const xqtref_t& type,355 const xqtref_t& type,
@@ -385,7 +357,7 @@
385 bool check_prime,357 bool check_prime,
386 store::Item* qname)358 store::Item* qname)
387 :359 :
388 cast_base_expr(ccb, sctx, loc, treat_expr_kind, inputExpr, type),360 cast_base_expr(ccb, sctx, udf, loc, treat_expr_kind, inputExpr, type),
389 theErrorKind(err),361 theErrorKind(err),
390 theCheckPrime(check_prime),362 theCheckPrime(check_prime),
391 theQName(qname)363 theQName(qname)
@@ -393,31 +365,20 @@
393}365}
394366
395367
396expr* treat_expr::cloneImpl(substitution_t& subst) const
397{
398 return theCCB->theEM->create_treat_expr(theSctx,
399 get_loc(),
400 get_input()->clone(subst),
401 get_target_type(),
402 get_err(),
403 get_check_prime(),
404 get_qname());
405}
406
407
408/***************************************************************************//**368/***************************************************************************//**
409369
410********************************************************************************/370********************************************************************************/
411promote_expr::promote_expr(371promote_expr::promote_expr(
412 CompilerCB* ccb,372 CompilerCB* ccb,
413 static_context* sctx,373 static_context* sctx,
374 user_function* udf,
414 const QueryLoc& loc,375 const QueryLoc& loc,
415 expr* input,376 expr* input,
416 const xqtref_t& type,377 const xqtref_t& type,
417 PromoteIterator::ErrorKind err,378 PromoteIterator::ErrorKind err,
418 store::Item* qname)379 store::Item* qname)
419 :380 :
420 cast_base_expr(ccb, sctx, loc, promote_expr_kind, input, type),381 cast_base_expr(ccb, sctx, udf, loc, promote_expr_kind, input, type),
421 theErrorKind(err),382 theErrorKind(err),
422 theQName(qname)383 theQName(qname)
423{384{
@@ -427,29 +388,19 @@
427}388}
428389
429390
430expr* promote_expr::cloneImpl(substitution_t& subst) const
431{
432 return theCCB->theEM->create_promote_expr(theSctx,
433 get_loc(),
434 get_input()->clone(subst),
435 get_target_type(),
436 theErrorKind,
437 theQName.getp());
438}
439
440
441/***************************************************************************//**391/***************************************************************************//**
442 Base for castable, instanceof392 Base for castable, instanceof
443********************************************************************************/393********************************************************************************/
444castable_base_expr::castable_base_expr(394castable_base_expr::castable_base_expr(
445 CompilerCB* ccb,395 CompilerCB* ccb,
446 static_context* sctx,396 static_context* sctx,
397 user_function* udf,
447 const QueryLoc& loc,398 const QueryLoc& loc,
448 expr_kind_t kind,399 expr_kind_t kind,
449 expr* input,400 expr* input,
450 const xqtref_t& type)401 const xqtref_t& type)
451 :402 :
452 cast_or_castable_base_expr(ccb, sctx, loc, kind, input, type)403 cast_or_castable_base_expr(ccb, sctx, udf, loc, kind, input, type)
453{404{
454}405}
455406
@@ -462,11 +413,12 @@
462castable_expr::castable_expr(413castable_expr::castable_expr(
463 CompilerCB* ccb,414 CompilerCB* ccb,
464 static_context* sctx,415 static_context* sctx,
416 user_function* udf,
465 const QueryLoc& loc,417 const QueryLoc& loc,
466 expr* inputExpr,418 expr* inputExpr,
467 const xqtref_t& type)419 const xqtref_t& type)
468 :420 :
469 castable_base_expr (ccb, sctx, loc, castable_expr_kind, inputExpr, type)421 castable_base_expr(ccb, sctx, udf, loc, castable_expr_kind, inputExpr, type)
470{422{
471}423}
472424
@@ -477,53 +429,37 @@
477}429}
478430
479431
480expr* castable_expr::cloneImpl(substitution_t& subst) const
481{
482 return theCCB->theEM->create_castable_expr(theSctx,
483 get_loc(),
484 get_input()->clone(subst),
485 get_target_type());
486}
487
488
489/***************************************************************************//**432/***************************************************************************//**
490 InstanceofExpr ::= TreatExpr ( "instance" "of" SequenceType )?433 InstanceofExpr ::= TreatExpr ( "instance" "of" SequenceType )?
491********************************************************************************/434********************************************************************************/
492instanceof_expr::instanceof_expr(435instanceof_expr::instanceof_expr(
493 CompilerCB* ccb,436 CompilerCB* ccb,
494 static_context* sctx,437 static_context* sctx,
438 user_function* udf,
495 const QueryLoc& loc,439 const QueryLoc& loc,
496 expr* inputExpr,440 expr* inputExpr,
497 const xqtref_t& type,441 const xqtref_t& type,
498 bool checkPrimeOnly)442 bool checkPrimeOnly)
499 :443 :
500 castable_base_expr(ccb, sctx, loc, instanceof_expr_kind, inputExpr, type),444 castable_base_expr(ccb, sctx, udf, loc, instanceof_expr_kind, inputExpr, type),
501 theCheckPrimeOnly(checkPrimeOnly)445 theCheckPrimeOnly(checkPrimeOnly)
502{446{
503}447}
504448
505449
506expr* instanceof_expr::cloneImpl(substitution_t& subst) const
507{
508 return theCCB->theEM->create_instanceof_expr(theSctx,
509 get_loc(),
510 get_input()->clone(subst),
511 get_target_type());
512}
513
514
515/***************************************************************************//**450/***************************************************************************//**
516451
517********************************************************************************/452********************************************************************************/
518name_cast_expr::name_cast_expr(453name_cast_expr::name_cast_expr(
519 CompilerCB* ccb,454 CompilerCB* ccb,
520 static_context* sctx,455 static_context* sctx,
456 user_function* udf,
521 const QueryLoc& loc,457 const QueryLoc& loc,
522 expr* inputExpr,458 expr* inputExpr,
523 const namespace_context* aNSCtx,459 const namespace_context* aNSCtx,
524 bool isAttrName)460 bool isAttrName)
525 :461 :
526 namespace_context_base_expr(ccb, sctx, loc, name_cast_expr_kind, aNSCtx),462 namespace_context_base_expr(ccb, sctx, udf, loc, name_cast_expr_kind, aNSCtx),
527 theInputExpr(inputExpr),463 theInputExpr(inputExpr),
528 theIsAttrName(isAttrName)464 theIsAttrName(isAttrName)
529{465{
@@ -542,27 +478,18 @@
542}478}
543479
544480
545expr* name_cast_expr::cloneImpl(substitution_t& subst) const
546{
547 return theCCB->theEM->create_name_cast_expr(theSctx,
548 get_loc(),
549 get_input()->clone(subst),
550 getNSCtx(),
551 theIsAttrName);
552}
553
554
555/***************************************************************************//**481/***************************************************************************//**
556 CompDocConstructor ::= "document" "{" Expr "}"482 CompDocConstructor ::= "document" "{" Expr "}"
557********************************************************************************/483********************************************************************************/
558doc_expr::doc_expr(484doc_expr::doc_expr(
559 CompilerCB* ccb,485 CompilerCB* ccb,
560 static_context* sctx,486 static_context* sctx,
487 user_function* udf,
561 const QueryLoc& loc,488 const QueryLoc& loc,
562 expr* aContent,489 expr* aContent,
563 bool copyNodes)490 bool copyNodes)
564 :491 :
565 expr(ccb, sctx, loc, doc_expr_kind),492 expr(ccb, sctx, udf, loc, doc_expr_kind),
566 theContent(aContent),493 theContent(aContent),
567 theCopyInputNodes(copyNodes)494 theCopyInputNodes(copyNodes)
568{495{
@@ -581,22 +508,13 @@
581}508}
582509
583510
584expr* doc_expr::cloneImpl(substitution_t& subst) const
585{
586 doc_expr* clone = theCCB->theEM->create_doc_expr(theSctx,
587 get_loc(),
588 CLONE(getContent(), subst),
589 theCopyInputNodes);
590 return clone;
591}
592
593
594/***************************************************************************//**511/***************************************************************************//**
595512
596********************************************************************************/513********************************************************************************/
597elem_expr::elem_expr(514elem_expr::elem_expr(
598 CompilerCB* ccb,515 CompilerCB* ccb,
599 static_context* sctx,516 static_context* sctx,
517 user_function* udf,
600 const QueryLoc& aLoc,518 const QueryLoc& aLoc,
601 expr* aQNameExpr,519 expr* aQNameExpr,
602 expr* attrs,520 expr* attrs,
@@ -604,7 +522,7 @@
604 const namespace_context* aNSCtx,522 const namespace_context* aNSCtx,
605 bool copyNodes)523 bool copyNodes)
606 :524 :
607 namespace_context_base_expr(ccb, sctx, aLoc, elem_expr_kind, aNSCtx),525 namespace_context_base_expr(ccb, sctx, udf, aLoc, elem_expr_kind, aNSCtx),
608 theQNameExpr(aQNameExpr),526 theQNameExpr(aQNameExpr),
609 theAttrs(attrs),527 theAttrs(attrs),
610 theContent(content),528 theContent(content),
@@ -619,13 +537,14 @@
619elem_expr::elem_expr(537elem_expr::elem_expr(
620 CompilerCB* ccb,538 CompilerCB* ccb,
621 static_context* sctx,539 static_context* sctx,
540 user_function* udf,
622 const QueryLoc& aLoc,541 const QueryLoc& aLoc,
623 expr* aQNameExpr,542 expr* aQNameExpr,
624 expr* content,543 expr* content,
625 const namespace_context* aNSCtx,544 const namespace_context* aNSCtx,
626 bool copyNodes)545 bool copyNodes)
627 :546 :
628 namespace_context_base_expr(ccb, sctx, aLoc, elem_expr_kind, aNSCtx),547 namespace_context_base_expr(ccb, sctx, udf, aLoc, elem_expr_kind, aNSCtx),
629 theQNameExpr(aQNameExpr),548 theQNameExpr(aQNameExpr),
630 theAttrs(0),549 theAttrs(0),
631 theContent(content),550 theContent(content),
@@ -663,30 +582,18 @@
663}582}
664583
665584
666expr* elem_expr::cloneImpl(substitution_t& subst) const
667{
668 elem_expr* clone = theCCB->theEM->create_elem_expr(theSctx,
669 get_loc(),
670 CLONE(getQNameExpr(), subst),
671 CLONE(getAttrs(), subst),
672 CLONE(getContent(), subst),
673 getNSCtx(),
674 theCopyInputNodes);
675 return clone;
676}
677
678
679/***************************************************************************//**585/***************************************************************************//**
680586
681********************************************************************************/587********************************************************************************/
682attr_expr::attr_expr(588attr_expr::attr_expr(
683 CompilerCB* ccb,589 CompilerCB* ccb,
684 static_context* sctx,590 static_context* sctx,
591 user_function* udf,
685 const QueryLoc& loc,592 const QueryLoc& loc,
686 expr* aQNameExpr,593 expr* aQNameExpr,
687 expr* aValueExpr)594 expr* aValueExpr)
688 :595 :
689 expr(ccb, sctx, loc, attr_expr_kind),596 expr(ccb, sctx, udf, loc, attr_expr_kind),
690 theQNameExpr(aQNameExpr),597 theQNameExpr(aQNameExpr),
691 theValueExpr(aValueExpr)598 theValueExpr(aValueExpr)
692{599{
@@ -730,15 +637,6 @@
730}637}
731638
732639
733expr* attr_expr::cloneImpl(substitution_t& subst) const
734{
735 return theCCB->theEM->create_attr_expr(theSctx,
736 get_loc(),
737 CLONE(getQNameExpr(), subst),
738 CLONE(getValueExpr(), subst));
739}
740
741
742DEF_EXPR_ACCEPT(attr_expr)640DEF_EXPR_ACCEPT(attr_expr)
743641
744642
@@ -748,11 +646,12 @@
748text_expr::text_expr(646text_expr::text_expr(
749 CompilerCB* ccb,647 CompilerCB* ccb,
750 static_context* sctx,648 static_context* sctx,
649 user_function* udf,
751 const QueryLoc& loc,650 const QueryLoc& loc,
752 text_constructor_type type_arg,651 text_constructor_type type_arg,
753 expr* content)652 expr* content)
754 :653 :
755 expr(ccb, sctx, loc, text_expr_kind),654 expr(ccb, sctx, udf, loc, text_expr_kind),
756 type(type_arg),655 type(type_arg),
757 theContentExpr(content)656 theContentExpr(content)
758{657{
@@ -773,23 +672,18 @@
773}672}
774673
775674
776expr* text_expr::cloneImpl(substitution_t& subst) const
777{
778 return theCCB->theEM->create_text_expr(theSctx, get_loc(), get_type(), CLONE(get_text(), subst));
779}
780
781
782/***************************************************************************//**675/***************************************************************************//**
783676
784********************************************************************************/677********************************************************************************/
785pi_expr::pi_expr(678pi_expr::pi_expr(
786 CompilerCB* ccb,679 CompilerCB* ccb,
787 static_context* sctx,680 static_context* sctx,
681 user_function* udf,
788 const QueryLoc& loc,682 const QueryLoc& loc,
789 expr* targetExpr,683 expr* targetExpr,
790 expr* contentExpr)684 expr* contentExpr)
791:685:
792 expr(ccb, sctx, loc, pi_expr_kind),686 expr(ccb, sctx, udf, loc, pi_expr_kind),
793 theTargetExpr(targetExpr),687 theTargetExpr(targetExpr),
794 theContentExpr(contentExpr)688 theContentExpr(contentExpr)
795{689{
@@ -823,23 +717,18 @@
823}717}
824718
825719
826expr* pi_expr::cloneImpl(substitution_t& subst) const
827{
828 return theCCB->theEM->create_pi_expr(theSctx,
829 get_loc(),
830 CLONE(get_target_expr(), subst),
831 CLONE(get_content_expr(), subst));
832}
833
834
835
836/*******************************************************************************720/*******************************************************************************
837 Normally, it is used to wrap a var_expr in order to represent a var reference721 Normally, it is used to wrap a var_expr in order to represent a var reference
838 (see var_expr.h). But it may wrap any other kind of expr as well.722 (see var_expr.h). But it may wrap any other kind of expr as well.
839********************************************************************************/723********************************************************************************/
840wrapper_expr::wrapper_expr(CompilerCB* ccb, static_context* sctx, const QueryLoc& loc, expr* wrapped)724wrapper_expr::wrapper_expr(
725 CompilerCB* ccb,
726 static_context* sctx,
727 user_function* udf,
728 const QueryLoc& loc,
729 expr* wrapped)
841 :730 :
842 expr(ccb, sctx, loc, wrapper_expr_kind),731 expr(ccb, sctx, udf, loc, wrapper_expr_kind),
843 theWrappedExpr(wrapped)732 theWrappedExpr(wrapped)
844{733{
845 compute_scripting_kind();734 compute_scripting_kind();
@@ -852,77 +741,89 @@
852}741}
853742
854743
855expr* wrapper_expr::cloneImpl(substitution_t& subst) const
856{
857 expr* e = theWrappedExpr->clone(subst);
858
859 if (theWrappedExpr->get_expr_kind() == var_expr_kind &&
860 e->get_expr_kind() != var_expr_kind)
861 return e;
862 else
863 return theCCB->theEM->create_wrapper_expr(theSctx, get_loc(), e);
864}
865
866
867/***************************************************************************//**744/***************************************************************************//**
868745
869********************************************************************************/746********************************************************************************/
870const_expr::const_expr(CompilerCB* ccb, static_context* sctx, const QueryLoc& loc, zstring& v)747const_expr::const_expr(
748 CompilerCB* ccb,
749 static_context* sctx,
750 user_function* udf,
751 const QueryLoc& loc,
752 zstring& v)
871 :753 :
872 expr(ccb, sctx, loc, const_expr_kind)754 expr(ccb, sctx, udf, loc, const_expr_kind)
873{755{
874 GENV_ITEMFACTORY->createString(theValue, v);756 GENV_ITEMFACTORY->createString(theValue, v);
875 theScriptingKind = SIMPLE_EXPR;757 theScriptingKind = SIMPLE_EXPR;
876}758}
877759
878760
879const_expr::const_expr(CompilerCB* ccb, static_context* sctx, const QueryLoc& loc, const std::string& v)761const_expr::const_expr(
880 :762 CompilerCB* ccb,
881 expr(ccb, sctx, loc, const_expr_kind)763 static_context* sctx,
882{764 user_function* udf,
883 zstring tmp(v);765 const QueryLoc& loc,
884 GENV_ITEMFACTORY->createString(theValue, tmp);766 const std::string& v)
885 theScriptingKind = SIMPLE_EXPR;767 :
886}768 expr(ccb, sctx, udf, loc, const_expr_kind)
887769{
888770 zstring tmp(v);
889const_expr::const_expr(CompilerCB* ccb, static_context* sctx, const QueryLoc& loc, const char* v)771 GENV_ITEMFACTORY->createString(theValue, tmp);
890 :772 theScriptingKind = SIMPLE_EXPR;
891 expr(ccb, sctx, loc, const_expr_kind)773}
892{774
893 zstring tmp(v);775
894 GENV_ITEMFACTORY->createString(theValue, tmp);776const_expr::const_expr(
895 theScriptingKind = SIMPLE_EXPR;777 CompilerCB* ccb,
896}778 static_context* sctx,
897779 user_function* udf,
898780 const QueryLoc& loc,
899const_expr::const_expr(CompilerCB* ccb, static_context* sctx, const QueryLoc& loc, xs_integer v)781 const char* v)
900 :782 :
901 expr(ccb, sctx, loc, const_expr_kind)783 expr(ccb, sctx, udf, loc, const_expr_kind)
784{
785 zstring tmp(v);
786 GENV_ITEMFACTORY->createString(theValue, tmp);
787 theScriptingKind = SIMPLE_EXPR;
788}
789
790
791const_expr::const_expr(
792 CompilerCB* ccb,
793 static_context* sctx,
794 user_function* udf,
795 const QueryLoc& loc,
796 xs_integer v)
797 :
798 expr(ccb, sctx, udf, loc, const_expr_kind)
902{799{
903 GENV_ITEMFACTORY->createInteger(theValue, v);800 GENV_ITEMFACTORY->createInteger(theValue, v);
904 theScriptingKind = SIMPLE_EXPR;801 theScriptingKind = SIMPLE_EXPR;
905}802}
906803
804
907const_expr::const_expr(805const_expr::const_expr(
908 CompilerCB* ccb,806 CompilerCB* ccb,
909 static_context* sctx,807 static_context* sctx,
808 user_function* udf,
910 const QueryLoc& loc,809 const QueryLoc& loc,
911 xs_decimal v)810 xs_decimal v)
912 :811 :
913 expr(ccb, sctx, loc, const_expr_kind)812 expr(ccb, sctx, udf, loc, const_expr_kind)
914{813{
915 GENV_ITEMFACTORY->createDecimal(theValue, v);814 GENV_ITEMFACTORY->createDecimal(theValue, v);
916 theScriptingKind = SIMPLE_EXPR;815 theScriptingKind = SIMPLE_EXPR;
917}816}
918817
818
919const_expr::const_expr(819const_expr::const_expr(
920 CompilerCB* ccb,820 CompilerCB* ccb,
921 static_context* sctx,821 static_context* sctx,
822 user_function* udf,
922 const QueryLoc& loc,823 const QueryLoc& loc,
923 xs_double v)824 xs_double v)
924 :825 :
925 expr(ccb, sctx, loc, const_expr_kind)826 expr(ccb, sctx, udf, loc, const_expr_kind)
926{827{
927 GENV_ITEMFACTORY->createDouble(theValue, v);828 GENV_ITEMFACTORY->createDouble(theValue, v);
928 theScriptingKind = SIMPLE_EXPR;829 theScriptingKind = SIMPLE_EXPR;
@@ -932,10 +833,11 @@
932const_expr::const_expr(833const_expr::const_expr(
933 CompilerCB* ccb,834 CompilerCB* ccb,
934 static_context* sctx,835 static_context* sctx,
836 user_function* udf,
935 const QueryLoc& loc,837 const QueryLoc& loc,
936 xs_boolean v)838 xs_boolean v)
937 :839 :
938 expr(ccb, sctx, loc, const_expr_kind)840 expr(ccb, sctx, udf, loc, const_expr_kind)
939{841{
940 GENV_ITEMFACTORY->createBoolean(theValue, v);842 GENV_ITEMFACTORY->createBoolean(theValue, v);
941 theScriptingKind = SIMPLE_EXPR;843 theScriptingKind = SIMPLE_EXPR;
@@ -945,10 +847,11 @@
945const_expr::const_expr(847const_expr::const_expr(
946 CompilerCB* ccb,848 CompilerCB* ccb,
947 static_context* sctx,849 static_context* sctx,
850 user_function* udf,
948 const QueryLoc& loc,851 const QueryLoc& loc,
949 const store::Item_t& v)852 const store::Item_t& v)
950 :853 :
951 expr(ccb, sctx, loc, const_expr_kind),854 expr(ccb, sctx, udf, loc, const_expr_kind),
952 theValue(v)855 theValue(v)
953{856{
954 theScriptingKind = SIMPLE_EXPR;857 theScriptingKind = SIMPLE_EXPR;
@@ -958,12 +861,13 @@
958const_expr::const_expr(861const_expr::const_expr(
959 CompilerCB* ccb,862 CompilerCB* ccb,
960 static_context* sctx,863 static_context* sctx,
864 user_function* udf,
961 const QueryLoc& aLoc,865 const QueryLoc& aLoc,
962 const char* aNamespace,866 const char* aNamespace,
963 const char* aPrefix,867 const char* aPrefix,
964 const char* aLocal)868 const char* aLocal)
965 :869 :
966 expr(ccb, sctx, aLoc, const_expr_kind)870 expr(ccb, sctx, udf, aLoc, const_expr_kind)
967{871{
968 GENV_ITEMFACTORY->createQName(theValue, aNamespace, aPrefix, aLocal);872 GENV_ITEMFACTORY->createQName(theValue, aNamespace, aPrefix, aLocal);
969 theScriptingKind = SIMPLE_EXPR;873 theScriptingKind = SIMPLE_EXPR;
@@ -976,21 +880,16 @@
976}880}
977881
978882
979expr* const_expr::cloneImpl(substitution_t&) const
980{
981 return theCCB->theEM->create_const_expr(theSctx, get_loc(), theValue);
982}
983
984
985/*******************************************************************************883/*******************************************************************************
986884
987********************************************************************************/885********************************************************************************/
988extension_expr::extension_expr(886extension_expr::extension_expr(
989 CompilerCB* ccb,887 CompilerCB* ccb,
990 static_context* sctx,888 static_context* sctx,
889 user_function* udf,
991 const QueryLoc& loc)890 const QueryLoc& loc)
992 :891 :
993 expr(ccb, sctx, loc, extension_expr_kind)892 expr(ccb, sctx, udf, loc, extension_expr_kind)
994{893{
995 compute_scripting_kind();894 compute_scripting_kind();
996}895}
@@ -999,10 +898,11 @@
999extension_expr::extension_expr(898extension_expr::extension_expr(
1000 CompilerCB* ccb,899 CompilerCB* ccb,
1001 static_context* sctx,900 static_context* sctx,
901 user_function* udf,
1002 const QueryLoc& loc,902 const QueryLoc& loc,
1003 expr* e)903 expr* e)
1004 :904 :
1005 expr(ccb, sctx, loc, extension_expr_kind),905 expr(ccb, sctx, udf, loc, extension_expr_kind),
1006 theExpr(e)906 theExpr(e)
1007{907{
1008 compute_scripting_kind();908 compute_scripting_kind();
@@ -1020,23 +920,6 @@
1020}920}
1021921
1022922
1023expr* extension_expr::cloneImpl(substitution_t& subst) const
1024{
1025 extension_expr* lClone(0);
1026 lClone = (
1027 theExpr == 0 ? theCCB->theEM->create_extension_expr(theSctx, get_loc())
1028 : theCCB->theEM->create_extension_expr(theSctx, get_loc(), theExpr->clone()) );
1029 // pragm doesn't contain expressions. Thus, it is not cloned.
1030 for ( std::vector<pragma*>::const_iterator lIter = thePragmas.begin();
1031 lIter != thePragmas.end();
1032 ++lIter )
1033 {
1034 lClone->add(*lIter);
1035 }
1036 return lClone;
1037}
1038
1039
1040/////////////////////////////////////////////////////////////////////////923/////////////////////////////////////////////////////////////////////////
1041// //924// //
1042// XQuery 3.0 expressions //925// XQuery 3.0 expressions //
@@ -1049,7 +932,8 @@
1049932
1050********************************************************************************/933********************************************************************************/
1051catch_clause::catch_clause(CompilerCB* ccb)934catch_clause::catch_clause(CompilerCB* ccb)
1052:theCCB(ccb)935 :
936 theCCB(ccb)
1053{937{
1054}938}
1055939
@@ -1057,10 +941,11 @@
1057trycatch_expr::trycatch_expr(941trycatch_expr::trycatch_expr(
1058 CompilerCB* ccb,942 CompilerCB* ccb,
1059 static_context* sctx,943 static_context* sctx,
944 user_function* udf,
1060 const QueryLoc& loc,945 const QueryLoc& loc,
1061 expr* tryExpr)946 expr* tryExpr)
1062 :947 :
1063 expr(ccb, sctx, loc, trycatch_expr_kind),948 expr(ccb, sctx, udf, loc, trycatch_expr_kind),
1064 theTryExpr(tryExpr)949 theTryExpr(tryExpr)
1065{950{
1066 compute_scripting_kind();951 compute_scripting_kind();
@@ -1145,6 +1030,7 @@
1145 {1030 {
1146 lClause->add_nametest_h(lIter->getp());1031 lClause->add_nametest_h(lIter->getp());
1147 }1032 }
1033
1148 for (var_map_t::const_iterator lIter = theVarMap.begin();1034 for (var_map_t::const_iterator lIter = theVarMap.begin();
1149 lIter != theVarMap.end();1035 lIter != theVarMap.end();
1150 ++lIter)1036 ++lIter)
@@ -1156,39 +1042,19 @@
1156}1042}
11571043
11581044
1159expr* trycatch_expr::cloneImpl(substitution_t& subst) const
1160{
1161 std::auto_ptr<trycatch_expr> lTryCatch(
1162 theCCB->theEM->create_trycatch_expr(theSctx, get_loc(), theTryExpr->clone(subst)));
1163
1164 for (std::vector<expr*>::const_iterator lIter = theCatchExprs.begin();
1165 lIter != theCatchExprs.end();
1166 ++lIter)
1167 {
1168 lTryCatch->add_catch_expr((*lIter)->clone(subst));
1169 }
1170
1171 for (csize i = 0; i < clause_count(); ++i)
1172 {
1173 lTryCatch->add_clause(theCatchClauses[i]->clone(subst));
1174 }
1175
1176 return lTryCatch.release();
1177}
1178
1179
1180/*******************************************************************************1045/*******************************************************************************
11811046
1182********************************************************************************/1047********************************************************************************/
1183eval_expr::eval_expr(1048eval_expr::eval_expr(
1184 CompilerCB* ccb,1049 CompilerCB* ccb,
1185 static_context* sctx,1050 static_context* sctx,
1051 user_function* udf,
1186 const QueryLoc& loc,1052 const QueryLoc& loc,
1187 expr* e,1053 expr* e,
1188 expr_script_kind_t scriptingKind,1054 expr_script_kind_t scriptingKind,
1189 namespace_context* nsCtx)1055 namespace_context* nsCtx)
1190 :1056 :
1191 namespace_context_base_expr(ccb, sctx, loc, eval_expr_kind, nsCtx),1057 namespace_context_base_expr(ccb, sctx, udf, loc, eval_expr_kind, nsCtx),
1192 theExpr(e),1058 theExpr(e),
1193 theInnerScriptingKind(scriptingKind),1059 theInnerScriptingKind(scriptingKind),
1194 theDoNodeCopy(false)1060 theDoNodeCopy(false)
@@ -1222,33 +1088,6 @@
1222}1088}
12231089
12241090
1225expr* eval_expr::cloneImpl(substitution_t& s) const
1226{
1227 eval_expr* new_eval = theCCB->theEM->
1228 create_eval_expr(theSctx,
1229 theLoc,
1230 theExpr->clone(s),
1231 theInnerScriptingKind,
1232 theNSCtx.getp());
1233
1234 new_eval->setNodeCopy(theDoNodeCopy);
1235
1236 new_eval->theOuterVarNames = theOuterVarNames;
1237 new_eval->theOuterVarTypes = theOuterVarTypes;
1238
1239 csize numVars = theOuterVarNames.size();
1240
1241 new_eval->theArgs.resize(numVars);
1242
1243 for (csize i = 0; i < numVars; ++i)
1244 {
1245 new_eval->theArgs[i] = theArgs[i]->clone(s);
1246 }
1247
1248 return new_eval;
1249}
1250
1251
1252#ifdef ZORBA_WITH_DEBUGGER1091#ifdef ZORBA_WITH_DEBUGGER
1253/*******************************************************************************1092/*******************************************************************************
12541093
@@ -1256,12 +1095,13 @@
1256debugger_expr::debugger_expr(1095debugger_expr::debugger_expr(
1257 CompilerCB* ccb,1096 CompilerCB* ccb,
1258 static_context* sctx,1097 static_context* sctx,
1098 user_function* udf,
1259 const QueryLoc& loc,1099 const QueryLoc& loc,
1260 expr* aChild,1100 expr* aChild,
1261 namespace_context* nsCtx,1101 namespace_context* nsCtx,
1262 bool aIsVarDeclaration)1102 bool aIsVarDeclaration)
1263 :1103 :
1264 namespace_context_base_expr(ccb, sctx, loc, debugger_expr_kind, nsCtx),1104 namespace_context_base_expr(ccb, sctx, udf, loc, debugger_expr_kind, nsCtx),
1265 theExpr(aChild),1105 theExpr(aChild),
1266 theIsVarDeclaration(aIsVarDeclaration)1106 theIsVarDeclaration(aIsVarDeclaration)
1267{1107{
@@ -1283,10 +1123,11 @@
1283function_trace_expr::function_trace_expr(1123function_trace_expr::function_trace_expr(
1284 CompilerCB* ccb,1124 CompilerCB* ccb,
1285 static_context* sctx,1125 static_context* sctx,
1126 user_function* udf,
1286 const QueryLoc& loc,1127 const QueryLoc& loc,
1287 expr* aChild)1128 expr* aChild)
1288 :1129 :
1289 expr(ccb, sctx, loc, aChild->get_expr_kind()),1130 expr(ccb, sctx, udf, loc, aChild->get_expr_kind()),
1290 theExpr(aChild),1131 theExpr(aChild),
1291 theFunctionArity(0)1132 theFunctionArity(0)
1292{1133{
@@ -1296,9 +1137,13 @@
1296}1137}
12971138
12981139
1299function_trace_expr::function_trace_expr(expr* aExpr)1140function_trace_expr::function_trace_expr(user_function* udf, expr* aExpr)
1300 :1141 :
1301 expr(aExpr->get_ccb(), aExpr->get_sctx(), aExpr->get_loc(), function_trace_expr_kind),1142 expr(aExpr->get_ccb(),
1143 aExpr->get_sctx(),
1144 udf,
1145 aExpr->get_loc(),
1146 function_trace_expr_kind),
1302 theExpr(aExpr),1147 theExpr(aExpr),
1303 theFunctionArity(0)1148 theFunctionArity(0)
1304{1149{
@@ -1319,20 +1164,5 @@
1319}1164}
13201165
13211166
1322expr* function_trace_expr::cloneImpl(substitution_t& s) const
1323{
1324 function_trace_expr* clone = theCCB->theEM->
1325 create_function_trace_expr(theExpr->clone(s));
1326
1327 clone->theFunctionName = theFunctionName;
1328 clone->theFunctionLocation = theFunctionLocation;
1329 clone->theFunctionCallLocation = theFunctionCallLocation;
1330 clone->theFunctionArity = theFunctionArity;
1331
1332 return clone;
1333}
1334
1335
1336
1337} /* namespace zorba */1167} /* namespace zorba */
1338/* vim:set et sw=2 ts=2: */1168/* vim:set et sw=2 ts=2: */
13391169
=== modified file 'src/compiler/expression/expr.h'
--- src/compiler/expression/expr.h 2012-10-08 12:09:36 +0000
+++ src/compiler/expression/expr.h 2012-10-09 13:35:26 +0000
@@ -58,14 +58,15 @@
58 friend class expr;58 friend class expr;
5959
60protected:60protected:
61 expr* theCondExpr;61 expr * theCondExpr;
62 expr* theThenExpr;62 expr * theThenExpr;
63 expr* theElseExpr;63 expr * theElseExpr;
6464
65protected:65protected:
66 if_expr(66 if_expr(
67 CompilerCB* ccb,67 CompilerCB* ccb,
68 static_context* sctx,68 static_context* sctx,
69 user_function* udf,
69 const QueryLoc& loc,70 const QueryLoc& loc,
70 expr* c,71 expr* c,
71 expr* t,72 expr* t,
@@ -80,8 +81,6 @@
8081
81 void compute_scripting_kind();82 void compute_scripting_kind();
8283
83 expr* cloneImpl(substitution_t& s) const;
84
85 void accept(expr_visitor&);84 void accept(expr_visitor&);
8685
87 std::ostream& put(std::ostream&) const;86 std::ostream& put(std::ostream&) const;
@@ -105,11 +104,17 @@
105 };104 };
106105
107protected:106protected:
108 order_type_t theType;107 order_type_t theType;
109 expr* theExpr;108 expr * theExpr;
110109
111protected:110protected:
112 order_expr(CompilerCB* ccb, static_context* sctx, const QueryLoc&, order_type_t, expr*);111 order_expr(
112 CompilerCB* ccb,
113 static_context* sctx,
114 user_function* udf,
115 const QueryLoc&,
116 order_type_t,
117 expr*);
113118
114public:119public:
115 order_type_t get_type() const { return theType; }120 order_type_t get_type() const { return theType; }
@@ -118,8 +123,6 @@
118123
119 void compute_scripting_kind();124 void compute_scripting_kind();
120125
121 expr* cloneImpl(substitution_t& s) const;
122
123 void accept(expr_visitor&);126 void accept(expr_visitor&);
124127
125 std::ostream& put(std::ostream&) const;128 std::ostream& put(std::ostream&) const;
@@ -139,17 +142,18 @@
139 ParseConstants::validation_mode_t theMode;142 ParseConstants::validation_mode_t theMode;
140 store::Item_t theTypeName;143 store::Item_t theTypeName;
141 rchandle<TypeManager> theTypeMgr;144 rchandle<TypeManager> theTypeMgr;
142 expr* theExpr;145 expr * theExpr;
143146
144protected:147protected:
145 validate_expr(148 validate_expr(
146 CompilerCB* ccb,149 CompilerCB* ccb,
147 static_context* sctx,150 static_context* sctx,
148 const QueryLoc&,151 user_function* udf,
149 ParseConstants::validation_mode_t,152 const QueryLoc&,
150 const store::Item_t& aTypeName,153 ParseConstants::validation_mode_t,
151 expr*,154 const store::Item_t& aTypeName,
152 rchandle<TypeManager>);155 expr*,
156 rchandle<TypeManager>);
153157
154public:158public:
155 expr* get_expr() const { return theExpr; }159 expr* get_expr() const { return theExpr; }
@@ -162,8 +166,6 @@
162166
163 void compute_scripting_kind();167 void compute_scripting_kind();
164168
165 expr* cloneImpl(substitution_t& s) const;
166
167 void accept(expr_visitor&);169 void accept(expr_visitor&);
168170
169 std::ostream& put(std::ostream&) const;171 std::ostream& put(std::ostream&) const;
@@ -184,6 +186,7 @@
184 namespace_context_base_expr(186 namespace_context_base_expr(
185 CompilerCB* ccb,187 CompilerCB* ccb,
186 static_context* sctx,188 static_context* sctx,
189 user_function* udf,
187 const QueryLoc& loc,190 const QueryLoc& loc,
188 expr_kind_t kind,191 expr_kind_t kind,
189 const namespace_context* aNSCtx);192 const namespace_context* aNSCtx);
@@ -207,12 +210,13 @@
207210
208protected:211protected:
209 cast_or_castable_base_expr(212 cast_or_castable_base_expr(
210 CompilerCB* ccb,213 CompilerCB* ccb,
211 static_context* sctx,214 static_context* sctx,
212 const QueryLoc& loc,215 user_function* udf,
213 expr_kind_t kind,216 const QueryLoc& loc,
214 expr* input,217 expr_kind_t kind,
215 const xqtref_t& type);218 expr* input,
219 const xqtref_t& type);
216220
217public:221public:
218 expr* get_input() const { return theInputExpr; }222 expr* get_input() const { return theInputExpr; }
@@ -234,12 +238,13 @@
234238
235protected:239protected:
236 cast_base_expr(240 cast_base_expr(
237 CompilerCB* ccb,241 CompilerCB* ccb,
238 static_context* sctx,242 static_context* sctx,
239 const QueryLoc& loc,243 user_function* udf,
240 expr_kind_t kind,244 const QueryLoc& loc,
241 expr* input,245 expr_kind_t kind,
242 const xqtref_t& type);246 expr* input,
247 const xqtref_t& type);
243};248};
244249
245250
@@ -258,6 +263,7 @@
258 cast_expr(263 cast_expr(
259 CompilerCB* ccb,264 CompilerCB* ccb,
260 static_context* sctx,265 static_context* sctx,
266 user_function* udf,
261 const QueryLoc&,267 const QueryLoc&,
262 expr*,268 expr*,
263 const xqtref_t&);269 const xqtref_t&);
@@ -265,8 +271,6 @@
265public:271public:
266 bool is_optional() const;272 bool is_optional() const;
267273
268 expr* cloneImpl(substitution_t& s) const;
269
270 void accept(expr_visitor&);274 void accept(expr_visitor&);
271275
272 std::ostream& put(std::ostream&) const;276 std::ostream& put(std::ostream&) const;
@@ -299,14 +303,15 @@
299303
300protected:304protected:
301 treat_expr(305 treat_expr(
302 CompilerCB* ccb,306 CompilerCB* ccb,
303 static_context* sctx,307 static_context* sctx,
304 const QueryLoc&,308 user_function* udf,
305 expr*,309 const QueryLoc&,
306 const xqtref_t&,310 expr*,
307 TreatIterator::ErrorKind err,311 const xqtref_t&,
308 bool check_prime = true,312 TreatIterator::ErrorKind err,
309 store::Item* qname = NULL);313 bool check_prime = true,
314 store::Item* qname = NULL);
310315
311public:316public:
312 TreatIterator::ErrorKind get_err() const { return theErrorKind; }317 TreatIterator::ErrorKind get_err() const { return theErrorKind; }
@@ -319,8 +324,6 @@
319324
320 store::Item_t get_qname() const { return theQName; }325 store::Item_t get_qname() const { return theQName; }
321326
322 expr* cloneImpl(substitution_t& s) const;
323
324 void accept(expr_visitor&);327 void accept(expr_visitor&);
325328
326 std::ostream& put(std::ostream&) const;329 std::ostream& put(std::ostream&) const;
@@ -379,6 +382,7 @@
379 promote_expr(382 promote_expr(
380 CompilerCB* ccb,383 CompilerCB* ccb,
381 static_context* sctx,384 static_context* sctx,
385 user_function* udf,
382 const QueryLoc& loc,386 const QueryLoc& loc,
383 expr* input,387 expr* input,
384 const xqtref_t& type,388 const xqtref_t& type,
@@ -386,8 +390,6 @@
386 store::Item* qname);390 store::Item* qname);
387391
388public:392public:
389 expr* cloneImpl(substitution_t& s) const;
390
391 PromoteIterator::ErrorKind get_err() const { return theErrorKind; }393 PromoteIterator::ErrorKind get_err() const { return theErrorKind; }
392394
393 void set_qname(const store::Item_t& qname) { theQName = qname; }395 void set_qname(const store::Item_t& qname) { theQName = qname; }
@@ -409,12 +411,13 @@
409411
410protected:412protected:
411 castable_base_expr(413 castable_base_expr(
412 CompilerCB* ccb,414 CompilerCB* ccb,
413 static_context* sctx,415 static_context* sctx,
414 const QueryLoc&,416 user_function* udf,
415 expr_kind_t kind,417 const QueryLoc&,
416 expr*,418 expr_kind_t kind,
417 const xqtref_t&);419 expr*,
420 const xqtref_t&);
418};421};
419422
420423
@@ -433,6 +436,7 @@
433 castable_expr(436 castable_expr(
434 CompilerCB* ccb,437 CompilerCB* ccb,
435 static_context* sctx,438 static_context* sctx,
439 user_function* udf,
436 const QueryLoc&,440 const QueryLoc&,
437 expr*,441 expr*,
438 const xqtref_t&);442 const xqtref_t&);
@@ -440,8 +444,6 @@
440public:444public:
441 bool is_optional() const;445 bool is_optional() const;
442446
443 expr* cloneImpl(substitution_t& s) const;
444
445 void accept(expr_visitor&);447 void accept(expr_visitor&);
446448
447 std::ostream& put(std::ostream&) const;449 std::ostream& put(std::ostream&) const;
@@ -470,6 +472,7 @@
470 instanceof_expr(472 instanceof_expr(
471 CompilerCB* ccb,473 CompilerCB* ccb,
472 static_context* sctx,474 static_context* sctx,
475 user_function* udf,
473 const QueryLoc&,476 const QueryLoc&,
474 expr*,477 expr*,
475 const xqtref_t&,478 const xqtref_t&,
@@ -478,8 +481,6 @@
478public:481public:
479 bool getCheckPrimeOnly() const { return theCheckPrimeOnly; }482 bool getCheckPrimeOnly() const { return theCheckPrimeOnly; }
480483
481 expr* cloneImpl(substitution_t& s) const;
482
483 void accept(expr_visitor&);484 void accept(expr_visitor&);
484485
485 std::ostream& put(std::ostream&) const;486 std::ostream& put(std::ostream&) const;
@@ -510,6 +511,7 @@
510 name_cast_expr(511 name_cast_expr(
511 CompilerCB* ccb,512 CompilerCB* ccb,
512 static_context* sctx,513 static_context* sctx,
514 user_function* udf,
513 const QueryLoc&,515 const QueryLoc&,
514 expr*,516 expr*,
515 const namespace_context*,517 const namespace_context*,
@@ -522,8 +524,6 @@
522524
523 void compute_scripting_kind();525 void compute_scripting_kind();
524526
525 expr* cloneImpl(substitution_t& s) const;
526
527 void accept(expr_visitor&);527 void accept(expr_visitor&);
528528
529 std::ostream& put(std::ostream&) const;529 std::ostream& put(std::ostream&) const;
@@ -540,11 +540,17 @@
540 friend class expr;540 friend class expr;
541541
542protected:542protected:
543 expr* theContent;543 expr * theContent;
544 bool theCopyInputNodes;544 bool theCopyInputNodes;
545545
546protected:546protected:
547 doc_expr(CompilerCB* ccb, static_context* sctx, const QueryLoc&, expr* content, bool copyNodes);547 doc_expr(
548 CompilerCB* ccb,
549 static_context* sctx,
550 user_function* udf,
551 const QueryLoc&,
552 expr* content,
553 bool copyNodes);
548554
549public:555public:
550 expr* getContent() const { return theContent; }556 expr* getContent() const { return theContent; }
@@ -555,8 +561,6 @@
555561
556 void compute_scripting_kind();562 void compute_scripting_kind();
557563
558 expr* cloneImpl(substitution_t& s) const;
559
560 void accept(expr_visitor&);564 void accept(expr_visitor&);
561565
562 std::ostream& put(std::ostream&) const;566 std::ostream& put(std::ostream&) const;
@@ -596,25 +600,27 @@
596 friend class expr;600 friend class expr;
597601
598protected:602protected:
599 expr* theQNameExpr;603 expr * theQNameExpr;
600 expr* theAttrs;604 expr * theAttrs;
601 expr* theContent;605 expr * theContent;
602 bool theCopyInputNodes;606 bool theCopyInputNodes;
603607
604protected:608protected:
605 elem_expr(609 elem_expr(
606 CompilerCB* ccb,610 CompilerCB* ccb,
607 static_context* sctx,611 static_context* sctx,
608 const QueryLoc&,612 user_function* udf,
609 expr* qnameExpr,613 const QueryLoc&,
610 expr* attrs,614 expr* qnameExpr,
611 expr* content,615 expr* attrs,
612 const namespace_context* nsCtx,616 expr* content,
613 bool copyNodes);617 const namespace_context* nsCtx,
618 bool copyNodes);
614619
615 elem_expr(620 elem_expr(
616 CompilerCB* ccb,621 CompilerCB* ccb,
617 static_context* sctx,622 static_context* sctx,
623 user_function* udf,
618 const QueryLoc&,624 const QueryLoc&,
619 expr* qnameExpr,625 expr* qnameExpr,
620 expr* content,626 expr* content,
@@ -634,8 +640,6 @@
634640
635 void compute_scripting_kind();641 void compute_scripting_kind();
636 642
637 expr* cloneImpl(substitution_t& s) const;
638
639 void accept(expr_visitor&);643 void accept(expr_visitor&);
640644
641 std::ostream& put(std::ostream&) const;645 std::ostream& put(std::ostream&) const;
@@ -673,16 +677,17 @@
673 friend class expr;677 friend class expr;
674678
675protected:679protected:
676 expr* theQNameExpr;680 expr * theQNameExpr;
677 expr* theValueExpr;681 expr * theValueExpr;
678682
679protected:683protected:
680 attr_expr(684 attr_expr(
681 CompilerCB* ccb,685 CompilerCB* ccb,
682 static_context* sctx,686 static_context* sctx,
683 const QueryLoc& loc,687 user_function* udf,
684 expr* aQNameExpr,688 const QueryLoc& loc,
685 expr* aValueExpr);689 expr* aQNameExpr,
690 expr* aValueExpr);
686691
687public:692public:
688 expr* getQNameExpr() const { return theQNameExpr; }693 expr* getQNameExpr() const { return theQNameExpr; }
@@ -693,8 +698,6 @@
693698
694 void compute_scripting_kind();699 void compute_scripting_kind();
695700
696 expr* cloneImpl(substitution_t& s) const;
697
698 void accept(expr_visitor&);701 void accept(expr_visitor&);
699702
700 std::ostream& put(std::ostream&) const;703 std::ostream& put(std::ostream&) const;
@@ -718,13 +721,14 @@
718 } text_constructor_type;721 } text_constructor_type;
719722
720protected:723protected:
721 text_constructor_type type;724 text_constructor_type type;
722 expr* theContentExpr;725 expr * theContentExpr;
723726
724protected:727protected:
725 text_expr(728 text_expr(
726 CompilerCB* ccb,729 CompilerCB* ccb,
727 static_context* sctx,730 static_context* sctx,
731 user_function* udf,
728 const QueryLoc&,732 const QueryLoc&,
729 text_constructor_type,733 text_constructor_type,
730 expr*);734 expr*);
@@ -736,8 +740,6 @@
736740
737 void compute_scripting_kind();741 void compute_scripting_kind();
738742
739 expr* cloneImpl(substitution_t& s) const;
740
741 void accept(expr_visitor&);743 void accept(expr_visitor&);
742744
743 std::ostream& put(std::ostream&) const;745 std::ostream& put(std::ostream&) const;
@@ -754,11 +756,17 @@
754 friend class expr;756 friend class expr;
755757
756protected:758protected:
757 expr* theTargetExpr;759 expr * theTargetExpr;
758 expr* theContentExpr;760 expr * theContentExpr;
759761
760protected:762protected:
761 pi_expr(CompilerCB* ccb, static_context* sctx, const QueryLoc&, expr*, expr*);763 pi_expr(
764 CompilerCB* ccb,
765 static_context* sctx,
766 user_function* udf,
767 const QueryLoc&,
768 expr*,
769 expr*);
762770
763public:771public:
764 expr* get_target_expr() const { return theTargetExpr; }772 expr* get_target_expr() const { return theTargetExpr; }
@@ -767,8 +775,6 @@
767775
768 void compute_scripting_kind();776 void compute_scripting_kind();
769777
770 expr* cloneImpl(substitution_t& s) const;
771
772 void accept(expr_visitor&);778 void accept(expr_visitor&);
773779
774 std::ostream& put(std::ostream&) const;780 std::ostream& put(std::ostream&) const;
@@ -788,31 +794,76 @@
788 store::Item_t theValue;794 store::Item_t theValue;
789795
790protected:796protected:
791 const_expr(CompilerCB*, static_context*, const QueryLoc&, zstring& sval);797 const_expr(
792798 CompilerCB*,
793 const_expr(CompilerCB*, static_context*, const QueryLoc&, const std::string& sval);799 static_context*,
794800 user_function* udf,
795 const_expr(CompilerCB*, static_context*, const QueryLoc&, const char* sval);801 const QueryLoc&,
796802 zstring& sval);
797 const_expr(CompilerCB*, static_context*, const QueryLoc&, xs_integer);803
798804 const_expr(
799 const_expr(CompilerCB*, static_context*, const QueryLoc&, xs_decimal);805 CompilerCB*,
800806 static_context*,
801 const_expr(CompilerCB*, static_context*, const QueryLoc&, xs_double);807 user_function* udf,
802808 const QueryLoc&,
803 const_expr(CompilerCB*, static_context*, const QueryLoc&, xs_boolean);809 const std::string& sval);
804810
805 const_expr(CompilerCB*, static_context*, const QueryLoc&, const store::Item_t&);811 const_expr(
806812 CompilerCB*,
807 const_expr(CompilerCB*, static_context*, const QueryLoc&, const char* ns, const char* pre, const char* local);813 static_context*,
814 user_function* udf,
815 const QueryLoc&,
816 const char* sval);
817
818 const_expr(
819 CompilerCB*,
820 static_context*,
821 user_function* udf,
822 const QueryLoc&,
823 xs_integer);
824
825 const_expr(
826 CompilerCB*,
827 static_context*,
828 user_function* udf,
829 const QueryLoc&,
830 xs_decimal);
831
832 const_expr(
833 CompilerCB*,
834 static_context*,
835 user_function* udf,
836 const QueryLoc&,
837 xs_double);
838
839 const_expr(
840 CompilerCB*,
841 static_context*,
842 user_function* udf,
843 const QueryLoc&,
844 xs_boolean);
845
846 const_expr(
847 CompilerCB*,
848 static_context*,
849 user_function* udf,
850 const QueryLoc&,
851 const store::Item_t&);
852
853 const_expr(
854 CompilerCB*,
855 static_context*,
856 user_function* udf,
857 const QueryLoc&,
858 const char* ns,
859 const char* pre,
860 const char* local);
808861
809public:862public:
810 store::Item* get_val() const { return theValue.getp(); }863 store::Item* get_val() const { return theValue.getp(); }
811864
812 void compute_scripting_kind();865 void compute_scripting_kind();
813866
814 expr* cloneImpl(substitution_t& s) const;
815
816 void accept(expr_visitor&);867 void accept(expr_visitor&);
817868
818 std::ostream& put(std::ostream&) const;869 std::ostream& put(std::ostream&) const;
@@ -829,13 +880,22 @@
829 friend class expr;880 friend class expr;
830881
831protected:882protected:
832 std::vector<pragma*> thePragmas;883 std::vector<pragma*> thePragmas;
833 expr* theExpr;884 expr * theExpr;
834885
835protected:886protected:
836 extension_expr(CompilerCB* ccb, static_context* sctx, const QueryLoc&);887 extension_expr(
888 CompilerCB* ccb,
889 static_context* sctx,
890 user_function* udf,
891 const QueryLoc&);
837892
838 extension_expr(CompilerCB* ccb, static_context* sctx, const QueryLoc&, expr*);893 extension_expr(
894 CompilerCB* ccb,
895 static_context* sctx,
896 user_function* udf,
897 const QueryLoc&,
898 expr*);
839899
840public:900public:
841 void add(pragma* p) { thePragmas.push_back(p); }901 void add(pragma* p) { thePragmas.push_back(p); }
@@ -844,8 +904,6 @@
844904
845 void compute_scripting_kind();905 void compute_scripting_kind();
846906
847 expr* cloneImpl(substitution_t& subst) const;
848
849 void accept(expr_visitor&);907 void accept(expr_visitor&);
850908
851 std::ostream& put(std::ostream&) const;909 std::ostream& put(std::ostream&) const;
@@ -934,7 +992,12 @@
934 std::vector<catch_clause*> theCatchClauses;992 std::vector<catch_clause*> theCatchClauses;
935993
936protected:994protected:
937 trycatch_expr(CompilerCB* ccb, static_context* sctx, const QueryLoc&, expr* tryExpr);995 trycatch_expr(
996 CompilerCB* ccb,
997 static_context* sctx,
998 user_function* udf,
999 const QueryLoc&,
1000 expr* tryExpr);
9381001
939public:1002public:
940 expr* get_try_expr() const { return theTryExpr; }1003 expr* get_try_expr() const { return theTryExpr; }
@@ -953,8 +1016,6 @@
9531016
954 void compute_scripting_kind();1017 void compute_scripting_kind();
9551018
956 expr* cloneImpl(substitution_t& subst) const;
957
958 void accept(expr_visitor&);1019 void accept(expr_visitor&);
9591020
960 std::ostream& put(std::ostream&) const;1021 std::ostream& put(std::ostream&) const;
@@ -979,10 +1040,15 @@
979 friend class ExprManager;1040 friend class ExprManager;
9801041
981protected:1042protected:
982 expr* theWrappedExpr;1043 expr * theWrappedExpr;
9831044
984protected:1045protected:
985 wrapper_expr(CompilerCB* ccb, static_context* sctx, const QueryLoc& loc, expr* wrapped);1046 wrapper_expr(
1047 CompilerCB* ccb,
1048 static_context* sctx,
1049 user_function* udf,
1050 const QueryLoc& loc,
1051 expr* wrapped);
9861052
987public:1053public:
988 expr* get_expr() const { return theWrappedExpr; }1054 expr* get_expr() const { return theWrappedExpr; }
@@ -993,8 +1059,6 @@
9931059
994 void accept(expr_visitor&);1060 void accept(expr_visitor&);
9951061
996 expr* cloneImpl(substitution_t& s) const;
997
998 std::ostream& put(std::ostream&) const;1062 std::ostream& put(std::ostream&) const;
999};1063};
10001064
@@ -1019,10 +1083,13 @@
1019 function_trace_expr(1083 function_trace_expr(
1020 CompilerCB* ccb,1084 CompilerCB* ccb,
1021 static_context* sctx,1085 static_context* sctx,
1086 user_function* udf,
1022 const QueryLoc& loc,1087 const QueryLoc& loc,
1023 expr* aChild);1088 expr* aChild);
10241089
1025 function_trace_expr(expr* aExpr);1090 function_trace_expr(
1091 user_function* udf,
1092 expr* aExpr);
10261093
1027public:1094public:
1028 virtual ~function_trace_expr();1095 virtual ~function_trace_expr();
@@ -1031,8 +1098,6 @@
10311098
1032 void accept(expr_visitor&);1099 void accept(expr_visitor&);
10331100
1034 expr* cloneImpl(substitution_t& s) const;
1035
1036 std::ostream& put(std::ostream&) const;1101 std::ostream& put(std::ostream&) const;
10371102
1038 expr* get_expr() const { return theExpr; }1103 expr* get_expr() const { return theExpr; }
@@ -1133,6 +1198,7 @@
1133 eval_expr(1198 eval_expr(
1134 CompilerCB* ccb,1199 CompilerCB* ccb,
1135 static_context* sctx,1200 static_context* sctx,
1201 user_function* udf,
1136 const QueryLoc& loc,1202 const QueryLoc& loc,
1137 expr* e,1203 expr* e,
1138 expr_script_kind_t scriptingKind,1204 expr_script_kind_t scriptingKind,
@@ -1166,8 +1232,6 @@
11661232
1167 void accept(expr_visitor&);1233 void accept(expr_visitor&);
11681234
1169 expr* cloneImpl(substitution_t& s) const;
1170
1171 std::ostream& put(std::ostream&) const;1235 std::ostream& put(std::ostream&) const;
1172};1236};
11731237
@@ -1205,6 +1269,7 @@
1205 debugger_expr(1269 debugger_expr(
1206 CompilerCB* ccb,1270 CompilerCB* ccb,
1207 static_context* sctx,1271 static_context* sctx,
1272 user_function* udf,
1208 const QueryLoc& loc,1273 const QueryLoc& loc,
1209 expr* aChild,1274 expr* aChild,
1210 namespace_context* nsCtx,1275 namespace_context* nsCtx,
12111276
=== modified file 'src/compiler/expression/expr_base.cpp'
--- src/compiler/expression/expr_base.cpp 2012-10-08 12:09:36 +0000
+++ src/compiler/expression/expr_base.cpp 2012-10-09 13:35:26 +0000
@@ -19,7 +19,6 @@
19#include "compiler/expression/expr.h"19#include "compiler/expression/expr.h"
20#include "compiler/expression/fo_expr.h"20#include "compiler/expression/fo_expr.h"
21#include "compiler/expression/flwor_expr.h"21#include "compiler/expression/flwor_expr.h"
22#include "compiler/expression/script_exprs.h"
23#include "compiler/expression/path_expr.h"22#include "compiler/expression/path_expr.h"
24#include "compiler/expression/expr_iter.h"23#include "compiler/expression/expr_iter.h"
25#include "compiler/expression/expr_visitor.h"24#include "compiler/expression/expr_visitor.h"
@@ -123,13 +122,19 @@
123/*******************************************************************************122/*******************************************************************************
124123
125********************************************************************************/124********************************************************************************/
126expr::expr(CompilerCB* ccb, static_context* sctx, const QueryLoc& loc, expr_kind_t k)125expr::expr(
126 CompilerCB* ccb,
127 static_context* sctx,
128 user_function* udf,
129 const QueryLoc& loc,
130 expr_kind_t k)
127 :131 :
132 theCCB(ccb),
128 theSctx(sctx),133 theSctx(sctx),
134 theUDF(udf),
129 theLoc(loc),135 theLoc(loc),
130 theKind(k),136 theKind(k),
131 theFlags1(0),137 theFlags1(0)
132 theCCB(ccb)
133{138{
134 theScriptingKind = UNKNOWN_SCRIPTING_KIND;139 theScriptingKind = UNKNOWN_SCRIPTING_KIND;
135140
@@ -239,40 +244,6 @@
239/*******************************************************************************244/*******************************************************************************
240245
241********************************************************************************/246********************************************************************************/
242expr* expr::clone() const
243{
244 substitution_t subst;
245 return clone(subst);
246}
247
248
249expr* expr::clone(substitution_t& subst) const
250{
251 expr* lNewExpr = cloneImpl(subst);
252
253 if (containsPragma())
254 {
255 lNewExpr->setContainsPragma(ANNOTATION_TRUE);
256 std::vector<pragma*> lPragmas;
257 theCCB->lookup_pragmas(this, lPragmas);
258 for (size_t i = 0; i < lPragmas.size(); ++i)
259 {
260 theCCB->add_pragma(lNewExpr, lPragmas[i]);
261 }
262 }
263 return lNewExpr;
264}
265
266
267expr* expr::cloneImpl(substitution_t& subst) const
268{
269 throw XQUERY_EXCEPTION(zerr::ZXQP0003_INTERNAL_ERROR, ERROR_LOC(get_loc()));
270}
271
272
273/*******************************************************************************
274
275********************************************************************************/
276void expr::accept_children(expr_visitor& v)247void expr::accept_children(expr_visitor& v)
277{248{
278 ExprIterator iter(this);249 ExprIterator iter(this);
@@ -1212,13 +1183,18 @@
1212********************************************************************************/1183********************************************************************************/
1213xqtref_t expr::get_return_type_with_empty_input(const expr* input) const1184xqtref_t expr::get_return_type_with_empty_input(const expr* input) const
1214{1185{
1215 expr* emptyExpr = theCCB->theEM->create_fo_expr(input->get_sctx(),1186 assert(input->get_udf() == theUDF);
1216 QueryLoc::null,1187
1217 GET_BUILTIN_FUNCTION(OP_CONCATENATE_N));1188 expr* emptyExpr = theCCB->theEM->
1189 create_fo_expr(input->get_sctx(),
1190 theUDF,
1191 QueryLoc::null,
1192 GET_BUILTIN_FUNCTION(OP_CONCATENATE_N));
1193
1218 expr::substitution_t subst;1194 expr::substitution_t subst;
1219 subst[input] = emptyExpr;1195 subst[input] = emptyExpr;
12201196
1221 expr* cloneExpr = clone(subst);1197 expr* cloneExpr = clone(theUDF, subst);
12221198
1223 return cloneExpr->get_return_type();1199 return cloneExpr->get_return_type();
1224}1200}
12251201
=== modified file 'src/compiler/expression/expr_base.h'
--- src/compiler/expression/expr_base.h 2012-10-08 12:09:36 +0000
+++ src/compiler/expression/expr_base.h 2012-10-09 13:35:26 +0000
@@ -173,8 +173,12 @@
173 static expr* * iter_done;173 static expr* * iter_done;
174174
175protected:175protected:
176 CompilerCB * const theCCB;
177
176 static_context * theSctx;178 static_context * theSctx;
177179
180 user_function * theUDF;
181
178 QueryLoc theLoc;182 QueryLoc theLoc;
179183
180 unsigned short theKind;184 unsigned short theKind;
@@ -186,8 +190,6 @@
186190
187 FreeVars theFreeVars;191 FreeVars theFreeVars;
188192
189 CompilerCB *const theCCB;
190
191public:193public:
192 static bool is_sequential(unsigned short theScriptingKind);194 static bool is_sequential(unsigned short theScriptingKind);
193195
@@ -196,14 +198,20 @@
196 static void checkNonUpdating(const expr* e);198 static void checkNonUpdating(const expr* e);
197199
198protected:200protected:
199 expr(CompilerCB*, static_context*, const QueryLoc&, expr_kind_t);201 expr(CompilerCB*, static_context*, user_function*, const QueryLoc&, expr_kind_t);
200202
201 expr() : theSctx(NULL), theFlags1(0), theCCB(NULL) {}203 expr() : theCCB(NULL), theSctx(NULL), theUDF(NULL), theFlags1(0) {}
202204
203public:205public:
204 virtual ~expr();206 virtual ~expr();
205207
206 CompilerCB* get_ccb() {return theCCB;}208 CompilerCB* get_ccb() { return theCCB; }
209
210 static_context* get_sctx() const { return theSctx; }
211
212 TypeManager* get_type_manager() const;
213
214 user_function* get_udf() const { return theUDF; }
207215
208 expr_kind_t get_expr_kind() const { return static_cast<expr_kind_t>(theKind); }216 expr_kind_t get_expr_kind() const { return static_cast<expr_kind_t>(theKind); }
209217
@@ -211,10 +219,6 @@
211219
212 void set_loc(const QueryLoc& loc) { theLoc = loc; }220 void set_loc(const QueryLoc& loc) { theLoc = loc; }
213221
214 static_context* get_sctx() const { return theSctx; }
215
216 TypeManager* get_type_manager() const;
217
218 uint32_t getFlags() const { return theFlags1; }222 uint32_t getFlags() const { return theFlags1; }
219223
220 void setFlags(uint32_t flags) { theFlags1 = flags; }224 void setFlags(uint32_t flags) { theFlags1 = flags; }
@@ -241,11 +245,9 @@
241245
242 xqtref_t get_return_type();246 xqtref_t get_return_type();
243247
244 expr* clone() const;248 expr* clone(user_function* udf) const;
245249
246 expr* clone(substitution_t&) const;250 expr* clone(user_function* udf, substitution_t& subst) const;
247
248 virtual expr* cloneImpl(substitution_t& substitution) const;
249251
250 virtual void accept(expr_visitor& v) = 0;252 virtual void accept(expr_visitor& v) = 0;
251253
252254
=== added file 'src/compiler/expression/expr_clone.cpp'
--- src/compiler/expression/expr_clone.cpp 1970-01-01 00:00:00 +0000
+++ src/compiler/expression/expr_clone.cpp 2012-10-09 13:35:26 +0000
@@ -0,0 +1,790 @@
1/*
2 * Copyright 2006-2008 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "compiler/expression/expr_base.h"
18#include "compiler/expression/update_exprs.h"
19#include "compiler/expression/expr.h"
20#include "compiler/expression/fo_expr.h"
21#include "compiler/expression/flwor_expr.h"
22#include "compiler/expression/script_exprs.h"
23#include "compiler/expression/path_expr.h"
24#include "compiler/expression/json_exprs.h"
25#include "compiler/expression/function_item_expr.h"
26#include "compiler/expression/ft_expr.h"
27#include "compiler/expression/expr_manager.h"
28
29#include "compiler/api/compilercb.h"
30
31#include "functions/function.h"
32
33#include "diagnostics/xquery_diagnostics.h"
34#include "diagnostics/util_macros.h"
35
36namespace zorba
37{
38
39#define CLONE(e, udf, subst) ((e) == NULL ? NULL : (e)->clone(udf, subst))
40
41
42/*******************************************************************************
43
44********************************************************************************/
45expr* expr::clone(user_function* udf) const
46{
47 substitution_t subst;
48 return clone(udf, subst);
49}
50
51
52expr* expr::clone(user_function* udf, substitution_t& subst) const
53{
54 expr* newExpr = NULL;
55
56 switch (get_expr_kind())
57 {
58 case const_expr_kind:
59 {
60 const const_expr* e = static_cast<const const_expr*>(this);
61
62 newExpr = theCCB->theEM->
63 create_const_expr(theSctx, udf, theLoc, e->theValue);
64
65 break;
66 }
67 case var_expr_kind:
68 {
69 expr::subst_iter_t i = subst.find(this);
70
71 if (i == subst.end())
72 newExpr = const_cast<expr*>(this);
73 else
74 newExpr = i->second;
75
76 break;
77 }
78 case doc_expr_kind:
79 {
80 const doc_expr* e = static_cast<const doc_expr*>(this);
81
82 newExpr = theCCB->theEM->
83 create_doc_expr(theSctx,
84 udf,
85 theLoc,
86 CLONE(e->getContent(), udf, subst),
87 e->theCopyInputNodes);
88 break;
89 }
90 case elem_expr_kind:
91 {
92 const elem_expr* e = static_cast<const elem_expr*>(this);
93
94 newExpr = theCCB->theEM->
95 create_elem_expr(theSctx,
96 udf,
97 theLoc,
98 CLONE(e->getQNameExpr(), udf, subst),
99 CLONE(e->getAttrs(), udf, subst),
100 CLONE(e->getContent(), udf, subst),
101 e->getNSCtx(),
102 e->theCopyInputNodes);
103 break;
104 }
105 case attr_expr_kind:
106 {
107 const attr_expr* e = static_cast<const attr_expr*>(this);
108
109 newExpr = theCCB->theEM->
110 create_attr_expr(theSctx,
111 udf,
112 theLoc,
113 CLONE(e->getQNameExpr(), udf, subst),
114 CLONE(e->getValueExpr(), udf, subst));
115 break;
116 }
117 case text_expr_kind:
118 {
119 const text_expr* e = static_cast<const text_expr*>(this);
120
121 newExpr = theCCB->theEM->
122 create_text_expr(theSctx,
123 udf,
124 theLoc,
125 e->get_type(),
126 CLONE(e->get_text(), udf, subst));
127 break;
128 }
129 case pi_expr_kind:
130 {
131 const pi_expr* e = static_cast<const pi_expr*>(this);
132
133 newExpr = theCCB->theEM->
134 create_pi_expr(theSctx,
135 udf,
136 theLoc,
137 CLONE(e->get_target_expr(), udf, subst),
138 CLONE(e->get_content_expr(), udf, subst));
139 break;
140 }
141#ifdef ZORBA_WITH_JSON
142 case json_direct_object_expr_kind:
143 {
144 const json_direct_object_expr* e = static_cast<const json_direct_object_expr*>(this);
145
146 std::vector<expr*> names;
147 std::vector<expr*> values;
148
149 names.reserve(e->theNames.size());
150 values.reserve(e->theValues.size());
151
152 std::vector<expr*>::const_iterator ite = e->theNames.begin();
153 std::vector<expr*>::const_iterator end = e->theNames.end();
154 for (; ite != end; ++ite)
155 {
156 names.push_back((*ite)->clone(udf, subst));
157 }
158
159 ite = e->theValues.begin();
160 end = e->theValues.end();
161 for (; ite != end; ++ite)
162 {
163 values.push_back((*ite)->clone(udf, subst));
164 }
165
166 newExpr = theCCB->theEM->
167 create_json_direct_object_expr(theSctx, udf, theLoc, names, values);
168
169 break;
170 }
171 case json_object_expr_kind:
172 {
173 const json_object_expr* e = static_cast<const json_object_expr*>(this);
174
175 newExpr = theCCB->theEM->
176 create_json_object_expr(theSctx,
177 udf,
178 theLoc,
179 (e->theContentExpr ?
180 e->theContentExpr->clone(udf, subst) : NULL),
181 e->theAccumulate);
182
183 break;
184 }
185 case json_array_expr_kind:
186 {
187 const json_array_expr* e = static_cast<const json_array_expr*>(this);
188
189 newExpr = theCCB->theEM->
190 create_json_array_expr(theSctx,
191 udf,
192 theLoc,
193 e->theContentExpr->clone(udf, subst));
194
195 break;
196 }
197#endif
198
199 case relpath_expr_kind:
200 {
201 const relpath_expr* e = static_cast<const relpath_expr*>(this);
202
203 relpath_expr* cloneExpr = theCCB->theEM->
204 create_relpath_expr(theSctx, udf, theLoc);
205
206 for (csize i = 0; i < e->size(); ++i)
207 {
208 cloneExpr->add_back((*e)[i]->clone(udf, subst));
209 }
210
211 newExpr = cloneExpr;
212 break;
213 }
214 case axis_step_expr_kind:
215 {
216 const axis_step_expr* e = static_cast<const axis_step_expr*>(this);
217
218 axis_step_expr* cloneExpr = theCCB->theEM->
219 create_axis_step_expr(theSctx, udf, theLoc);
220
221 cloneExpr->setAxis(e->getAxis());
222 cloneExpr->setTest(static_cast<match_expr*>(CLONE(e->getTest(), udf, subst)));
223 cloneExpr->theReverseOrder = e->theReverseOrder;
224
225 newExpr = cloneExpr;
226 break;
227 }
228 case match_expr_kind:
229 {
230 const match_expr* e = static_cast<const match_expr*>(this);
231
232 match_expr* cloneExpr = theCCB->theEM->
233 create_match_expr(theSctx, udf, theLoc);
234
235 cloneExpr->setTestKind(e->getTestKind());
236 cloneExpr->setDocTestKind(e->getDocTestKind());
237 cloneExpr->setWildName(e->getWildName());
238 cloneExpr->setWildKind(e->getWildKind());
239 cloneExpr->setQName(e->getQName());
240 cloneExpr->setTypeName(e->getTypeName());
241 cloneExpr->setNilledAllowed(e->getNilledAllowed());
242
243 newExpr = cloneExpr;
244 break;
245 }
246
247 case flwor_expr_kind:
248 case gflwor_expr_kind:
249 {
250 const flwor_expr* e = static_cast<const flwor_expr*>(this);
251
252 flwor_expr* cloneExpr = theCCB->theEM->
253 create_flwor_expr(theSctx, udf, theLoc, e->theIsGeneral);
254
255 csize numClauses = e->num_clauses();
256
257 for (csize i = 0; i < numClauses; ++i)
258 {
259 flwor_clause* cloneClause = e->theClauses[i]->clone(udf, subst);
260
261 cloneExpr->add_clause(cloneClause, false);
262 }
263
264 cloneExpr->set_return_expr(e->theReturnExpr->clone(udf, subst));
265
266 newExpr = cloneExpr;
267 break;
268 }
269 case if_expr_kind:
270 {
271 const if_expr* e = static_cast<const if_expr*>(this);
272
273 newExpr = theCCB->theEM->
274 create_if_expr(theSctx,
275 udf,
276 theLoc,
277 e->get_cond_expr()->clone(udf, subst),
278 e->get_then_expr()->clone(udf, subst),
279 e->get_else_expr()->clone(udf, subst));
280 break;
281 }
282 case trycatch_expr_kind:
283 {
284 const trycatch_expr* e = static_cast<const trycatch_expr*>(this);
285
286 trycatch_expr* cloneExpr = theCCB->theEM->
287 create_trycatch_expr(theSctx, udf, theLoc, e->theTryExpr->clone(udf, subst));
288
289 for (std::vector<expr*>::const_iterator ite = e->theCatchExprs.begin();
290 ite != e->theCatchExprs.end();
291 ++ite)
292 {
293 cloneExpr->add_catch_expr((*ite)->clone(udf, subst));
294 }
295
296 for (csize i = 0; i < e->clause_count(); ++i)
297 {
298 cloneExpr->add_clause(e->theCatchClauses[i]->clone(subst));
299 }
300
301 newExpr = cloneExpr;
302 break;
303 }
304 case fo_expr_kind:
305 {
306 const fo_expr* e = static_cast<const fo_expr*>(this);
307
308 if (e->get_func()->getKind() == FunctionConsts::STATIC_COLLECTIONS_DML_COLLECTION_1)
309 {
310 expr::subst_iter_t i = subst.find(this);
311
312 if (i != subst.end())
313 {
314 newExpr = i->second;
315 break;
316 }
317 }
318
319 fo_expr* cloneExpr = theCCB->theEM->
320 create_fo_expr(theSctx, udf, theLoc, e->get_func());
321
322 cloneExpr->theArgs.reserve(e->theArgs.size());
323
324 for (csize i = 0; i < e->theArgs.size(); ++i)
325 cloneExpr->theArgs.push_back(e->theArgs[i]->clone(udf, subst));
326
327 cloneExpr->theScriptingKind = e->theScriptingKind;
328
329 newExpr = cloneExpr;
330 break;
331 }
332 case dynamic_function_invocation_expr_kind:
333 {
334 const dynamic_function_invocation_expr* e =
335 static_cast<const dynamic_function_invocation_expr*>(this);
336
337 checked_vector<expr*> newArgs;
338 for (checked_vector<expr*>::const_iterator ite = e->theArgs.begin();
339 ite != e->theArgs.end();
340 ++ite)
341 {
342 newArgs.push_back((*ite)->clone(udf, subst));
343 }
344
345 newExpr = theCCB->theEM->
346 create_dynamic_function_invocation_expr(theSctx,
347 udf,
348 theLoc,
349 e->theExpr->clone(udf, subst),
350 newArgs);
351 break;
352 }
353 case function_item_expr_kind:
354 {
355 const function_item_expr* e = static_cast<const function_item_expr*>(this);
356
357 function_item_expr* cloneExpr = theCCB->theEM->
358 create_function_item_expr(theSctx,
359 udf,
360 theLoc,
361 e->theFunction->getName(),
362 e->theFunction.getp(),
363 e->theArity);
364
365 std::vector<expr*> lNewVariables;
366 for (std::vector<expr*>::const_iterator ite = e->theScopedVariables.begin();
367 ite != e->theScopedVariables.end();
368 ++ite)
369 {
370 cloneExpr->add_variable((*ite)->clone(udf, subst));
371 }
372
373 newExpr = cloneExpr;
374 break;
375 }
376 case castable_expr_kind:
377 {
378 const castable_expr* e = static_cast<const castable_expr*>(this);
379
380 newExpr = theCCB->theEM->
381 create_castable_expr(theSctx,
382 udf,
383 theLoc,
384 e->get_input()->clone(udf, subst),
385 e->get_target_type());
386
387 break;
388 }
389 case cast_expr_kind:
390 {
391 const cast_expr* e = static_cast<const cast_expr*>(this);
392
393 newExpr = theCCB->theEM->
394 create_cast_expr(theSctx,
395 udf,
396 theLoc,
397 e->get_input()->clone(udf, subst),
398 e->get_target_type());
399 break;
400 }
401 case instanceof_expr_kind:
402 {
403 const instanceof_expr* e = static_cast<const instanceof_expr*>(this);
404
405 newExpr = theCCB->theEM->
406 create_instanceof_expr(theSctx,
407 udf,
408 theLoc,
409 e->get_input()->clone(udf, subst),
410 e->get_target_type());
411 break;
412 }
413 case treat_expr_kind:
414 {
415 const treat_expr* e = static_cast<const treat_expr*>(this);
416
417 newExpr = theCCB->theEM->
418 create_treat_expr(theSctx,
419 udf,
420 theLoc,
421 e->get_input()->clone(udf, subst),
422 e->get_target_type(),
423 e->get_err(),
424 e->get_check_prime(),
425 e->get_qname());
426 break;
427 }
428 case promote_expr_kind:
429 {
430 const promote_expr* e = static_cast<const promote_expr*>(this);
431
432 newExpr = theCCB->theEM->
433 create_promote_expr(theSctx,
434 udf,
435 theLoc,
436 e->get_input()->clone(udf, subst),
437 e->get_target_type(),
438 e->theErrorKind,
439 e->theQName.getp());
440 break;
441 }
442 case name_cast_expr_kind:
443 {
444 const name_cast_expr* e = static_cast<const name_cast_expr*>(this);
445
446 newExpr = theCCB->theEM->
447 create_name_cast_expr(theSctx,
448 udf,
449 theLoc,
450 e->get_input()->clone(udf, subst),
451 e->getNSCtx(),
452 e->theIsAttrName);
453 break;
454 }
455 case validate_expr_kind:
456 {
457 const validate_expr* e = static_cast<const validate_expr*>(this);
458
459 newExpr = theCCB->theEM->
460 create_validate_expr(theSctx,
461 udf,
462 theLoc,
463 e->get_valmode(),
464 const_cast<store::Item*>(e->get_type_name()),
465 e->get_expr()->clone(udf, subst),
466 e->get_typemgr());
467
468 break;
469 }
470 case extension_expr_kind:
471 {
472 const extension_expr* e = static_cast<const extension_expr*>(this);
473
474 extension_expr* cloneExpr;
475 if(e->theExpr == 0)
476 {
477 cloneExpr = theCCB->theEM->create_extension_expr(theSctx, udf, theLoc);
478 }
479 else
480 {
481 cloneExpr = theCCB->theEM->
482 create_extension_expr(theSctx, udf, theLoc, e->theExpr->clone(udf, subst));
483 }
484
485 // pragma doesn't contain expressions. Thus, it is not cloned.
486 for (std::vector<pragma*>::const_iterator lIter = e->thePragmas.begin();
487 lIter != e->thePragmas.end();
488 ++lIter)
489 {
490 cloneExpr->add(*lIter);
491 }
492
493 newExpr = cloneExpr;
494 break;
495 }
496 case order_expr_kind:
497 {
498 const order_expr* e = static_cast<const order_expr*>(this);
499
500 newExpr = theCCB->theEM->
501 create_order_expr(theSctx,
502 udf,
503 theLoc,
504 e->get_type(),
505 e->get_expr()->clone(udf, subst));
506 break;
507 }
508#ifndef ZORBA_NO_FULL_TEXT
509 case ft_expr_kind:
510 {
511 const ftcontains_expr* e = static_cast<const ftcontains_expr*>(this);
512
513 newExpr = theCCB->theEM->
514 create_ftcontains_expr(theSctx,
515 udf,
516 theLoc,
517 e->range_->clone(udf, subst),
518 e->ftselection_->clone(udf, subst).release(),
519 (e->ftignore_ == NULL ? 0 : e->ftignore_->clone(udf, subst)));
520
521 break;
522 }
523#endif /* ZORBA_NO_FULL_TEXT */
524
525 case delete_expr_kind:
526 {
527 const delete_expr* e = static_cast<const delete_expr*>(this);
528
529 newExpr = theCCB->theEM->
530 create_delete_expr(theSctx, udf, theLoc, e->getTargetExpr()->clone(udf, subst));
531
532 break;
533 }
534 case insert_expr_kind:
535 {
536 const insert_expr* e = static_cast<const insert_expr*>(this);
537
538 newExpr = theCCB->theEM->
539 create_insert_expr(theSctx,
540 udf,
541 theLoc,
542 e->getType(),
543 e->getSourceExpr()->clone(udf, subst),
544 e->getTargetExpr()->clone(udf, subst));
545 break;
546 }
547 case rename_expr_kind:
548 {
549 const rename_expr* e = static_cast<const rename_expr*>(this);
550
551 newExpr = theCCB->theEM->
552 create_rename_expr(theSctx,
553 udf,
554 theLoc,
555 e->getTargetExpr()->clone(udf, subst),
556 e->getNameExpr()->clone(udf, subst));
557 break;
558 }
559 case replace_expr_kind:
560 {
561 const zorba::replace_expr* e = static_cast<const zorba::replace_expr*>(this);
562
563 newExpr = theCCB->theEM->
564 create_replace_expr(theSctx,
565 udf,
566 theLoc,
567 e->getType(),
568 e->getTargetExpr()->clone(udf, subst),
569 e->getReplaceExpr()->clone(udf, subst));
570 break;
571 }
572 case transform_expr_kind:
573 {
574 const transform_expr* e = static_cast<const transform_expr*>(this);
575
576 ZORBA_ASSERT(e->theModifyExpr && e->theReturnExpr);
577
578 transform_expr* cloneExpr = theCCB->theEM->
579 create_transform_expr(theSctx, udf, theLoc);
580
581 for (std::vector<copy_clause*>::const_iterator ite = e->theCopyClauses.begin();
582 ite != e->theCopyClauses.end();
583 ++ite)
584 {
585 cloneExpr->add_back((*ite)->clone(udf, subst));
586 }
587
588 cloneExpr->setModifyExpr(e->theModifyExpr->clone(udf, subst));
589 cloneExpr->setReturnExpr(e->theReturnExpr->clone(udf, subst));
590
591 newExpr = cloneExpr;
592 break;
593 }
594
595 case block_expr_kind:
596 {
597 const block_expr* e = static_cast<const block_expr*>(this);
598
599 checked_vector<expr*> seq2;
600 for (csize i = 0; i < e->theArgs.size(); ++i)
601 seq2.push_back(e->theArgs[i]->clone(udf, subst));
602
603 newExpr = theCCB->theEM->
604 create_block_expr(theSctx, udf, theLoc, true, seq2, NULL);
605
606 break;
607 }
608 case var_decl_expr_kind:
609 {
610 const var_decl_expr* e = static_cast<const var_decl_expr*>(this);
611
612 var_expr* varCopy = theCCB->theEM->create_var_expr(udf, *e->theVarExpr);
613 subst[e->theVarExpr] = varCopy;
614
615 newExpr = theCCB->theEM->
616 create_var_decl_expr(theSctx,
617 udf,
618 theLoc,
619 varCopy,
620 (e->theInitExpr ? e->theInitExpr->clone(udf, subst) : NULL));
621
622 break;
623 }
624 case var_set_expr_kind:
625 {
626 const var_set_expr* e = static_cast<const var_set_expr*>(this);
627
628 expr* varClone = e->theVarExpr->clone(udf, subst);
629
630 ZORBA_ASSERT(varClone->get_expr_kind() == var_expr_kind);
631
632 newExpr = theCCB->theEM->
633 create_var_set_expr(theSctx,
634 udf,
635 theLoc,
636 static_cast<var_expr*>(varClone),
637 e->theExpr->clone(udf, subst));
638 break;
639 }
640 case apply_expr_kind:
641 {
642 const apply_expr* e = static_cast<const apply_expr*>(this);
643
644 newExpr = theCCB->theEM->
645 create_apply_expr(theSctx,
646 udf,
647 theLoc,
648 e->theExpr->clone(udf, subst),
649 e->theDiscardXDM);
650
651 break;
652 }
653 case exit_expr_kind:
654 {
655 const exit_expr* e = static_cast<const exit_expr*>(this);
656
657 newExpr = theCCB->theEM->
658 create_exit_expr(theSctx, udf, theLoc, e->get_expr()->clone(udf, subst));
659
660 subst[this] = newExpr;
661
662 break;
663 }
664 case exit_catcher_expr_kind:
665 {
666 const exit_catcher_expr* e = static_cast<const exit_catcher_expr*>(this);
667
668 expr* clonedInput = e->get_expr()->clone(udf, subst);
669
670 std::vector<expr*> clonedExits;
671 std::vector<expr*>::const_iterator ite = e->theExitExprs.begin();
672 std::vector<expr*>::const_iterator end = e->theExitExprs.end();
673 for (; ite != end; ++ite)
674 {
675 assert(subst.find(*ite) != subst.end());
676
677 clonedExits.push_back(subst[*ite]);
678 }
679
680 newExpr = theCCB->theEM->
681 create_exit_catcher_expr(theSctx, udf, theLoc, clonedInput, clonedExits);
682
683 break;
684 }
685 case flowctl_expr_kind:
686 {
687 const flowctl_expr* e = static_cast<const flowctl_expr*>(this);
688
689 newExpr = theCCB->theEM->
690 create_flowctl_expr(theSctx, udf, theLoc, e->get_action());
691
692 break;
693 }
694 case while_expr_kind:
695 {
696 const while_expr* e = static_cast<const while_expr*>(this);
697
698 newExpr = theCCB->theEM->
699 create_while_expr(theSctx, udf, theLoc, e->get_body()->clone(udf, subst));
700
701 break;
702 }
703 case eval_expr_kind:
704 {
705 const eval_expr* e = static_cast<const eval_expr*>(this);
706
707 newExpr = theCCB->theEM->
708 create_eval_expr(theSctx,
709 udf,
710 theLoc,
711 e->theExpr->clone(udf, subst),
712 e->theInnerScriptingKind,
713 e->theNSCtx.getp());
714
715 eval_expr* newEval = static_cast<eval_expr*>(newExpr);
716
717 newEval->setNodeCopy(e->theDoNodeCopy);
718
719 newEval->theOuterVarNames = e->theOuterVarNames;
720 newEval->theOuterVarTypes = e->theOuterVarTypes;
721
722 csize numVars = e->theOuterVarNames.size();
723
724 newEval->theArgs.resize(numVars);
725
726 for (csize i = 0; i < numVars; ++i)
727 {
728 newEval->theArgs[i] = e->theArgs[i]->clone(udf, subst);
729 }
730
731 break;
732 }
733 case wrapper_expr_kind:
734 {
735 const wrapper_expr* e = static_cast<const wrapper_expr*>(this);
736
737 expr* wrappedClone = e->theWrappedExpr->clone(udf, subst);
738
739 if (e->theWrappedExpr->get_expr_kind() == var_expr_kind &&
740 wrappedClone->get_expr_kind() != var_expr_kind)
741 {
742 newExpr = wrappedClone;
743 }
744 else
745 {
746 newExpr = theCCB->theEM->create_wrapper_expr(theSctx, udf, theLoc, wrappedClone);
747 }
748
749 break;
750 }
751 case function_trace_expr_kind:
752 {
753 const function_trace_expr* e = static_cast<const function_trace_expr*>(this);
754
755 function_trace_expr* cloneExpr = theCCB->theEM->
756 create_function_trace_expr(udf, e->theExpr->clone(udf, subst));
757
758 cloneExpr->theFunctionName = e->theFunctionName;
759 cloneExpr->theFunctionLocation = e->theFunctionLocation;
760 cloneExpr->theFunctionCallLocation = e->theFunctionCallLocation;
761 cloneExpr->theFunctionArity = e->theFunctionArity;
762
763 newExpr = cloneExpr;
764 break;
765 }
766 case debugger_expr_kind:
767 default:
768 {
769 RAISE_ERROR(zerr::ZXQP0003_INTERNAL_ERROR, theLoc,
770 ERROR_PARAMS(ZED(CloneNotImplemented)));
771 }
772 }
773
774 if (containsPragma())
775 {
776 newExpr->setContainsPragma(ANNOTATION_TRUE);
777
778 std::vector<pragma*> pragmas;
779 theCCB->lookup_pragmas(this, pragmas);
780
781 for (csize i = 0; i < pragmas.size(); ++i)
782 {
783 theCCB->add_pragma(newExpr, pragmas[i]);
784 }
785 }
786
787 return newExpr;
788}
789
790}
0791
=== modified file 'src/compiler/expression/expr_manager.cpp'
--- src/compiler/expression/expr_manager.cpp 2012-10-08 12:09:36 +0000
+++ src/compiler/expression/expr_manager.cpp 2012-10-09 13:35:26 +0000
@@ -35,60 +35,6 @@
35namespace zorba35namespace zorba
36{36{
3737
38#if 0
39//A simple expression that can just be deallocated without calling the
40//destructor.
41class NullExpr : public expr
42{
43public:
44 NullExpr() : expr(NULL, NULL, QueryLoc(), unknown_expr_kind) {}
45
46 void accept(expr_visitor& v) {}
47
48 void compute_scripting_kind() {}
49
50 std::ostream& put(std::ostream& stream) const { return stream; }
51};
52
53
54class NullFlworClause : public flwor_clause
55{
56public:
57 //it being a let clause is arbitrary, it doesn't matter what type it is.
58 NullFlworClause() :flwor_clause(NULL, NULL, QueryLoc(), flwor_clause::let_clause) {}
59
60 std::ostream& put(std::ostream& stream) const { return stream; }
61
62 flwor_clause* clone(expr::substitution_t &) const { return NULL; }
63};
64
65
66class NullWincond : public flwor_wincond
67{
68public:
69 NullWincond() : flwor_wincond(NULL, NULL, false, vars(), vars(), NULL) {}
70
71 std::ostream& put(std::ostream& stream) const { return stream; }
72};
73
74
75class NullCatchClause : public catch_clause
76{
77public:
78 NullCatchClause() : catch_clause(NULL) {}
79
80 std::ostream& put(std::ostream& stream) const{return stream;}
81};
82
83
84class NullCopyClause : public copy_clause
85{
86public:
87 NullCopyClause() : copy_clause(NULL, NULL, NULL) {}
88};
89#endif
90
91
92ExprManager::ExprManager(CompilerCB* ccb)38ExprManager::ExprManager(CompilerCB* ccb)
93 :39 :
94 theCCB(ccb)40 theCCB(ccb)
@@ -219,49 +165,54 @@
219165
220if_expr* ExprManager::create_if_expr(166if_expr* ExprManager::create_if_expr(
221 static_context* sctx,167 static_context* sctx,
168 user_function* udf,
222 const QueryLoc& loc,169 const QueryLoc& loc,
223 expr* cond_expr,170 expr* cond_expr,
224 expr* then_expr,171 expr* then_expr,
225 expr* else_expr)172 expr* else_expr)
226{173{
227 CREATE_AND_RETURN_EXPR(if_expr, sctx, loc, cond_expr, then_expr, else_expr);174 CREATE_AND_RETURN_EXPR(if_expr, sctx, udf, loc, cond_expr, then_expr, else_expr);
228}175}
229176
230177
231order_expr* ExprManager::create_order_expr(178order_expr* ExprManager::create_order_expr(
232 static_context* sctx,179 static_context* sctx,
180 user_function* udf,
233 const QueryLoc& loc,181 const QueryLoc& loc,
234 order_expr::order_type_t order,182 order_expr::order_type_t order,
235 expr* exp)183 expr* exp)
236{184{
237 CREATE_AND_RETURN_EXPR(order_expr, sctx, loc, order, exp);185 CREATE_AND_RETURN_EXPR(order_expr, sctx, udf, loc, order, exp);
238}186}
239187
240188
241validate_expr* ExprManager::create_validate_expr(189validate_expr* ExprManager::create_validate_expr(
242 static_context* sctx,190 static_context* sctx,
191 user_function* udf,
243 const QueryLoc& loc,192 const QueryLoc& loc,
244 ParseConstants::validation_mode_t mode,193 ParseConstants::validation_mode_t mode,
245 const store::Item_t& aTypeName,194 const store::Item_t& aTypeName,
246 expr* validated,195 expr* validated,
247 rchandle<TypeManager> tm)196 rchandle<TypeManager> tm)
248{197{
249 CREATE_AND_RETURN_EXPR(validate_expr, sctx, loc, mode, aTypeName, validated, tm);198 CREATE_AND_RETURN_EXPR(validate_expr, sctx, udf, loc, mode, aTypeName, validated, tm);
250}199}
251200
252201
253cast_expr* ExprManager::create_cast_expr(202cast_expr* ExprManager::create_cast_expr(
254 static_context* sctx,203 static_context* sctx,
204 user_function* udf,
255 const QueryLoc& loc,205 const QueryLoc& loc,
256 expr* casted,206 expr* casted,
257 xqtref_t type)207 xqtref_t type)
258{208{
259 CREATE_AND_RETURN_EXPR(cast_expr, sctx, loc, casted, type);209 CREATE_AND_RETURN_EXPR(cast_expr, sctx, udf, loc, casted, type);
260}210}
261211
262212
263treat_expr* ExprManager::create_treat_expr(213treat_expr* ExprManager::create_treat_expr(
264 static_context* sctx,214 static_context* sctx,
215 user_function* udf,
265 const QueryLoc& loc,216 const QueryLoc& loc,
266 expr* treated,217 expr* treated,
267 const xqtref_t& type,218 const xqtref_t& type,
@@ -270,67 +221,73 @@
270 store::Item* qname)221 store::Item* qname)
271{222{
272 CREATE_AND_RETURN_EXPR(treat_expr,223 CREATE_AND_RETURN_EXPR(treat_expr,
273 sctx, loc, treated, type, err, check_prime, qname);224 sctx, udf, loc, treated, type, err, check_prime, qname);
274}225}
275226
276227
277promote_expr* ExprManager::create_promote_expr(228promote_expr* ExprManager::create_promote_expr(
278 static_context* sctx,229 static_context* sctx,
230 user_function* udf,
279 const QueryLoc& loc,231 const QueryLoc& loc,
280 expr* promoted,232 expr* promoted,
281 const xqtref_t& type,233 const xqtref_t& type,
282 PromoteIterator::ErrorKind err,234 PromoteIterator::ErrorKind err,
283 store::Item* qname)235 store::Item* qname)
284{236{
285 CREATE_AND_RETURN_EXPR(promote_expr, sctx, loc, promoted, type, err, qname);237 CREATE_AND_RETURN_EXPR(promote_expr, sctx, udf, loc, promoted, type, err, qname);
286}238}
287239
288240
289castable_expr* ExprManager::create_castable_expr(241castable_expr* ExprManager::create_castable_expr(
290 static_context* sctx,242 static_context* sctx,
243 user_function* udf,
291 const QueryLoc& loc,244 const QueryLoc& loc,
292 expr* castable,245 expr* castable,
293 xqtref_t type)246 xqtref_t type)
294{247{
295 CREATE_AND_RETURN_EXPR(castable_expr, sctx, loc, castable, type);248 CREATE_AND_RETURN_EXPR(castable_expr, sctx, udf, loc, castable, type);
296}249}
297250
298251
299instanceof_expr* ExprManager::create_instanceof_expr(252instanceof_expr* ExprManager::create_instanceof_expr(
300 static_context* sctx,253 static_context* sctx,
254 user_function* udf,
301 const QueryLoc& loc,255 const QueryLoc& loc,
302 expr* instanced,256 expr* instanced,
303 xqtref_t type,257 xqtref_t type,
304 bool checkPrimeOnly)258 bool checkPrimeOnly)
305{259{
306 CREATE_AND_RETURN_EXPR(instanceof_expr,260 CREATE_AND_RETURN_EXPR(instanceof_expr,
307 sctx, loc, instanced, type, checkPrimeOnly);261 sctx, udf, loc, instanced, type, checkPrimeOnly);
308}262}
309263
310264
311name_cast_expr* ExprManager::create_name_cast_expr(265name_cast_expr* ExprManager::create_name_cast_expr(
312 static_context* sctx,266 static_context* sctx,
267 user_function* udf,
313 const QueryLoc& loc,268 const QueryLoc& loc,
314 expr* casted,269 expr* casted,
315 const namespace_context* ns,270 const namespace_context* ns,
316 bool isAttr)271 bool isAttr)
317{272{
318 CREATE_AND_RETURN_EXPR(name_cast_expr, sctx, loc, casted, ns, isAttr);273 CREATE_AND_RETURN_EXPR(name_cast_expr, sctx, udf, loc, casted, ns, isAttr);
319}274}
320275
321276
322doc_expr* ExprManager::create_doc_expr(277doc_expr* ExprManager::create_doc_expr(
323 static_context* sctx,278 static_context* sctx,
279 user_function* udf,
324 const QueryLoc& loc,280 const QueryLoc& loc,
325 expr* content,281 expr* content,
326 bool copyNodes)282 bool copyNodes)
327{283{
328 CREATE_AND_RETURN_EXPR(doc_expr, sctx, loc, content, copyNodes);284 CREATE_AND_RETURN_EXPR(doc_expr, sctx, udf, loc, content, copyNodes);
329}285}
330286
331287
332elem_expr* ExprManager::create_elem_expr(288elem_expr* ExprManager::create_elem_expr(
333 static_context* sctx,289 static_context* sctx,
290 user_function* udf,
334 const QueryLoc& loc,291 const QueryLoc& loc,
335 expr* qnameExpr,292 expr* qnameExpr,
336 expr* attrs,293 expr* attrs,
@@ -339,12 +296,13 @@
339 bool copyNodes)296 bool copyNodes)
340{297{
341 CREATE_AND_RETURN_EXPR(elem_expr,298 CREATE_AND_RETURN_EXPR(elem_expr,
342 sctx, loc, qnameExpr, attrs, content, nsCtx, copyNodes);299 sctx, udf, loc, qnameExpr, attrs, content, nsCtx, copyNodes);
343}300}
344301
345302
346elem_expr* ExprManager::create_elem_expr(303elem_expr* ExprManager::create_elem_expr(
347 static_context* sctx,304 static_context* sctx,
305 user_function* udf,
348 const QueryLoc& loc,306 const QueryLoc& loc,
349 expr* qnameExpr,307 expr* qnameExpr,
350 expr* content,308 expr* content,
@@ -352,137 +310,151 @@
352 bool copyNodes)310 bool copyNodes)
353{311{
354 CREATE_AND_RETURN_EXPR(elem_expr,312 CREATE_AND_RETURN_EXPR(elem_expr,
355 sctx, loc, qnameExpr, content, nsCtx, copyNodes);313 sctx, udf, loc, qnameExpr, content, nsCtx, copyNodes);
356}314}
357315
358316
359attr_expr* ExprManager::create_attr_expr(317attr_expr* ExprManager::create_attr_expr(
360 static_context* sctx,318 static_context* sctx,
319 user_function* udf,
361 const QueryLoc& loc,320 const QueryLoc& loc,
362 expr* aQNameExpr,321 expr* aQNameExpr,
363 expr* aValueExpr)322 expr* aValueExpr)
364{323{
365 CREATE_AND_RETURN_EXPR(attr_expr, sctx, loc, aQNameExpr, aValueExpr);324 CREATE_AND_RETURN_EXPR(attr_expr, sctx, udf, loc, aQNameExpr, aValueExpr);
366}325}
367326
368327
369text_expr* ExprManager::create_text_expr(328text_expr* ExprManager::create_text_expr(
370 static_context* sctx,329 static_context* sctx,
330 user_function* udf,
371 const QueryLoc& loc,331 const QueryLoc& loc,
372 text_expr::text_constructor_type textType,332 text_expr::text_constructor_type textType,
373 expr* text)333 expr* text)
374{334{
375 CREATE_AND_RETURN_EXPR(text_expr, sctx, loc, textType, text);335 CREATE_AND_RETURN_EXPR(text_expr, sctx, udf, loc, textType, text);
376}336}
377337
378338
379pi_expr* ExprManager::create_pi_expr(339pi_expr* ExprManager::create_pi_expr(
380 static_context* sctx,340 static_context* sctx,
341 user_function* udf,
381 const QueryLoc& loc,342 const QueryLoc& loc,
382 expr* targetExpr,343 expr* targetExpr,
383 expr* contentExpr)344 expr* contentExpr)
384{345{
385 CREATE_AND_RETURN_EXPR(pi_expr, sctx, loc, targetExpr, contentExpr);346 CREATE_AND_RETURN_EXPR(pi_expr, sctx, udf, loc, targetExpr, contentExpr);
386}347}
387348
388349
389const_expr* ExprManager::create_const_expr(350const_expr* ExprManager::create_const_expr(
390 static_context* sctx,351 static_context* sctx,
352 user_function* udf,
391 const QueryLoc& loc,353 const QueryLoc& loc,
392 zstring& sval)354 zstring& sval)
393{355{
394 CREATE_AND_RETURN_EXPR(const_expr, sctx, loc, sval);356 CREATE_AND_RETURN_EXPR(const_expr, sctx, udf, loc, sval);
395}357}
396358
397359
398const_expr* ExprManager::create_const_expr(360const_expr* ExprManager::create_const_expr(
399 static_context* sctx,361 static_context* sctx,
362 user_function* udf,
400 const QueryLoc& loc,363 const QueryLoc& loc,
401 const std::string& sval)364 const std::string& sval)
402{365{
403 CREATE_AND_RETURN_EXPR(const_expr, sctx, loc, sval);366 CREATE_AND_RETURN_EXPR(const_expr, sctx, udf, loc, sval);
404}367}
405368
406369
407const_expr* ExprManager::create_const_expr(370const_expr* ExprManager::create_const_expr(
408 static_context* sctx,371 static_context* sctx,
372 user_function* udf,
409 const QueryLoc& loc,373 const QueryLoc& loc,
410 const char* sval)374 const char* sval)
411{375{
412 CREATE_AND_RETURN_EXPR(const_expr, sctx, loc, sval);376 CREATE_AND_RETURN_EXPR(const_expr, sctx, udf, loc, sval);
413}377}
414378
415379
416const_expr* ExprManager::create_const_expr(380const_expr* ExprManager::create_const_expr(
417 static_context* sctx,381 static_context* sctx,
382 user_function* udf,
418 const QueryLoc& loc,383 const QueryLoc& loc,
419 xs_integer val)384 xs_integer val)
420{385{
421 CREATE_AND_RETURN_EXPR(const_expr, sctx, loc, val);386 CREATE_AND_RETURN_EXPR(const_expr, sctx, udf, loc, val);
422}387}
423388
424389
425const_expr* ExprManager::create_const_expr(390const_expr* ExprManager::create_const_expr(
426 static_context* sctx,391 static_context* sctx,
392 user_function* udf,
427 const QueryLoc& loc,393 const QueryLoc& loc,
428 xs_decimal val)394 xs_decimal val)
429{395{
430 CREATE_AND_RETURN_EXPR(const_expr, sctx, loc, val);396 CREATE_AND_RETURN_EXPR(const_expr, sctx, udf, loc, val);
431}397}
432398
433399
434const_expr* ExprManager::create_const_expr(400const_expr* ExprManager::create_const_expr(
435 static_context* sctx,401 static_context* sctx,
402 user_function* udf,
436 const QueryLoc& loc,403 const QueryLoc& loc,
437 xs_double val)404 xs_double val)
438{405{
439 CREATE_AND_RETURN_EXPR(const_expr, sctx, loc, val);406 CREATE_AND_RETURN_EXPR(const_expr, sctx, udf, loc, val);
440}407}
441408
442409
443const_expr* ExprManager::create_const_expr(410const_expr* ExprManager::create_const_expr(
444 static_context* sctx,411 static_context* sctx,
412 user_function* udf,
445 const QueryLoc& loc,413 const QueryLoc& loc,
446 xs_boolean val)414 xs_boolean val)
447{415{
448 CREATE_AND_RETURN_EXPR(const_expr, sctx, loc, val);416 CREATE_AND_RETURN_EXPR(const_expr, sctx, udf, loc, val);
449}417}
450418
451419
452const_expr* ExprManager::create_const_expr(420const_expr* ExprManager::create_const_expr(
453 static_context* sctx,421 static_context* sctx,
422 user_function* udf,
454 const QueryLoc& loc,423 const QueryLoc& loc,
455 store::Item_t val)424 store::Item_t val)
456{425{
457 CREATE_AND_RETURN_EXPR(const_expr, sctx, loc, val);426 CREATE_AND_RETURN_EXPR(const_expr, sctx, udf, loc, val);
458}427}
459428
460429
461const_expr* ExprManager::create_const_expr(430const_expr* ExprManager::create_const_expr(
462 static_context* sctx,431 static_context* sctx,
432 user_function* udf,
463 const QueryLoc& loc,433 const QueryLoc& loc,
464 const char* ns,434 const char* ns,
465 const char* pre,435 const char* pre,
466 const char* local)436 const char* local)
467{437{
468 CREATE_AND_RETURN_EXPR(const_expr, sctx, loc, ns, pre, local);438 CREATE_AND_RETURN_EXPR(const_expr, sctx, udf, loc, ns, pre, local);
469}439}
470440
471441
472extension_expr* ExprManager::create_extension_expr(442extension_expr* ExprManager::create_extension_expr(
473 static_context* sctx,443 static_context* sctx,
444 user_function* udf,
474 const QueryLoc& loc)445 const QueryLoc& loc)
475{446{
476 CREATE_AND_RETURN_EXPR(extension_expr, sctx, loc);447 CREATE_AND_RETURN_EXPR(extension_expr, sctx, udf, loc);
477}448}
478449
479450
480extension_expr* ExprManager::create_extension_expr(451extension_expr* ExprManager::create_extension_expr(
481 static_context* sctx,452 static_context* sctx,
453 user_function* udf,
482 const QueryLoc& loc,454 const QueryLoc& loc,
483 expr* extended)455 expr* extended)
484{456{
485 CREATE_AND_RETURN_EXPR(extension_expr, sctx, loc, extended);457 CREATE_AND_RETURN_EXPR(extension_expr, sctx, udf, loc, extended);
486}458}
487459
488460
@@ -494,35 +466,40 @@
494466
495trycatch_expr* ExprManager::create_trycatch_expr(467trycatch_expr* ExprManager::create_trycatch_expr(
496 static_context* sctx,468 static_context* sctx,
469 user_function* udf,
497 const QueryLoc& loc,470 const QueryLoc& loc,
498 expr* tryExpr)471 expr* tryExpr)
499{472{
500 CREATE_AND_RETURN_EXPR(trycatch_expr, sctx, loc, tryExpr);473 CREATE_AND_RETURN_EXPR(trycatch_expr, sctx, udf, loc, tryExpr);
501}474}
502475
503476
504wrapper_expr* ExprManager::create_wrapper_expr(477wrapper_expr* ExprManager::create_wrapper_expr(
505 static_context* sctx,478 static_context* sctx,
479 user_function* udf,
506 const QueryLoc& loc,480 const QueryLoc& loc,
507 expr* wrapped)481 expr* wrapped)
508{482{
509 CREATE_AND_RETURN_EXPR(wrapper_expr, sctx, loc, wrapped);483 CREATE_AND_RETURN_EXPR(wrapper_expr, sctx, udf, loc, wrapped);
510}484}
511485
512486#if 0
513function_trace_expr* ExprManager::create_function_trace_expr(487function_trace_expr* ExprManager::create_function_trace_expr(
514 static_context* sctx,488 static_context* sctx,
489 user_function* udf,
515 const QueryLoc& loc,490 const QueryLoc& loc,
516 expr* aChild)491 expr* aChild)
517{492{
518 CREATE_AND_RETURN_EXPR(function_trace_expr, sctx, loc, aChild);493 CREATE_AND_RETURN_EXPR(function_trace_expr, sctx, udf, loc, aChild);
519}494}
520495#endif
521496
522function_trace_expr* ExprManager::create_function_trace_expr(expr* aExpr)497function_trace_expr* ExprManager::create_function_trace_expr(
498 user_function* udf,
499 expr* aExpr)
523{500{
524 //this function gets the ExprManager from the expression it recieves.501 //this function gets the ExprManager from the expression it recieves.
525 function_trace_expr* e = new (theMemoryMgr) function_trace_expr(aExpr);502 function_trace_expr* e = new (theMemoryMgr) function_trace_expr(udf, aExpr);
526 reg(e);503 reg(e);
527 return e;504 return e;
528}505}
@@ -530,25 +507,27 @@
530507
531eval_expr* ExprManager::create_eval_expr(508eval_expr* ExprManager::create_eval_expr(
532 static_context* sctx,509 static_context* sctx,
510 user_function* udf,
533 const QueryLoc& loc,511 const QueryLoc& loc,
534 expr* e,512 expr* e,
535 expr_script_kind_t scriptingKind,513 expr_script_kind_t scriptingKind,
536 namespace_context* nsCtx)514 namespace_context* nsCtx)
537{515{
538 CREATE_AND_RETURN_EXPR(eval_expr, sctx, loc, e, scriptingKind, nsCtx);516 CREATE_AND_RETURN_EXPR(eval_expr, sctx, udf, loc, e, scriptingKind, nsCtx);
539}517}
540518
541#ifdef ZORBA_WITH_DEBUGGER519#ifdef ZORBA_WITH_DEBUGGER
542520
543debugger_expr* ExprManager::create_debugger_expr(521debugger_expr* ExprManager::create_debugger_expr(
544 static_context* sctx,522 static_context* sctx,
523 user_function* udf,
545 const QueryLoc& loc,524 const QueryLoc& loc,
546 expr* aChild,525 expr* aChild,
547 namespace_context* nsCtx,526 namespace_context* nsCtx,
548 bool aIsVarDeclaration)527 bool aIsVarDeclaration)
549{528{
550 CREATE_AND_RETURN_EXPR(debugger_expr,529 CREATE_AND_RETURN_EXPR(debugger_expr,
551 sctx, loc, aChild, nsCtx, aIsVarDeclaration);530 sctx, udf, loc, aChild, nsCtx, aIsVarDeclaration);
552}531}
553532
554#endif533#endif
@@ -557,17 +536,20 @@
557536
558var_expr* ExprManager::create_var_expr(537var_expr* ExprManager::create_var_expr(
559 static_context* sctx,538 static_context* sctx,
539 user_function* udf,
560 const QueryLoc& loc,540 const QueryLoc& loc,
561 var_expr::var_kind k,541 var_expr::var_kind k,
562 store::Item* name)542 store::Item* name)
563{543{
564 CREATE_AND_RETURN_EXPR(var_expr, sctx, loc, k, name);544 CREATE_AND_RETURN_EXPR(var_expr, sctx, udf, loc, k, name);
565}545}
566546
567547
568var_expr* ExprManager::create_var_expr(const var_expr& source)548var_expr* ExprManager::create_var_expr(
549 user_function* udf,
550 const var_expr& source)
569{551{
570 var_expr* e = new (theMemoryMgr) var_expr(source);552 var_expr* e = new (theMemoryMgr) var_expr(udf, source);
571 reg(e);553 reg(e);
572 return e;554 return e;
573}555}
@@ -580,30 +562,33 @@
580562
581json_array_expr* ExprManager::create_json_array_expr(563json_array_expr* ExprManager::create_json_array_expr(
582 static_context* sctx,564 static_context* sctx,
565 user_function* udf,
583 const QueryLoc& loc,566 const QueryLoc& loc,
584 expr* content)567 expr* content)
585{568{
586 CREATE_AND_RETURN_EXPR(json_array_expr, sctx, loc, content);569 CREATE_AND_RETURN_EXPR(json_array_expr, sctx, udf, loc, content);
587}570}
588571
589572
590json_object_expr* ExprManager::create_json_object_expr(573json_object_expr* ExprManager::create_json_object_expr(
591 static_context* sctx,574 static_context* sctx,
575 user_function* udf,
592 const QueryLoc& loc,576 const QueryLoc& loc,
593 expr* content,577 expr* content,
594 bool accumulate)578 bool accumulate)
595{579{
596 CREATE_AND_RETURN_EXPR(json_object_expr, sctx, loc, content, accumulate);580 CREATE_AND_RETURN_EXPR(json_object_expr, sctx, udf, loc, content, accumulate);
597}581}
598582
599583
600json_direct_object_expr* ExprManager::create_json_direct_object_expr(584json_direct_object_expr* ExprManager::create_json_direct_object_expr(
601 static_context* sctx,585 static_context* sctx,
586 user_function* udf,
602 const QueryLoc& loc,587 const QueryLoc& loc,
603 std::vector<expr*>& names,588 std::vector<expr*>& names,
604 std::vector<expr*>& values)589 std::vector<expr*>& values)
605{590{
606 CREATE_AND_RETURN_EXPR(json_direct_object_expr, sctx, loc, names, values);591 CREATE_AND_RETURN_EXPR(json_direct_object_expr, sctx, udf, loc, names, values);
607}592}
608593
609594
@@ -614,43 +599,47 @@
614599
615insert_expr* ExprManager::create_insert_expr(600insert_expr* ExprManager::create_insert_expr(
616 static_context* sctx,601 static_context* sctx,
602 user_function* udf,
617 const QueryLoc& loc,603 const QueryLoc& loc,
618 store::UpdateConsts::InsertType insertType,604 store::UpdateConsts::InsertType insertType,
619 expr* aSourceExpr,605 expr* aSourceExpr,
620 expr* aTargetExpr)606 expr* aTargetExpr)
621{607{
622 CREATE_AND_RETURN_EXPR(insert_expr,608 CREATE_AND_RETURN_EXPR(insert_expr,
623 sctx, loc, insertType, aSourceExpr, aTargetExpr);609 sctx, udf, loc, insertType, aSourceExpr, aTargetExpr);
624}610}
625611
626612
627delete_expr* ExprManager::create_delete_expr(613delete_expr* ExprManager::create_delete_expr(
628 static_context* sctx,614 static_context* sctx,
615 user_function* udf,
629 const QueryLoc& loc,616 const QueryLoc& loc,
630 expr* aTargetExpr)617 expr* aTargetExpr)
631{618{
632 CREATE_AND_RETURN_EXPR(delete_expr, sctx, loc, aTargetExpr);619 CREATE_AND_RETURN_EXPR(delete_expr, sctx, udf, loc, aTargetExpr);
633}620}
634621
635622
636replace_expr* ExprManager::create_replace_expr(623replace_expr* ExprManager::create_replace_expr(
637 static_context* sctx,624 static_context* sctx,
625 user_function* udf,
638 const QueryLoc& loc,626 const QueryLoc& loc,
639 store::UpdateConsts::ReplaceType aType,627 store::UpdateConsts::ReplaceType aType,
640 expr* aSourceExpr,628 expr* aSourceExpr,
641 expr* aTargetExpr)629 expr* aTargetExpr)
642{630{
643 CREATE_AND_RETURN_EXPR(replace_expr, sctx, loc, aType, aSourceExpr, aTargetExpr);631 CREATE_AND_RETURN_EXPR(replace_expr, sctx, udf, loc, aType, aSourceExpr, aTargetExpr);
644}632}
645633
646634
647rename_expr* ExprManager::create_rename_expr(635rename_expr* ExprManager::create_rename_expr(
648 static_context* sctx,636 static_context* sctx,
637 user_function* udf,
649 const QueryLoc& loc,638 const QueryLoc& loc,
650 expr* aSourceExpr,639 expr* aSourceExpr,
651 expr* aTargetExpr)640 expr* aTargetExpr)
652{641{
653 CREATE_AND_RETURN_EXPR(rename_expr, sctx, loc, aSourceExpr, aTargetExpr);642 CREATE_AND_RETURN_EXPR(rename_expr, sctx, udf, loc, aSourceExpr, aTargetExpr);
654}643}
655644
656645
@@ -662,112 +651,126 @@
662651
663transform_expr* ExprManager::create_transform_expr(652transform_expr* ExprManager::create_transform_expr(
664 static_context* sctx,653 static_context* sctx,
654 user_function* udf,
665 const QueryLoc& loc)655 const QueryLoc& loc)
666{656{
667 CREATE_AND_RETURN_EXPR(transform_expr, sctx, loc);657 CREATE_AND_RETURN_EXPR(transform_expr, sctx, udf, loc);
668}658}
669659
670660
671block_expr* ExprManager::create_block_expr(661block_expr* ExprManager::create_block_expr(
672 static_context* sctx,662 static_context* sctx,
663 user_function* udf,
673 const QueryLoc& loc,664 const QueryLoc& loc,
674 bool allowLastUpdating,665 bool allowLastUpdating,
675 std::vector<expr*>& seq,666 std::vector<expr*>& seq,
676 std::vector<var_expr*>* assignedVars)667 std::vector<var_expr*>* assignedVars)
677{668{
678 CREATE_AND_RETURN_EXPR(block_expr,669 CREATE_AND_RETURN_EXPR(block_expr,
679 sctx, loc, allowLastUpdating, seq, assignedVars);670 sctx, udf, loc, allowLastUpdating, seq, assignedVars);
680}671}
681672
682673
683apply_expr* ExprManager::create_apply_expr(674apply_expr* ExprManager::create_apply_expr(
684 static_context* sctx,675 static_context* sctx,
676 user_function* udf,
685 const QueryLoc& loc,677 const QueryLoc& loc,
686 expr* inExpr,678 expr* inExpr,
687 bool discardXDM)679 bool discardXDM)
688{680{
689 CREATE_AND_RETURN_EXPR(apply_expr, sctx, loc, inExpr, discardXDM);681 CREATE_AND_RETURN_EXPR(apply_expr, sctx, udf, loc, inExpr, discardXDM);
690}682}
691683
692684
693var_decl_expr* ExprManager::create_var_decl_expr(685var_decl_expr* ExprManager::create_var_decl_expr(
694 static_context* sctx,686 static_context* sctx,
687 user_function* udf,
695 const QueryLoc& loc,688 const QueryLoc& loc,
696 var_expr* varExpr,689 var_expr* varExpr,
697 expr* initExpr)690 expr* initExpr)
698{691{
699 CREATE_AND_RETURN_EXPR(var_decl_expr, sctx, loc, varExpr, initExpr);692 CREATE_AND_RETURN_EXPR(var_decl_expr, sctx, udf, loc, varExpr, initExpr);
700}693}
701694
702695
703var_set_expr* ExprManager::create_var_set_expr(696var_set_expr* ExprManager::create_var_set_expr(
704 static_context* sctx,697 static_context* sctx,
698 user_function* udf,
705 const QueryLoc& loc,699 const QueryLoc& loc,
706 var_expr* varExpr,700 var_expr* varExpr,
707 expr* setExpr)701 expr* setExpr)
708{702{
709 CREATE_AND_RETURN_EXPR(var_set_expr, sctx, loc, varExpr, setExpr);703 CREATE_AND_RETURN_EXPR(var_set_expr, sctx, udf, loc, varExpr, setExpr);
710}704}
711705
712706
713exit_expr* ExprManager::create_exit_expr(707exit_expr* ExprManager::create_exit_expr(
714 static_context* sctx,708 static_context* sctx,
709 user_function* udf,
715 const QueryLoc& loc,710 const QueryLoc& loc,
716 expr* inExpr)711 expr* inExpr)
717{712{
718 CREATE_AND_RETURN_EXPR(exit_expr, sctx, loc, inExpr);713 CREATE_AND_RETURN_EXPR(exit_expr, sctx, udf, loc, inExpr);
719}714}
720715
721716
722exit_catcher_expr* ExprManager::create_exit_catcher_expr(717exit_catcher_expr* ExprManager::create_exit_catcher_expr(
723 static_context* sctx,718 static_context* sctx,
719 user_function* udf,
724 const QueryLoc& loc,720 const QueryLoc& loc,
725 expr* inExpr,721 expr* inExpr,
726 std::vector<expr*>& exitExprs)722 std::vector<expr*>& exitExprs)
727{723{
728 CREATE_AND_RETURN_EXPR(exit_catcher_expr, sctx, loc, inExpr, exitExprs);724 CREATE_AND_RETURN_EXPR(exit_catcher_expr, sctx, udf, loc, inExpr, exitExprs);
729}725}
730726
731727
732flowctl_expr* ExprManager::create_flowctl_expr(728flowctl_expr* ExprManager::create_flowctl_expr(
733 static_context* sctx,729 static_context* sctx,
730 user_function* udf,
734 const QueryLoc& loc,731 const QueryLoc& loc,
735 flowctl_expr::action action)732 flowctl_expr::action action)
736{733{
737 CREATE_AND_RETURN_EXPR(flowctl_expr, sctx, loc, action);734 CREATE_AND_RETURN_EXPR(flowctl_expr, sctx, udf, loc, action);
738}735}
739736
740737
741while_expr* ExprManager::create_while_expr(738while_expr* ExprManager::create_while_expr(
742 static_context* sctx, const QueryLoc& loc, expr* body)739 static_context* sctx,
740 user_function* udf,
741 const QueryLoc& loc,
742 expr* body)
743{743{
744 CREATE_AND_RETURN_EXPR(while_expr, sctx, loc, body);744 CREATE_AND_RETURN_EXPR(while_expr, sctx, udf, loc, body);
745}745}
746746
747747
748////////////////////////////////////////////////////////////////////////////////748////////////////////////////////////////////////////////////////////////////////
749749
750relpath_expr* ExprManager::create_relpath_expr(750relpath_expr* ExprManager::create_relpath_expr(
751 static_context* sctx,751 static_context* sctx,
752 const QueryLoc& loc)752 user_function* udf,
753 const QueryLoc& loc)
753{754{
754 CREATE_AND_RETURN_EXPR(relpath_expr, sctx, loc);755 CREATE_AND_RETURN_EXPR(relpath_expr, sctx, udf, loc);
755}756}
756757
757758
758axis_step_expr* ExprManager::create_axis_step_expr(759axis_step_expr* ExprManager::create_axis_step_expr(
759 static_context* sctx,760 static_context* sctx,
761 user_function* udf,
760 const QueryLoc& loc)762 const QueryLoc& loc)
761{763{
762 CREATE_AND_RETURN_EXPR(axis_step_expr, sctx, loc);764 CREATE_AND_RETURN_EXPR(axis_step_expr, sctx, udf, loc);
763}765}
764766
765767
766match_expr* ExprManager::create_match_expr(768match_expr* ExprManager::create_match_expr(
767 static_context* sctx,769 static_context* sctx,
770 user_function* udf,
768 const QueryLoc& loc)771 const QueryLoc& loc)
769{772{
770 CREATE_AND_RETURN_EXPR(match_expr, sctx, loc);773 CREATE_AND_RETURN_EXPR(match_expr, sctx, udf, loc);
771}774}
772775
773776
@@ -776,92 +779,105 @@
776dynamic_function_invocation_expr*779dynamic_function_invocation_expr*
777ExprManager::create_dynamic_function_invocation_expr(780ExprManager::create_dynamic_function_invocation_expr(
778 static_context* sctx,781 static_context* sctx,
782 user_function* udf,
779 const QueryLoc& loc,783 const QueryLoc& loc,
780 expr* anExpr,784 expr* anExpr,
781 const std::vector<expr*>& args)785 const std::vector<expr*>& args)
782{786{
783 CREATE_AND_RETURN_EXPR(dynamic_function_invocation_expr, sctx, loc, anExpr, args);787 CREATE_AND_RETURN_EXPR(dynamic_function_invocation_expr, sctx, udf, loc, anExpr, args);
784}788}
785789
786790
787function_item_expr* ExprManager::create_function_item_expr(791function_item_expr* ExprManager::create_function_item_expr(
788 static_context* sctx,792 static_context* sctx,
793 user_function* udf,
789 const QueryLoc& loc,794 const QueryLoc& loc,
790 const store::Item* aQName,795 const store::Item* aQName,
791 function* f,796 function* f,
792 uint32_t aArity)797 uint32_t aArity)
793{798{
794 CREATE_AND_RETURN_EXPR(function_item_expr, sctx, loc, aQName, f, aArity);799 CREATE_AND_RETURN_EXPR(function_item_expr, sctx, udf, loc, aQName, f, aArity);
795}800}
796801
797802
798function_item_expr* ExprManager::create_function_item_expr(803function_item_expr* ExprManager::create_function_item_expr(
799 static_context* sctx,804 static_context* sctx,
805 user_function* udf,
800 const QueryLoc& loc)806 const QueryLoc& loc)
801{807{
802 CREATE_AND_RETURN_EXPR(function_item_expr, sctx, loc);808 CREATE_AND_RETURN_EXPR(function_item_expr, sctx, udf, loc);
803}809}
804810
805811
806ftcontains_expr* ExprManager::create_ftcontains_expr(812ftcontains_expr* ExprManager::create_ftcontains_expr(
807 static_context* sctx,813 static_context* sctx,
814 user_function* udf,
808 QueryLoc const& loc,815 QueryLoc const& loc,
809 expr* range,816 expr* range,
810 ftnode *ftselection,817 ftnode *ftselection,
811 expr* ftignore)818 expr* ftignore)
812{819{
813 CREATE_AND_RETURN_EXPR(ftcontains_expr, sctx, loc, range, ftselection, ftignore);820 CREATE_AND_RETURN_EXPR(ftcontains_expr, sctx, udf, loc, range, ftselection, ftignore);
814}821}
815822
816823
817////////////////////////////////////////////////////////////////////////////////824////////////////////////////////////////////////////////////////////////////////
818825
819//this calls the static create_seq within fo_expr826//this calls the static create_seq within fo_expr
820fo_expr* ExprManager::create_seq(static_context* sctx, const QueryLoc& loc)827fo_expr* ExprManager::create_seq(
828 static_context* sctx,
829 user_function* udf,
830 const QueryLoc& loc)
821{831{
822 //TODO make fo_expr use this factory to generate everything832 //TODO make fo_expr use this factory to generate everything
823 return fo_expr::create_seq(theCCB, sctx, loc);833 return fo_expr::create_seq(theCCB, sctx, udf, loc);
824}834}
825835
826836
827fo_expr* ExprManager::create_fo_expr(837fo_expr* ExprManager::create_fo_expr(
828 static_context* sctx,838 static_context* sctx,
839 user_function* udf,
829 const QueryLoc& loc,840 const QueryLoc& loc,
830 const function* f,841 const function* f,
831 expr* arg)842 expr* arg)
832{843{
833 CREATE_AND_RETURN_EXPR(fo_expr, sctx, loc, f, arg);844 CREATE_AND_RETURN_EXPR(fo_expr, sctx, udf, loc, f, arg);
834}845}
835846
836847
837fo_expr* ExprManager::create_fo_expr(848fo_expr* ExprManager::create_fo_expr(
838 static_context* sctx,849 static_context* sctx,
850 user_function* udf,
839 const QueryLoc& loc,851 const QueryLoc& loc,
840 const function* f,852 const function* f,
841 expr* arg1,853 expr* arg1,
842 expr* arg2)854 expr* arg2)
843{855{
844 CREATE_AND_RETURN_EXPR(fo_expr, sctx, loc, f, arg1, arg2);856 CREATE_AND_RETURN_EXPR(fo_expr, sctx, udf, loc, f, arg1, arg2);
845}857}
846858
847859
848fo_expr* ExprManager::create_fo_expr(860fo_expr* ExprManager::create_fo_expr(
849 static_context* sctx,861 static_context* sctx,
862 user_function* udf,
850 const QueryLoc& loc,863 const QueryLoc& loc,
851 const function* f,864 const function* f,
852 const std::vector<expr*>& args)865 const std::vector<expr*>& args)
853{866{
854 CREATE_AND_RETURN_EXPR(fo_expr, sctx, loc, f, args);867 CREATE_AND_RETURN_EXPR(fo_expr, sctx, udf, loc, f, args);
855}868}
856869
870
857fo_expr* ExprManager::create_fo_expr(871fo_expr* ExprManager::create_fo_expr(
858 static_context* sctx,872 static_context* sctx,
873 user_function* udf,
859 const QueryLoc& loc,874 const QueryLoc& loc,
860 const function* f)875 const function* f)
861{876{
862877
863 CREATE_AND_RETURN_EXPR(fo_expr, sctx, loc, f);878 CREATE_AND_RETURN_EXPR(fo_expr, sctx, udf, loc, f);
864}879}
880
865////////////////////////////////////////////////////////////////////////////////881////////////////////////////////////////////////////////////////////////////////
866882
867for_clause* ExprManager::create_for_clause(883for_clause* ExprManager::create_for_clause(
@@ -877,6 +893,7 @@
877 sctx, theCCB, loc, varExpr, domainExpr, posVarExpr, scoreVarExpr, isOuter);893 sctx, theCCB, loc, varExpr, domainExpr, posVarExpr, scoreVarExpr, isOuter);
878}894}
879895
896
880let_clause* ExprManager::create_let_clause(897let_clause* ExprManager::create_let_clause(
881 static_context* sctx,898 static_context* sctx,
882 const QueryLoc& loc,899 const QueryLoc& loc,
@@ -887,6 +904,7 @@
887 CREATE_AND_RETURN(let_clause, sctx, theCCB, loc, varExpr, domainExpr, lazy);904 CREATE_AND_RETURN(let_clause, sctx, theCCB, loc, varExpr, domainExpr, lazy);
888}905}
889906
907
890window_clause* ExprManager::create_window_clause(908window_clause* ExprManager::create_window_clause(
891 static_context* sctx,909 static_context* sctx,
892 const QueryLoc& loc,910 const QueryLoc& loc,
@@ -901,16 +919,18 @@
901 sctx, theCCB, loc, winKind, varExpr, domainExpr, winStart, winStop, lazy);919 sctx, theCCB, loc, winKind, varExpr, domainExpr, winStart, winStop, lazy);
902}920}
903921
922
904flwor_wincond* ExprManager::create_flwor_wincond(923flwor_wincond* ExprManager::create_flwor_wincond(
905 static_context* sctx,924 static_context* sctx,
906 bool isOnly,925 bool isOnly,
907 const flwor_wincond::vars& in_vars,926 const flwor_wincond::vars& in_vars,
908 const flwor_wincond::vars& out_vars,927 const flwor_wincond::vars& out_vars,
909 expr* cond)928 expr* cond)
910{929{
911 CREATE_AND_RETURN(flwor_wincond, theCCB, sctx, isOnly, in_vars, out_vars, cond);930 CREATE_AND_RETURN(flwor_wincond, theCCB, sctx, isOnly, in_vars, out_vars, cond);
912}931}
913932
933
914group_clause* ExprManager::create_group_clause(934group_clause* ExprManager::create_group_clause(
915 static_context* sctx,935 static_context* sctx,
916 const QueryLoc& loc,936 const QueryLoc& loc,
@@ -921,40 +941,54 @@
921 CREATE_AND_RETURN(group_clause, sctx, theCCB, loc, gvars, ngvars, collations);941 CREATE_AND_RETURN(group_clause, sctx, theCCB, loc, gvars, ngvars, collations);
922}942}
923943
944
924orderby_clause* ExprManager::create_orderby_clause(945orderby_clause* ExprManager::create_orderby_clause(
925 static_context* sctx,946 static_context* sctx,
926 const QueryLoc& loc,947 const QueryLoc& loc,
927 bool stable,948 bool stable,
928 const std::vector<OrderModifier>& modifiers,949 const std::vector<OrderModifier>& modifiers,
929 const std::vector<expr*>& orderingExprs)950 const std::vector<expr*>& orderingExprs)
930{951{
931 CREATE_AND_RETURN(orderby_clause, sctx, theCCB, loc, stable, modifiers, orderingExprs);952 CREATE_AND_RETURN(orderby_clause, sctx, theCCB, loc, stable, modifiers, orderingExprs);
932}953}
933954
955
934materialize_clause* ExprManager::create_materialize_clause(956materialize_clause* ExprManager::create_materialize_clause(
935 static_context* sctx, const QueryLoc& loc)957 static_context* sctx,
958 const QueryLoc& loc)
936{959{
937 CREATE_AND_RETURN(materialize_clause, sctx, theCCB, loc);960 CREATE_AND_RETURN(materialize_clause, sctx, theCCB, loc);
938}961}
939962
963
940count_clause* ExprManager::create_count_clause(964count_clause* ExprManager::create_count_clause(
941 static_context* sctx, const QueryLoc& loc, var_expr* var)965 static_context* sctx,
966 const QueryLoc& loc,
967 var_expr* var)
942{968{
943 CREATE_AND_RETURN(count_clause, sctx, theCCB, loc, var);969 CREATE_AND_RETURN(count_clause, sctx, theCCB, loc, var);
944}970}
945971
972
946where_clause* ExprManager::create_where_clause(973where_clause* ExprManager::create_where_clause(
947 static_context* sctx, const QueryLoc& loc, expr* where)974 static_context* sctx,
975 const QueryLoc& loc,
976 expr* where)
948{977{
949 CREATE_AND_RETURN(where_clause, sctx, theCCB, loc, where);978 CREATE_AND_RETURN(where_clause, sctx, theCCB, loc, where);
950}979}
951980
981
952flwor_expr* ExprManager::create_flwor_expr(982flwor_expr* ExprManager::create_flwor_expr(
953 static_context* sctx, const QueryLoc& loc, bool general)983 static_context* sctx,
984 user_function* udf,
985 const QueryLoc& loc,
986 bool general)
954{987{
955 CREATE_AND_RETURN_EXPR(flwor_expr, sctx, loc, general);988 CREATE_AND_RETURN_EXPR(flwor_expr, sctx, udf, loc, general);
956}989}
957990
991
958pragma* ExprManager::create_pragma(992pragma* ExprManager::create_pragma(
959 const store::Item_t& name,993 const store::Item_t& name,
960 const zstring& lit)994 const zstring& lit)
961995
=== modified file 'src/compiler/expression/expr_manager.h'
--- src/compiler/expression/expr_manager.h 2012-10-08 12:09:36 +0000
+++ src/compiler/expression/expr_manager.h 2012-10-09 13:35:26 +0000
@@ -31,6 +31,7 @@
3131
32class CompilerCB;32class CompilerCB;
3333
34
34class ExprManager35class ExprManager
35{36{
36private:37private:
@@ -75,6 +76,7 @@
75public:76public:
76 if_expr* create_if_expr(77 if_expr* create_if_expr(
77 static_context* sctx,78 static_context* sctx,
79 user_function* udf,
78 const QueryLoc& loc,80 const QueryLoc& loc,
79 expr* cond_expr,81 expr* cond_expr,
80 expr* then_expr,82 expr* then_expr,
@@ -82,12 +84,14 @@
8284
83 order_expr* create_order_expr(85 order_expr* create_order_expr(
84 static_context* sctx,86 static_context* sctx,
87 user_function* udf,
85 const QueryLoc& loc,88 const QueryLoc& loc,
86 order_expr::order_type_t,89 order_expr::order_type_t,
87 expr*);90 expr*);
8891
89 validate_expr* create_validate_expr(92 validate_expr* create_validate_expr(
90 static_context*,93 static_context*,
94 user_function* udf,
91 const QueryLoc&,95 const QueryLoc&,
92 ParseConstants::validation_mode_t,96 ParseConstants::validation_mode_t,
93 const store::Item_t& aTypeName,97 const store::Item_t& aTypeName,
@@ -96,12 +100,14 @@
96100
97 cast_expr* create_cast_expr(101 cast_expr* create_cast_expr(
98 static_context* sctx,102 static_context* sctx,
103 user_function* udf,
99 const QueryLoc&,104 const QueryLoc&,
100 expr*,105 expr*,
101 xqtref_t);106 xqtref_t);
102107
103 treat_expr* create_treat_expr(108 treat_expr* create_treat_expr(
104 static_context* sctx,109 static_context* sctx,
110 user_function* udf,
105 const QueryLoc& loc,111 const QueryLoc& loc,
106 expr* input,112 expr* input,
107 const xqtref_t& type,113 const xqtref_t& type,
@@ -112,6 +118,7 @@
112118
113 promote_expr* create_promote_expr(119 promote_expr* create_promote_expr(
114 static_context* sctx,120 static_context* sctx,
121 user_function* udf,
115 const QueryLoc& loc,122 const QueryLoc& loc,
116 expr* input,123 expr* input,
117 const xqtref_t& type,124 const xqtref_t& type,
@@ -120,12 +127,14 @@
120127
121 castable_expr* create_castable_expr(128 castable_expr* create_castable_expr(
122 static_context* sctx,129 static_context* sctx,
130 user_function* udf,
123 const QueryLoc&,131 const QueryLoc&,
124 expr*,132 expr*,
125 xqtref_t);133 xqtref_t);
126134
127 instanceof_expr* create_instanceof_expr(135 instanceof_expr* create_instanceof_expr(
128 static_context* sctx,136 static_context* sctx,
137 user_function* udf,
129 const QueryLoc&,138 const QueryLoc&,
130 expr*,139 expr*,
131 xqtref_t,140 xqtref_t,
@@ -133,6 +142,7 @@
133142
134 name_cast_expr* create_name_cast_expr(143 name_cast_expr* create_name_cast_expr(
135 static_context* sctx,144 static_context* sctx,
145 user_function* udf,
136 const QueryLoc&,146 const QueryLoc&,
137 expr*,147 expr*,
138 const namespace_context*,148 const namespace_context*,
@@ -140,12 +150,14 @@
140150
141 doc_expr* create_doc_expr(151 doc_expr* create_doc_expr(
142 static_context* sctx,152 static_context* sctx,
153 user_function* udf,
143 const QueryLoc&,154 const QueryLoc&,
144 expr* content,155 expr* content,
145 bool copyNodes);156 bool copyNodes);
146157
147 elem_expr* create_elem_expr(158 elem_expr* create_elem_expr(
148 static_context* sctx,159 static_context* sctx,
160 user_function* udf,
149 const QueryLoc&,161 const QueryLoc&,
150 expr* qnameExpr,162 expr* qnameExpr,
151 expr* attrs,163 expr* attrs,
@@ -155,6 +167,7 @@
155167
156 elem_expr* create_elem_expr(168 elem_expr* create_elem_expr(
157 static_context* sctx,169 static_context* sctx,
170 user_function* udf,
158 const QueryLoc&,171 const QueryLoc&,
159 expr* qnameExpr,172 expr* qnameExpr,
160 expr* content,173 expr* content,
@@ -163,64 +176,76 @@
163176
164 attr_expr* create_attr_expr(177 attr_expr* create_attr_expr(
165 static_context* sctx,178 static_context* sctx,
179 user_function* udf,
166 const QueryLoc& loc,180 const QueryLoc& loc,
167 expr* aQNameExpr,181 expr* aQNameExpr,
168 expr* aValueExpr);182 expr* aValueExpr);
169183
170 text_expr* create_text_expr(184 text_expr* create_text_expr(
171 static_context* sctx,185 static_context* sctx,
186 user_function* udf,
172 const QueryLoc&,187 const QueryLoc&,
173 text_expr::text_constructor_type,188 text_expr::text_constructor_type,
174 expr*);189 expr*);
175190
176 pi_expr* create_pi_expr(191 pi_expr* create_pi_expr(
177 static_context* sctx,192 static_context* sctx,
193 user_function* udf,
178 const QueryLoc&,194 const QueryLoc&,
179 expr*,195 expr*,
180 expr*);196 expr*);
181197
182 const_expr* create_const_expr(198 const_expr* create_const_expr(
183 static_context* sctx,199 static_context* sctx,
200 user_function* udf,
184 const QueryLoc&,201 const QueryLoc&,
185 zstring& sval);202 zstring& sval);
186203
187 const_expr* create_const_expr(204 const_expr* create_const_expr(
188 static_context* sctx,205 static_context* sctx,
206 user_function* udf,
189 const QueryLoc&,207 const QueryLoc&,
190 const std::string& sval);208 const std::string& sval);
191209
192 const_expr* create_const_expr(210 const_expr* create_const_expr(
193 static_context* sctx,211 static_context* sctx,
212 user_function* udf,
194 const QueryLoc&,213 const QueryLoc&,
195 const char* sval);214 const char* sval);
196215
197 const_expr* create_const_expr(216 const_expr* create_const_expr(
198 static_context* sctx,217 static_context* sctx,
218 user_function* udf,
199 const QueryLoc&,219 const QueryLoc&,
200 xs_integer);220 xs_integer);
201221
202 const_expr* create_const_expr(222 const_expr* create_const_expr(
203 static_context* sctx,223 static_context* sctx,
224 user_function* udf,
204 const QueryLoc&,225 const QueryLoc&,
205 xs_decimal);226 xs_decimal);
206227
207 const_expr* create_const_expr(228 const_expr* create_const_expr(
208 static_context* sctx,229 static_context* sctx,
230 user_function* udf,
209 const QueryLoc&,231 const QueryLoc&,
210 xs_double);232 xs_double);
211233
212 const_expr* create_const_expr(234 const_expr* create_const_expr(
213 static_context* sctx,235 static_context* sctx,
236 user_function* udf,
214 const QueryLoc&,237 const QueryLoc&,
215 xs_boolean);238 xs_boolean);
216239
217 const_expr* create_const_expr(240 const_expr* create_const_expr(
218 static_context* sctx,241 static_context* sctx,
242 user_function* udf,
219 const QueryLoc&,243 const QueryLoc&,
220 store::Item_t);244 store::Item_t);
221245
222 const_expr* create_const_expr(246 const_expr* create_const_expr(
223 static_context* sctx,247 static_context* sctx,
248 user_function* udf,
224 const QueryLoc&,249 const QueryLoc&,
225 const char* ns,250 const char* ns,
226 const char* pre,251 const char* pre,
@@ -228,10 +253,12 @@
228253
229 extension_expr* create_extension_expr(254 extension_expr* create_extension_expr(
230 static_context* sctx,255 static_context* sctx,
256 user_function* udf,
231 const QueryLoc&);257 const QueryLoc&);
232258
233 extension_expr* create_extension_expr(259 extension_expr* create_extension_expr(
234 static_context* sctx,260 static_context* sctx,
261 user_function* udf,
235 const QueryLoc&,262 const QueryLoc&,
236 expr*);263 expr*);
237264
@@ -239,23 +266,31 @@
239266
240 trycatch_expr* create_trycatch_expr(267 trycatch_expr* create_trycatch_expr(
241 static_context* sctx,268 static_context* sctx,
269 user_function* udf,
242 const QueryLoc&,270 const QueryLoc&,
243 expr* tryExpr);271 expr* tryExpr);
244272
245 wrapper_expr* create_wrapper_expr(273 wrapper_expr* create_wrapper_expr(
246 static_context* sctx,274 static_context* sctx,
275 user_function* udf,
247 const QueryLoc& loc,276 const QueryLoc& loc,
248 expr* wrapped);277 expr* wrapped);
249278
279#if 0
250 function_trace_expr* create_function_trace_expr(280 function_trace_expr* create_function_trace_expr(
251 static_context* sctx,281 static_context* sctx,
282 user_function* udf,
252 const QueryLoc& loc,283 const QueryLoc& loc,
253 expr* aChild);284 expr* aChild);
285#endif
254286
255 function_trace_expr* create_function_trace_expr(expr* aExpr);287 function_trace_expr* create_function_trace_expr(
288 user_function* udf,
289 expr* aExpr);
256290
257 eval_expr* create_eval_expr(291 eval_expr* create_eval_expr(
258 static_context* sctx,292 static_context* sctx,
293 user_function* udf,
259 const QueryLoc& loc,294 const QueryLoc& loc,
260 expr* e,295 expr* e,
261 expr_script_kind_t scriptingKind,296 expr_script_kind_t scriptingKind,
@@ -264,6 +299,7 @@
264#ifdef ZORBA_WITH_DEBUGGER299#ifdef ZORBA_WITH_DEBUGGER
265 debugger_expr* create_debugger_expr(300 debugger_expr* create_debugger_expr(
266 static_context* sctx,301 static_context* sctx,
302 user_function* udf,
267 const QueryLoc& loc,303 const QueryLoc& loc,
268 expr* aChild,304 expr* aChild,
269 namespace_context* nsCtx,305 namespace_context* nsCtx,
@@ -274,11 +310,12 @@
274310
275 var_expr* create_var_expr(311 var_expr* create_var_expr(
276 static_context* sctx,312 static_context* sctx,
313 user_function* udf,
277 const QueryLoc& loc,314 const QueryLoc& loc,
278 var_expr::var_kind k,315 var_expr::var_kind k,
279 store::Item* name);316 store::Item* name);
280317
281 var_expr* create_var_expr(const var_expr& source);318 var_expr* create_var_expr(user_function* udf, const var_expr& source);
282319
283////////////////////////////////////////////////////////////////////////////////320////////////////////////////////////////////////////////////////////////////////
284321
@@ -286,17 +323,20 @@
286323
287 json_array_expr* create_json_array_expr(324 json_array_expr* create_json_array_expr(
288 static_context* sctx,325 static_context* sctx,
326 user_function* udf,
289 const QueryLoc& loc,327 const QueryLoc& loc,
290 expr* content);328 expr* content);
291329
292 json_object_expr* create_json_object_expr(330 json_object_expr* create_json_object_expr(
293 static_context* sctx,331 static_context* sctx,
332 user_function* udf,
294 const QueryLoc& loc,333 const QueryLoc& loc,
295 expr* content,334 expr* content,
296 bool accumulate);335 bool accumulate);
297336
298 json_direct_object_expr* create_json_direct_object_expr(337 json_direct_object_expr* create_json_direct_object_expr(
299 static_context* sctx,338 static_context* sctx,
339 user_function* udf,
300 const QueryLoc&,340 const QueryLoc&,
301 std::vector<expr*>& names,341 std::vector<expr*>& names,
302 std::vector<expr*>& values);342 std::vector<expr*>& values);
@@ -307,6 +347,7 @@
307347
308 insert_expr* create_insert_expr(348 insert_expr* create_insert_expr(
309 static_context* sctx,349 static_context* sctx,
350 user_function* udf,
310 const QueryLoc&,351 const QueryLoc&,
311 store::UpdateConsts::InsertType,352 store::UpdateConsts::InsertType,
312 expr* aSourceExpr,353 expr* aSourceExpr,
@@ -314,11 +355,13 @@
314355
315 delete_expr* create_delete_expr(356 delete_expr* create_delete_expr(
316 static_context* sctx,357 static_context* sctx,
358 user_function* udf,
317 const QueryLoc&,359 const QueryLoc&,
318 expr*);360 expr*);
319361
320 replace_expr* create_replace_expr(362 replace_expr* create_replace_expr(
321 static_context* sctx,363 static_context* sctx,
364 user_function* udf,
322 const QueryLoc&,365 const QueryLoc&,
323 store::UpdateConsts::ReplaceType aType,366 store::UpdateConsts::ReplaceType aType,
324 expr*,367 expr*,
@@ -326,6 +369,7 @@
326369
327 rename_expr* create_rename_expr(370 rename_expr* create_rename_expr(
328 static_context* sctx,371 static_context* sctx,
372 user_function* udf,
329 const QueryLoc&,373 const QueryLoc&,
330 expr*,374 expr*,
331 expr*);375 expr*);
@@ -334,10 +378,12 @@
334378
335 transform_expr* create_transform_expr(379 transform_expr* create_transform_expr(
336 static_context* sctx,380 static_context* sctx,
381 user_function* udf,
337 const QueryLoc& loc);382 const QueryLoc& loc);
338383
339 block_expr* create_block_expr(384 block_expr* create_block_expr(
340 static_context* sctx,385 static_context* sctx,
386 user_function* udf,
341 const QueryLoc& loc,387 const QueryLoc& loc,
342 bool allowLastUpdating,388 bool allowLastUpdating,
343 std::vector<expr*>& seq,389 std::vector<expr*>& seq,
@@ -345,61 +391,79 @@
345391
346 apply_expr* create_apply_expr(392 apply_expr* create_apply_expr(
347 static_context* sctx,393 static_context* sctx,
394 user_function* udf,
348 const QueryLoc& loc,395 const QueryLoc& loc,
349 expr* inExpr,396 expr* inExpr,
350 bool discardXDM);397 bool discardXDM);
351398
352 var_decl_expr* create_var_decl_expr(399 var_decl_expr* create_var_decl_expr(
353 static_context* sctx,400 static_context* sctx,
401 user_function* udf,
354 const QueryLoc& loc,402 const QueryLoc& loc,
355 var_expr* varExpr,403 var_expr* varExpr,
356 expr* initExpr);404 expr* initExpr);
357405
358 var_set_expr* create_var_set_expr(406 var_set_expr* create_var_set_expr(
359 static_context* sctx,407 static_context* sctx,
408 user_function* udf,
360 const QueryLoc& loc,409 const QueryLoc& loc,
361 var_expr* varExpr,410 var_expr* varExpr,
362 expr* setExpr);411 expr* setExpr);
363412
364 exit_expr* create_exit_expr(413 exit_expr* create_exit_expr(
365 static_context* sctx,414 static_context* sctx,
415 user_function* udf,
366 const QueryLoc& loc,416 const QueryLoc& loc,
367 expr* inExpr);417 expr* inExpr);
368418
369 exit_catcher_expr* create_exit_catcher_expr(419 exit_catcher_expr* create_exit_catcher_expr(
370 static_context* sctx,420 static_context* sctx,
421 user_function* udf,
371 const QueryLoc& loc,422 const QueryLoc& loc,
372 expr* inExpr,423 expr* inExpr,
373 std::vector<expr*>& exitExprs);424 std::vector<expr*>& exitExprs);
374425
375 flowctl_expr* create_flowctl_expr(426 flowctl_expr* create_flowctl_expr(
376 static_context* sctx,427 static_context* sctx,
428 user_function* udf,
377 const QueryLoc& loc,429 const QueryLoc& loc,
378 flowctl_expr::action action);430 flowctl_expr::action action);
379431
380 while_expr* create_while_expr(432 while_expr* create_while_expr(
381 static_context* sctx,433 static_context* sctx,
434 user_function* udf,
382 const QueryLoc& loc,435 const QueryLoc& loc,
383 expr* body);436 expr* body);
384437
385////////////////////////////////////////////////////////////////////////////////438////////////////////////////////////////////////////////////////////////////////
386439
387 relpath_expr* create_relpath_expr(static_context* sctx, const QueryLoc& loc);440 relpath_expr* create_relpath_expr(
388441 static_context* sctx,
389 axis_step_expr* create_axis_step_expr(static_context* sctx, const QueryLoc&);442 user_function* udf,
390443 const QueryLoc& loc);
391 match_expr* create_match_expr(static_context* sctx, const QueryLoc&);444
445 axis_step_expr* create_axis_step_expr(
446 static_context* sctx,
447 user_function* udf,
448 const QueryLoc&);
449
450 match_expr* create_match_expr(
451 static_context* sctx,
452 user_function* udf,
453 const QueryLoc&);
392454
393////////////////////////////////////////////////////////////////////////////////455////////////////////////////////////////////////////////////////////////////////
394456
395 dynamic_function_invocation_expr* create_dynamic_function_invocation_expr(457 dynamic_function_invocation_expr* create_dynamic_function_invocation_expr(
396 static_context* sctx,458 static_context* sctx,
459 user_function* udf,
397 const QueryLoc& loc,460 const QueryLoc& loc,
398 expr* anExpr,461 expr* anExpr,
399 const std::vector<expr*>& args);462 const std::vector<expr*>& args);
400463
401 function_item_expr* create_function_item_expr(464 function_item_expr* create_function_item_expr(
402 static_context* sctx,465 static_context* sctx,
466 user_function* udf,
403 const QueryLoc& loc,467 const QueryLoc& loc,
404 const store::Item* aQName,468 const store::Item* aQName,
405 function* f,469 function* f,
@@ -407,10 +471,12 @@
407471
408 function_item_expr* create_function_item_expr(472 function_item_expr* create_function_item_expr(
409 static_context* sctx,473 static_context* sctx,
474 user_function* udf,
410 const QueryLoc& loc);475 const QueryLoc& loc);
411476
412 ftcontains_expr* create_ftcontains_expr(477 ftcontains_expr* create_ftcontains_expr(
413 static_context*,478 static_context*,
479 user_function* udf,
414 QueryLoc const&,480 QueryLoc const&,
415 expr* range,481 expr* range,
416 ftnode *ftselection,482 ftnode *ftselection,
@@ -419,16 +485,21 @@
419////////////////////////////////////////////////////////////////////////////////485////////////////////////////////////////////////////////////////////////////////
420486
421 //this calls the static create_seq within fo_expr487 //this calls the static create_seq within fo_expr
422 fo_expr* create_seq(static_context* sctx, const QueryLoc &);488 fo_expr* create_seq(
489 static_context* sctx,
490 user_function* udf,
491 const QueryLoc &);
423492
424 fo_expr* create_fo_expr(493 fo_expr* create_fo_expr(
425 static_context* sctx,494 static_context* sctx,
495 user_function* udf,
426 const QueryLoc& loc,496 const QueryLoc& loc,
427 const function* f,497 const function* f,
428 expr* arg);498 expr* arg);
429499
430 fo_expr* create_fo_expr(500 fo_expr* create_fo_expr(
431 static_context* sctx,501 static_context* sctx,
502 user_function* udf,
432 const QueryLoc& loc,503 const QueryLoc& loc,
433 const function* f,504 const function* f,
434 expr* arg1,505 expr* arg1,
@@ -436,12 +507,14 @@
436507
437 fo_expr* create_fo_expr(508 fo_expr* create_fo_expr(
438 static_context* sctx,509 static_context* sctx,
510 user_function* udf,
439 const QueryLoc& loc,511 const QueryLoc& loc,
440 const function* f,512 const function* f,
441 const std::vector<expr*>& args);513 const std::vector<expr*>& args);
442514
443 fo_expr* create_fo_expr(515 fo_expr* create_fo_expr(
444 static_context* sctx,516 static_context* sctx,
517 user_function* udf,
445 const QueryLoc& loc,518 const QueryLoc& loc,
446 const function* f);519 const function* f);
447520
@@ -510,6 +583,7 @@
510583
511 flwor_expr* create_flwor_expr(584 flwor_expr* create_flwor_expr(
512 static_context* sctx,585 static_context* sctx,
586 user_function* udf,
513 const QueryLoc& loc,587 const QueryLoc& loc,
514 bool general);588 bool general);
515 589
@@ -524,17 +598,20 @@
524598
525json_array_expr* create_json_array_expr(599json_array_expr* create_json_array_expr(
526 static_context* sctx,600 static_context* sctx,
601 user_function* udf,
527 const QueryLoc& loc,602 const QueryLoc& loc,
528 expr* content);603 expr* content);
529604
530json_object_expr* create_json_object_expr(605json_object_expr* create_json_object_expr(
531 static_context* sctx,606 static_context* sctx,
607 user_function* udf,
532 const QueryLoc& loc,608 const QueryLoc& loc,
533 expr* content,609 expr* content,
534 bool accumulate);610 bool accumulate);
535611
536json_direct_object_expr* create_json_direct_object_expr(612json_direct_object_expr* create_json_direct_object_expr(
537 static_context* sctx,613 static_context* sctx,
614 user_function* udf,
538 const QueryLoc& loc,615 const QueryLoc& loc,
539 std::vector<expr*>& names,616 std::vector<expr*>& names,
540 std::vector<expr*>& values);617 std::vector<expr*>& values);
541618
=== modified file 'src/compiler/expression/flwor_expr.cpp'
--- src/compiler/expression/flwor_expr.cpp 2012-10-08 12:09:36 +0000
+++ src/compiler/expression/flwor_expr.cpp 2012-10-09 13:35:26 +0000
@@ -107,6 +107,7 @@
107 {107 {
108 theDomainExpr = theCCB->theEM->108 theDomainExpr = theCCB->theEM->
109 create_treat_expr(theDomainExpr->get_sctx(),109 create_treat_expr(theDomainExpr->get_sctx(),
110 theDomainExpr->get_udf(),
110 theDomainExpr->get_loc(),111 theDomainExpr->get_loc(),
111 theDomainExpr,112 theDomainExpr,
112 varType,113 varType,
@@ -173,11 +174,13 @@
173 *declaredType));174 *declaredType));
174 }175 }
175176
176 domainExpr = theCCB->theEM->create_treat_expr(sctx,177 domainExpr = theCCB->theEM->
177 loc,178 create_treat_expr(sctx,
178 domainExpr,179 domainExpr->get_udf(),
179 declaredType,180 loc,
180 TreatIterator::TYPE_MATCH);181 domainExpr,
182 declaredType,
183 TreatIterator::TYPE_MATCH);
181184
182 set_expr(domainExpr);185 set_expr(domainExpr);
183 }186 }
@@ -225,18 +228,18 @@
225}228}
226229
227230
228flwor_clause* for_clause::clone(expr::substitution_t& subst) const231flwor_clause* for_clause::clone(user_function* udf, expr::substitution_t& subst) const
229{232{
230 expr* domainCopy = theDomainExpr->clone(subst);233 expr* domainCopy = theDomainExpr->clone(udf, subst);
231234
232 var_expr* varCopy = theCCB->theEM->create_var_expr(*theVarExpr);235 var_expr* varCopy = theCCB->theEM->create_var_expr(udf, *theVarExpr);
233 subst[theVarExpr] = varCopy;236 subst[theVarExpr] = varCopy;
234237
235 var_expr* posvarCopy = NULL;238 var_expr* posvarCopy = NULL;
236 var_expr* pos_var_ptr = thePosVarExpr;239 var_expr* pos_var_ptr = thePosVarExpr;
237 if (pos_var_ptr)240 if (pos_var_ptr)
238 {241 {
239 posvarCopy = theCCB->theEM->create_var_expr(*pos_var_ptr);242 posvarCopy = theCCB->theEM->create_var_expr(udf, *pos_var_ptr);
240 subst[pos_var_ptr] = posvarCopy;243 subst[pos_var_ptr] = posvarCopy;
241 }244 }
242245
@@ -244,17 +247,17 @@
244 var_expr* score_var_ptr = theScoreVarExpr;247 var_expr* score_var_ptr = theScoreVarExpr;
245 if (score_var_ptr)248 if (score_var_ptr)
246 {249 {
247 scorevarCopy = theCCB->theEM->create_var_expr(*score_var_ptr);250 scorevarCopy = theCCB->theEM->create_var_expr(udf, *score_var_ptr);
248 subst[score_var_ptr] = scorevarCopy;251 subst[score_var_ptr] = scorevarCopy;
249 }252 }
250253
251 return theCCB->theEM->create_for_clause(theContext,254 return theCCB->theEM->create_for_clause(theContext,
252 get_loc(),255 get_loc(),
253 varCopy,256 varCopy,
254 domainCopy,257 domainCopy,
255 posvarCopy,258 posvarCopy,
256 scorevarCopy,259 scorevarCopy,
257 theAllowingEmpty);260 theAllowingEmpty);
258}261}
259262
260263
@@ -298,11 +301,13 @@
298 ERROR_PARAMS(ZED(BadType_23o), *domainType, ZED(NoTreatAs_4), *declaredType));301 ERROR_PARAMS(ZED(BadType_23o), *domainType, ZED(NoTreatAs_4), *declaredType));
299 }302 }
300303
301 domainExpr = theCCB->theEM->create_treat_expr(sctx,304 domainExpr = theCCB->theEM->
302 loc,305 create_treat_expr(sctx,
303 domainExpr,306 domainExpr->get_udf(),
304 declaredType,307 loc,
305 TreatIterator::TYPE_MATCH);308 domainExpr,
309 declaredType,
310 TreatIterator::TYPE_MATCH);
306311
307 set_expr(domainExpr);312 set_expr(domainExpr);
308 }313 }
@@ -332,11 +337,11 @@
332}337}
333338
334339
335flwor_clause* let_clause::clone(expr::substitution_t& subst) const340flwor_clause* let_clause::clone(user_function* udf, expr::substitution_t& subst) const
336{341{
337 expr* domainCopy = theDomainExpr->clone(subst);342 expr* domainCopy = theDomainExpr->clone(udf, subst);
338343
339 var_expr* varCopy = theCCB->theEM->create_var_expr(*theVarExpr);344 var_expr* varCopy = theCCB->theEM->create_var_expr(udf, *theVarExpr);
340 subst[theVarExpr] = varCopy;345 subst[theVarExpr] = varCopy;
341346
342#if 0347#if 0
@@ -350,10 +355,10 @@
350#endif355#endif
351356
352 return theCCB->theEM->create_let_clause(theContext,357 return theCCB->theEM->create_let_clause(theContext,
353 get_loc(),358 get_loc(),
354 varCopy,359 varCopy,
355 domainCopy,360 domainCopy,
356 theLazyEval);361 theLazyEval);
357}362}
358363
359364
@@ -403,6 +408,7 @@
403 {408 {
404 domainExpr = theCCB->theEM->409 domainExpr = theCCB->theEM->
405 create_treat_expr(sctx,410 create_treat_expr(sctx,
411 domainExpr->get_udf(),
406 loc,412 loc,
407 domainExpr,413 domainExpr,
408 varType,414 varType,
@@ -441,21 +447,23 @@
441}447}
442448
443449
444flwor_clause* window_clause::clone(expr::substitution_t& subst) const450flwor_clause* window_clause::clone(
451 user_function* udf,
452 expr::substitution_t& subst) const
445{453{
446 expr* domainCopy = theDomainExpr->clone(subst);454 expr* domainCopy = theDomainExpr->clone(udf, subst);
447455
448 var_expr* varCopy = theCCB->theEM->create_var_expr(*theVarExpr);456 var_expr* varCopy = theCCB->theEM->create_var_expr(udf, *theVarExpr);
449 subst[theVarExpr] = varCopy;457 subst[theVarExpr] = varCopy;
450458
451 flwor_wincond* cloneStartCond = NULL;459 flwor_wincond* cloneStartCond = NULL;
452 flwor_wincond* cloneStopCond = NULL;460 flwor_wincond* cloneStopCond = NULL;
453461
454 if (theWinStartCond != NULL)462 if (theWinStartCond != NULL)
455 cloneStartCond = theWinStartCond->clone(subst);463 cloneStartCond = theWinStartCond->clone(udf, subst);
456464
457 if (theWinStopCond != NULL)465 if (theWinStopCond != NULL)
458 cloneStopCond = theWinStopCond->clone(subst);466 cloneStopCond = theWinStopCond->clone(udf, subst);
459467
460 return theCCB->theEM->create_window_clause(theContext,468 return theCCB->theEM->create_window_clause(theContext,
461 get_loc(),469 get_loc(),
@@ -493,15 +501,17 @@
493501
494 xqtref_t condType = theCondExpr->get_return_type();502 xqtref_t condType = theCondExpr->get_return_type();
495503
496 if(!TypeOps::is_equal(tm,504 if (!TypeOps::is_equal(tm,
497 *condType,505 *condType,
498 *GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE,506 *GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE,
499 theCondExpr->get_loc()))507 theCondExpr->get_loc()))
500 {508 {
501 theCondExpr = theCCB->theEM->create_fo_expr(theCondExpr->get_sctx(),509 theCondExpr = theCCB->theEM->
502 theCondExpr->get_loc(),510 create_fo_expr(theCondExpr->get_sctx(),
503 GET_BUILTIN_FUNCTION(FN_BOOLEAN_1),511 theCondExpr->get_udf(),
504 theCondExpr);512 theCondExpr->get_loc(),
513 GET_BUILTIN_FUNCTION(FN_BOOLEAN_1),
514 theCondExpr);
505 }515 }
506 }516 }
507}517}
@@ -514,14 +524,15 @@
514524
515525
516flwor_wincond::vars::vars()526flwor_wincond::vars::vars()
517:527 :
518posvar(NULL),528 posvar(NULL),
519curr(NULL),529 curr(NULL),
520prev(NULL),530 prev(NULL),
521next(NULL)531 next(NULL)
522{532{
523}533}
524534
535
525flwor_wincond::vars::~vars()536flwor_wincond::vars::~vars()
526{537{
527// set_flwor_clause(NULL);538// set_flwor_clause(NULL);
@@ -539,33 +550,34 @@
539550
540void flwor_wincond::vars::clone(551void flwor_wincond::vars::clone(
541 ExprManager* mgr,552 ExprManager* mgr,
553 user_function* udf,
542 flwor_wincond::vars& cloneVars,554 flwor_wincond::vars& cloneVars,
543 expr::substitution_t& subst) const555 expr::substitution_t& subst) const
544{556{
545 if (posvar != NULL)557 if (posvar != NULL)
546 {558 {
547 var_expr* varCopy = mgr->create_var_expr(*posvar);559 var_expr* varCopy = mgr->create_var_expr(udf, *posvar);
548 subst[posvar] = varCopy;560 subst[posvar] = varCopy;
549 cloneVars.posvar = varCopy;561 cloneVars.posvar = varCopy;
550 }562 }
551563
552 if (curr != NULL)564 if (curr != NULL)
553 {565 {
554 var_expr* varCopy = mgr->create_var_expr(*curr);566 var_expr* varCopy = mgr->create_var_expr(udf, *curr);
555 subst[curr] = varCopy;567 subst[curr] = varCopy;
556 cloneVars.curr = varCopy;568 cloneVars.curr = varCopy;
557 }569 }
558570
559 if (prev != NULL)571 if (prev != NULL)
560 {572 {
561 var_expr* varCopy = mgr->create_var_expr(*prev);573 var_expr* varCopy = mgr->create_var_expr(udf, *prev);
562 subst[prev] = varCopy;574 subst[prev] = varCopy;
563 cloneVars.prev = varCopy;575 cloneVars.prev = varCopy;
564 }576 }
565577
566 if (next != NULL)578 if (next != NULL)
567 {579 {
568 var_expr* varCopy = mgr->create_var_expr(*next);580 var_expr* varCopy = mgr->create_var_expr(udf, *next);
569 subst[next] = varCopy;581 subst[next] = varCopy;
570 cloneVars.next = varCopy;582 cloneVars.next = varCopy;
571 }583 }
@@ -579,21 +591,23 @@
579}591}
580592
581593
582flwor_wincond* flwor_wincond::clone(expr::substitution_t& subst) const594flwor_wincond* flwor_wincond::clone(
595 user_function* udf,
596 expr::substitution_t& subst) const
583{597{
584 flwor_wincond::vars cloneInVars;598 flwor_wincond::vars cloneInVars;
585 flwor_wincond::vars cloneOutVars;599 flwor_wincond::vars cloneOutVars;
586600
587 theInputVars.clone(theCCB->theEM, cloneInVars, subst);601 theInputVars.clone(theCCB->theEM, udf, cloneInVars, subst);
588 theOutputVars.clone(theCCB->theEM, cloneOutVars, subst);602 theOutputVars.clone(theCCB->theEM, udf, cloneOutVars, subst);
589603
590 expr* cloneCondExpr = theCondExpr->clone(subst);604 expr* cloneCondExpr = theCondExpr->clone(udf, subst);
591605
592 return theCCB->theEM->create_flwor_wincond(NULL,606 return theCCB->theEM->create_flwor_wincond(NULL,
593 theIsOnly,607 theIsOnly,
594 cloneInVars,608 cloneInVars,
595 cloneOutVars,609 cloneOutVars,
596 cloneCondExpr);610 cloneCondExpr);
597}611}
598612
599613
@@ -663,7 +677,9 @@
663}677}
664678
665679
666flwor_clause* group_clause::clone(expr::substitution_t& subst) const680flwor_clause* group_clause::clone(
681 user_function* udf,
682 expr::substitution_t& subst) const
667{683{
668 csize numGroupVars = theGroupVars.size();684 csize numGroupVars = theGroupVars.size();
669 csize numNonGroupVars = theNonGroupVars.size();685 csize numNonGroupVars = theNonGroupVars.size();
@@ -680,23 +696,29 @@
680696
681 for (csize i = 0; i < numGroupVars; ++i)697 for (csize i = 0; i < numGroupVars; ++i)
682 {698 {
683 cloneGroupVars[i].first = theGroupVars[i].first->clone(subst);699 cloneGroupVars[i].first = theGroupVars[i].first->clone(udf, subst);
684 cloneGroupVars[i].second = exprMgr->create_var_expr(*theGroupVars[i].second);700
701 cloneGroupVars[i].second = exprMgr->
702 create_var_expr(udf, *theGroupVars[i].second);
703
685 subst[theGroupVars[i].second] = cloneGroupVars[i].second;704 subst[theGroupVars[i].second] = cloneGroupVars[i].second;
686 }705 }
687706
688 for (csize i = 0; i < numNonGroupVars; ++i)707 for (csize i = 0; i < numNonGroupVars; ++i)
689 {708 {
690 cloneNonGroupVars[i].first = theNonGroupVars[i].first->clone(subst);709 cloneNonGroupVars[i].first = theNonGroupVars[i].first->clone(udf, subst);
691 cloneNonGroupVars[i].second = exprMgr->create_var_expr(*theNonGroupVars[i].second);710
711 cloneNonGroupVars[i].second = exprMgr->
712 create_var_expr(udf, *theNonGroupVars[i].second);
713
692 subst[theNonGroupVars[i].second] = cloneNonGroupVars[i].second;714 subst[theNonGroupVars[i].second] = cloneNonGroupVars[i].second;
693 }715 }
694716
695 return theCCB->theEM->create_group_clause(theContext,717 return theCCB->theEM->create_group_clause(theContext,
696 get_loc(),718 get_loc(),
697 cloneGroupVars,719 cloneGroupVars,
698 cloneNonGroupVars,720 cloneNonGroupVars,
699 theCollations);721 theCollations);
700}722}
701723
702724
@@ -726,7 +748,9 @@
726}748}
727749
728750
729flwor_clause* orderby_clause::clone(expr::substitution_t& subst) const751flwor_clause* orderby_clause::clone(
752 user_function* udf,
753 expr::substitution_t& subst) const
730{754{
731 csize numColumns = num_columns();755 csize numColumns = num_columns();
732756
@@ -734,14 +758,14 @@
734758
735 for (csize i = 0; i < numColumns; ++i)759 for (csize i = 0; i < numColumns; ++i)
736 {760 {
737 cloneExprs[i] = theOrderingExprs[i]->clone(subst);761 cloneExprs[i] = theOrderingExprs[i]->clone(udf, subst);
738 }762 }
739763
740 return theCCB->theEM->create_orderby_clause(theContext,764 return theCCB->theEM->create_orderby_clause(theContext,
741 get_loc(),765 get_loc(),
742 theStableOrder,766 theStableOrder,
743 theModifiers,767 theModifiers,
744 cloneExprs);768 cloneExprs);
745}769}
746770
747771
@@ -758,7 +782,9 @@
758}782}
759783
760784
761flwor_clause* materialize_clause::clone(expr::substitution_t& subst) const785flwor_clause* materialize_clause::clone(
786 user_function* udf,
787 expr::substitution_t& subst) const
762{788{
763 // we will reach here under the following scenario:789 // we will reach here under the following scenario:
764 // 1. We do plan seriazation790 // 1. We do plan seriazation
@@ -792,11 +818,13 @@
792}818}
793819
794820
795flwor_clause* count_clause::clone(expr::substitution_t& subst) const821flwor_clause* count_clause::clone(
822 user_function* udf,
823 expr::substitution_t& subst) const
796{824{
797 ExprManager* exprMgr = theVarExpr->get_ccb()->theEM;825 ExprManager* exprMgr = theVarExpr->get_ccb()->theEM;
798826
799 var_expr* cloneVar = exprMgr->create_var_expr(*theVarExpr);827 var_expr* cloneVar = exprMgr->create_var_expr(udf, *theVarExpr);
800 subst[theVarExpr] = cloneVar;828 subst[theVarExpr] = cloneVar;
801829
802 return theCCB->theEM->create_count_clause(theContext, get_loc(), cloneVar);830 return theCCB->theEM->create_count_clause(theContext, get_loc(), cloneVar);
@@ -825,9 +853,11 @@
825}853}
826854
827855
828flwor_clause* where_clause::clone(expr::substitution_t& subst) const856flwor_clause* where_clause::clone(
857 user_function* udf,
858 expr::substitution_t& subst) const
829{859{
830 expr* cloneExpr = theWhereExpr->clone(subst);860 expr* cloneExpr = theWhereExpr->clone(udf, subst);
831861
832 return theCCB->theEM->create_where_clause(theContext, get_loc(), cloneExpr);862 return theCCB->theEM->create_where_clause(theContext, get_loc(), cloneExpr);
833}863}
@@ -839,10 +869,11 @@
839flwor_expr::flwor_expr(869flwor_expr::flwor_expr(
840 CompilerCB* ccb,870 CompilerCB* ccb,
841 static_context* sctx,871 static_context* sctx,
872 user_function* udf,
842 const QueryLoc& loc,873 const QueryLoc& loc,
843 bool general)874 bool general)
844 :875 :
845 expr(ccb, sctx, loc, (general ? gflwor_expr_kind : flwor_expr_kind)),876 expr(ccb, sctx, udf, loc, (general ? gflwor_expr_kind : flwor_expr_kind)),
846 theIsGeneral(general),877 theIsGeneral(general),
847 theHasSequentialClauses(false),878 theHasSequentialClauses(false),
848 theReturnExpr(NULL)879 theReturnExpr(NULL)
@@ -1167,27 +1198,5 @@
1167}1198}
11681199
11691200
1170/*******************************************************************************
1171
1172********************************************************************************/
1173expr* flwor_expr::cloneImpl(substitution_t& subst) const
1174{
1175 ulong numClauses = num_clauses();
1176
1177 flwor_expr* cloneFlwor = theCCB->theEM->create_flwor_expr(theSctx, get_loc(), theIsGeneral);
1178
1179 for (ulong i = 0; i < numClauses; ++i)
1180 {
1181 flwor_clause* cloneClause = theClauses[i]->clone(subst);
1182
1183 cloneFlwor->add_clause(cloneClause, false);
1184 }
1185
1186 cloneFlwor->set_return_expr(theReturnExpr->clone(subst));
1187
1188 return cloneFlwor;
1189}
1190
1191
1192} // namespace zorba1201} // namespace zorba
1193/* vim:set et sw=2 ts=2: */1202/* vim:set et sw=2 ts=2: */
11941203
=== modified file 'src/compiler/expression/flwor_expr.h'
--- src/compiler/expression/flwor_expr.h 2012-10-08 12:09:36 +0000
+++ src/compiler/expression/flwor_expr.h 2012-10-09 13:35:26 +0000
@@ -105,7 +105,9 @@
105105
106 virtual var_expr* get_score_var() const { return NULL; }106 virtual var_expr* get_score_var() const { return NULL; }
107107
108 virtual flwor_clause* clone(expr::substitution_t& substitution) const = 0;108 virtual flwor_clause* clone(
109 user_function* udf,
110 expr::substitution_t& substitution) const = 0;
109};111};
110112
111113
@@ -207,7 +209,7 @@
207209
208 void set_score_var(var_expr* v);210 void set_score_var(var_expr* v);
209211
210 flwor_clause* clone(expr::substitution_t& substitution) const;212 flwor_clause* clone(user_function* udf, expr::substitution_t& substitution) const;
211213
212 std::ostream& put(std::ostream&) const;214 std::ostream& put(std::ostream&) const;
213};215};
@@ -247,7 +249,7 @@
247249
248 bool lazyEval() const { return theLazyEval; }250 bool lazyEval() const { return theLazyEval; }
249251
250 flwor_clause* clone(expr::substitution_t& substitution) const;252 flwor_clause* clone(user_function* udf, expr::substitution_t& substitution) const;
251253
252 std::ostream& put(std::ostream&) const;254 std::ostream& put(std::ostream&) const;
253};255};
@@ -303,7 +305,7 @@
303305
304 bool lazyEval() const { return theLazyEval; }306 bool lazyEval() const { return theLazyEval; }
305307
306 flwor_clause* clone(expr::substitution_t& substitution) const;308 flwor_clause* clone(user_function* udf, expr::substitution_t& substitution) const;
307309
308 std::ostream& put(std::ostream&) const;310 std::ostream& put(std::ostream&) const;
309};311};
@@ -354,10 +356,16 @@
354 var_expr* next;356 var_expr* next;
355357
356 vars();358 vars();
359
357 ~vars();360 ~vars();
361
358 void set_flwor_clause(flwor_clause* c);362 void set_flwor_clause(flwor_clause* c);
359363
360 void clone(ExprManager* mgr, vars& cloneVars, expr::substitution_t& subst) const;364 void clone(
365 ExprManager* mgr,
366 user_function* udf,
367 vars& cloneVars,
368 expr::substitution_t& subst) const;
361369
362 std::ostream& put(std::ostream&) const;370 std::ostream& put(std::ostream&) const;
363 };371 };
@@ -394,7 +402,7 @@
394402
395 void set_flwor_clause(flwor_clause *);403 void set_flwor_clause(flwor_clause *);
396404
397 flwor_wincond* clone(expr::substitution_t& substitution) const;405 flwor_wincond* clone(user_function* udf, expr::substitution_t& substitution) const;
398406
399 std::ostream& put(std::ostream&) const;407 std::ostream& put(std::ostream&) const;
400};408};
@@ -484,7 +492,7 @@
484492
485 expr* get_input_for_nongroup_var(const var_expr* var);493 expr* get_input_for_nongroup_var(const var_expr* var);
486494
487 flwor_clause* clone(expr::substitution_t& substitution) const;495 flwor_clause* clone(user_function* udf, expr::substitution_t& substitution) const;
488496
489 std::ostream& put(std::ostream&) const;497 std::ostream& put(std::ostream&) const;
490};498};
@@ -552,7 +560,7 @@
552560
553 void set_column_expr(csize i, expr* e) { theOrderingExprs[i] = e; }561 void set_column_expr(csize i, expr* e) { theOrderingExprs[i] = e; }
554562
555 flwor_clause* clone(expr::substitution_t& substitution) const;563 flwor_clause* clone(user_function* udf, expr::substitution_t& substitution) const;
556564
557 std::ostream& put(std::ostream&) const;565 std::ostream& put(std::ostream&) const;
558};566};
@@ -572,7 +580,7 @@
572 materialize_clause(static_context* sctx, CompilerCB* ccb, const QueryLoc& loc);580 materialize_clause(static_context* sctx, CompilerCB* ccb, const QueryLoc& loc);
573581
574public:582public:
575 flwor_clause* clone(expr::substitution_t& substitution) const;583 flwor_clause* clone(user_function* udf, expr::substitution_t& substitution) const;
576584
577 std::ostream& put(std::ostream&) const;585 std::ostream& put(std::ostream&) const;
578};586};
@@ -597,7 +605,7 @@
597605
598 var_expr* get_var() const { return theVarExpr; }606 var_expr* get_var() const { return theVarExpr; }
599607
600 flwor_clause* clone(expr::substitution_t& substitution) const;608 flwor_clause* clone(user_function* udf, expr::substitution_t& substitution) const;
601};609};
602610
603611
@@ -619,7 +627,7 @@
619627
620 void set_expr(expr* where);628 void set_expr(expr* where);
621629
622 flwor_clause* clone(expr::substitution_t& substitution) const;630 flwor_clause* clone(user_function* udf, expr::substitution_t& substitution) const;
623};631};
624632
625633
@@ -665,7 +673,12 @@
665 expr * theReturnExpr;673 expr * theReturnExpr;
666674
667protected:675protected:
668 flwor_expr(CompilerCB* ccb, static_context* sctx, const QueryLoc& loc, bool general);676 flwor_expr(
677 CompilerCB* ccb,
678 static_context* sctx,
679 user_function* udf,
680 const QueryLoc& loc,
681 bool general);
669682
670public:683public:
671 bool is_general() const { return theIsGeneral; }684 bool is_general() const { return theIsGeneral; }
@@ -704,8 +717,6 @@
704717
705 void get_vars_defined(std::vector<var_expr*>& varExprs) const;718 void get_vars_defined(std::vector<var_expr*>& varExprs) const;
706719
707 expr* cloneImpl(substitution_t& substitution) const;
708
709 // The following 5 methods are for the simple flwor only. They should be720 // The following 5 methods are for the simple flwor only. They should be
710 // removed eventually.721 // removed eventually.
711 expr* get_where() const;722 expr* get_where() const;
712723
=== modified file 'src/compiler/expression/fo_expr.cpp'
--- src/compiler/expression/fo_expr.cpp 2012-10-08 12:09:36 +0000
+++ src/compiler/expression/fo_expr.cpp 2012-10-09 13:35:26 +0000
@@ -55,11 +55,15 @@
55 UnionExpr, and IntersectExceptExpr.55 UnionExpr, and IntersectExceptExpr.
56********************************************************************************/56********************************************************************************/
5757
58fo_expr* fo_expr::create_seq(CompilerCB* ccb, static_context* sctx, const QueryLoc& loc)58fo_expr* fo_expr::create_seq(
59 CompilerCB* ccb,
60 static_context* sctx,
61 user_function* udf,
62 const QueryLoc& loc)
59{63{
60 function* f = BuiltinFunctionLibrary::getFunction(FunctionConsts::OP_CONCATENATE_N);64 function* f = BuiltinFunctionLibrary::getFunction(FunctionConsts::OP_CONCATENATE_N);
6165
62 std::auto_ptr<fo_expr> fo(ccb->theEM->create_fo_expr(sctx, loc, f));66 std::auto_ptr<fo_expr> fo(ccb->theEM->create_fo_expr(sctx, udf, loc, f));
6367
64 return fo.release();68 return fo.release();
65}69}
@@ -68,10 +72,11 @@
68fo_expr::fo_expr(72fo_expr::fo_expr(
69 CompilerCB* ccb,73 CompilerCB* ccb,
70 static_context* sctx,74 static_context* sctx,
75 user_function* udf,
71 const QueryLoc& loc,76 const QueryLoc& loc,
72 const function* f)77 const function* f)
73 :78 :
74 expr(ccb, sctx, loc, fo_expr_kind),79 expr(ccb, sctx, udf, loc, fo_expr_kind),
75 theFunction(const_cast<function*>(f))80 theFunction(const_cast<function*>(f))
76{81{
77 // This method is private and it is to be used only by the clone method82 // This method is private and it is to be used only by the clone method
@@ -83,11 +88,12 @@
83fo_expr::fo_expr(88fo_expr::fo_expr(
84 CompilerCB* ccb,89 CompilerCB* ccb,
85 static_context* sctx,90 static_context* sctx,
91 user_function* udf,
86 const QueryLoc& loc,92 const QueryLoc& loc,
87 const function* f,93 const function* f,
88 expr* arg)94 expr* arg)
89 :95 :
90 expr(ccb, sctx, loc, fo_expr_kind),96 expr(ccb, sctx, udf, loc, fo_expr_kind),
91 theFunction(const_cast<function*>(f))97 theFunction(const_cast<function*>(f))
92{98{
93 assert(f != NULL);99 assert(f != NULL);
@@ -101,12 +107,13 @@
101fo_expr::fo_expr(107fo_expr::fo_expr(
102 CompilerCB* ccb,108 CompilerCB* ccb,
103 static_context* sctx,109 static_context* sctx,
110 user_function* udf,
104 const QueryLoc& loc,111 const QueryLoc& loc,
105 const function* f,112 const function* f,
106 expr* arg1,113 expr* arg1,
107 expr* arg2)114 expr* arg2)
108 :115 :
109 expr(ccb, sctx, loc, fo_expr_kind),116 expr(ccb, sctx, udf, loc, fo_expr_kind),
110 theFunction(const_cast<function*>(f))117 theFunction(const_cast<function*>(f))
111{118{
112 assert(f != NULL);119 assert(f != NULL);
@@ -121,11 +128,12 @@
121fo_expr::fo_expr(128fo_expr::fo_expr(
122 CompilerCB* ccb,129 CompilerCB* ccb,
123 static_context* sctx,130 static_context* sctx,
131 user_function* udf,
124 const QueryLoc& loc,132 const QueryLoc& loc,
125 const function* f,133 const function* f,
126 const std::vector<expr*>& args)134 const std::vector<expr*>& args)
127 :135 :
128 expr(ccb, sctx, loc, fo_expr_kind),136 expr(ccb, sctx, udf, loc, fo_expr_kind),
129 theArgs(args),137 theArgs(args),
130 theFunction(const_cast<function*>(f))138 theFunction(const_cast<function*>(f))
131{139{
@@ -273,29 +281,6 @@
273}281}
274282
275283
276expr* fo_expr::cloneImpl(substitution_t& subst) const
277{
278 if (get_func()->getKind() == FunctionConsts::STATIC_COLLECTIONS_DML_COLLECTION_1)
279 {
280 expr::subst_iter_t i = subst.find(this);
281
282 if (i != subst.end())
283 return i->second;
284 }
285
286 std::auto_ptr<fo_expr> fo(theCCB->theEM->create_fo_expr(theSctx,
287 get_loc(),
288 get_func()));
289
290 for (csize i = 0; i < theArgs.size(); ++i)
291 fo->theArgs.push_back(theArgs[i]->clone(subst));
292
293 fo->theScriptingKind = theScriptingKind;
294
295 return fo.release();
296}
297
298
299}284}
300285
301/* vim:set et sw=2 ts=2: */286/* vim:set et sw=2 ts=2: */
302287
=== modified file 'src/compiler/expression/fo_expr.h'
--- src/compiler/expression/fo_expr.h 2012-10-08 12:09:36 +0000
+++ src/compiler/expression/fo_expr.h 2012-10-09 13:35:26 +0000
@@ -45,12 +45,24 @@
45public:45public:
4646
47protected:47protected:
48 static fo_expr* create_seq(CompilerCB* ccb, static_context* sctx, const QueryLoc&);48 static fo_expr* create_seq(
49 CompilerCB* ccb,
50 static_context* sctx,
51 user_function* udf,
52 const QueryLoc&);
4953
50protected:54protected:
51 fo_expr(55 fo_expr(
52 CompilerCB* ccb,56 CompilerCB* ccb,
53 static_context* sctx,57 static_context* sctx,
58 user_function* udf,
59 const QueryLoc& loc,
60 const function* f);
61
62 fo_expr(
63 CompilerCB* ccb,
64 static_context* sctx,
65 user_function* udf,
54 const QueryLoc& loc,66 const QueryLoc& loc,
55 const function* f,67 const function* f,
56 expr* arg);68 expr* arg);
@@ -58,6 +70,7 @@
58 fo_expr(70 fo_expr(
59 CompilerCB* ccb,71 CompilerCB* ccb,
60 static_context* sctx,72 static_context* sctx,
73 user_function* udf,
61 const QueryLoc& loc,74 const QueryLoc& loc,
62 const function* f,75 const function* f,
63 expr* arg1,76 expr* arg1,
@@ -66,6 +79,7 @@
66 fo_expr(79 fo_expr(
67 CompilerCB* ccb,80 CompilerCB* ccb,
68 static_context* sctx,81 static_context* sctx,
82 user_function* udf,
69 const QueryLoc& loc,83 const QueryLoc& loc,
70 const function* f,84 const function* f,
71 const std::vector<expr*>& args);85 const std::vector<expr*>& args);
@@ -95,8 +109,6 @@
95109
96 void compute_scripting_kind();110 void compute_scripting_kind();
97111
98 expr* cloneImpl(substitution_t& s) const;
99
100 void accept(expr_visitor&);112 void accept(expr_visitor&);
101113
102 std::ostream& put(std::ostream&) const;114 std::ostream& put(std::ostream&) const;
103115
=== modified file 'src/compiler/expression/ft_expr.cpp'
--- src/compiler/expression/ft_expr.cpp 2012-10-08 12:09:36 +0000
+++ src/compiler/expression/ft_expr.cpp 2012-10-09 13:35:26 +0000
@@ -35,12 +35,13 @@
35ftcontains_expr::ftcontains_expr(35ftcontains_expr::ftcontains_expr(
36 CompilerCB* ccb,36 CompilerCB* ccb,
37 static_context* sctx,37 static_context* sctx,
38 user_function* udf,
38 QueryLoc const &loc,39 QueryLoc const &loc,
39 expr* range,40 expr* range,
40 ftnode *ftselection,41 ftnode *ftselection,
41 expr* ftignore42 expr* ftignore
42) :43) :
43 expr(ccb, sctx, loc, ft_expr_kind ),44 expr(ccb, sctx, udf, loc, ft_expr_kind ),
44 range_( range ),45 range_( range ),
45 ftselection_( ftselection ),46 ftselection_( ftselection ),
46 ftignore_( ftignore )47 ftignore_( ftignore )
@@ -50,6 +51,7 @@
50 compute_scripting_kind();51 compute_scripting_kind();
51}52}
5253
54
53void ftcontains_expr::accept( expr_visitor &v ) {55void ftcontains_expr::accept( expr_visitor &v ) {
54 if ( v.begin_visit( *this ) ) {56 if ( v.begin_visit( *this ) ) {
55 EV_ACCEPT( range_, v );57 EV_ACCEPT( range_, v );
@@ -59,16 +61,9 @@
59 v.end_visit( *this );61 v.end_visit( *this );
60}62}
6163
62expr* ftcontains_expr::cloneImpl( substitution_t &s ) const {
63 return theCCB->theEM->create_ftcontains_expr(
64 theSctx, get_loc(),
65 range_->clone( s ),
66 ftselection_->clone( s ).release(),
67 ftignore_ == NULL ? 0 : ftignore_->clone( s )
68 );
69}
7064
71void ftcontains_expr::compute_scripting_kind() {65void ftcontains_expr::compute_scripting_kind()
66{
72 checkSimpleExpr(range_);67 checkSimpleExpr(range_);
7368
74 theScriptingKind = SIMPLE_EXPR;69 theScriptingKind = SIMPLE_EXPR;
7570
=== modified file 'src/compiler/expression/ft_expr.h'
--- src/compiler/expression/ft_expr.h 2012-10-08 12:09:36 +0000
+++ src/compiler/expression/ft_expr.h 2012-10-09 13:35:26 +0000
@@ -29,6 +29,7 @@
29 */29 */
30class ftcontains_expr : public expr30class ftcontains_expr : public expr
31{31{
32 friend class expr;
32 friend class ExprIterator;33 friend class ExprIterator;
33 friend class ExprManager;34 friend class ExprManager;
3435
@@ -36,6 +37,7 @@
36 ftcontains_expr(37 ftcontains_expr(
37 CompilerCB* ccb,38 CompilerCB* ccb,
38 static_context*,39 static_context*,
40 user_function*,
39 QueryLoc const&,41 QueryLoc const&,
40 expr* range,42 expr* range,
41 ftnode *ftselection,43 ftnode *ftselection,
@@ -43,8 +45,6 @@
43 );45 );
4446
45public:47public:
46 expr* cloneImpl( substitution_t& ) const;
47
48 void compute_scripting_kind();48 void compute_scripting_kind();
4949
50 expr* get_range() const { return range_; }50 expr* get_range() const { return range_; }
5151
=== modified file 'src/compiler/expression/ftnode.cpp'
--- src/compiler/expression/ftnode.cpp 2012-09-19 21:16:15 +0000
+++ src/compiler/expression/ftnode.cpp 2012-10-09 13:35:26 +0000
@@ -171,37 +171,60 @@
171///////////////////////////////////////////////////////////////////////////////171///////////////////////////////////////////////////////////////////////////////
172172
173template<typename PointerType>173template<typename PointerType>
174inline PointerType clone_ptr( PointerType p, expr::substitution_t &s ) {174inline PointerType clone_ptr(
175 return static_cast<PointerType>( p->clone( s ).release() );175 PointerType p,
176 user_function* udf,
177 expr::substitution_t &s )
178{
179 return static_cast<PointerType>( p->clone( udf, s ).release() );
176}180}
177181
182
178template<>183template<>
179inline expr* clone_ptr( expr* p, expr::substitution_t &s ) {184inline expr* clone_ptr( expr* p, user_function* udf, expr::substitution_t &s ) {
180 return static_cast<expr*>( p->clone( s ) );185 return static_cast<expr*>( p->clone(udf, s) );
181}186}
182187
188
183template<class RCHandleValueType>189template<class RCHandleValueType>
184inline RCHandleValueType* clone_ptr( rchandle<RCHandleValueType> const &p,190inline RCHandleValueType* clone_ptr(
185 expr::substitution_t &s ) {191 rchandle<RCHandleValueType> const &p,
186 return static_cast<RCHandleValueType*>( p->clone( s ).release() );192 user_function* udf,
193 expr::substitution_t &s )
194{
195 return static_cast<RCHandleValueType*>( p->clone(udf, s).release() );
187}196}
188197
198
189template<typename PointerType>199template<typename PointerType>
190inline PointerType clone_ptr_if( PointerType p, expr::substitution_t &s ) {200inline PointerType clone_ptr_if(
191 return p ? clone_ptr( p, s ) : nullptr;201 PointerType p,
202 user_function* udf,
203 expr::substitution_t &s )
204{
205 return p ? clone_ptr( p, udf, s ) : nullptr;
192}206}
193207
208
194template<class RCHandleValueType>209template<class RCHandleValueType>
195inline RCHandleValueType* clone_ptr_if( rchandle<RCHandleValueType> const &p,210inline RCHandleValueType* clone_ptr_if(
196 expr::substitution_t &s ) {211 rchandle<RCHandleValueType> const &p,
197 return p.isNull() ? nullptr : clone_ptr( p, s );212 user_function* udf,
213 expr::substitution_t &s )
214{
215 return p.isNull() ? nullptr : clone_ptr( p, udf, s );
198}216}
199217
218
200template<class ContainerType>219template<class ContainerType>
201void clone_list( ContainerType const &from, ContainerType *to,220void clone_list(
202 expr::substitution_t &s ) {221 ContainerType const &from,
222 ContainerType *to,
223 user_function* udf,
224 expr::substitution_t &s )
225{
203 FOR_EACH( typename ContainerType, i, from )226 FOR_EACH( typename ContainerType, i, from )
204 to->push_back( clone_ptr( *i, s ) );227 to->push_back( clone_ptr( *i, udf, s ) );
205}228}
206229
207///////////////////////////////////////////////////////////////////////////////230///////////////////////////////////////////////////////////////////////////////
@@ -221,9 +244,9 @@
221 END_VISIT( v );244 END_VISIT( v );
222}245}
223246
224ftnode_t ftand::clone( expr::substitution_t &s ) const {247ftnode_t ftand::clone(user_function* udf, expr::substitution_t &s ) const {
225 ftnode_list_t copy;248 ftnode_list_t copy;
226 clone_list( get_node_list(), &copy, s );249 clone_list( get_node_list(), &copy, udf, s );
227 return new ftand( get_loc(), copy );250 return new ftand( get_loc(), copy );
228}251}
229252
@@ -251,7 +274,7 @@
251 END_VISIT( v );274 END_VISIT( v );
252}275}
253276
254ftnode_t ftcase_option::clone( expr::substitution_t& ) const {277ftnode_t ftcase_option::clone(user_function* udf, expr::substitution_t& ) const {
255 return new ftcase_option( get_loc(), mode_ );278 return new ftcase_option( get_loc(), mode_ );
256}279}
257280
@@ -279,7 +302,7 @@
279 END_VISIT( v );302 END_VISIT( v );
280}303}
281304
282ftnode_t ftcontent_filter::clone( expr::substitution_t &s ) const {305ftnode_t ftcontent_filter::clone(user_function* udf, expr::substitution_t &s ) const {
283 return new ftcontent_filter( get_loc(), mode_ );306 return new ftcontent_filter( get_loc(), mode_ );
284}307}
285308
@@ -308,7 +331,7 @@
308 END_VISIT( v );331 END_VISIT( v );
309}332}
310333
311ftnode_t ftdiacritics_option::clone( expr::substitution_t& ) const {334ftnode_t ftdiacritics_option::clone(user_function* udf, expr::substitution_t& ) const {
312 return new ftdiacritics_option( get_loc(), mode_ );335 return new ftdiacritics_option( get_loc(), mode_ );
313}336}
314337
@@ -345,8 +368,8 @@
345 END_VISIT( v );368 END_VISIT( v );
346}369}
347370
348ftnode_t ftdistance_filter::clone( expr::substitution_t &s ) const {371ftnode_t ftdistance_filter::clone(user_function* udf, expr::substitution_t &s ) const {
349 return new ftdistance_filter( get_loc(), clone_ptr_if( range_, s ), unit_ );372 return new ftdistance_filter( get_loc(), clone_ptr_if( range_, udf, s ), unit_ );
350}373}
351374
352ostream& ftdistance_filter::put( ostream &o ) const {375ostream& ftdistance_filter::put( ostream &o ) const {
@@ -384,9 +407,9 @@
384 END_VISIT( v );407 END_VISIT( v );
385}408}
386409
387ftnode_t ftextension_selection::clone( expr::substitution_t &s ) const {410ftnode_t ftextension_selection::clone(user_function* udf, expr::substitution_t &s ) const {
388 return new ftextension_selection(411 return new ftextension_selection(
389 get_loc(), pragmas_, clone_ptr_if( ftselection_, s )412 get_loc(), pragmas_, clone_ptr_if( ftselection_, udf, s )
390 );413 );
391}414}
392415
@@ -418,7 +441,7 @@
418 END_VISIT( v );441 END_VISIT( v );
419}442}
420443
421ftnode_t ftextension_option::clone( expr::substitution_t& ) const {
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches