Merge lp:~zorba-coders/zorba/feature-pragma_no_copy into lp:zorba
- feature-pragma_no_copy
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Matthias Brantner |
Approved revision: | 10910 |
Merged at revision: | 11053 |
Proposed branch: | lp:~zorba-coders/zorba/feature-pragma_no_copy |
Merge into: | lp:zorba |
Diff against target: |
2816 lines (+773/-343) 49 files modified
ChangeLog (+1/-0) doc/zorba/options.dox (+22/-0) src/compiler/api/compilercb.cpp (+43/-0) src/compiler/api/compilercb.h (+23/-0) src/compiler/expression/CMakeLists.txt (+1/-0) src/compiler/expression/expr.cpp (+23/-31) src/compiler/expression/expr.h (+25/-40) src/compiler/expression/expr_base.cpp (+42/-0) src/compiler/expression/expr_base.h (+14/-3) src/compiler/expression/expr_manager.cpp (+23/-0) src/compiler/expression/expr_manager.h (+7/-0) src/compiler/expression/expr_put.cpp (+1/-0) src/compiler/expression/flwor_expr.cpp (+1/-1) src/compiler/expression/flwor_expr.h (+1/-1) src/compiler/expression/fo_expr.cpp (+1/-1) src/compiler/expression/fo_expr.h (+1/-1) src/compiler/expression/ft_expr.cpp (+1/-1) src/compiler/expression/ft_expr.h (+2/-1) src/compiler/expression/function_item_expr.cpp (+2/-2) src/compiler/expression/function_item_expr.h (+2/-2) src/compiler/expression/json_exprs.cpp (+3/-3) src/compiler/expression/json_exprs.h (+3/-3) src/compiler/expression/path_expr.cpp (+3/-3) src/compiler/expression/path_expr.h (+3/-3) src/compiler/expression/pragma.cpp (+37/-0) src/compiler/expression/pragma.h (+44/-0) src/compiler/expression/script_exprs.cpp (+8/-8) src/compiler/expression/script_exprs.h (+8/-8) src/compiler/expression/update_exprs.cpp (+5/-5) src/compiler/expression/update_exprs.h (+7/-7) src/compiler/expression/var_expr.cpp (+1/-1) src/compiler/expression/var_expr.h (+1/-1) src/compiler/translator/translator.cpp (+30/-12) src/context/static_context.h (+0/-2) src/functions/func_collections_impl.cpp (+157/-20) src/functions/function.h (+5/-0) src/functions/pregenerated/func_collections.h (+20/-0) src/runtime/collections/collections_base.h (+14/-6) src/runtime/collections/pregenerated/collections.h (+30/-20) src/runtime/spec/codegen-h.xq (+5/-0) src/runtime/spec/collections/collections.xml (+40/-10) src/runtime/spec/plan_iter_visitor_h.xq (+0/-2) src/runtime/spec/printer_visitor_h.xq (+1/-5) src/runtime/visitors/pregenerated/printer_visitor.cpp (+0/-140) src/runtime/visitors/printer_visitor_impl.cpp (+35/-0) src/zorbamisc/ns_consts.h (+1/-0) test/rbkt/ExpCompilerResults/IterPlan/zorba/collections/no_copy_01.iter (+61/-0) test/rbkt/ExpQueryResults/zorba/collections/no_copy_01.xml.res (+1/-0) test/rbkt/Queries/zorba/collections/no_copy_01.xq (+14/-0) |
To merge this branch: | bzr merge lp:~zorba-coders/zorba/feature-pragma_no_copy |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Markos Zaharioudakis | Approve | ||
Matthias Brantner | Approve | ||
Review via email: mp+112816@code.launchpad.net |
Commit message
pragma for preventing copying of nodes in functions that insert into collections
Description of the change
pragma for preventing copying of nodes in functions that insert into collections
For example
declare namespace ext = "http://
(# ext:no-copy #) {
dml:
};
Zorba Build Bot (zorba-buildbot) wrote : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job feature-
All tests succeeded!
Zorba Build Bot (zorba-buildbot) wrote : | # |
Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 1 Pending.
Matthias Brantner (matthias-brantner) : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~zorba-coders/zorba/feature-pragma_no_copy into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job feature-
finished. The final status was:
1 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
Zorba Build Bot (zorba-buildbot) wrote : | # |
There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job feature-
All tests succeeded!
Zorba Build Bot (zorba-buildbot) wrote : | # |
Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 1 Approve, 2 Pending.
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~zorba-coders/zorba/feature-pragma_no_copy into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job feature-
finished. The final status was:
2 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job feature-
All tests succeeded!
Zorba Build Bot (zorba-buildbot) wrote : | # |
Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 1 Approve, 2 Pending.
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job feature-
All tests succeeded!
Zorba Build Bot (zorba-buildbot) wrote : | # |
Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 1 Approve, 2 Pending.
Markos Zaharioudakis (markos-za) : | # |
Markos Zaharioudakis (markos-za) wrote : | # |
Why is the processPragma method defined only for static_
ChangeLog needs updating
Tiny optimization: if you want to erase the last N entries in a vector, you can just use resize(). This applies to the code in translator.cpp:8470
Matthias Brantner (matthias-brantner) wrote : | # |
> Why is the processPragma method defined only for
> static_
> other collection-insert functions as well?
>
> ChangeLog needs updating
>
> Tiny optimization: if you want to erase the last N entries in a vector, you
> can just use resize(). This applies to the code in translator.cpp:8470
All of the are fixed.
Zorba Build Bot (zorba-buildbot) wrote : | # |
There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.
Markos Zaharioudakis (markos-za) wrote : | # |
I am going to approve, but it would be nice if you added an "iter" test to make sure that the optimization is applied and we won't loose it somehow in the future. To do so, you must first make PrinterVisitor print theNeedToCpy data member of the various ZorbaInsertNodesXXX iterators. This will probably involve messing with the runtime code generator (ouch!). Then you print the iterators plan of your no_copy_01.xq, and save it in test/rbkt/
Markos Zaharioudakis (markos-za) : | # |
- 10910. By Matthias Brantner
-
iterator plan test for the no-copy pragma
Matthias Brantner (matthias-brantner) wrote : | # |
> I am going to approve, but it would be nice if you added an "iter" test to
> make sure that the optimization is applied and we won't loose it somehow in
> the future. To do so, you must first make PrinterVisitor print theNeedToCpy
> data member of the various ZorbaInsertNodesXXX iterators. This will probably
> involve messing with the runtime code generator (ouch!). Then you print the
> iterators plan of your no_copy_01.xq, and save it in
> test/rbkt/
done
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job feature-
All tests succeeded!
Preview Diff
1 | === modified file 'ChangeLog' |
2 | --- ChangeLog 2012-09-18 22:11:29 +0000 |
3 | +++ ChangeLog 2012-09-19 21:43:18 +0000 |
4 | @@ -14,6 +14,7 @@ |
5 | takes options to parameterize the parsing process (see bug #1047547) |
6 | * Implemented semantics of null for comparison and arithmetics operations. |
7 | * Positional pagination support for index probes |
8 | + * Recognize the no-copy pragma to avoid copying nodes before insertion into a collection. |
9 | |
10 | Optimizations: |
11 | * New memory management for compiler expressions (no more ref counting) |
12 | |
13 | === modified file 'doc/zorba/options.dox' |
14 | --- doc/zorba/options.dox 2012-09-17 00:36:37 +0000 |
15 | +++ doc/zorba/options.dox 2012-09-19 21:43:18 +0000 |
16 | @@ -491,4 +491,26 @@ |
17 | $arity as xs:integer) as xs:QName* external; |
18 | \endcode |
19 | |
20 | +\section pragma_introduction Extension Expressions |
21 | + |
22 | +An extension expression consists of one or more pragmas, followed by an expression enclosed in curly braces. |
23 | +A pragma might be used to modify the behavior or semantics of the expression enclosed in curly braces. |
24 | +Pragmas are denoted by the delimiters (# and #), and consists of an identifying EQName. |
25 | +Zorba recognizes pragmas having the namespace <tt>http://www.zorba-xquery.com/extensions</tt>. |
26 | +Specifically, Zorba recognizes the following pragmas: |
27 | + |
28 | +<ul> |
29 | + <li><b>no-copy</b> In order to indicate that a node that should be inserted into a collection does not need to be copied before inserting it. Not copying a node improves performance. However, the user needs to make sure that the node does not have a parent and is not modified in any other expression. For example, in the following example snippet, the node refered to by <tt>$n</tt> will not be copied before insertion into the collection. |
30 | +\code |
31 | +import module namespace db = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml"; |
32 | + |
33 | +declare namespace ext = "http://www.zorba-xquery.com/extensions"; |
34 | + |
35 | +let $n := <a/> |
36 | +return (# ext:no-copy #) { $n is db:apply-insert-last(xs:QName("local:bar"), $n) } |
37 | +\endcode |
38 | + </li> |
39 | +</ul> |
40 | + |
41 | + |
42 | */ |
43 | |
44 | === modified file 'src/compiler/api/compilercb.cpp' |
45 | --- src/compiler/api/compilercb.cpp 2012-09-17 00:36:37 +0000 |
46 | +++ src/compiler/api/compilercb.cpp 2012-09-19 21:43:18 +0000 |
47 | @@ -223,5 +223,48 @@ |
48 | } |
49 | |
50 | |
51 | +/***************************************************************************//** |
52 | + |
53 | +********************************************************************************/ |
54 | +void CompilerCB::add_pragma(const expr* e, pragma* p) |
55 | +{ |
56 | + thePragmas.insert(std::make_pair(e, p)); |
57 | +} |
58 | + |
59 | + |
60 | +void |
61 | +CompilerCB::lookup_pragmas(const expr* e, std::vector<pragma*>& pragmas) const |
62 | +{ |
63 | + pragmas.clear(); |
64 | + |
65 | + std::pair<PragmaMapIter, PragmaMapIter> lRange = thePragmas.equal_range(e); |
66 | + while (lRange.first != lRange.second) |
67 | + { |
68 | + pragmas.push_back(lRange.first->second); |
69 | + ++lRange.first; |
70 | + } |
71 | +} |
72 | + |
73 | +bool |
74 | +CompilerCB::lookup_pragma( |
75 | + const expr* e, |
76 | + const zstring& localname, |
77 | + pragma*& p) const |
78 | +{ |
79 | + std::pair<PragmaMapIter, PragmaMapIter> lRange = thePragmas.equal_range(e); |
80 | + while (lRange.first != lRange.second) |
81 | + { |
82 | + if (lRange.first->second->theQName->getLocalName() == localname) |
83 | + { |
84 | + p = lRange.first->second; |
85 | + return true; |
86 | + } |
87 | + ++lRange.first; |
88 | + } |
89 | + return false; |
90 | +} |
91 | + |
92 | + |
93 | + |
94 | } /* namespace zorba */ |
95 | /* vim:set et sw=2 ts=2: */ |
96 | |
97 | === modified file 'src/compiler/api/compilercb.h' |
98 | --- src/compiler/api/compilercb.h 2012-09-17 00:36:37 +0000 |
99 | +++ src/compiler/api/compilercb.h 2012-09-19 21:43:18 +0000 |
100 | @@ -29,6 +29,7 @@ |
101 | // without having the definition of static_context availble. |
102 | # include "context/static_context.h" |
103 | #endif |
104 | +#include "compiler/expression/pragma.h" |
105 | |
106 | #include "zorbaserialization/class_serializer.h" |
107 | |
108 | @@ -102,6 +103,13 @@ |
109 | A counter used to create unique names for temporary (query-specific) indexes |
110 | created to perform hashjoins (see rewriter/rules/index_join_rule.cpp). |
111 | |
112 | + thePragmas: |
113 | + ------------- |
114 | + A multimap from expr* to pragma such that not every expression needs |
115 | + to keep it's own list of pragmas. Since the expr* pointer is only valid |
116 | + until codegen finished, the pragmas can only be used in the compiler. |
117 | + |
118 | + |
119 | theConfig.lib_module : |
120 | ---------------------- |
121 | If true, then if the query string that is given by the user is a library |
122 | @@ -191,6 +199,10 @@ |
123 | |
124 | ExprManager * const theEM; |
125 | |
126 | + typedef std::multimap<const expr*, pragma*> PragmaMap; |
127 | + typedef PragmaMap::const_iterator PragmaMapIter; |
128 | + PragmaMap thePragmas; |
129 | + |
130 | public: |
131 | SERIALIZABLE_CLASS(CompilerCB); |
132 | CompilerCB(::zorba::serialization::Archiver& ar); |
133 | @@ -221,6 +233,17 @@ |
134 | |
135 | MemoryManager& getMemoryManager() const { return theEM->getMemory(); } |
136 | |
137 | + // |
138 | + // Pragmas |
139 | + // |
140 | + void add_pragma(const expr* e, pragma* p); |
141 | + |
142 | + void |
143 | + lookup_pragmas(const expr* e, std::vector<pragma*>& pragmas) const; |
144 | + |
145 | + bool |
146 | + lookup_pragma(const expr* e, const zstring& localname, pragma*&) const; |
147 | + |
148 | }; |
149 | |
150 | |
151 | |
152 | === modified file 'src/compiler/expression/CMakeLists.txt' |
153 | --- src/compiler/expression/CMakeLists.txt 2012-09-17 00:36:37 +0000 |
154 | +++ src/compiler/expression/CMakeLists.txt 2012-09-19 21:43:18 +0000 |
155 | @@ -27,6 +27,7 @@ |
156 | script_exprs.cpp |
157 | update_exprs.cpp |
158 | function_item_expr.cpp |
159 | + pragma.cpp |
160 | mem_manager.cpp |
161 | expr_manager.cpp) |
162 | |
163 | |
164 | === modified file 'src/compiler/expression/expr.cpp' |
165 | --- src/compiler/expression/expr.cpp 2012-09-17 00:36:37 +0000 |
166 | +++ src/compiler/expression/expr.cpp 2012-09-19 21:43:18 +0000 |
167 | @@ -166,7 +166,7 @@ |
168 | } |
169 | |
170 | |
171 | -expr* if_expr::clone(substitution_t& subst) const |
172 | +expr* if_expr::cloneImpl(substitution_t& subst) const |
173 | { |
174 | return theCCB->theEM->create_if_expr(theSctx, |
175 | get_loc(), |
176 | @@ -203,7 +203,7 @@ |
177 | } |
178 | |
179 | |
180 | -expr* order_expr::clone(substitution_t& subst) const |
181 | +expr* order_expr::cloneImpl(substitution_t& subst) const |
182 | { |
183 | return theCCB->theEM->create_order_expr(theSctx, get_loc(), get_type(), get_expr()->clone(subst)); |
184 | } |
185 | @@ -242,7 +242,7 @@ |
186 | } |
187 | |
188 | |
189 | -expr* validate_expr::clone(substitution_t& subst) const |
190 | +expr* validate_expr::cloneImpl(substitution_t& subst) const |
191 | { |
192 | return theCCB->theEM->create_validate_expr(theSctx, |
193 | get_loc(), |
194 | @@ -363,7 +363,7 @@ |
195 | } |
196 | |
197 | |
198 | -expr* cast_expr::clone(substitution_t& subst) const |
199 | +expr* cast_expr::cloneImpl(substitution_t& subst) const |
200 | { |
201 | return theCCB->theEM->create_cast_expr(theSctx, |
202 | get_loc(), |
203 | @@ -393,7 +393,7 @@ |
204 | } |
205 | |
206 | |
207 | -expr* treat_expr::clone(substitution_t& subst) const |
208 | +expr* treat_expr::cloneImpl(substitution_t& subst) const |
209 | { |
210 | return theCCB->theEM->create_treat_expr(theSctx, |
211 | get_loc(), |
212 | @@ -424,7 +424,7 @@ |
213 | } |
214 | |
215 | |
216 | -expr* promote_expr::clone(substitution_t& subst) const |
217 | +expr* promote_expr::cloneImpl(substitution_t& subst) const |
218 | { |
219 | return theCCB->theEM->create_promote_expr(theSctx, |
220 | get_loc(), |
221 | @@ -468,13 +468,13 @@ |
222 | } |
223 | |
224 | |
225 | -bool castable_expr::is_optional() const |
226 | +bool castable_expr::is_optional() const |
227 | { |
228 | - return theTargetType->get_quantifier() == TypeConstants::QUANT_QUESTION; |
229 | + return theTargetType->get_quantifier() == TypeConstants::QUANT_QUESTION; |
230 | } |
231 | |
232 | |
233 | -expr* castable_expr::clone(substitution_t& subst) const |
234 | +expr* castable_expr::cloneImpl(substitution_t& subst) const |
235 | { |
236 | return theCCB->theEM->create_castable_expr(theSctx, |
237 | get_loc(), |
238 | @@ -500,7 +500,7 @@ |
239 | } |
240 | |
241 | |
242 | -expr* instanceof_expr::clone(substitution_t& subst) const |
243 | +expr* instanceof_expr::cloneImpl(substitution_t& subst) const |
244 | { |
245 | return theCCB->theEM->create_instanceof_expr(theSctx, |
246 | get_loc(), |
247 | @@ -539,7 +539,7 @@ |
248 | } |
249 | |
250 | |
251 | -expr* name_cast_expr::clone(substitution_t& subst) const |
252 | +expr* name_cast_expr::cloneImpl(substitution_t& subst) const |
253 | { |
254 | return theCCB->theEM->create_name_cast_expr(theSctx, |
255 | get_loc(), |
256 | @@ -578,7 +578,7 @@ |
257 | } |
258 | |
259 | |
260 | -expr* doc_expr::clone(substitution_t& subst) const |
261 | +expr* doc_expr::cloneImpl(substitution_t& subst) const |
262 | { |
263 | doc_expr* clone = theCCB->theEM->create_doc_expr(theSctx, |
264 | get_loc(), |
265 | @@ -660,7 +660,7 @@ |
266 | } |
267 | |
268 | |
269 | -expr* elem_expr::clone(substitution_t& subst) const |
270 | +expr* elem_expr::cloneImpl(substitution_t& subst) const |
271 | { |
272 | elem_expr* clone = theCCB->theEM->create_elem_expr(theSctx, |
273 | get_loc(), |
274 | @@ -727,7 +727,7 @@ |
275 | } |
276 | |
277 | |
278 | -expr* attr_expr::clone(substitution_t& subst) const |
279 | +expr* attr_expr::cloneImpl(substitution_t& subst) const |
280 | { |
281 | return theCCB->theEM->create_attr_expr(theSctx, |
282 | get_loc(), |
283 | @@ -770,7 +770,7 @@ |
284 | } |
285 | |
286 | |
287 | -expr* text_expr::clone(substitution_t& subst) const |
288 | +expr* text_expr::cloneImpl(substitution_t& subst) const |
289 | { |
290 | return theCCB->theEM->create_text_expr(theSctx, get_loc(), get_type(), CLONE(get_text(), subst)); |
291 | } |
292 | @@ -820,7 +820,7 @@ |
293 | } |
294 | |
295 | |
296 | -expr* pi_expr::clone(substitution_t& subst) const |
297 | +expr* pi_expr::cloneImpl(substitution_t& subst) const |
298 | { |
299 | return theCCB->theEM->create_pi_expr(theSctx, |
300 | get_loc(), |
301 | @@ -849,7 +849,7 @@ |
302 | } |
303 | |
304 | |
305 | -expr* wrapper_expr::clone(substitution_t& subst) const |
306 | +expr* wrapper_expr::cloneImpl(substitution_t& subst) const |
307 | { |
308 | expr* e = theWrappedExpr->clone(subst); |
309 | |
310 | @@ -973,7 +973,7 @@ |
311 | } |
312 | |
313 | |
314 | -expr* const_expr::clone(substitution_t&) const |
315 | +expr* const_expr::cloneImpl(substitution_t&) const |
316 | { |
317 | return theCCB->theEM->create_const_expr(theSctx, get_loc(), theValue); |
318 | } |
319 | @@ -982,14 +982,6 @@ |
320 | /******************************************************************************* |
321 | |
322 | ********************************************************************************/ |
323 | -pragma::pragma(store::Item_t name, std::string const& content) |
324 | - : |
325 | - theQName(name), |
326 | - theContent(content) |
327 | -{ |
328 | -} |
329 | - |
330 | - |
331 | extension_expr::extension_expr( |
332 | CompilerCB* ccb, |
333 | static_context* sctx, |
334 | @@ -1025,14 +1017,14 @@ |
335 | } |
336 | |
337 | |
338 | -expr* extension_expr::clone(substitution_t& subst) const |
339 | +expr* extension_expr::cloneImpl(substitution_t& subst) const |
340 | { |
341 | extension_expr* lClone(0); |
342 | lClone = ( |
343 | theExpr == 0 ? theCCB->theEM->create_extension_expr(theSctx, get_loc()) |
344 | : theCCB->theEM->create_extension_expr(theSctx, get_loc(), theExpr->clone()) ); |
345 | // pragm doesn't contain expressions. Thus, it is not cloned. |
346 | - for ( std::vector<rchandle<pragma> >::const_iterator lIter = thePragmas.begin(); |
347 | + for ( std::vector<pragma*>::const_iterator lIter = thePragmas.begin(); |
348 | lIter != thePragmas.end(); |
349 | ++lIter ) |
350 | { |
351 | @@ -1161,7 +1153,7 @@ |
352 | } |
353 | |
354 | |
355 | -expr* trycatch_expr::clone(substitution_t& subst) const |
356 | +expr* trycatch_expr::cloneImpl(substitution_t& subst) const |
357 | { |
358 | std::auto_ptr<trycatch_expr> lTryCatch( |
359 | theCCB->theEM->create_trycatch_expr(theSctx, get_loc(), theTryExpr->clone(subst))); |
360 | @@ -1228,7 +1220,7 @@ |
361 | } |
362 | |
363 | |
364 | -expr* eval_expr::clone(substitution_t& s) const |
365 | +expr* eval_expr::cloneImpl(substitution_t& s) const |
366 | { |
367 | eval_expr* new_eval = theCCB->theEM->create_eval_expr( |
368 | NULL, |
369 | @@ -1320,7 +1312,7 @@ |
370 | } |
371 | |
372 | |
373 | -expr* function_trace_expr::clone(substitution_t& s) const |
374 | +expr* function_trace_expr::cloneImpl(substitution_t& s) const |
375 | { |
376 | function_trace_expr* clone = theCCB->theEM-> |
377 | create_function_trace_expr(theExpr->clone(s)); |
378 | |
379 | === modified file 'src/compiler/expression/expr.h' |
380 | --- src/compiler/expression/expr.h 2012-09-17 00:36:37 +0000 |
381 | +++ src/compiler/expression/expr.h 2012-09-19 21:43:18 +0000 |
382 | @@ -46,6 +46,7 @@ |
383 | class expr_visitor; |
384 | class NodeNameTest; |
385 | class signature; |
386 | +class pragma; |
387 | |
388 | /******************************************************************************* |
389 | [68] IfExpr ::= "if" "(" Expr ")" "then" ExprSingle "else" ExprSingle |
390 | @@ -79,7 +80,7 @@ |
391 | |
392 | void compute_scripting_kind(); |
393 | |
394 | - expr* clone(substitution_t& s) const; |
395 | + expr* cloneImpl(substitution_t& s) const; |
396 | |
397 | void accept(expr_visitor&); |
398 | |
399 | @@ -117,7 +118,7 @@ |
400 | |
401 | void compute_scripting_kind(); |
402 | |
403 | - expr* clone(substitution_t& s) const; |
404 | + expr* cloneImpl(substitution_t& s) const; |
405 | |
406 | void accept(expr_visitor&); |
407 | |
408 | @@ -161,7 +162,7 @@ |
409 | |
410 | void compute_scripting_kind(); |
411 | |
412 | - expr* clone(substitution_t& s) const; |
413 | + expr* cloneImpl(substitution_t& s) const; |
414 | |
415 | void accept(expr_visitor&); |
416 | |
417 | @@ -264,7 +265,7 @@ |
418 | public: |
419 | bool is_optional() const; |
420 | |
421 | - expr* clone(substitution_t& s) const; |
422 | + expr* cloneImpl(substitution_t& s) const; |
423 | |
424 | void accept(expr_visitor&); |
425 | |
426 | @@ -318,7 +319,7 @@ |
427 | |
428 | store::Item_t get_qname() const { return theQName; } |
429 | |
430 | - expr* clone(substitution_t& s) const; |
431 | + expr* cloneImpl(substitution_t& s) const; |
432 | |
433 | void accept(expr_visitor&); |
434 | |
435 | @@ -382,7 +383,7 @@ |
436 | store::Item* qname); |
437 | |
438 | public: |
439 | - expr* clone(substitution_t& s) const; |
440 | + expr* cloneImpl(substitution_t& s) const; |
441 | |
442 | PromoteIterator::ErrorKind get_err() const { return theErrorKind; } |
443 | |
444 | @@ -436,7 +437,7 @@ |
445 | public: |
446 | bool is_optional() const; |
447 | |
448 | - expr* clone(substitution_t& s) const; |
449 | + expr* cloneImpl(substitution_t& s) const; |
450 | |
451 | void accept(expr_visitor&); |
452 | |
453 | @@ -474,7 +475,7 @@ |
454 | public: |
455 | bool getCheckPrimeOnly() const { return theCheckPrimeOnly; } |
456 | |
457 | - expr* clone(substitution_t& s) const; |
458 | + expr* cloneImpl(substitution_t& s) const; |
459 | |
460 | void accept(expr_visitor&); |
461 | |
462 | @@ -518,7 +519,7 @@ |
463 | |
464 | void compute_scripting_kind(); |
465 | |
466 | - expr* clone(substitution_t& s) const; |
467 | + expr* cloneImpl(substitution_t& s) const; |
468 | |
469 | void accept(expr_visitor&); |
470 | |
471 | @@ -551,7 +552,7 @@ |
472 | |
473 | void compute_scripting_kind(); |
474 | |
475 | - expr* clone(substitution_t& s) const; |
476 | + expr* cloneImpl(substitution_t& s) const; |
477 | |
478 | void accept(expr_visitor&); |
479 | |
480 | @@ -629,8 +630,8 @@ |
481 | void setCopyInputNodes() { theCopyInputNodes = true; } |
482 | |
483 | void compute_scripting_kind(); |
484 | - |
485 | - expr* clone(substitution_t& s) const; |
486 | + |
487 | + expr* cloneImpl(substitution_t& s) const; |
488 | |
489 | void accept(expr_visitor&); |
490 | |
491 | @@ -689,7 +690,7 @@ |
492 | |
493 | void compute_scripting_kind(); |
494 | |
495 | - expr* clone(substitution_t& s) const; |
496 | + expr* cloneImpl(substitution_t& s) const; |
497 | |
498 | void accept(expr_visitor&); |
499 | |
500 | @@ -732,7 +733,7 @@ |
501 | |
502 | void compute_scripting_kind(); |
503 | |
504 | - expr* clone(substitution_t& s) const; |
505 | + expr* cloneImpl(substitution_t& s) const; |
506 | |
507 | void accept(expr_visitor&); |
508 | |
509 | @@ -763,7 +764,7 @@ |
510 | |
511 | void compute_scripting_kind(); |
512 | |
513 | - expr* clone(substitution_t& s) const; |
514 | + expr* cloneImpl(substitution_t& s) const; |
515 | |
516 | void accept(expr_visitor&); |
517 | |
518 | @@ -807,7 +808,7 @@ |
519 | |
520 | void compute_scripting_kind(); |
521 | |
522 | - expr* clone(substitution_t& s) const; |
523 | + expr* cloneImpl(substitution_t& s) const; |
524 | |
525 | void accept(expr_visitor&); |
526 | |
527 | @@ -818,22 +819,6 @@ |
528 | /***************************************************************************//** |
529 | |
530 | ********************************************************************************/ |
531 | -class pragma : public SimpleRCObject |
532 | -{ |
533 | - friend class expr; |
534 | - |
535 | -public: |
536 | - store::Item_t theQName; |
537 | - std::string theContent; |
538 | - |
539 | -public: |
540 | - pragma(store::Item_t name, std::string const& content); |
541 | -}; |
542 | - |
543 | - |
544 | -/***************************************************************************//** |
545 | - |
546 | -********************************************************************************/ |
547 | class extension_expr : public expr |
548 | { |
549 | friend class ExprManager; |
550 | @@ -841,8 +826,8 @@ |
551 | friend class expr; |
552 | |
553 | protected: |
554 | - std::vector<rchandle<pragma> > thePragmas; |
555 | - expr* theExpr; |
556 | + std::vector<pragma*> thePragmas; |
557 | + expr* theExpr; |
558 | |
559 | protected: |
560 | extension_expr(CompilerCB* ccb, static_context* sctx, const QueryLoc&); |
561 | @@ -850,13 +835,13 @@ |
562 | extension_expr(CompilerCB* ccb, static_context* sctx, const QueryLoc&, expr*); |
563 | |
564 | public: |
565 | - void add(rchandle<pragma> p) { thePragmas.push_back(p); } |
566 | + void add(pragma* p) { thePragmas.push_back(p); } |
567 | |
568 | expr* get_expr() const { return theExpr; } |
569 | |
570 | void compute_scripting_kind(); |
571 | |
572 | - expr* clone(substitution_t& subst) const; |
573 | + expr* cloneImpl(substitution_t& subst) const; |
574 | |
575 | void accept(expr_visitor&); |
576 | |
577 | @@ -965,7 +950,7 @@ |
578 | |
579 | void compute_scripting_kind(); |
580 | |
581 | - expr* clone(substitution_t& subst) const; |
582 | + expr* cloneImpl(substitution_t& subst) const; |
583 | |
584 | void accept(expr_visitor&); |
585 | |
586 | @@ -1005,7 +990,7 @@ |
587 | |
588 | void accept(expr_visitor&); |
589 | |
590 | - expr* clone(substitution_t& s) const; |
591 | + expr* cloneImpl(substitution_t& s) const; |
592 | |
593 | std::ostream& put(std::ostream&) const; |
594 | }; |
595 | @@ -1043,7 +1028,7 @@ |
596 | |
597 | void accept(expr_visitor&); |
598 | |
599 | - expr* clone(substitution_t& s) const; |
600 | + expr* cloneImpl(substitution_t& s) const; |
601 | |
602 | std::ostream& put(std::ostream&) const; |
603 | |
604 | @@ -1167,7 +1152,7 @@ |
605 | |
606 | void accept(expr_visitor&); |
607 | |
608 | - expr* clone(substitution_t& s) const; |
609 | + expr* cloneImpl(substitution_t& s) const; |
610 | |
611 | std::ostream& put(std::ostream&) const; |
612 | }; |
613 | |
614 | === modified file 'src/compiler/expression/expr_base.cpp' |
615 | --- src/compiler/expression/expr_base.cpp 2012-09-17 00:36:37 +0000 |
616 | +++ src/compiler/expression/expr_base.cpp 2012-09-19 21:43:18 +0000 |
617 | @@ -248,6 +248,24 @@ |
618 | |
619 | expr* expr::clone(substitution_t& subst) const |
620 | { |
621 | + expr* lNewExpr = cloneImpl(subst); |
622 | + |
623 | + if (containsPragma()) |
624 | + { |
625 | + lNewExpr->setContainsPragma(ANNOTATION_TRUE); |
626 | + std::vector<pragma*> lPragmas; |
627 | + theCCB->lookup_pragmas(this, lPragmas); |
628 | + for (size_t i = 0; i < lPragmas.size(); ++i) |
629 | + { |
630 | + theCCB->add_pragma(lNewExpr, lPragmas[i]); |
631 | + } |
632 | + } |
633 | + return lNewExpr; |
634 | +} |
635 | + |
636 | + |
637 | +expr* expr::cloneImpl(substitution_t& subst) const |
638 | +{ |
639 | throw XQUERY_EXCEPTION(zerr::ZXQP0003_INTERNAL_ERROR, ERROR_LOC(get_loc())); |
640 | } |
641 | |
642 | @@ -545,6 +563,30 @@ |
643 | |
644 | |
645 | /******************************************************************************* |
646 | + |
647 | +********************************************************************************/ |
648 | +BoolAnnotationValue expr::getContainsPragma() const |
649 | +{ |
650 | + return (BoolAnnotationValue) |
651 | + ((theFlags1 & CONTAINS_PRAGMA_MASK) >> CONTAINS_PRAGMA); |
652 | +} |
653 | + |
654 | + |
655 | +void expr::setContainsPragma(BoolAnnotationValue v) |
656 | +{ |
657 | + theFlags1 &= ~CONTAINS_PRAGMA_MASK; |
658 | + theFlags1 |= (v << CONTAINS_PRAGMA); |
659 | +} |
660 | + |
661 | + |
662 | +bool expr::containsPragma() const |
663 | +{ |
664 | + BoolAnnotationValue v = getContainsPragma(); |
665 | + return (v == ANNOTATION_TRUE || v == ANNOTATION_TRUE_FIXED); |
666 | +} |
667 | + |
668 | + |
669 | +/******************************************************************************* |
670 | This annotation tells whether the expr must produce nodes that belong to |
671 | "standalone" trees or not. A tree is standalone if it does not contain |
672 | references to other trees. Such references are created when the optimizer |
673 | |
674 | === modified file 'src/compiler/expression/expr_base.h' |
675 | --- src/compiler/expression/expr_base.h 2012-09-17 00:36:37 +0000 |
676 | +++ src/compiler/expression/expr_base.h 2012-09-19 21:43:18 +0000 |
677 | @@ -148,7 +148,8 @@ |
678 | CONTAINS_RECURSIVE_CALL = 12, |
679 | PROPAGATES_INPUT_NODES = 14, |
680 | WILL_BE_SERIALIZED = 16, |
681 | - MUST_COPY_NODES = 18 |
682 | + MUST_COPY_NODES = 18, |
683 | + CONTAINS_PRAGMA = 20 |
684 | } Annotationkey; |
685 | |
686 | typedef enum |
687 | @@ -162,7 +163,8 @@ |
688 | CONTAINS_RECURSIVE_CALL_MASK = 0x3000, |
689 | PROPAGATES_INPUT_NODES_MASK = 0xC000, |
690 | WILL_BE_SERIALIZED_MASK = 0x30000, |
691 | - MUST_COPY_NODES_MASK = 0xC0000 |
692 | + MUST_COPY_NODES_MASK = 0xC0000, |
693 | + CONTAINS_PRAGMA_MASK = 0x300000 |
694 | } AnnotationMask; |
695 | |
696 | |
697 | @@ -241,7 +243,9 @@ |
698 | |
699 | expr* clone() const; |
700 | |
701 | - virtual expr* clone(substitution_t& substitution) const; |
702 | + expr* clone(substitution_t&) const; |
703 | + |
704 | + virtual expr* cloneImpl(substitution_t& substitution) const; |
705 | |
706 | virtual void accept(expr_visitor& v) = 0; |
707 | |
708 | @@ -318,6 +322,13 @@ |
709 | |
710 | bool willBeSerialized() const; |
711 | |
712 | + // Annotation : containsPragma |
713 | + BoolAnnotationValue getContainsPragma() const; |
714 | + |
715 | + void setContainsPragma(BoolAnnotationValue v); |
716 | + |
717 | + bool containsPragma() const; |
718 | + |
719 | // Annotation : free vars |
720 | const FreeVars& getFreeVars() const { return theFreeVars; } |
721 | |
722 | |
723 | === modified file 'src/compiler/expression/expr_manager.cpp' |
724 | --- src/compiler/expression/expr_manager.cpp 2012-09-19 16:26:55 +0000 |
725 | +++ src/compiler/expression/expr_manager.cpp 2012-09-19 21:43:18 +0000 |
726 | @@ -30,6 +30,7 @@ |
727 | #include "script_exprs.h" |
728 | #include "update_exprs.h" |
729 | #include "json_exprs.h" |
730 | +#include "pragma.h" |
731 | |
732 | namespace zorba |
733 | { |
734 | @@ -152,6 +153,15 @@ |
735 | clause->~copy_clause(); |
736 | // new (clause) NullCopyClause(); |
737 | } |
738 | + |
739 | + for(std::vector<pragma*>::iterator iter = thePragmas.begin(); |
740 | + iter != thePragmas.end(); |
741 | + ++iter) |
742 | + { |
743 | + pragma* pragma = *iter; |
744 | + pragma->~pragma(); |
745 | + // new (clause) NullCopyClause(); |
746 | + } |
747 | } |
748 | |
749 | |
750 | @@ -185,6 +195,12 @@ |
751 | } |
752 | |
753 | |
754 | +void ExprManager::reg(pragma* pragma) |
755 | +{ |
756 | + thePragmas.push_back(pragma); |
757 | +} |
758 | + |
759 | + |
760 | //////////////////////////////////////////////////////////////////////////////// |
761 | |
762 | #define CREATE_AND_RETURN_EXPR(EXPRTYPE, ...) \ |
763 | @@ -940,6 +956,13 @@ |
764 | CREATE_AND_RETURN_EXPR(flwor_expr, sctx, loc, general); |
765 | } |
766 | |
767 | +pragma* ExprManager::create_pragma( |
768 | + const store::Item_t& name, |
769 | + const zstring& lit) |
770 | +{ |
771 | + CREATE_AND_RETURN(pragma, name, lit); |
772 | +} |
773 | + |
774 | //////////////////////////////////////////////////////////////////////////////// |
775 | |
776 | |
777 | |
778 | === modified file 'src/compiler/expression/expr_manager.h' |
779 | --- src/compiler/expression/expr_manager.h 2012-09-17 00:36:37 +0000 |
780 | +++ src/compiler/expression/expr_manager.h 2012-09-19 21:43:18 +0000 |
781 | @@ -39,6 +39,7 @@ |
782 | std::vector<flwor_wincond*> theWinconds; |
783 | std::vector<catch_clause*> theCatchClauses; |
784 | std::vector<copy_clause*> theCopyClauses; |
785 | + std::vector<pragma*> thePragmas; |
786 | MemoryManager theMemoryMgr; |
787 | CompilerCB *const theCCB; |
788 | |
789 | @@ -57,6 +58,8 @@ |
790 | |
791 | void reg(copy_clause*); |
792 | |
793 | + void reg(pragma*); |
794 | + |
795 | private: |
796 | //An ExprManager is the only object to handle a collection of Exprs and |
797 | //the memory in which they recide. Copying it in a senseful way would. |
798 | @@ -510,6 +513,10 @@ |
799 | static_context* sctx, |
800 | const QueryLoc& loc, |
801 | bool general); |
802 | + |
803 | + pragma* create_pragma( |
804 | + const store::Item_t&, |
805 | + const zstring&); |
806 | }; |
807 | |
808 | //////////////////////////////////////////////////////////////////////////////// |
809 | |
810 | === modified file 'src/compiler/expression/expr_put.cpp' |
811 | --- src/compiler/expression/expr_put.cpp 2012-09-17 00:36:37 +0000 |
812 | +++ src/compiler/expression/expr_put.cpp 2012-09-19 21:43:18 +0000 |
813 | @@ -40,6 +40,7 @@ |
814 | #include "compiler/expression/var_expr.h" |
815 | #include "compiler/expression/flwor_expr.h" |
816 | #include "compiler/expression/function_item_expr.h" |
817 | +#include "compiler/expression/pragma.h" |
818 | #include "compiler/parser/parse_constants.h" |
819 | |
820 | #include "diagnostics/assert.h" |
821 | |
822 | === modified file 'src/compiler/expression/flwor_expr.cpp' |
823 | --- src/compiler/expression/flwor_expr.cpp 2012-09-17 00:36:37 +0000 |
824 | +++ src/compiler/expression/flwor_expr.cpp 2012-09-19 21:43:18 +0000 |
825 | @@ -1163,7 +1163,7 @@ |
826 | /******************************************************************************* |
827 | |
828 | ********************************************************************************/ |
829 | -expr* flwor_expr::clone(substitution_t& subst) const |
830 | +expr* flwor_expr::cloneImpl(substitution_t& subst) const |
831 | { |
832 | ulong numClauses = num_clauses(); |
833 | |
834 | |
835 | === modified file 'src/compiler/expression/flwor_expr.h' |
836 | --- src/compiler/expression/flwor_expr.h 2012-09-17 00:36:37 +0000 |
837 | +++ src/compiler/expression/flwor_expr.h 2012-09-19 21:43:18 +0000 |
838 | @@ -702,7 +702,7 @@ |
839 | |
840 | void get_vars_defined(std::vector<var_expr*>& varExprs) const; |
841 | |
842 | - expr* clone(substitution_t& substitution) const; |
843 | + expr* cloneImpl(substitution_t& substitution) const; |
844 | |
845 | // The following 5 methods are for the simple flwor only. They should be |
846 | // removed eventually. |
847 | |
848 | === modified file 'src/compiler/expression/fo_expr.cpp' |
849 | --- src/compiler/expression/fo_expr.cpp 2012-09-17 00:36:37 +0000 |
850 | +++ src/compiler/expression/fo_expr.cpp 2012-09-19 21:43:18 +0000 |
851 | @@ -266,7 +266,7 @@ |
852 | } |
853 | |
854 | |
855 | -expr* fo_expr::clone(substitution_t& subst) const |
856 | +expr* fo_expr::cloneImpl(substitution_t& subst) const |
857 | { |
858 | if (get_func()->getKind() == FunctionConsts::STATIC_COLLECTIONS_DML_COLLECTION_1) |
859 | { |
860 | |
861 | === modified file 'src/compiler/expression/fo_expr.h' |
862 | --- src/compiler/expression/fo_expr.h 2012-09-17 00:36:37 +0000 |
863 | +++ src/compiler/expression/fo_expr.h 2012-09-19 21:43:18 +0000 |
864 | @@ -93,7 +93,7 @@ |
865 | |
866 | void compute_scripting_kind(); |
867 | |
868 | - expr* clone(substitution_t& s) const; |
869 | + expr* cloneImpl(substitution_t& s) const; |
870 | |
871 | void accept(expr_visitor&); |
872 | |
873 | |
874 | === modified file 'src/compiler/expression/ft_expr.cpp' |
875 | --- src/compiler/expression/ft_expr.cpp 2012-09-17 00:36:37 +0000 |
876 | +++ src/compiler/expression/ft_expr.cpp 2012-09-19 21:43:18 +0000 |
877 | @@ -59,7 +59,7 @@ |
878 | v.end_visit( *this ); |
879 | } |
880 | |
881 | -expr* ftcontains_expr::clone( substitution_t &s ) const { |
882 | +expr* ftcontains_expr::cloneImpl( substitution_t &s ) const { |
883 | return theCCB->theEM->create_ftcontains_expr( |
884 | theSctx, get_loc(), |
885 | range_->clone( s ), |
886 | |
887 | === modified file 'src/compiler/expression/ft_expr.h' |
888 | --- src/compiler/expression/ft_expr.h 2012-09-17 00:36:37 +0000 |
889 | +++ src/compiler/expression/ft_expr.h 2012-09-19 21:43:18 +0000 |
890 | @@ -43,7 +43,8 @@ |
891 | ); |
892 | |
893 | public: |
894 | - expr* clone( substitution_t& ) const; |
895 | + expr* cloneImpl( substitution_t& ) const; |
896 | + |
897 | void compute_scripting_kind(); |
898 | |
899 | expr* get_range() const { return range_; } |
900 | |
901 | === modified file 'src/compiler/expression/function_item_expr.cpp' |
902 | --- src/compiler/expression/function_item_expr.cpp 2012-09-17 00:36:37 +0000 |
903 | +++ src/compiler/expression/function_item_expr.cpp 2012-09-19 21:43:18 +0000 |
904 | @@ -56,7 +56,7 @@ |
905 | } |
906 | |
907 | |
908 | -expr* dynamic_function_invocation_expr::clone(substitution_t& s) const |
909 | +expr* dynamic_function_invocation_expr::cloneImpl(substitution_t& s) const |
910 | { |
911 | checked_vector<expr*> lNewArgs; |
912 | for (checked_vector<expr*>::const_iterator lIter = theArgs.begin(); |
913 | @@ -144,7 +144,7 @@ |
914 | } |
915 | |
916 | |
917 | -expr* function_item_expr::clone(substitution_t& s) const |
918 | +expr* function_item_expr::cloneImpl(substitution_t& s) const |
919 | { |
920 | std::auto_ptr<function_item_expr> lNewExpr( |
921 | theCCB->theEM->create_function_item_expr(theSctx, |
922 | |
923 | === modified file 'src/compiler/expression/function_item_expr.h' |
924 | --- src/compiler/expression/function_item_expr.h 2012-09-17 00:36:37 +0000 |
925 | +++ src/compiler/expression/function_item_expr.h 2012-09-19 21:43:18 +0000 |
926 | @@ -59,7 +59,7 @@ |
927 | |
928 | void compute_scripting_kind(); |
929 | |
930 | - expr* clone(substitution_t& s) const; |
931 | + expr* cloneImpl(substitution_t& s) const; |
932 | |
933 | void accept(expr_visitor&); |
934 | |
935 | @@ -143,7 +143,7 @@ |
936 | |
937 | void compute_scripting_kind(); |
938 | |
939 | - expr* clone(substitution_t& s) const; |
940 | + expr* cloneImpl(substitution_t& s) const; |
941 | |
942 | void accept(expr_visitor&); |
943 | |
944 | |
945 | === modified file 'src/compiler/expression/json_exprs.cpp' |
946 | --- src/compiler/expression/json_exprs.cpp 2012-09-17 00:36:37 +0000 |
947 | +++ src/compiler/expression/json_exprs.cpp 2012-09-19 21:43:18 +0000 |
948 | @@ -60,7 +60,7 @@ |
949 | } |
950 | |
951 | |
952 | -expr* json_array_expr::clone(substitution_t& subst) const |
953 | +expr* json_array_expr::cloneImpl(substitution_t& subst) const |
954 | { |
955 | return theCCB->theEM-> |
956 | create_json_array_expr(theSctx, |
957 | @@ -108,7 +108,7 @@ |
958 | } |
959 | |
960 | |
961 | -expr* json_object_expr::clone(substitution_t& subst) const |
962 | +expr* json_object_expr::cloneImpl(substitution_t& subst) const |
963 | { |
964 | return theCCB->theEM-> |
965 | create_json_object_expr(theSctx, |
966 | @@ -175,7 +175,7 @@ |
967 | } |
968 | |
969 | |
970 | -expr* json_direct_object_expr::clone(substitution_t& subst) const |
971 | +expr* json_direct_object_expr::cloneImpl(substitution_t& subst) const |
972 | { |
973 | std::vector<expr*> names; |
974 | std::vector<expr*> values; |
975 | |
976 | === modified file 'src/compiler/expression/json_exprs.h' |
977 | --- src/compiler/expression/json_exprs.h 2012-09-17 00:36:37 +0000 |
978 | +++ src/compiler/expression/json_exprs.h 2012-09-19 21:43:18 +0000 |
979 | @@ -53,7 +53,7 @@ |
980 | |
981 | void compute_scripting_kind(); |
982 | |
983 | - expr* clone(substitution_t& s) const; |
984 | + expr* cloneImpl(substitution_t& s) const; |
985 | |
986 | void accept(expr_visitor&); |
987 | |
988 | @@ -92,7 +92,7 @@ |
989 | |
990 | void compute_scripting_kind(); |
991 | |
992 | - expr* clone(substitution_t& s) const; |
993 | + expr* cloneImpl(substitution_t& s) const; |
994 | |
995 | void accept(expr_visitor&); |
996 | |
997 | @@ -134,7 +134,7 @@ |
998 | |
999 | void compute_scripting_kind(); |
1000 | |
1001 | - expr* clone(substitution_t& s) const; |
1002 | + expr* cloneImpl(substitution_t& s) const; |
1003 | |
1004 | void accept(expr_visitor&); |
1005 | |
1006 | |
1007 | === modified file 'src/compiler/expression/path_expr.cpp' |
1008 | --- src/compiler/expression/path_expr.cpp 2012-09-17 00:36:37 +0000 |
1009 | +++ src/compiler/expression/path_expr.cpp 2012-09-19 21:43:18 +0000 |
1010 | @@ -100,7 +100,7 @@ |
1011 | } |
1012 | |
1013 | |
1014 | -expr* relpath_expr::clone(substitution_t& subst) const |
1015 | +expr* relpath_expr::cloneImpl(substitution_t& subst) const |
1016 | { |
1017 | std::auto_ptr<relpath_expr> re(theCCB->theEM->create_relpath_expr(theSctx, get_loc())); |
1018 | |
1019 | @@ -148,7 +148,7 @@ |
1020 | } |
1021 | |
1022 | |
1023 | -expr* axis_step_expr::clone(substitution_t& subst) const |
1024 | +expr* axis_step_expr::cloneImpl(substitution_t& subst) const |
1025 | { |
1026 | axis_step_expr* ae = theCCB->theEM->create_axis_step_expr(theSctx, get_loc()); |
1027 | ae->setAxis(getAxis()); |
1028 | @@ -220,7 +220,7 @@ |
1029 | } |
1030 | |
1031 | |
1032 | -expr* match_expr::clone(substitution_t& subst) const |
1033 | +expr* match_expr::cloneImpl(substitution_t& subst) const |
1034 | { |
1035 | match_expr* me = theCCB->theEM->create_match_expr(theSctx, get_loc()); |
1036 | me->setTestKind(getTestKind()); |
1037 | |
1038 | === modified file 'src/compiler/expression/path_expr.h' |
1039 | --- src/compiler/expression/path_expr.h 2012-09-17 00:36:37 +0000 |
1040 | +++ src/compiler/expression/path_expr.h 2012-09-19 21:43:18 +0000 |
1041 | @@ -78,7 +78,7 @@ |
1042 | |
1043 | void compute_scripting_kind(); |
1044 | |
1045 | - expr* clone(substitution_t &) const; |
1046 | + expr* cloneImpl(substitution_t &) const; |
1047 | |
1048 | void accept(expr_visitor&); |
1049 | |
1050 | @@ -135,7 +135,7 @@ |
1051 | |
1052 | void compute_scripting_kind(); |
1053 | |
1054 | - expr* clone(substitution_t &) const; |
1055 | + expr* cloneImpl(substitution_t &) const; |
1056 | |
1057 | void accept(expr_visitor&); |
1058 | |
1059 | @@ -213,7 +213,7 @@ |
1060 | |
1061 | void compute_scripting_kind(); |
1062 | |
1063 | - expr* clone(substitution_t &) const; |
1064 | + expr* cloneImpl(substitution_t &) const; |
1065 | |
1066 | void accept(expr_visitor&); |
1067 | |
1068 | |
1069 | === added file 'src/compiler/expression/pragma.cpp' |
1070 | --- src/compiler/expression/pragma.cpp 1970-01-01 00:00:00 +0000 |
1071 | +++ src/compiler/expression/pragma.cpp 2012-09-19 21:43:18 +0000 |
1072 | @@ -0,0 +1,37 @@ |
1073 | +/* |
1074 | + * Copyright 2006-2012 The FLWOR Foundation. |
1075 | + * |
1076 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
1077 | + * you may not use this file except in compliance with the License. |
1078 | + * You may obtain a copy of the License at |
1079 | + * |
1080 | + * http://www.apache.org/licenses/LICENSE-2.0 |
1081 | + * |
1082 | + * Unless required by applicable law or agreed to in writing, software |
1083 | + * distributed under the License is distributed on an "AS IS" BASIS, |
1084 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
1085 | + * See the License for the specific language governing permissions and |
1086 | + * limitations under the License. |
1087 | + */ |
1088 | +#include "pragma.h" |
1089 | +#include "zorbatypes/rchandle.h" |
1090 | +#include "store/api/item.h" |
1091 | + |
1092 | +namespace zorba |
1093 | +{ |
1094 | + |
1095 | +/******************************************************************************* |
1096 | + |
1097 | +*******************************************************************************/ |
1098 | +pragma::pragma(const store::Item_t& name, zstring const& content) |
1099 | + : |
1100 | + theQName(name), |
1101 | + theContent(content) |
1102 | +{ |
1103 | +} |
1104 | + |
1105 | +pragma::~pragma() |
1106 | +{ |
1107 | +} |
1108 | + |
1109 | +} |
1110 | |
1111 | === added file 'src/compiler/expression/pragma.h' |
1112 | --- src/compiler/expression/pragma.h 1970-01-01 00:00:00 +0000 |
1113 | +++ src/compiler/expression/pragma.h 2012-09-19 21:43:18 +0000 |
1114 | @@ -0,0 +1,44 @@ |
1115 | +/* |
1116 | + * Copyright 2006-2012 The FLWOR Foundation. |
1117 | + * |
1118 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
1119 | + * you may not use this file except in compliance with the License. |
1120 | + * You may obtain a copy of the License at |
1121 | + * |
1122 | + * http://www.apache.org/licenses/LICENSE-2.0 |
1123 | + * |
1124 | + * Unless required by applicable law or agreed to in writing, software |
1125 | + * distributed under the License is distributed on an "AS IS" BASIS, |
1126 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
1127 | + * See the License for the specific language governing permissions and |
1128 | + * limitations under the License. |
1129 | + */ |
1130 | +#pragma once |
1131 | +#ifndef ZORBA_COMPILER_PRAGMA_H |
1132 | +#define ZORBA_COMPILER_PRAGMA_H |
1133 | + |
1134 | +#include "store/api/item.h" |
1135 | + |
1136 | +namespace zorba |
1137 | +{ |
1138 | + |
1139 | +/***************************************************************************//** |
1140 | + |
1141 | +********************************************************************************/ |
1142 | +class pragma |
1143 | +{ |
1144 | + friend class expr; |
1145 | + |
1146 | +public: |
1147 | + store::Item_t theQName; |
1148 | + zstring theContent; |
1149 | + |
1150 | +public: |
1151 | + pragma(const store::Item_t& name, zstring const& content); |
1152 | + |
1153 | + ~pragma(); |
1154 | +}; |
1155 | + |
1156 | +} /* namespace zorba */ |
1157 | + |
1158 | +#endif |
1159 | |
1160 | === modified file 'src/compiler/expression/script_exprs.cpp' |
1161 | --- src/compiler/expression/script_exprs.cpp 2012-09-17 00:36:37 +0000 |
1162 | +++ src/compiler/expression/script_exprs.cpp 2012-09-19 21:43:18 +0000 |
1163 | @@ -166,7 +166,7 @@ |
1164 | } |
1165 | |
1166 | |
1167 | -expr* block_expr::clone(substitution_t& subst) const |
1168 | +expr* block_expr::cloneImpl(substitution_t& subst) const |
1169 | { |
1170 | checked_vector<expr*> seq2; |
1171 | for (csize i = 0; i < theArgs.size(); ++i) |
1172 | @@ -205,7 +205,7 @@ |
1173 | } |
1174 | |
1175 | |
1176 | -expr* apply_expr::clone(substitution_t& subst) const |
1177 | +expr* apply_expr::cloneImpl(substitution_t& subst) const |
1178 | { |
1179 | return theCCB->theEM->create_apply_expr(theSctx, get_loc(), theExpr->clone(subst), theDiscardXDM); |
1180 | } |
1181 | @@ -262,7 +262,7 @@ |
1182 | } |
1183 | |
1184 | |
1185 | -expr* var_decl_expr::clone(substitution_t& s) const |
1186 | +expr* var_decl_expr::cloneImpl(substitution_t& s) const |
1187 | { |
1188 | var_expr* varCopy = theCCB->theEM->create_var_expr(*theVarExpr); |
1189 | s[theVarExpr] = varCopy; |
1190 | @@ -319,7 +319,7 @@ |
1191 | } |
1192 | |
1193 | |
1194 | -expr* var_set_expr::clone(substitution_t& s) const |
1195 | +expr* var_set_expr::cloneImpl(substitution_t& s) const |
1196 | { |
1197 | expr* varClone = theVarExpr->clone(s); |
1198 | |
1199 | @@ -368,7 +368,7 @@ |
1200 | } |
1201 | |
1202 | |
1203 | -expr* exit_expr::clone(substitution_t& subst) const |
1204 | +expr* exit_expr::cloneImpl(substitution_t& subst) const |
1205 | { |
1206 | expr* clone = theCCB->theEM->create_exit_expr(theSctx, get_loc(), get_expr()->clone(subst)); |
1207 | |
1208 | @@ -438,7 +438,7 @@ |
1209 | } |
1210 | |
1211 | |
1212 | -expr* exit_catcher_expr::clone(substitution_t& subst) const |
1213 | +expr* exit_catcher_expr::cloneImpl(substitution_t& subst) const |
1214 | { |
1215 | expr* clonedInput = get_expr()->clone(subst); |
1216 | |
1217 | @@ -479,7 +479,7 @@ |
1218 | } |
1219 | |
1220 | |
1221 | -expr* flowctl_expr::clone(substitution_t& subst) const |
1222 | +expr* flowctl_expr::cloneImpl(substitution_t& subst) const |
1223 | { |
1224 | return theCCB->theEM->create_flowctl_expr(theSctx, get_loc(), get_action()); |
1225 | } |
1226 | @@ -524,7 +524,7 @@ |
1227 | } |
1228 | |
1229 | |
1230 | -expr* while_expr::clone(substitution_t& subst) const |
1231 | +expr* while_expr::cloneImpl(substitution_t& subst) const |
1232 | { |
1233 | return theCCB->theEM->create_while_expr(theSctx, get_loc(), get_body()->clone(subst)); |
1234 | } |
1235 | |
1236 | === modified file 'src/compiler/expression/script_exprs.h' |
1237 | --- src/compiler/expression/script_exprs.h 2012-09-17 00:36:37 +0000 |
1238 | +++ src/compiler/expression/script_exprs.h 2012-09-19 21:43:18 +0000 |
1239 | @@ -130,7 +130,7 @@ |
1240 | |
1241 | expr* operator[](csize i) { return theArgs[i]; } |
1242 | |
1243 | - expr* clone(substitution_t& s) const; |
1244 | + expr* cloneImpl(substitution_t& s) const; |
1245 | |
1246 | void accept(expr_visitor&); |
1247 | |
1248 | @@ -173,7 +173,7 @@ |
1249 | |
1250 | void compute_scripting_kind(); |
1251 | |
1252 | - expr* clone(substitution_t& s) const; |
1253 | + expr* cloneImpl(substitution_t& s) const; |
1254 | |
1255 | void accept(expr_visitor&); |
1256 | |
1257 | @@ -236,7 +236,7 @@ |
1258 | |
1259 | void compute_scripting_kind(); |
1260 | |
1261 | - expr* clone(substitution_t& s) const; |
1262 | + expr* cloneImpl(substitution_t& s) const; |
1263 | |
1264 | void accept(expr_visitor&); |
1265 | |
1266 | @@ -282,7 +282,7 @@ |
1267 | |
1268 | void compute_scripting_kind(); |
1269 | |
1270 | - expr* clone(substitution_t& s) const; |
1271 | + expr* cloneImpl(substitution_t& s) const; |
1272 | |
1273 | void accept(expr_visitor&); |
1274 | |
1275 | @@ -320,7 +320,7 @@ |
1276 | |
1277 | void compute_scripting_kind(); |
1278 | |
1279 | - expr* clone(substitution_t& s) const; |
1280 | + expr* cloneImpl(substitution_t& s) const; |
1281 | |
1282 | void accept(expr_visitor&); |
1283 | |
1284 | @@ -379,7 +379,7 @@ |
1285 | |
1286 | void compute_scripting_kind(); |
1287 | |
1288 | - expr* clone(substitution_t& s) const; |
1289 | + expr* cloneImpl(substitution_t& s) const; |
1290 | |
1291 | void accept(expr_visitor&); |
1292 | |
1293 | @@ -408,7 +408,7 @@ |
1294 | public: |
1295 | enum action get_action() const { return theAction; } |
1296 | |
1297 | - expr* clone(substitution_t& s) const; |
1298 | + expr* cloneImpl(substitution_t& s) const; |
1299 | |
1300 | void compute_scripting_kind(); |
1301 | |
1302 | @@ -442,7 +442,7 @@ |
1303 | |
1304 | void compute_scripting_kind(); |
1305 | |
1306 | - expr* clone(substitution_t& s) const; |
1307 | + expr* cloneImpl(substitution_t& s) const; |
1308 | |
1309 | void accept(expr_visitor&); |
1310 | |
1311 | |
1312 | === modified file 'src/compiler/expression/update_exprs.cpp' |
1313 | --- src/compiler/expression/update_exprs.cpp 2012-09-17 00:36:37 +0000 |
1314 | +++ src/compiler/expression/update_exprs.cpp 2012-09-19 21:43:18 +0000 |
1315 | @@ -82,7 +82,7 @@ |
1316 | } |
1317 | |
1318 | |
1319 | -expr* insert_expr::clone(substitution_t& subst) const |
1320 | +expr* insert_expr::cloneImpl(substitution_t& subst) const |
1321 | { |
1322 | return theCCB->theEM->create_insert_expr(theSctx, |
1323 | get_loc(), |
1324 | @@ -106,7 +106,7 @@ |
1325 | } |
1326 | |
1327 | |
1328 | -expr* delete_expr::clone(substitution_t& subst) const |
1329 | +expr* delete_expr::cloneImpl(substitution_t& subst) const |
1330 | { |
1331 | return theCCB->theEM->create_delete_expr(theSctx, get_loc(), getTargetExpr()->clone(subst)); |
1332 | } |
1333 | @@ -129,7 +129,7 @@ |
1334 | } |
1335 | |
1336 | |
1337 | -expr* replace_expr::clone(substitution_t& subst) const |
1338 | +expr* replace_expr::cloneImpl(substitution_t& subst) const |
1339 | { |
1340 | return theCCB->theEM->create_replace_expr(theSctx, |
1341 | get_loc(), |
1342 | @@ -154,7 +154,7 @@ |
1343 | } |
1344 | |
1345 | |
1346 | -expr* rename_expr::clone(substitution_t& subst) const |
1347 | +expr* rename_expr::cloneImpl(substitution_t& subst) const |
1348 | { |
1349 | return theCCB->theEM->create_rename_expr(theSctx, |
1350 | get_loc(), |
1351 | @@ -247,7 +247,7 @@ |
1352 | } |
1353 | |
1354 | |
1355 | -expr* transform_expr::clone(substitution_t& subst) const |
1356 | +expr* transform_expr::cloneImpl(substitution_t& subst) const |
1357 | { |
1358 | ZORBA_ASSERT(theModifyExpr && theReturnExpr); |
1359 | |
1360 | |
1361 | === modified file 'src/compiler/expression/update_exprs.h' |
1362 | --- src/compiler/expression/update_exprs.h 2012-09-17 00:36:37 +0000 |
1363 | +++ src/compiler/expression/update_exprs.h 2012-09-19 21:43:18 +0000 |
1364 | @@ -84,8 +84,8 @@ |
1365 | |
1366 | public: |
1367 | store::UpdateConsts::InsertType getType() const { return theType; } |
1368 | - |
1369 | - expr* clone(substitution_t& s) const; |
1370 | + |
1371 | + expr* cloneImpl(substitution_t& s) const; |
1372 | |
1373 | void accept(expr_visitor&); |
1374 | |
1375 | @@ -107,7 +107,7 @@ |
1376 | delete_expr(CompilerCB* ccb, static_context* sctx, const QueryLoc&, expr*); |
1377 | |
1378 | public: |
1379 | - expr* clone(substitution_t& s) const; |
1380 | + expr* cloneImpl(substitution_t& s) const; |
1381 | |
1382 | void accept(expr_visitor&); |
1383 | |
1384 | @@ -141,7 +141,7 @@ |
1385 | |
1386 | expr* getReplaceExpr() const { return theSourceExpr; } |
1387 | |
1388 | - expr* clone(substitution_t& s) const; |
1389 | + expr* cloneImpl(substitution_t& s) const; |
1390 | |
1391 | void accept(expr_visitor&); |
1392 | |
1393 | @@ -167,9 +167,9 @@ |
1394 | expr*); |
1395 | |
1396 | public: |
1397 | - expr* getNameExpr() const { return theSourceExpr; } |
1398 | + expr* getNameExpr() const { return theSourceExpr; } |
1399 | |
1400 | - expr* clone(substitution_t& s) const; |
1401 | + expr* cloneImpl(substitution_t& s) const; |
1402 | |
1403 | void accept(expr_visitor&); |
1404 | |
1405 | @@ -249,7 +249,7 @@ |
1406 | |
1407 | void compute_scripting_kind(); |
1408 | |
1409 | - expr* clone(substitution_t& s) const; |
1410 | + expr* cloneImpl(substitution_t& s) const; |
1411 | |
1412 | void accept(expr_visitor&); |
1413 | |
1414 | |
1415 | === modified file 'src/compiler/expression/var_expr.cpp' |
1416 | --- src/compiler/expression/var_expr.cpp 2012-09-17 00:36:37 +0000 |
1417 | +++ src/compiler/expression/var_expr.cpp 2012-09-19 21:43:18 +0000 |
1418 | @@ -336,7 +336,7 @@ |
1419 | /******************************************************************************* |
1420 | |
1421 | ********************************************************************************/ |
1422 | -expr* var_expr::clone(expr::substitution_t& subst) const |
1423 | +expr* var_expr::cloneImpl(expr::substitution_t& subst) const |
1424 | { |
1425 | expr::subst_iter_t i = subst.find(this); |
1426 | |
1427 | |
1428 | === modified file 'src/compiler/expression/var_expr.h' |
1429 | --- src/compiler/expression/var_expr.h 2012-09-17 00:36:37 +0000 |
1430 | +++ src/compiler/expression/var_expr.h 2012-09-19 21:43:18 +0000 |
1431 | @@ -265,7 +265,7 @@ |
1432 | |
1433 | void compute_scripting_kind(); |
1434 | |
1435 | - expr* clone(substitution_t& subst) const; |
1436 | + expr* cloneImpl(substitution_t& subst) const; |
1437 | |
1438 | void accept(expr_visitor&); |
1439 | |
1440 | |
1441 | === modified file 'src/compiler/translator/translator.cpp' |
1442 | --- src/compiler/translator/translator.cpp 2012-09-18 22:11:29 +0000 |
1443 | +++ src/compiler/translator/translator.cpp 2012-09-19 21:43:18 +0000 |
1444 | @@ -56,6 +56,7 @@ |
1445 | #include "compiler/expression/flwor_expr.h" |
1446 | #include "compiler/expression/path_expr.h" |
1447 | #include "compiler/expression/function_item_expr.h" |
1448 | +#include "compiler/expression/pragma.h" |
1449 | #include "compiler/rewriter/framework/rewriter_context.h" |
1450 | #include "compiler/rewriter/framework/rewriter.h" |
1451 | #include "compiler/xqddf/value_index.h" |
1452 | @@ -641,6 +642,8 @@ |
1453 | |
1454 | std::vector<var_expr*> theScopedVars; |
1455 | |
1456 | + std::vector<pragma*> theScopedPragmas; |
1457 | + |
1458 | StaticContextConsts::xquery_version_t theMaxLibModuleVersion; |
1459 | |
1460 | public: |
1461 | @@ -8480,14 +8483,21 @@ |
1462 | void* begin_visit(const ExtensionExpr& v) |
1463 | { |
1464 | TRACE_VISIT(); |
1465 | - return no_state; |
1466 | -} |
1467 | |
1468 | -void end_visit(const ExtensionExpr& v, void* /*visit_state*/) |
1469 | -{ |
1470 | - TRACE_VISIT_OUT(); |
1471 | if (v.get_expr() == NULL) |
1472 | + { |
1473 | throw XQUERY_EXCEPTION( err::XQST0079, ERROR_LOC(loc) ); |
1474 | + } |
1475 | + |
1476 | + return no_state; |
1477 | +} |
1478 | + |
1479 | +void end_visit(const ExtensionExpr& v, void* /*visit_state*/) |
1480 | +{ |
1481 | + TRACE_VISIT_OUT(); |
1482 | + |
1483 | + size_t lNumPragmas = v.get_pragma_list()->get_pragmas().size(); |
1484 | + theScopedPragmas.resize(theScopedPragmas.size() - lNumPragmas); |
1485 | } |
1486 | |
1487 | |
1488 | @@ -8513,19 +8523,25 @@ |
1489 | void* begin_visit(const Pragma& v) |
1490 | { |
1491 | TRACE_VISIT(); |
1492 | + store::Item_t lQName; |
1493 | + expand_no_default_qname(lQName, v.get_name(), v.get_name()->get_location()); |
1494 | + |
1495 | + if (lQName->getPrefix().empty() && lQName->getNamespace().empty()) |
1496 | + { |
1497 | + RAISE_ERROR(err::XPST0081, loc, ERROR_PARAMS(lQName->getStringValue())); |
1498 | + } |
1499 | + |
1500 | + pragma* lPragma = theExprManager->create_pragma(lQName, v.get_pragma_lit()); |
1501 | + |
1502 | + // popped in end_visit(ExtensionExpr) |
1503 | + theScopedPragmas.push_back(lPragma); |
1504 | + |
1505 | return no_state; |
1506 | } |
1507 | |
1508 | void end_visit(const Pragma& v, void* /*visit_state*/) |
1509 | { |
1510 | TRACE_VISIT_OUT(); |
1511 | - |
1512 | - // may raise XPST0081 |
1513 | - if (!v.get_name()->is_eqname()) |
1514 | - { |
1515 | - zstring ns; |
1516 | - theSctx->lookup_ns(ns, v.get_name()->get_prefix(), loc); |
1517 | - } |
1518 | } |
1519 | |
1520 | |
1521 | @@ -10885,6 +10901,8 @@ |
1522 | |
1523 | } // switch |
1524 | |
1525 | + f->processPragma(resultExpr, theScopedPragmas); |
1526 | + |
1527 | push_nodestack(resultExpr); |
1528 | } |
1529 | } |
1530 | |
1531 | === modified file 'src/context/static_context.h' |
1532 | --- src/context/static_context.h 2012-09-17 00:36:37 +0000 |
1533 | +++ src/context/static_context.h 2012-09-19 21:43:18 +0000 |
1534 | @@ -439,7 +439,6 @@ |
1535 | Feature flags that are used when a particular feature (e.g. scripting |
1536 | or ddl) is enabled. The definition of the features is located in |
1537 | context/featueres.h. |
1538 | - |
1539 | ********************************************************************************/ |
1540 | |
1541 | class static_context : public SimpleRCObject |
1542 | @@ -981,7 +980,6 @@ |
1543 | |
1544 | void get_collations(std::vector<std::string>& collations) const; |
1545 | |
1546 | - |
1547 | // |
1548 | // Options |
1549 | // |
1550 | |
1551 | === modified file 'src/functions/func_collections_impl.cpp' |
1552 | --- src/functions/func_collections_impl.cpp 2012-09-18 16:29:31 +0000 |
1553 | +++ src/functions/func_collections_impl.cpp 2012-09-19 21:43:18 +0000 |
1554 | @@ -19,6 +19,9 @@ |
1555 | #include "runtime/collections/collections.h" |
1556 | |
1557 | #include "compiler/expression/expr_consts.h" |
1558 | +#include "compiler/expression/expr_base.h" |
1559 | +#include "compiler/expression/pragma.h" |
1560 | +#include "compiler/api/compilercb.h" |
1561 | |
1562 | namespace zorba |
1563 | { |
1564 | @@ -26,6 +29,40 @@ |
1565 | /******************************************************************************* |
1566 | |
1567 | ********************************************************************************/ |
1568 | +bool |
1569 | +hasNoCopyPragma(expr& e) |
1570 | +{ |
1571 | + pragma* p; |
1572 | + return e.get_ccb()->lookup_pragma(&e, "no-copy", p); |
1573 | +} |
1574 | + |
1575 | + |
1576 | +/******************************************************************************* |
1577 | + |
1578 | +********************************************************************************/ |
1579 | +void |
1580 | +processPragmaInternal(zorba::expr* e, const std::vector<zorba::pragma*>& p) |
1581 | +{ |
1582 | + for (std::vector<zorba::pragma*>::const_iterator lIter = p.begin(); |
1583 | + lIter != p.end(); |
1584 | + ++lIter) |
1585 | + { |
1586 | + pragma* p = *lIter; |
1587 | + if (p->theQName->getNamespace() == ZORBA_EXTENSIONS_NS) |
1588 | + { |
1589 | + if (p->theQName->getLocalName() == "no-copy") |
1590 | + { |
1591 | + e->get_ccb()->add_pragma(e, p); |
1592 | + e->setContainsPragma(ANNOTATION_TRUE); |
1593 | + } |
1594 | + } |
1595 | + } |
1596 | +} |
1597 | + |
1598 | + |
1599 | +/******************************************************************************* |
1600 | + |
1601 | +********************************************************************************/ |
1602 | PlanIter_t static_collections_dml_collection::codegen( |
1603 | CompilerCB*, |
1604 | static_context* sctx, |
1605 | @@ -102,8 +139,16 @@ |
1606 | /******************************************************************************* |
1607 | |
1608 | ********************************************************************************/ |
1609 | +void |
1610 | +zorba::static_collections_dml_insert_nodes::processPragma( |
1611 | + zorba::expr* e, |
1612 | + const std::vector<zorba::pragma*>& p) const |
1613 | +{ |
1614 | + processPragmaInternal(e, p); |
1615 | +} |
1616 | + |
1617 | PlanIter_t static_collections_dml_insert_nodes::codegen( |
1618 | - CompilerCB*, |
1619 | + CompilerCB* cb, |
1620 | static_context* sctx, |
1621 | const QueryLoc& loc, |
1622 | std::vector<PlanIter_t>& argv, |
1623 | @@ -114,15 +159,25 @@ |
1624 | bool const dynamic = |
1625 | ns == static_context::ZORBA_STORE_DYNAMIC_COLLECTIONS_DML_FN_NS; |
1626 | |
1627 | - return new ZorbaInsertNodesIterator(sctx, loc, argv, dynamic); |
1628 | + bool const copy = !hasNoCopyPragma(ann); |
1629 | + |
1630 | + return new ZorbaInsertNodesIterator(sctx, loc, argv, dynamic, copy); |
1631 | } |
1632 | |
1633 | |
1634 | /******************************************************************************* |
1635 | |
1636 | ********************************************************************************/ |
1637 | +void |
1638 | +zorba::static_collections_dml_insert_nodes_first::processPragma( |
1639 | + zorba::expr* e, |
1640 | + const std::vector<zorba::pragma*>& p) const |
1641 | +{ |
1642 | + processPragmaInternal(e, p); |
1643 | +} |
1644 | + |
1645 | PlanIter_t static_collections_dml_insert_nodes_first::codegen( |
1646 | - CompilerCB*, |
1647 | + CompilerCB* cb, |
1648 | static_context* sctx, |
1649 | const QueryLoc& loc, |
1650 | std::vector<PlanIter_t>& argv, |
1651 | @@ -133,15 +188,25 @@ |
1652 | bool const dynamic = |
1653 | ns == static_context::ZORBA_STORE_DYNAMIC_COLLECTIONS_DML_FN_NS; |
1654 | |
1655 | - return new ZorbaInsertNodesFirstIterator(sctx, loc, argv, dynamic); |
1656 | + bool const copy = !hasNoCopyPragma(ann); |
1657 | + |
1658 | + return new ZorbaInsertNodesFirstIterator(sctx, loc, argv, dynamic, copy); |
1659 | } |
1660 | |
1661 | |
1662 | /******************************************************************************* |
1663 | |
1664 | ********************************************************************************/ |
1665 | +void |
1666 | +zorba::static_collections_dml_insert_nodes_last::processPragma( |
1667 | + zorba::expr* e, |
1668 | + const std::vector<zorba::pragma*>& p) const |
1669 | +{ |
1670 | + processPragmaInternal(e, p); |
1671 | +} |
1672 | + |
1673 | PlanIter_t static_collections_dml_insert_nodes_last::codegen( |
1674 | - CompilerCB*, |
1675 | + CompilerCB* cb, |
1676 | static_context* sctx, |
1677 | const QueryLoc& loc, |
1678 | std::vector<PlanIter_t>& argv, |
1679 | @@ -152,15 +217,25 @@ |
1680 | bool const dynamic = |
1681 | ns == static_context::ZORBA_STORE_DYNAMIC_COLLECTIONS_DML_FN_NS; |
1682 | |
1683 | - return new ZorbaInsertNodesLastIterator(sctx, loc, argv, dynamic); |
1684 | + bool const copy = !hasNoCopyPragma(ann); |
1685 | + |
1686 | + return new ZorbaInsertNodesLastIterator(sctx, loc, argv, dynamic, copy); |
1687 | } |
1688 | |
1689 | |
1690 | /******************************************************************************* |
1691 | |
1692 | ********************************************************************************/ |
1693 | +void |
1694 | +zorba::static_collections_dml_insert_nodes_before::processPragma( |
1695 | + zorba::expr* e, |
1696 | + const std::vector<zorba::pragma*>& p) const |
1697 | +{ |
1698 | + processPragmaInternal(e, p); |
1699 | +} |
1700 | + |
1701 | PlanIter_t static_collections_dml_insert_nodes_before::codegen( |
1702 | - CompilerCB*, |
1703 | + CompilerCB* cb, |
1704 | static_context* sctx, |
1705 | const QueryLoc& loc, |
1706 | std::vector<PlanIter_t>& argv, |
1707 | @@ -171,15 +246,25 @@ |
1708 | bool const dynamic = |
1709 | ns == static_context::ZORBA_STORE_DYNAMIC_COLLECTIONS_DML_FN_NS; |
1710 | |
1711 | - return new ZorbaInsertNodesBeforeIterator(sctx, loc, argv, dynamic); |
1712 | + bool const copy = !hasNoCopyPragma(ann); |
1713 | + |
1714 | + return new ZorbaInsertNodesBeforeIterator(sctx, loc, argv, dynamic, copy); |
1715 | } |
1716 | |
1717 | |
1718 | /******************************************************************************* |
1719 | |
1720 | ********************************************************************************/ |
1721 | +void |
1722 | +zorba::static_collections_dml_insert_nodes_after::processPragma( |
1723 | + zorba::expr* e, |
1724 | + const std::vector<zorba::pragma*>& p) const |
1725 | +{ |
1726 | + processPragmaInternal(e, p); |
1727 | +} |
1728 | + |
1729 | PlanIter_t static_collections_dml_insert_nodes_after::codegen( |
1730 | - CompilerCB*, |
1731 | + CompilerCB* cb, |
1732 | static_context* sctx, |
1733 | const QueryLoc& loc, |
1734 | std::vector<PlanIter_t>& argv, |
1735 | @@ -190,15 +275,25 @@ |
1736 | bool const dynamic = |
1737 | ns == static_context::ZORBA_STORE_DYNAMIC_COLLECTIONS_DML_FN_NS; |
1738 | |
1739 | - return new ZorbaInsertNodesAfterIterator(sctx, loc, argv, dynamic); |
1740 | + bool const copy = !hasNoCopyPragma(ann); |
1741 | + |
1742 | + return new ZorbaInsertNodesAfterIterator(sctx, loc, argv, dynamic, copy); |
1743 | } |
1744 | |
1745 | |
1746 | /******************************************************************************* |
1747 | |
1748 | ********************************************************************************/ |
1749 | +void |
1750 | +zorba::static_collections_dml_apply_insert_nodes::processPragma( |
1751 | + zorba::expr* e, |
1752 | + const std::vector<zorba::pragma*>& p) const |
1753 | +{ |
1754 | + processPragmaInternal(e, p); |
1755 | +} |
1756 | + |
1757 | PlanIter_t static_collections_dml_apply_insert_nodes::codegen( |
1758 | - CompilerCB*, |
1759 | + CompilerCB* cb, |
1760 | static_context* sctx, |
1761 | const QueryLoc& loc, |
1762 | std::vector<PlanIter_t>& argv, |
1763 | @@ -209,7 +304,9 @@ |
1764 | bool const dynamic = |
1765 | ns == static_context::ZORBA_STORE_DYNAMIC_COLLECTIONS_DML_FN_NS; |
1766 | |
1767 | - return new ZorbaApplyInsertNodesIterator(sctx, loc, argv, dynamic); |
1768 | + bool const copy = !hasNoCopyPragma(ann); |
1769 | + |
1770 | + return new ZorbaApplyInsertNodesIterator(sctx, loc, argv, dynamic, copy); |
1771 | } |
1772 | |
1773 | |
1774 | @@ -224,8 +321,16 @@ |
1775 | /******************************************************************************* |
1776 | |
1777 | ********************************************************************************/ |
1778 | +void |
1779 | +zorba::static_collections_dml_apply_insert_nodes_first::processPragma( |
1780 | + zorba::expr* e, |
1781 | + const std::vector<zorba::pragma*>& p) const |
1782 | +{ |
1783 | + processPragmaInternal(e, p); |
1784 | +} |
1785 | + |
1786 | PlanIter_t static_collections_dml_apply_insert_nodes_first::codegen( |
1787 | - CompilerCB*, |
1788 | + CompilerCB* cb, |
1789 | static_context* sctx, |
1790 | const QueryLoc& loc, |
1791 | std::vector<PlanIter_t>& argv, |
1792 | @@ -236,7 +341,9 @@ |
1793 | bool const dynamic = |
1794 | ns == static_context::ZORBA_STORE_DYNAMIC_COLLECTIONS_DML_FN_NS; |
1795 | |
1796 | - return new ZorbaApplyInsertNodesFirstIterator(sctx, loc, argv, dynamic); |
1797 | + bool const copy = !hasNoCopyPragma(ann); |
1798 | + |
1799 | + return new ZorbaApplyInsertNodesFirstIterator(sctx, loc, argv, dynamic, copy); |
1800 | } |
1801 | |
1802 | |
1803 | @@ -251,8 +358,16 @@ |
1804 | /******************************************************************************* |
1805 | |
1806 | ********************************************************************************/ |
1807 | +void |
1808 | +zorba::static_collections_dml_apply_insert_nodes_last::processPragma( |
1809 | + zorba::expr* e, |
1810 | + const std::vector<zorba::pragma*>& p) const |
1811 | +{ |
1812 | + processPragmaInternal(e, p); |
1813 | +} |
1814 | + |
1815 | PlanIter_t static_collections_dml_apply_insert_nodes_last::codegen( |
1816 | - CompilerCB*, |
1817 | + CompilerCB* cb, |
1818 | static_context* sctx, |
1819 | const QueryLoc& loc, |
1820 | std::vector<PlanIter_t>& argv, |
1821 | @@ -263,7 +378,9 @@ |
1822 | bool const dynamic = |
1823 | ns == static_context::ZORBA_STORE_DYNAMIC_COLLECTIONS_DML_FN_NS; |
1824 | |
1825 | - return new ZorbaApplyInsertNodesLastIterator(sctx, loc, argv, dynamic); |
1826 | + bool const copy = !hasNoCopyPragma(ann); |
1827 | + |
1828 | + return new ZorbaApplyInsertNodesLastIterator(sctx, loc, argv, dynamic, copy); |
1829 | } |
1830 | |
1831 | |
1832 | @@ -278,8 +395,16 @@ |
1833 | /******************************************************************************* |
1834 | |
1835 | ********************************************************************************/ |
1836 | +void |
1837 | +zorba::static_collections_dml_apply_insert_nodes_before::processPragma( |
1838 | + zorba::expr* e, |
1839 | + const std::vector<zorba::pragma*>& p) const |
1840 | +{ |
1841 | + processPragmaInternal(e, p); |
1842 | +} |
1843 | + |
1844 | PlanIter_t static_collections_dml_apply_insert_nodes_before::codegen( |
1845 | - CompilerCB*, |
1846 | + CompilerCB* cb, |
1847 | static_context* sctx, |
1848 | const QueryLoc& loc, |
1849 | std::vector<PlanIter_t>& argv, |
1850 | @@ -290,7 +415,9 @@ |
1851 | bool const dynamic = |
1852 | ns == static_context::ZORBA_STORE_DYNAMIC_COLLECTIONS_DML_FN_NS; |
1853 | |
1854 | - return new ZorbaApplyInsertNodesBeforeIterator(sctx, loc, argv, dynamic); |
1855 | + bool const copy = !hasNoCopyPragma(ann); |
1856 | + |
1857 | + return new ZorbaApplyInsertNodesBeforeIterator(sctx, loc, argv, dynamic, copy); |
1858 | } |
1859 | |
1860 | |
1861 | @@ -306,8 +433,16 @@ |
1862 | /******************************************************************************* |
1863 | |
1864 | ********************************************************************************/ |
1865 | +void |
1866 | +zorba::static_collections_dml_apply_insert_nodes_after::processPragma( |
1867 | + zorba::expr* e, |
1868 | + const std::vector<zorba::pragma*>& p) const |
1869 | +{ |
1870 | + processPragmaInternal(e, p); |
1871 | +} |
1872 | + |
1873 | PlanIter_t static_collections_dml_apply_insert_nodes_after::codegen( |
1874 | - CompilerCB*, |
1875 | + CompilerCB* cb, |
1876 | static_context* sctx, |
1877 | const QueryLoc& loc, |
1878 | std::vector<PlanIter_t>& argv, |
1879 | @@ -318,7 +453,9 @@ |
1880 | bool const dynamic = |
1881 | ns == static_context::ZORBA_STORE_DYNAMIC_COLLECTIONS_DML_FN_NS; |
1882 | |
1883 | - return new ZorbaApplyInsertNodesAfterIterator(sctx, loc, argv, dynamic); |
1884 | + bool const copy = !hasNoCopyPragma(ann); |
1885 | + |
1886 | + return new ZorbaApplyInsertNodesAfterIterator(sctx, loc, argv, dynamic, copy); |
1887 | } |
1888 | |
1889 | |
1890 | |
1891 | === modified file 'src/functions/function.h' |
1892 | --- src/functions/function.h 2012-09-17 00:36:37 +0000 |
1893 | +++ src/functions/function.h 2012-09-19 21:43:18 +0000 |
1894 | @@ -39,6 +39,7 @@ |
1895 | class fo_expr; |
1896 | class CompilerCB; |
1897 | class expr; |
1898 | +class pragma; |
1899 | |
1900 | |
1901 | /******************************************************************************* |
1902 | @@ -224,6 +225,10 @@ |
1903 | return NULL; |
1904 | } |
1905 | |
1906 | + virtual void processPragma( |
1907 | + expr* expr, |
1908 | + const std::vector<pragma*>& pragmas) const { return; } |
1909 | + |
1910 | virtual PlanIter_t codegen( |
1911 | CompilerCB* cb, |
1912 | static_context* sctx, |
1913 | |
1914 | === modified file 'src/functions/pregenerated/func_collections.h' |
1915 | --- src/functions/pregenerated/func_collections.h 2012-09-17 00:36:37 +0000 |
1916 | +++ src/functions/pregenerated/func_collections.h 2012-09-19 21:43:18 +0000 |
1917 | @@ -217,6 +217,8 @@ |
1918 | |
1919 | bool mustCopyInputNodes(expr* fo, csize producer) const { return producer == 1; } |
1920 | |
1921 | + void processPragma(expr*, const std::vector<pragma*>&) const; |
1922 | + |
1923 | CODEGEN_DECL(); |
1924 | }; |
1925 | |
1926 | @@ -238,6 +240,8 @@ |
1927 | |
1928 | bool mustCopyInputNodes(expr* fo, csize producer) const { return producer == 1; } |
1929 | |
1930 | + void processPragma(expr*, const std::vector<pragma*>&) const; |
1931 | + |
1932 | CODEGEN_DECL(); |
1933 | }; |
1934 | |
1935 | @@ -259,6 +263,8 @@ |
1936 | |
1937 | bool mustCopyInputNodes(expr* fo, csize producer) const { return producer == 1; } |
1938 | |
1939 | + void processPragma(expr*, const std::vector<pragma*>&) const; |
1940 | + |
1941 | CODEGEN_DECL(); |
1942 | }; |
1943 | |
1944 | @@ -280,6 +286,8 @@ |
1945 | |
1946 | bool mustCopyInputNodes(expr* fo, csize producer) const { return producer == 2; } |
1947 | |
1948 | + void processPragma(expr*, const std::vector<pragma*>&) const; |
1949 | + |
1950 | CODEGEN_DECL(); |
1951 | }; |
1952 | |
1953 | @@ -301,6 +309,8 @@ |
1954 | |
1955 | bool mustCopyInputNodes(expr* fo, csize producer) const { return producer == 2; } |
1956 | |
1957 | + void processPragma(expr*, const std::vector<pragma*>&) const; |
1958 | + |
1959 | CODEGEN_DECL(); |
1960 | }; |
1961 | |
1962 | @@ -324,6 +334,8 @@ |
1963 | |
1964 | bool mustCopyInputNodes(expr* fo, csize producer) const { return producer == 1; } |
1965 | |
1966 | + void processPragma(expr*, const std::vector<pragma*>&) const; |
1967 | + |
1968 | CODEGEN_DECL(); |
1969 | }; |
1970 | |
1971 | @@ -347,6 +359,8 @@ |
1972 | |
1973 | bool mustCopyInputNodes(expr* fo, csize producer) const { return producer == 1; } |
1974 | |
1975 | + void processPragma(expr*, const std::vector<pragma*>&) const; |
1976 | + |
1977 | CODEGEN_DECL(); |
1978 | }; |
1979 | |
1980 | @@ -370,6 +384,8 @@ |
1981 | |
1982 | bool mustCopyInputNodes(expr* fo, csize producer) const { return producer == 1; } |
1983 | |
1984 | + void processPragma(expr*, const std::vector<pragma*>&) const; |
1985 | + |
1986 | CODEGEN_DECL(); |
1987 | }; |
1988 | |
1989 | @@ -393,6 +409,8 @@ |
1990 | |
1991 | bool mustCopyInputNodes(expr* fo, csize producer) const { return producer == 2; } |
1992 | |
1993 | + void processPragma(expr*, const std::vector<pragma*>&) const; |
1994 | + |
1995 | CODEGEN_DECL(); |
1996 | }; |
1997 | |
1998 | @@ -416,6 +434,8 @@ |
1999 | |
2000 | bool mustCopyInputNodes(expr* fo, csize producer) const { return producer == 2; } |
2001 | |
2002 | + void processPragma(expr*, const std::vector<pragma*>&) const; |
2003 | + |
2004 | CODEGEN_DECL(); |
2005 | }; |
2006 | |
2007 | |
2008 | === modified file 'src/runtime/collections/collections_base.h' |
2009 | --- src/runtime/collections/collections_base.h 2012-09-17 00:36:37 +0000 |
2010 | +++ src/runtime/collections/collections_base.h 2012-09-19 21:43:18 +0000 |
2011 | @@ -59,6 +59,7 @@ |
2012 | { |
2013 | protected: |
2014 | bool theIsDynamic; |
2015 | + bool theNeedToCopy; |
2016 | |
2017 | protected: |
2018 | |
2019 | @@ -79,8 +80,6 @@ |
2020 | store::Item_t copyNode; |
2021 | xs_integer targetPos; |
2022 | |
2023 | - store::CopyMode lCopyMode; |
2024 | - |
2025 | this->consumeNext(collName, this->theChildren[0].getp(), planState); |
2026 | |
2027 | collectionDecl = getCollection(collName, collection); |
2028 | @@ -101,10 +100,12 @@ |
2029 | } |
2030 | } |
2031 | |
2032 | + store::CopyMode lCopyMode; |
2033 | getCopyMode(lCopyMode, this->theSctx); |
2034 | |
2035 | - lCopyMode.theDoCopy = ! |
2036 | - this->theChildren[this->theChildren.size()-1]->isConstructor(); |
2037 | + lCopyMode.theDoCopy = |
2038 | + !(this->theChildren[this->theChildren.size()-1]->isConstructor() || |
2039 | + !theNeedToCopy); |
2040 | |
2041 | while (this->consumeNext(node, |
2042 | this->theChildren[this->theChildren.size()-1].getp(), |
2043 | @@ -144,10 +145,12 @@ |
2044 | static_context* sctx, |
2045 | const QueryLoc& loc, |
2046 | std::vector<PlanIter_t>& children, |
2047 | - bool isDynamic) |
2048 | + bool isDynamic, |
2049 | + bool needToCopy) |
2050 | : |
2051 | NaryBaseIterator<Iter, State>(sctx, loc, children), |
2052 | - theIsDynamic(isDynamic) |
2053 | + theIsDynamic(isDynamic), |
2054 | + theNeedToCopy(needToCopy) |
2055 | { |
2056 | } |
2057 | |
2058 | @@ -157,7 +160,12 @@ |
2059 | { |
2060 | serialize_baseclass(ar, (NaryBaseIterator<Iter, State>*)this); |
2061 | ar & theIsDynamic; |
2062 | + ar & theNeedToCopy; |
2063 | } |
2064 | + |
2065 | + bool isDynamic() const { return theIsDynamic; } |
2066 | + |
2067 | + bool needToCopy() const { return theNeedToCopy; } |
2068 | }; |
2069 | |
2070 | } // namespace zorba |
2071 | |
2072 | === modified file 'src/runtime/collections/pregenerated/collections.h' |
2073 | --- src/runtime/collections/pregenerated/collections.h 2012-09-18 16:29:31 +0000 |
2074 | +++ src/runtime/collections/pregenerated/collections.h 2012-09-19 21:43:18 +0000 |
2075 | @@ -381,9 +381,10 @@ |
2076 | static_context* sctx, |
2077 | const QueryLoc& loc, |
2078 | std::vector<PlanIter_t>& children, |
2079 | - bool isDynamic) |
2080 | + bool isDynamic, |
2081 | + bool needToCopy) |
2082 | : |
2083 | - ZorbaCollectionIteratorHelper<ZorbaInsertNodesIterator, PlanIteratorState>(sctx, loc, children, isDynamic) |
2084 | + ZorbaCollectionIteratorHelper<ZorbaInsertNodesIterator, PlanIteratorState>(sctx, loc, children, isDynamic, needToCopy) |
2085 | {} |
2086 | |
2087 | virtual ~ZorbaInsertNodesIterator(); |
2088 | @@ -416,9 +417,10 @@ |
2089 | static_context* sctx, |
2090 | const QueryLoc& loc, |
2091 | std::vector<PlanIter_t>& children, |
2092 | - bool isDynamic) |
2093 | + bool isDynamic, |
2094 | + bool needToCopy) |
2095 | : |
2096 | - ZorbaCollectionIteratorHelper<ZorbaInsertNodesFirstIterator, PlanIteratorState>(sctx, loc, children, isDynamic) |
2097 | + ZorbaCollectionIteratorHelper<ZorbaInsertNodesFirstIterator, PlanIteratorState>(sctx, loc, children, isDynamic, needToCopy) |
2098 | {} |
2099 | |
2100 | virtual ~ZorbaInsertNodesFirstIterator(); |
2101 | @@ -451,9 +453,10 @@ |
2102 | static_context* sctx, |
2103 | const QueryLoc& loc, |
2104 | std::vector<PlanIter_t>& children, |
2105 | - bool isDynamic) |
2106 | + bool isDynamic, |
2107 | + bool needToCopy) |
2108 | : |
2109 | - ZorbaCollectionIteratorHelper<ZorbaInsertNodesLastIterator, PlanIteratorState>(sctx, loc, children, isDynamic) |
2110 | + ZorbaCollectionIteratorHelper<ZorbaInsertNodesLastIterator, PlanIteratorState>(sctx, loc, children, isDynamic, needToCopy) |
2111 | {} |
2112 | |
2113 | virtual ~ZorbaInsertNodesLastIterator(); |
2114 | @@ -486,9 +489,10 @@ |
2115 | static_context* sctx, |
2116 | const QueryLoc& loc, |
2117 | std::vector<PlanIter_t>& children, |
2118 | - bool isDynamic) |
2119 | + bool isDynamic, |
2120 | + bool needToCopy) |
2121 | : |
2122 | - ZorbaCollectionIteratorHelper<ZorbaInsertNodesBeforeIterator, PlanIteratorState>(sctx, loc, children, isDynamic) |
2123 | + ZorbaCollectionIteratorHelper<ZorbaInsertNodesBeforeIterator, PlanIteratorState>(sctx, loc, children, isDynamic, needToCopy) |
2124 | {} |
2125 | |
2126 | virtual ~ZorbaInsertNodesBeforeIterator(); |
2127 | @@ -523,9 +527,10 @@ |
2128 | static_context* sctx, |
2129 | const QueryLoc& loc, |
2130 | std::vector<PlanIter_t>& children, |
2131 | - bool isDynamic) |
2132 | + bool isDynamic, |
2133 | + bool needToCopy) |
2134 | : |
2135 | - ZorbaCollectionIteratorHelper<ZorbaInsertNodesAfterIterator, PlanIteratorState>(sctx, loc, children, isDynamic), |
2136 | + ZorbaCollectionIteratorHelper<ZorbaInsertNodesAfterIterator, PlanIteratorState>(sctx, loc, children, isDynamic, needToCopy), |
2137 | theIsDynamic(isDynamic) |
2138 | {} |
2139 | |
2140 | @@ -573,9 +578,10 @@ |
2141 | static_context* sctx, |
2142 | const QueryLoc& loc, |
2143 | std::vector<PlanIter_t>& children, |
2144 | - bool isDynamic) |
2145 | + bool isDynamic, |
2146 | + bool needToCopy) |
2147 | : |
2148 | - ZorbaCollectionIteratorHelper<ZorbaApplyInsertNodesIterator, ZorbaApplyInsertNodesIteratorState>(sctx, loc, children, isDynamic) |
2149 | + ZorbaCollectionIteratorHelper<ZorbaApplyInsertNodesIterator, ZorbaApplyInsertNodesIteratorState>(sctx, loc, children, isDynamic, needToCopy) |
2150 | {} |
2151 | |
2152 | virtual ~ZorbaApplyInsertNodesIterator(); |
2153 | @@ -622,9 +628,10 @@ |
2154 | static_context* sctx, |
2155 | const QueryLoc& loc, |
2156 | std::vector<PlanIter_t>& children, |
2157 | - bool isDynamic) |
2158 | + bool isDynamic, |
2159 | + bool needToCopy) |
2160 | : |
2161 | - ZorbaCollectionIteratorHelper<ZorbaApplyInsertNodesFirstIterator, ZorbaApplyInsertNodesFirstIteratorState>(sctx, loc, children, isDynamic) |
2162 | + ZorbaCollectionIteratorHelper<ZorbaApplyInsertNodesFirstIterator, ZorbaApplyInsertNodesFirstIteratorState>(sctx, loc, children, isDynamic, needToCopy) |
2163 | {} |
2164 | |
2165 | virtual ~ZorbaApplyInsertNodesFirstIterator(); |
2166 | @@ -671,9 +678,10 @@ |
2167 | static_context* sctx, |
2168 | const QueryLoc& loc, |
2169 | std::vector<PlanIter_t>& children, |
2170 | - bool isDynamic) |
2171 | + bool isDynamic, |
2172 | + bool needToCopy) |
2173 | : |
2174 | - ZorbaCollectionIteratorHelper<ZorbaApplyInsertNodesLastIterator, ZorbaApplyInsertNodesLastIteratorState>(sctx, loc, children, isDynamic) |
2175 | + ZorbaCollectionIteratorHelper<ZorbaApplyInsertNodesLastIterator, ZorbaApplyInsertNodesLastIteratorState>(sctx, loc, children, isDynamic, needToCopy) |
2176 | {} |
2177 | |
2178 | virtual ~ZorbaApplyInsertNodesLastIterator(); |
2179 | @@ -720,9 +728,10 @@ |
2180 | static_context* sctx, |
2181 | const QueryLoc& loc, |
2182 | std::vector<PlanIter_t>& children, |
2183 | - bool isDynamic) |
2184 | + bool isDynamic, |
2185 | + bool needToCopy) |
2186 | : |
2187 | - ZorbaCollectionIteratorHelper<ZorbaApplyInsertNodesBeforeIterator, ZorbaApplyInsertNodesBeforeIteratorState>(sctx, loc, children, isDynamic) |
2188 | + ZorbaCollectionIteratorHelper<ZorbaApplyInsertNodesBeforeIterator, ZorbaApplyInsertNodesBeforeIteratorState>(sctx, loc, children, isDynamic, needToCopy) |
2189 | {} |
2190 | |
2191 | virtual ~ZorbaApplyInsertNodesBeforeIterator(); |
2192 | @@ -769,9 +778,10 @@ |
2193 | static_context* sctx, |
2194 | const QueryLoc& loc, |
2195 | std::vector<PlanIter_t>& children, |
2196 | - bool isDynamic) |
2197 | + bool isDynamic, |
2198 | + bool needToCopy) |
2199 | : |
2200 | - ZorbaCollectionIteratorHelper<ZorbaApplyInsertNodesAfterIterator, ZorbaApplyInsertNodesAfterIteratorState>(sctx, loc, children, isDynamic) |
2201 | + ZorbaCollectionIteratorHelper<ZorbaApplyInsertNodesAfterIterator, ZorbaApplyInsertNodesAfterIteratorState>(sctx, loc, children, isDynamic, needToCopy) |
2202 | {} |
2203 | |
2204 | virtual ~ZorbaApplyInsertNodesAfterIterator(); |
2205 | |
2206 | === modified file 'src/runtime/spec/codegen-h.xq' |
2207 | --- src/runtime/spec/codegen-h.xq 2012-09-17 00:36:37 +0000 |
2208 | +++ src/runtime/spec/codegen-h.xq 2012-09-19 21:43:18 +0000 |
2209 | @@ -326,6 +326,11 @@ |
2210 | string-join(($gen:newline, $gen:indent, |
2211 | 'bool mustCopyInputNodes(expr* fo, csize producer) const;', |
2212 | $gen:newline),'') |
2213 | + else if (name($meth) eq 'zorba:processPragma') |
2214 | + then |
2215 | + string-join(($gen:newline, $gen:indent, |
2216 | + 'void processPragma(expr*, const std::vector<pragma*>&) const;', |
2217 | + $gen:newline), '') |
2218 | else |
2219 | () |
2220 | else |
2221 | |
2222 | === modified file 'src/runtime/spec/collections/collections.xml' |
2223 | --- src/runtime/spec/collections/collections.xml 2012-09-18 16:29:31 +0000 |
2224 | +++ src/runtime/spec/collections/collections.xml 2012-09-19 21:43:18 +0000 |
2225 | @@ -384,7 +384,8 @@ |
2226 | ********************************************************************************/ |
2227 | --> |
2228 | <zorba:iterator name="ZorbaInsertNodesIterator" |
2229 | - base="ZorbaCollectionIteratorHelper<ZorbaInsertNodesIterator, PlanIteratorState>"> |
2230 | + base="ZorbaCollectionIteratorHelper<ZorbaInsertNodesIterator, PlanIteratorState>" |
2231 | + generateVisitor="false"> |
2232 | |
2233 | <zorba:description author="Zorba Team"> |
2234 | zorba:insert-nodes |
2235 | @@ -416,12 +417,14 @@ |
2236 | <zorba:getScriptingKind returnValue="UPDATING_EXPR"/> |
2237 | <zorba:accessesDynCtx returnValue="true"/> |
2238 | <zorba:mustCopyInputNodes producer="1"/> |
2239 | + <zorba:processPragma/> |
2240 | </zorba:methods> |
2241 | |
2242 | </zorba:function> |
2243 | |
2244 | <zorba:constructor> |
2245 | <zorba:parameter type="bool" name="isDynamic" base="true"/> |
2246 | + <zorba:parameter type="bool" name="needToCopy" base="true"/> |
2247 | </zorba:constructor> |
2248 | |
2249 | <zorba:method const="true" name="getCollection" |
2250 | @@ -437,7 +440,8 @@ |
2251 | ********************************************************************************/ |
2252 | --> |
2253 | <zorba:iterator name="ZorbaInsertNodesFirstIterator" |
2254 | - base="ZorbaCollectionIteratorHelper<ZorbaInsertNodesFirstIterator, PlanIteratorState>"> |
2255 | + base="ZorbaCollectionIteratorHelper<ZorbaInsertNodesFirstIterator, PlanIteratorState>" |
2256 | + generateVisitor="false"> |
2257 | |
2258 | <zorba:description author="Zorba Team"> |
2259 | zorba:insert-nodes-first |
2260 | @@ -474,12 +478,14 @@ |
2261 | <zorba:getScriptingKind returnValue="UPDATING_EXPR"/> |
2262 | <zorba:accessesDynCtx returnValue="true"/> |
2263 | <zorba:mustCopyInputNodes producer="1"/> |
2264 | + <zorba:processPragma/> |
2265 | </zorba:methods> |
2266 | |
2267 | </zorba:function> |
2268 | |
2269 | <zorba:constructor> |
2270 | <zorba:parameter type="bool" name="isDynamic" base="true"/> |
2271 | + <zorba:parameter type="bool" name="needToCopy" base="true"/> |
2272 | </zorba:constructor> |
2273 | |
2274 | <zorba:method const="true" name="getCollection" |
2275 | @@ -495,7 +501,8 @@ |
2276 | ********************************************************************************/ |
2277 | --> |
2278 | <zorba:iterator name="ZorbaInsertNodesLastIterator" |
2279 | - base="ZorbaCollectionIteratorHelper<ZorbaInsertNodesLastIterator, PlanIteratorState>"> |
2280 | + base="ZorbaCollectionIteratorHelper<ZorbaInsertNodesLastIterator, PlanIteratorState>" |
2281 | + generateVisitor="false"> |
2282 | |
2283 | <zorba:description author="Zorba Team"> |
2284 | zorba:insert-nodes-last |
2285 | @@ -531,12 +538,14 @@ |
2286 | <zorba:getScriptingKind returnValue="UPDATING_EXPR"/> |
2287 | <zorba:accessesDynCtx returnValue="true"/> |
2288 | <zorba:mustCopyInputNodes producer="1"/> |
2289 | + <zorba:processPragma/> |
2290 | </zorba:methods> |
2291 | |
2292 | </zorba:function> |
2293 | |
2294 | <zorba:constructor> |
2295 | <zorba:parameter type="bool" name="isDynamic" base="true"/> |
2296 | + <zorba:parameter type="bool" name="needToCopy" base="true"/> |
2297 | </zorba:constructor> |
2298 | |
2299 | <zorba:method const="true" name="getCollection" |
2300 | @@ -552,7 +561,8 @@ |
2301 | ********************************************************************************/ |
2302 | --> |
2303 | <zorba:iterator name="ZorbaInsertNodesBeforeIterator" |
2304 | - base="ZorbaCollectionIteratorHelper<ZorbaInsertNodesBeforeIterator, PlanIteratorState>"> |
2305 | + base="ZorbaCollectionIteratorHelper<ZorbaInsertNodesBeforeIterator, PlanIteratorState>" |
2306 | + generateVisitor="false"> |
2307 | |
2308 | <zorba:description author="Zorba Team"> |
2309 | zorba:insert-nodes-before |
2310 | @@ -592,12 +602,14 @@ |
2311 | <zorba:getScriptingKind returnValue="UPDATING_EXPR"/> |
2312 | <zorba:accessesDynCtx returnValue="true"/> |
2313 | <zorba:mustCopyInputNodes producer="2"/> |
2314 | + <zorba:processPragma/> |
2315 | </zorba:methods> |
2316 | |
2317 | </zorba:function> |
2318 | |
2319 | <zorba:constructor> |
2320 | <zorba:parameter type="bool" name="isDynamic" base="true"/> |
2321 | + <zorba:parameter type="bool" name="needToCopy" base="true"/> |
2322 | </zorba:constructor> |
2323 | |
2324 | <zorba:method const="true" name="getCollection" |
2325 | @@ -613,7 +625,8 @@ |
2326 | ********************************************************************************/ |
2327 | --> |
2328 | <zorba:iterator name="ZorbaInsertNodesAfterIterator" |
2329 | - base="ZorbaCollectionIteratorHelper<ZorbaInsertNodesAfterIterator, PlanIteratorState>"> |
2330 | + base="ZorbaCollectionIteratorHelper<ZorbaInsertNodesAfterIterator, PlanIteratorState>" |
2331 | + generateVisitor="false"> |
2332 | |
2333 | <zorba:description author="Zorba Team"> |
2334 | zorba:insert-nodes-after |
2335 | @@ -653,12 +666,14 @@ |
2336 | <zorba:getScriptingKind returnValue="UPDATING_EXPR"/> |
2337 | <zorba:accessesDynCtx returnValue="true"/> |
2338 | <zorba:mustCopyInputNodes producer="2"/> |
2339 | + <zorba:processPragma/> |
2340 | </zorba:methods> |
2341 | |
2342 | </zorba:function> |
2343 | |
2344 | <zorba:constructor> |
2345 | <zorba:parameter type="bool" name="isDynamic" base="true"/> |
2346 | + <zorba:parameter type="bool" name="needToCopy" base="true"/> |
2347 | </zorba:constructor> |
2348 | |
2349 | <zorba:member type="bool" name="theIsDynamic"/> |
2350 | @@ -676,7 +691,8 @@ |
2351 | ********************************************************************************/ |
2352 | --> |
2353 | <zorba:iterator name="ZorbaApplyInsertNodesIterator" |
2354 | - base="ZorbaCollectionIteratorHelper<ZorbaApplyInsertNodesIterator, ZorbaApplyInsertNodesIteratorState>"> |
2355 | + base="ZorbaCollectionIteratorHelper<ZorbaApplyInsertNodesIterator, ZorbaApplyInsertNodesIteratorState>" |
2356 | + generateVisitor="false"> |
2357 | |
2358 | <zorba:description author="Zorba Team"> |
2359 | zorba:apply-insert-nodes |
2360 | @@ -709,12 +725,14 @@ |
2361 | <zorba:accessesDynCtx returnValue="true"/> |
2362 | <zorba:propagatesInputNodes/> |
2363 | <zorba:mustCopyInputNodes producer="1"/> |
2364 | + <zorba:processPragma/> |
2365 | </zorba:methods> |
2366 | |
2367 | </zorba:function> |
2368 | |
2369 | <zorba:constructor> |
2370 | <zorba:parameter type="bool" name="isDynamic" base="true"/> |
2371 | + <zorba:parameter type="bool" name="needToCopy" base="true"/> |
2372 | </zorba:constructor> |
2373 | |
2374 | <zorba:method const="true" name="getCollection" |
2375 | @@ -737,7 +755,8 @@ |
2376 | ********************************************************************************/ |
2377 | --> |
2378 | <zorba:iterator name="ZorbaApplyInsertNodesFirstIterator" |
2379 | - base="ZorbaCollectionIteratorHelper<ZorbaApplyInsertNodesFirstIterator, ZorbaApplyInsertNodesFirstIteratorState>"> |
2380 | + base="ZorbaCollectionIteratorHelper<ZorbaApplyInsertNodesFirstIterator, ZorbaApplyInsertNodesFirstIteratorState>" |
2381 | + generateVisitor="false"> |
2382 | |
2383 | <zorba:description author="Zorba Team"> |
2384 | zorba:apply-insertnodes-first |
2385 | @@ -776,12 +795,14 @@ |
2386 | <zorba:accessesDynCtx returnValue="true"/> |
2387 | <zorba:propagatesInputNodes/> |
2388 | <zorba:mustCopyInputNodes producer="1"/> |
2389 | + <zorba:processPragma/> |
2390 | </zorba:methods> |
2391 | |
2392 | </zorba:function> |
2393 | |
2394 | <zorba:constructor> |
2395 | <zorba:parameter type="bool" name="isDynamic" base="true"/> |
2396 | + <zorba:parameter type="bool" name="needToCopy" base="true"/> |
2397 | </zorba:constructor> |
2398 | |
2399 | <zorba:method const="true" name="getCollection" |
2400 | @@ -804,7 +825,8 @@ |
2401 | ********************************************************************************/ |
2402 | --> |
2403 | <zorba:iterator name="ZorbaApplyInsertNodesLastIterator" |
2404 | - base="ZorbaCollectionIteratorHelper<ZorbaApplyInsertNodesLastIterator, ZorbaApplyInsertNodesLastIteratorState>"> |
2405 | + base="ZorbaCollectionIteratorHelper<ZorbaApplyInsertNodesLastIterator, ZorbaApplyInsertNodesLastIteratorState>" |
2406 | + generateVisitor="false"> |
2407 | |
2408 | <zorba:description author="Zorba Team"> |
2409 | zorba:apply-insertnodes-last |
2410 | @@ -843,12 +865,14 @@ |
2411 | <zorba:accessesDynCtx returnValue="true"/> |
2412 | <zorba:propagatesInputNodes/> |
2413 | <zorba:mustCopyInputNodes producer="1"/> |
2414 | + <zorba:processPragma/> |
2415 | </zorba:methods> |
2416 | |
2417 | </zorba:function> |
2418 | |
2419 | <zorba:constructor> |
2420 | <zorba:parameter type="bool" name="isDynamic" base="true"/> |
2421 | + <zorba:parameter type="bool" name="needToCopy" base="true"/> |
2422 | </zorba:constructor> |
2423 | |
2424 | <zorba:method const="true" name="getCollection" |
2425 | @@ -871,7 +895,8 @@ |
2426 | ********************************************************************************/ |
2427 | --> |
2428 | <zorba:iterator name="ZorbaApplyInsertNodesBeforeIterator" |
2429 | - base="ZorbaCollectionIteratorHelper<ZorbaApplyInsertNodesBeforeIterator, ZorbaApplyInsertNodesBeforeIteratorState>"> |
2430 | + base="ZorbaCollectionIteratorHelper<ZorbaApplyInsertNodesBeforeIterator, ZorbaApplyInsertNodesBeforeIteratorState>" |
2431 | + generateVisitor="false"> |
2432 | |
2433 | <zorba:description author="Zorba Team"> |
2434 | zorba:apply-insert-nodes-before |
2435 | @@ -914,12 +939,14 @@ |
2436 | <zorba:accessesDynCtx returnValue="true"/> |
2437 | <zorba:propagatesInputNodes/> |
2438 | <zorba:mustCopyInputNodes producer="2"/> |
2439 | + <zorba:processPragma/> |
2440 | </zorba:methods> |
2441 | |
2442 | </zorba:function> |
2443 | |
2444 | <zorba:constructor> |
2445 | <zorba:parameter type="bool" name="isDynamic" base="true"/> |
2446 | + <zorba:parameter type="bool" name="needToCopy" base="true"/> |
2447 | </zorba:constructor> |
2448 | |
2449 | <zorba:method const="true" name="getCollection" |
2450 | @@ -942,7 +969,8 @@ |
2451 | ********************************************************************************/ |
2452 | --> |
2453 | <zorba:iterator name="ZorbaApplyInsertNodesAfterIterator" |
2454 | - base="ZorbaCollectionIteratorHelper<ZorbaApplyInsertNodesAfterIterator, ZorbaApplyInsertNodesAfterIteratorState>"> |
2455 | + base="ZorbaCollectionIteratorHelper<ZorbaApplyInsertNodesAfterIterator, ZorbaApplyInsertNodesAfterIteratorState>" |
2456 | + generateVisitor="false"> |
2457 | |
2458 | <zorba:description author="Zorba Team"> |
2459 | zorba:apply-insertnodes-after |
2460 | @@ -985,12 +1013,14 @@ |
2461 | <zorba:accessesDynCtx returnValue="true"/> |
2462 | <zorba:propagatesInputNodes/> |
2463 | <zorba:mustCopyInputNodes producer="2"/> |
2464 | + <zorba:processPragma/> |
2465 | </zorba:methods> |
2466 | |
2467 | </zorba:function> |
2468 | |
2469 | <zorba:constructor> |
2470 | <zorba:parameter type="bool" name="isDynamic" base="true"/> |
2471 | + <zorba:parameter type="bool" name="needToCopy" base="true"/> |
2472 | </zorba:constructor> |
2473 | |
2474 | <zorba:method const="true" name="getCollection" |
2475 | |
2476 | === modified file 'src/runtime/spec/plan_iter_visitor_h.xq' |
2477 | --- src/runtime/spec/plan_iter_visitor_h.xq 2012-09-17 00:36:37 +0000 |
2478 | +++ src/runtime/spec/plan_iter_visitor_h.xq 2012-09-19 21:43:18 +0000 |
2479 | @@ -64,11 +64,9 @@ |
2480 | let $doc := fn:parse-xml(file:read-text($file))/zorba:iterators |
2481 | |
2482 | return string-join(for $iter in $doc//zorba:iterator return |
2483 | - if(fn:not($iter/@generateVisitor) or $iter/@generateVisitor eq "true") then |
2484 | if(fn:not($iter/@name = "")) then |
2485 | local:process-iter($iter, $type) |
2486 | else () |
2487 | - else () |
2488 | ,$gen:newline) |
2489 | }; |
2490 | |
2491 | |
2492 | === modified file 'src/runtime/spec/printer_visitor_h.xq' |
2493 | --- src/runtime/spec/printer_visitor_h.xq 2012-09-17 00:36:37 +0000 |
2494 | +++ src/runtime/spec/printer_visitor_h.xq 2012-09-19 21:43:18 +0000 |
2495 | @@ -37,13 +37,9 @@ |
2496 | string-join ( |
2497 | for $iter in $doc//zorba:iterator |
2498 | return |
2499 | - if( fn:not($iter/@generateVisitor) or |
2500 | - $iter/@generateVisitor eq "true") |
2501 | - then |
2502 | if(fn:not($iter/@name = "")) then |
2503 | local:process-iter($iter) |
2504 | - else () |
2505 | - else (), |
2506 | + else (), |
2507 | concat($gen:newline, $gen:newline)) |
2508 | }; |
2509 | |
2510 | |
2511 | === modified file 'src/runtime/visitors/pregenerated/printer_visitor.cpp' |
2512 | --- src/runtime/visitors/pregenerated/printer_visitor.cpp 2012-09-17 00:36:37 +0000 |
2513 | +++ src/runtime/visitors/pregenerated/printer_visitor.cpp 2012-09-19 21:43:18 +0000 |
2514 | @@ -408,146 +408,6 @@ |
2515 | // </ZorbaIndexOfIterator> |
2516 | |
2517 | |
2518 | -// <ZorbaInsertNodesIterator> |
2519 | -void PrinterVisitor::beginVisit ( const ZorbaInsertNodesIterator& a) { |
2520 | - thePrinter.startBeginVisit("ZorbaInsertNodesIterator", ++theId); |
2521 | - printCommons( &a, theId ); |
2522 | - thePrinter.endBeginVisit( theId ); |
2523 | -} |
2524 | - |
2525 | -void PrinterVisitor::endVisit ( const ZorbaInsertNodesIterator& ) { |
2526 | - thePrinter.startEndVisit(); |
2527 | - thePrinter.endEndVisit(); |
2528 | -} |
2529 | -// </ZorbaInsertNodesIterator> |
2530 | - |
2531 | - |
2532 | -// <ZorbaInsertNodesFirstIterator> |
2533 | -void PrinterVisitor::beginVisit ( const ZorbaInsertNodesFirstIterator& a) { |
2534 | - thePrinter.startBeginVisit("ZorbaInsertNodesFirstIterator", ++theId); |
2535 | - printCommons( &a, theId ); |
2536 | - thePrinter.endBeginVisit( theId ); |
2537 | -} |
2538 | - |
2539 | -void PrinterVisitor::endVisit ( const ZorbaInsertNodesFirstIterator& ) { |
2540 | - thePrinter.startEndVisit(); |
2541 | - thePrinter.endEndVisit(); |
2542 | -} |
2543 | -// </ZorbaInsertNodesFirstIterator> |
2544 | - |
2545 | - |
2546 | -// <ZorbaInsertNodesLastIterator> |
2547 | -void PrinterVisitor::beginVisit ( const ZorbaInsertNodesLastIterator& a) { |
2548 | - thePrinter.startBeginVisit("ZorbaInsertNodesLastIterator", ++theId); |
2549 | - printCommons( &a, theId ); |
2550 | - thePrinter.endBeginVisit( theId ); |
2551 | -} |
2552 | - |
2553 | -void PrinterVisitor::endVisit ( const ZorbaInsertNodesLastIterator& ) { |
2554 | - thePrinter.startEndVisit(); |
2555 | - thePrinter.endEndVisit(); |
2556 | -} |
2557 | -// </ZorbaInsertNodesLastIterator> |
2558 | - |
2559 | - |
2560 | -// <ZorbaInsertNodesBeforeIterator> |
2561 | -void PrinterVisitor::beginVisit ( const ZorbaInsertNodesBeforeIterator& a) { |
2562 | - thePrinter.startBeginVisit("ZorbaInsertNodesBeforeIterator", ++theId); |
2563 | - printCommons( &a, theId ); |
2564 | - thePrinter.endBeginVisit( theId ); |
2565 | -} |
2566 | - |
2567 | -void PrinterVisitor::endVisit ( const ZorbaInsertNodesBeforeIterator& ) { |
2568 | - thePrinter.startEndVisit(); |
2569 | - thePrinter.endEndVisit(); |
2570 | -} |
2571 | -// </ZorbaInsertNodesBeforeIterator> |
2572 | - |
2573 | - |
2574 | -// <ZorbaInsertNodesAfterIterator> |
2575 | -void PrinterVisitor::beginVisit ( const ZorbaInsertNodesAfterIterator& a) { |
2576 | - thePrinter.startBeginVisit("ZorbaInsertNodesAfterIterator", ++theId); |
2577 | - printCommons( &a, theId ); |
2578 | - thePrinter.endBeginVisit( theId ); |
2579 | -} |
2580 | - |
2581 | -void PrinterVisitor::endVisit ( const ZorbaInsertNodesAfterIterator& ) { |
2582 | - thePrinter.startEndVisit(); |
2583 | - thePrinter.endEndVisit(); |
2584 | -} |
2585 | -// </ZorbaInsertNodesAfterIterator> |
2586 | - |
2587 | - |
2588 | -// <ZorbaApplyInsertNodesIterator> |
2589 | -void PrinterVisitor::beginVisit ( const ZorbaApplyInsertNodesIterator& a) { |
2590 | - thePrinter.startBeginVisit("ZorbaApplyInsertNodesIterator", ++theId); |
2591 | - printCommons( &a, theId ); |
2592 | - thePrinter.endBeginVisit( theId ); |
2593 | -} |
2594 | - |
2595 | -void PrinterVisitor::endVisit ( const ZorbaApplyInsertNodesIterator& ) { |
2596 | - thePrinter.startEndVisit(); |
2597 | - thePrinter.endEndVisit(); |
2598 | -} |
2599 | -// </ZorbaApplyInsertNodesIterator> |
2600 | - |
2601 | - |
2602 | -// <ZorbaApplyInsertNodesFirstIterator> |
2603 | -void PrinterVisitor::beginVisit ( const ZorbaApplyInsertNodesFirstIterator& a) { |
2604 | - thePrinter.startBeginVisit("ZorbaApplyInsertNodesFirstIterator", ++theId); |
2605 | - printCommons( &a, theId ); |
2606 | - thePrinter.endBeginVisit( theId ); |
2607 | -} |
2608 | - |
2609 | -void PrinterVisitor::endVisit ( const ZorbaApplyInsertNodesFirstIterator& ) { |
2610 | - thePrinter.startEndVisit(); |
2611 | - thePrinter.endEndVisit(); |
2612 | -} |
2613 | -// </ZorbaApplyInsertNodesFirstIterator> |
2614 | - |
2615 | - |
2616 | -// <ZorbaApplyInsertNodesLastIterator> |
2617 | -void PrinterVisitor::beginVisit ( const ZorbaApplyInsertNodesLastIterator& a) { |
2618 | - thePrinter.startBeginVisit("ZorbaApplyInsertNodesLastIterator", ++theId); |
2619 | - printCommons( &a, theId ); |
2620 | - thePrinter.endBeginVisit( theId ); |
2621 | -} |
2622 | - |
2623 | -void PrinterVisitor::endVisit ( const ZorbaApplyInsertNodesLastIterator& ) { |
2624 | - thePrinter.startEndVisit(); |
2625 | - thePrinter.endEndVisit(); |
2626 | -} |
2627 | -// </ZorbaApplyInsertNodesLastIterator> |
2628 | - |
2629 | - |
2630 | -// <ZorbaApplyInsertNodesBeforeIterator> |
2631 | -void PrinterVisitor::beginVisit ( const ZorbaApplyInsertNodesBeforeIterator& a) { |
2632 | - thePrinter.startBeginVisit("ZorbaApplyInsertNodesBeforeIterator", ++theId); |
2633 | - printCommons( &a, theId ); |
2634 | - thePrinter.endBeginVisit( theId ); |
2635 | -} |
2636 | - |
2637 | -void PrinterVisitor::endVisit ( const ZorbaApplyInsertNodesBeforeIterator& ) { |
2638 | - thePrinter.startEndVisit(); |
2639 | - thePrinter.endEndVisit(); |
2640 | -} |
2641 | -// </ZorbaApplyInsertNodesBeforeIterator> |
2642 | - |
2643 | - |
2644 | -// <ZorbaApplyInsertNodesAfterIterator> |
2645 | -void PrinterVisitor::beginVisit ( const ZorbaApplyInsertNodesAfterIterator& a) { |
2646 | - thePrinter.startBeginVisit("ZorbaApplyInsertNodesAfterIterator", ++theId); |
2647 | - printCommons( &a, theId ); |
2648 | - thePrinter.endBeginVisit( theId ); |
2649 | -} |
2650 | - |
2651 | -void PrinterVisitor::endVisit ( const ZorbaApplyInsertNodesAfterIterator& ) { |
2652 | - thePrinter.startEndVisit(); |
2653 | - thePrinter.endEndVisit(); |
2654 | -} |
2655 | -// </ZorbaApplyInsertNodesAfterIterator> |
2656 | - |
2657 | - |
2658 | // <ZorbaDeleteNodesIterator> |
2659 | void PrinterVisitor::beginVisit ( const ZorbaDeleteNodesIterator& a) { |
2660 | thePrinter.startBeginVisit("ZorbaDeleteNodesIterator", ++theId); |
2661 | |
2662 | === modified file 'src/runtime/visitors/printer_visitor_impl.cpp' |
2663 | --- src/runtime/visitors/printer_visitor_impl.cpp 2012-09-18 16:29:31 +0000 |
2664 | +++ src/runtime/visitors/printer_visitor_impl.cpp 2012-09-19 21:43:18 +0000 |
2665 | @@ -58,6 +58,7 @@ |
2666 | #include "runtime/scripting/scripting.h" |
2667 | #include "runtime/json/json_constructors.h" |
2668 | #include "runtime/collections/collections_impl.h" |
2669 | +#include "runtime/collections/collections.h" |
2670 | |
2671 | #ifdef ZORBA_WITH_DEBUGGER |
2672 | #include "debugger/debugger_commons.h" |
2673 | @@ -1476,6 +1477,40 @@ |
2674 | |
2675 | #undef PRINTER_INDEX_PROBE_VISITOR_DEFINITION |
2676 | |
2677 | +#define PRINTER_INSERT_NODES_VISITOR_DEFINITION(class) \ |
2678 | + void PrinterVisitor::beginVisit ( const class& a ) \ |
2679 | + { \ |
2680 | + thePrinter.startBeginVisit(#class, ++theId); \ |
2681 | + if (a.isDynamic()) \ |
2682 | + { \ |
2683 | + thePrinter.addAttribute("is-dynamic", "true"); \ |
2684 | + } \ |
2685 | + if (a.needToCopy()) \ |
2686 | + { \ |
2687 | + thePrinter.addAttribute("need-to-copy", "true"); \ |
2688 | + } \ |
2689 | + printCommons( &a, theId ); \ |
2690 | + thePrinter.endBeginVisit( theId); \ |
2691 | + } \ |
2692 | + void PrinterVisitor::endVisit ( const class& ) \ |
2693 | + { \ |
2694 | + thePrinter.startEndVisit(); \ |
2695 | + thePrinter.endEndVisit(); \ |
2696 | + } |
2697 | + |
2698 | + PRINTER_INSERT_NODES_VISITOR_DEFINITION(ZorbaInsertNodesIterator); |
2699 | + PRINTER_INSERT_NODES_VISITOR_DEFINITION(ZorbaInsertNodesFirstIterator); |
2700 | + PRINTER_INSERT_NODES_VISITOR_DEFINITION(ZorbaInsertNodesLastIterator); |
2701 | + PRINTER_INSERT_NODES_VISITOR_DEFINITION(ZorbaInsertNodesBeforeIterator); |
2702 | + PRINTER_INSERT_NODES_VISITOR_DEFINITION(ZorbaInsertNodesAfterIterator); |
2703 | + PRINTER_INSERT_NODES_VISITOR_DEFINITION(ZorbaApplyInsertNodesIterator); |
2704 | + PRINTER_INSERT_NODES_VISITOR_DEFINITION(ZorbaApplyInsertNodesFirstIterator); |
2705 | + PRINTER_INSERT_NODES_VISITOR_DEFINITION(ZorbaApplyInsertNodesLastIterator); |
2706 | + PRINTER_INSERT_NODES_VISITOR_DEFINITION(ZorbaApplyInsertNodesBeforeIterator); |
2707 | + PRINTER_INSERT_NODES_VISITOR_DEFINITION(ZorbaApplyInsertNodesAfterIterator); |
2708 | + |
2709 | +#undef PRINTER_INSERT_NODES_VISITOR_DEFINITION |
2710 | + |
2711 | PRINTER_VISITOR_DEFINITION(DynamicFnCallIterator); |
2712 | |
2713 | PRINTER_VISITOR_DEFINITION(EvalIterator); |
2714 | |
2715 | === modified file 'src/zorbamisc/ns_consts.h' |
2716 | --- src/zorbamisc/ns_consts.h 2012-09-17 00:36:37 +0000 |
2717 | +++ src/zorbamisc/ns_consts.h 2012-09-19 21:43:18 +0000 |
2718 | @@ -56,6 +56,7 @@ |
2719 | #define ZORBA_FEATURES_NS ZORBA_NS "features" |
2720 | #define ZORBA_ANNOTATIONS_NS ZORBA_NS "annotations" |
2721 | #define ZORBA_COLLATION_NS_BASE ZORBA_NS "collations/" |
2722 | +#define ZORBA_EXTENSIONS_NS ZORBA_NS "extensions" |
2723 | |
2724 | // TODO these probably should not be in "ns_consts" |
2725 | #define ZORBA_OPTION_ENABLE_DTD "enable-dtd" |
2726 | |
2727 | === added file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/collections/no_copy_01.iter' |
2728 | --- test/rbkt/ExpCompilerResults/IterPlan/zorba/collections/no_copy_01.iter 1970-01-01 00:00:00 +0000 |
2729 | +++ test/rbkt/ExpCompilerResults/IterPlan/zorba/collections/no_copy_01.iter 2012-09-19 21:43:18 +0000 |
2730 | @@ -0,0 +1,61 @@ |
2731 | +Iterator tree for main query: |
2732 | +<SequentialIterator> |
2733 | + <ApplyIterator> |
2734 | + <ZorbaCreateCollectionIterator> |
2735 | + <SingletonIterator value="xs:QName(http://www.w3.org/2005/xquery-local-functions,local,bar)"/> |
2736 | + </ZorbaCreateCollectionIterator> |
2737 | + </ApplyIterator> |
2738 | + <FnConcatIterator> |
2739 | + <MaterializeIterator> |
2740 | + <flwor::FLWORIterator> |
2741 | + <ForVariable name="n"> |
2742 | + <ElementIterator> |
2743 | + <SingletonIterator value="xs:QName(,,a)"/> |
2744 | + </ElementIterator> |
2745 | + </ForVariable> |
2746 | + <MaterializeClause> |
2747 | + <MaterializeForVariable inputVar="n : "/> |
2748 | + </MaterializeClause> |
2749 | + <ReturnClause> |
2750 | + <IsSameNodeIterator> |
2751 | + <ForVarIterator varname="n"/> |
2752 | + <MaterializeIterator> |
2753 | + <TreatIterator type="[NodeXQType anyNode content=[XQType ANY_TYPE_KIND*]]" quant="?"> |
2754 | + <ZorbaApplyInsertNodesLastIterator is-dynamic="true" need-to-copy="true"> |
2755 | + <SingletonIterator value="xs:QName(http://www.w3.org/2005/xquery-local-functions,local,bar)"/> |
2756 | + <ForVarIterator varname="n"/> |
2757 | + </ZorbaApplyInsertNodesLastIterator> |
2758 | + </TreatIterator> |
2759 | + </MaterializeIterator> |
2760 | + </IsSameNodeIterator> |
2761 | + </ReturnClause> |
2762 | + </flwor::FLWORIterator> |
2763 | + </MaterializeIterator> |
2764 | + <MaterializeIterator> |
2765 | + <flwor::FLWORIterator> |
2766 | + <ForVariable name="n"> |
2767 | + <ElementIterator> |
2768 | + <SingletonIterator value="xs:QName(,,a)"/> |
2769 | + </ElementIterator> |
2770 | + </ForVariable> |
2771 | + <MaterializeClause> |
2772 | + <MaterializeForVariable inputVar="n : "/> |
2773 | + </MaterializeClause> |
2774 | + <ReturnClause> |
2775 | + <IsSameNodeIterator> |
2776 | + <ForVarIterator varname="n"/> |
2777 | + <MaterializeIterator> |
2778 | + <TreatIterator type="[NodeXQType anyNode content=[XQType ANY_TYPE_KIND*]]" quant="?"> |
2779 | + <ZorbaApplyInsertNodesLastIterator is-dynamic="true"> |
2780 | + <SingletonIterator value="xs:QName(http://www.w3.org/2005/xquery-local-functions,local,bar)"/> |
2781 | + <ForVarIterator varname="n"/> |
2782 | + </ZorbaApplyInsertNodesLastIterator> |
2783 | + </TreatIterator> |
2784 | + </MaterializeIterator> |
2785 | + </IsSameNodeIterator> |
2786 | + </ReturnClause> |
2787 | + </flwor::FLWORIterator> |
2788 | + </MaterializeIterator> |
2789 | + </FnConcatIterator> |
2790 | +</SequentialIterator> |
2791 | + |
2792 | |
2793 | === added file 'test/rbkt/ExpQueryResults/zorba/collections/no_copy_01.xml.res' |
2794 | --- test/rbkt/ExpQueryResults/zorba/collections/no_copy_01.xml.res 1970-01-01 00:00:00 +0000 |
2795 | +++ test/rbkt/ExpQueryResults/zorba/collections/no_copy_01.xml.res 2012-09-19 21:43:18 +0000 |
2796 | @@ -0,0 +1,1 @@ |
2797 | +false true |
2798 | |
2799 | === added file 'test/rbkt/Queries/zorba/collections/no_copy_01.xq' |
2800 | --- test/rbkt/Queries/zorba/collections/no_copy_01.xq 1970-01-01 00:00:00 +0000 |
2801 | +++ test/rbkt/Queries/zorba/collections/no_copy_01.xq 2012-09-19 21:43:18 +0000 |
2802 | @@ -0,0 +1,14 @@ |
2803 | +import module namespace db = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml"; |
2804 | +import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl"; |
2805 | + |
2806 | +declare namespace ext = "http://www.zorba-xquery.com/extensions"; |
2807 | + |
2808 | +ddl:create(xs:QName("local:bar")); |
2809 | + |
2810 | +(: needs to copy because $n is used twice and the constructor is not inlined => false:) |
2811 | +let $n := <a/> |
2812 | +return $n is db:apply-insert-last(xs:QName("local:bar"), $n), |
2813 | + |
2814 | +(: doesn't need to copy because the pragma is used => true :) |
2815 | +let $n := <a/> |
2816 | +return (# ext:no-copy #) { $n is db:apply-insert-last(xs:QName("local:bar"), $n) } |
Validation queue starting for merge proposal. zorbatest. lambda. nu:8080/ remotequeue/ feature- pragma_ no_copy- 2012-06- 29T17-23- 58.019Z/ log.html
Log at: http://