Merge lp:~zorba-coders/zorba/markos-scratch into lp:zorba
- markos-scratch
- Merge into trunk
Proposed by
Markos Zaharioudakis
Status: | Merged |
---|---|
Approved by: | Markos Zaharioudakis |
Approved revision: | 10975 |
Merged at revision: | 11110 |
Proposed branch: | lp:~zorba-coders/zorba/markos-scratch |
Merge into: | lp:zorba |
Diff against target: |
4951 lines (+1239/-1080) 51 files modified
ChangeLog (+1/-0) src/compiler/api/compilercb.cpp (+1/-0) src/compiler/api/compilercb.h (+5/-5) src/compiler/codegen/plan_visitor.cpp (+37/-29) src/compiler/expression/expr.cpp (+43/-28) src/compiler/expression/expr.h (+42/-65) src/compiler/expression/expr_base.cpp (+28/-11) src/compiler/expression/expr_base.h (+0/-1) src/compiler/expression/expr_clone.cpp (+6/-5) src/compiler/expression/expr_consts.h (+59/-0) src/compiler/expression/expr_iter.cpp (+307/-145) src/compiler/expression/expr_manager.cpp (+14/-9) src/compiler/expression/expr_manager.h (+37/-17) src/compiler/expression/expr_put.cpp (+15/-15) src/compiler/expression/expr_type.cpp (+12/-16) src/compiler/expression/expr_utils.h (+8/-0) src/compiler/expression/flwor_expr.cpp (+13/-10) src/compiler/expression/flwor_expr.h (+32/-31) src/compiler/expression/fo_expr.cpp (+1/-0) src/compiler/expression/fo_expr.h (+0/-24) src/compiler/expression/ftnode.h (+4/-0) src/compiler/expression/script_exprs.cpp (+2/-2) src/compiler/expression/script_exprs.h (+3/-6) src/compiler/expression/update_exprs.cpp (+1/-0) src/compiler/rewriter/framework/rewriter.h (+1/-3) src/compiler/rewriter/rewriters/default_optimizer.cpp (+0/-3) src/compiler/rewriter/rules/flwor_rules.cpp (+42/-34) src/compiler/rewriter/rules/fold_rules.cpp (+125/-184) src/compiler/rewriter/rules/hoist_rules.cpp (+1/-1) src/compiler/rewriter/rules/index_join_rule.cpp (+2/-2) src/compiler/rewriter/rules/nodeid_rules.cpp (+8/-8) src/compiler/rewriter/rules/path_rules.cpp (+11/-11) src/compiler/rewriter/rules/ruleset.h (+18/-2) src/compiler/rewriter/rules/type_rules.cpp (+3/-3) src/compiler/rewriter/tools/dataflow_annotations.cpp (+22/-62) src/compiler/rewriter/tools/dataflow_annotations.h (+0/-3) src/compiler/rewriter/tools/expr_tools.cpp (+1/-1) src/compiler/translator/translator.cpp (+137/-131) src/compiler/xqddf/value_index.cpp (+1/-0) src/functions/func_booleans_impl.cpp (+1/-2) src/functions/func_collections_impl.cpp (+3/-0) src/functions/func_sequences_impl.cpp (+143/-111) src/functions/func_sequences_impl.h (+9/-37) src/functions/function.h (+2/-2) src/functions/function_consts.h (+2/-1) src/functions/udf.h (+3/-1) src/runtime/core/sequencetypes.cpp (+24/-24) src/runtime/core/sequencetypes.h (+6/-35) src/runtime/eval/eval.cpp (+1/-0) src/runtime/function_item/function_item.cpp (+1/-0) src/runtime/json/jsoniq_functions_impl.cpp (+1/-0) |
To merge this branch: | bzr merge lp:~zorba-coders/zorba/markos-scratch |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Markos Zaharioudakis | Approve | ||
Review via email: mp+131166@code.launchpad.net |
Commit message
reduced include dependencies on the compiler + various optimizer optimizations
Description of the change
reduced include dependencies on the compiler + various optimizer optimizations
To post a comment you must log in.
Revision history for this message
Markos Zaharioudakis (markos-za) : | # |
review:
Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : | # |
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job markos-
All tests succeeded!
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'ChangeLog' |
2 | --- ChangeLog 2012-10-23 21:07:15 +0000 |
3 | +++ ChangeLog 2012-10-24 11:34:21 +0000 |
4 | @@ -8,6 +8,7 @@ |
5 | |
6 | Optimizations: |
7 | * Optimized the MarkExpr and EliminateFlworVariables rules of the optimizer |
8 | + * Optimized the MarkFreeVars optimizer rule |
9 | |
10 | Bug Fixes/Other Changes: |
11 | * Fixed mustCopyInputNodes() method of no-copy, and jsoniq functions. |
12 | |
13 | === modified file 'src/compiler/api/compilercb.cpp' |
14 | --- src/compiler/api/compilercb.cpp 2012-10-12 09:05:54 +0000 |
15 | +++ src/compiler/api/compilercb.cpp 2012-10-24 11:34:21 +0000 |
16 | @@ -17,6 +17,7 @@ |
17 | |
18 | #include "compiler/api/compilercb.h" |
19 | #include "compiler/expression/expr_base.h" |
20 | +#include "compiler/expression/expr_manager.h" |
21 | |
22 | #ifdef ZORBA_WITH_DEBUGGER |
23 | #include "debugger/debugger_commons.h" |
24 | |
25 | === modified file 'src/compiler/api/compilercb.h' |
26 | --- src/compiler/api/compilercb.h 2012-10-12 09:05:54 +0000 |
27 | +++ src/compiler/api/compilercb.h 2012-10-24 11:34:21 +0000 |
28 | @@ -29,19 +29,21 @@ |
29 | // without having the definition of static_context availble. |
30 | # include "context/static_context.h" |
31 | #endif |
32 | + |
33 | #include "compiler/expression/pragma.h" |
34 | |
35 | #include "zorbaserialization/class_serializer.h" |
36 | |
37 | -#include "compiler/expression/mem_manager.h" |
38 | -#include "compiler/expression/expr_manager.h" |
39 | |
40 | -namespace zorba { |
41 | +namespace zorba |
42 | +{ |
43 | |
44 | #ifdef ZORBA_WITH_DEBUGGER |
45 | class DebuggerCommons; |
46 | #endif |
47 | class static_context; |
48 | +class ExprManager; |
49 | + |
50 | |
51 | /******************************************************************************* |
52 | There is one CompilerCB per query plus one CompilerCB per invocation of an |
53 | @@ -233,8 +235,6 @@ |
54 | |
55 | ExprManager* getExprManager() const { return theEM; } |
56 | |
57 | - MemoryManager& getMemoryManager() const { return theEM->getMemory(); } |
58 | - |
59 | // |
60 | // Pragmas |
61 | // |
62 | |
63 | === modified file 'src/compiler/codegen/plan_visitor.cpp' |
64 | --- src/compiler/codegen/plan_visitor.cpp 2012-10-08 12:09:36 +0000 |
65 | +++ src/compiler/codegen/plan_visitor.cpp 2012-10-24 11:34:21 +0000 |
66 | @@ -31,6 +31,7 @@ |
67 | #include "system/globalenv.h" |
68 | #include "system/properties.h" |
69 | |
70 | +#include "compiler/expression/expr_manager.h" |
71 | #include "compiler/api/compilercb.h" |
72 | #include "compiler/codegen/plan_visitor.h" |
73 | #include "compiler/expression/expr.h" |
74 | @@ -896,7 +897,9 @@ |
75 | { |
76 | ++numForClauses; |
77 | |
78 | - if (c->get_expr()->is_sequential()) |
79 | + const for_clause* fc = static_cast<const for_clause*>(c); |
80 | + |
81 | + if (fc->get_expr()->is_sequential()) |
82 | { |
83 | // TODO: do not convert to general flwor if the whole flwor consists |
84 | // of a single FOR followed by RETURN. |
85 | @@ -907,7 +910,9 @@ |
86 | } |
87 | else if (c->get_kind() == flwor_clause::let_clause) |
88 | { |
89 | - if (c->get_expr()->is_sequential()) |
90 | + const let_clause* lc = static_cast<const let_clause*>(c); |
91 | + |
92 | + if (lc->get_expr()->is_sequential()) |
93 | { |
94 | if (numForClauses > 0) |
95 | { |
96 | @@ -933,7 +938,7 @@ |
97 | { |
98 | materialize_clause* mat = |
99 | theCCB->theEM->create_materialize_clause(v.get_sctx(), |
100 | - v.get_return_expr()->get_loc()); |
101 | + v.get_return_expr()->get_loc()); |
102 | |
103 | v.add_clause(mat); |
104 | ++numClauses; |
105 | @@ -960,14 +965,17 @@ |
106 | case flwor_clause::let_clause: |
107 | case flwor_clause::window_clause: |
108 | { |
109 | + expr* domExpr = static_cast<const forletwin_clause*>(c)->get_expr(); |
110 | + |
111 | if (k == flwor_clause::for_clause || k == flwor_clause::window_clause) |
112 | { |
113 | - xqtref_t domainType = c->get_expr()->get_return_type(); |
114 | + xqtref_t domainType = domExpr->get_return_type(); |
115 | + |
116 | if (domainType->get_quantifier() != TypeConstants::QUANT_ONE) |
117 | ++numForClauses; |
118 | } |
119 | |
120 | - if (c->get_expr()->is_sequential()) |
121 | + if (domExpr->is_sequential()) |
122 | { |
123 | if (k == flwor_clause::for_clause || |
124 | k == flwor_clause::window_clause || |
125 | @@ -981,12 +989,12 @@ |
126 | v.get_clause(i-1)->get_kind() != flwor_clause::order_clause && |
127 | v.get_clause(i-1)->get_kind() != flwor_clause::group_clause) |
128 | { |
129 | - orderby_clause* mat = |
130 | - theCCB->theEM->create_orderby_clause(v.get_sctx(), |
131 | - c->get_loc(), |
132 | - true, |
133 | - modifiers, |
134 | - orderingExprs); |
135 | + orderby_clause* mat = theCCB->theEM-> |
136 | + create_orderby_clause(v.get_sctx(), |
137 | + c->get_loc(), |
138 | + true, |
139 | + modifiers, |
140 | + orderingExprs); |
141 | |
142 | v.add_clause(i, mat); |
143 | ++i; |
144 | @@ -997,12 +1005,12 @@ |
145 | (i < numClauses - 1 && |
146 | v.get_clause(i+1)->get_kind() != flwor_clause::group_clause)) |
147 | { |
148 | - orderby_clause* mat = |
149 | - theCCB->theEM->create_orderby_clause(v.get_sctx(), |
150 | - c->get_loc(), |
151 | - true, |
152 | - modifiers, |
153 | - orderingExprs); |
154 | + orderby_clause* mat = theCCB->theEM-> |
155 | + create_orderby_clause(v.get_sctx(), |
156 | + c->get_loc(), |
157 | + true, |
158 | + modifiers, |
159 | + orderingExprs); |
160 | |
161 | v.add_clause(i+1, mat); |
162 | ++numClauses; |
163 | @@ -1032,12 +1040,12 @@ |
164 | lastClause->get_kind() != flwor_clause::order_clause && |
165 | lastClause->get_kind() != flwor_clause::group_clause) |
166 | { |
167 | - orderby_clause* mat = |
168 | - theCCB->theEM->create_orderby_clause(v.get_sctx(), |
169 | - v.get_return_expr()->get_loc(), |
170 | - true, |
171 | - modifiers, |
172 | - orderingExprs); |
173 | + orderby_clause* mat = theCCB->theEM-> |
174 | + create_orderby_clause(v.get_sctx(), |
175 | + v.get_return_expr()->get_loc(), |
176 | + true, |
177 | + modifiers, |
178 | + orderingExprs); |
179 | |
180 | v.add_clause(mat); |
181 | ++numClauses; |
182 | @@ -1566,7 +1574,7 @@ |
183 | |
184 | return new flwor::WindowIterator(sctx, |
185 | var->get_loc(), |
186 | - wc->get_winkind() == window_clause::tumbling_window ? flwor::WindowIterator::TUMBLING : flwor::WindowIterator::SLIDING, |
187 | + wc->get_winkind() == tumbling_window ? flwor::WindowIterator::TUMBLING : flwor::WindowIterator::SLIDING, |
188 | PREV_ITER, |
189 | domainIter, |
190 | var->get_name(), |
191 | @@ -2272,10 +2280,10 @@ |
192 | enum FlowCtlException::action a; |
193 | switch (v.get_action()) |
194 | { |
195 | - case flowctl_expr::BREAK: |
196 | + case FLOW_BREAK: |
197 | a = FlowCtlException::BREAK; |
198 | break; |
199 | - case flowctl_expr::CONTINUE: |
200 | + case FLOW_CONTINUE: |
201 | a = FlowCtlException::CONTINUE; |
202 | break; |
203 | default: |
204 | @@ -3022,7 +3030,7 @@ |
205 | |
206 | theConstructorsStack.push(&v); |
207 | |
208 | - if (v.get_type() == text_expr::text_constructor) |
209 | + if (v.get_type() == text_constructor) |
210 | theEnclosedContextStack.push(TEXT_CONTENT); |
211 | else |
212 | theEnclosedContextStack.push(ATTRIBUTE_CONTENT); |
213 | @@ -3049,11 +3057,11 @@ |
214 | |
215 | switch (v.get_type()) |
216 | { |
217 | - case text_expr::text_constructor: |
218 | + case text_constructor: |
219 | push_itstack(new TextIterator(sctx, qloc, content, isRoot)); |
220 | break; |
221 | |
222 | - case text_expr::comment_constructor: |
223 | + case comment_constructor: |
224 | push_itstack(new CommentIterator(sctx, qloc, content, isRoot)); |
225 | break; |
226 | |
227 | |
228 | === modified file 'src/compiler/expression/expr.cpp' |
229 | --- src/compiler/expression/expr.cpp 2012-10-22 15:10:23 +0000 |
230 | +++ src/compiler/expression/expr.cpp 2012-10-24 11:34:21 +0000 |
231 | @@ -174,12 +174,12 @@ |
232 | static_context* sctx, |
233 | user_function* udf, |
234 | const QueryLoc& loc, |
235 | - order_type_t type, |
236 | - expr* inExpr) |
237 | + DocOrderMode type, |
238 | + expr* input) |
239 | : |
240 | expr(ccb, sctx, udf, loc, order_expr_kind), |
241 | - theType(type), |
242 | - theExpr(inExpr) |
243 | + theInput(input), |
244 | + theType(type) |
245 | { |
246 | compute_scripting_kind(); |
247 | } |
248 | @@ -187,7 +187,7 @@ |
249 | |
250 | void order_expr::compute_scripting_kind() |
251 | { |
252 | - theScriptingKind = theExpr->get_scripting_detail(); |
253 | + theScriptingKind = theInput->get_scripting_detail(); |
254 | |
255 | if (is_vacuous()) |
256 | theScriptingKind = SIMPLE_EXPR; |
257 | @@ -204,14 +204,14 @@ |
258 | const QueryLoc& loc, |
259 | enum ParseConstants::validation_mode_t mode, |
260 | const store::Item_t& typeName, |
261 | - expr* inExpr, |
262 | + expr* input, |
263 | rchandle<TypeManager> typemgr) |
264 | : |
265 | expr(ccb, sctx, udf, loc, validate_expr_kind), |
266 | + theInput(input), |
267 | theMode(mode), |
268 | theTypeName(typeName), |
269 | - theTypeMgr(typemgr), |
270 | - theExpr(inExpr) |
271 | + theTypeMgr(typemgr) |
272 | { |
273 | compute_scripting_kind(); |
274 | } |
275 | @@ -219,9 +219,9 @@ |
276 | |
277 | void validate_expr::compute_scripting_kind() |
278 | { |
279 | - checkNonUpdating(theExpr); |
280 | + checkNonUpdating(theInput); |
281 | |
282 | - theScriptingKind = theExpr->get_scripting_detail(); |
283 | + theScriptingKind = theInput->get_scripting_detail(); |
284 | |
285 | if (is_vacuous()) |
286 | theScriptingKind = SIMPLE_EXPR; |
287 | @@ -266,7 +266,7 @@ |
288 | const xqtref_t& type) |
289 | : |
290 | expr(ccb, sctx, udf, loc, kind), |
291 | - theInputExpr(input), |
292 | + theInput(input), |
293 | theTargetType(type) |
294 | { |
295 | assert(type != NULL); |
296 | @@ -290,9 +290,9 @@ |
297 | |
298 | void cast_or_castable_base_expr::compute_scripting_kind() |
299 | { |
300 | - checkNonUpdating(theInputExpr); |
301 | + checkNonUpdating(theInput); |
302 | |
303 | - theScriptingKind = theInputExpr->get_scripting_detail(); |
304 | + theScriptingKind = theInput->get_scripting_detail(); |
305 | |
306 | if (is_vacuous()) |
307 | theScriptingKind = SIMPLE_EXPR; |
308 | @@ -355,7 +355,7 @@ |
309 | const QueryLoc& loc, |
310 | expr* inputExpr, |
311 | const xqtref_t& type, |
312 | - TreatIterator::ErrorKind err, |
313 | + TreatErrorKind err, |
314 | bool check_prime, |
315 | store::Item* qname) |
316 | : |
317 | @@ -378,7 +378,7 @@ |
318 | const QueryLoc& loc, |
319 | expr* input, |
320 | const xqtref_t& type, |
321 | - PromoteIterator::ErrorKind err, |
322 | + PromoteErrorKind err, |
323 | store::Item* qname) |
324 | : |
325 | cast_base_expr(ccb, sctx, udf, loc, promote_expr_kind, input, type), |
326 | @@ -663,7 +663,7 @@ |
327 | static_context* sctx, |
328 | user_function* udf, |
329 | const QueryLoc& loc, |
330 | - text_constructor_type type_arg, |
331 | + TextConstructorType type_arg, |
332 | expr* content) |
333 | : |
334 | expr(ccb, sctx, udf, loc, text_expr_kind), |
335 | @@ -743,10 +743,10 @@ |
336 | static_context* sctx, |
337 | user_function* udf, |
338 | const QueryLoc& loc, |
339 | - expr* wrapped) |
340 | + expr* input) |
341 | : |
342 | expr(ccb, sctx, udf, loc, wrapper_expr_kind), |
343 | - theWrappedExpr(wrapped) |
344 | + theInput(input) |
345 | { |
346 | compute_scripting_kind(); |
347 | } |
348 | @@ -754,7 +754,7 @@ |
349 | |
350 | void wrapper_expr::compute_scripting_kind() |
351 | { |
352 | - theScriptingKind = theWrappedExpr->get_scripting_detail(); |
353 | + theScriptingKind = theInput->get_scripting_detail(); |
354 | } |
355 | |
356 | |
357 | @@ -1105,6 +1105,14 @@ |
358 | } |
359 | |
360 | |
361 | +void eval_expr::add_var(var_expr* var) |
362 | +{ |
363 | + theOuterVarNames.push_back(var->get_name()); |
364 | + theOuterVarTypes.push_back(var->get_return_type()); |
365 | + theArgs.push_back(var); |
366 | +} |
367 | + |
368 | + |
369 | #ifdef ZORBA_WITH_DEBUGGER |
370 | /******************************************************************************* |
371 | |
372 | @@ -1131,6 +1139,13 @@ |
373 | theScriptingKind = theExpr->get_scripting_detail(); |
374 | } |
375 | |
376 | + |
377 | +void debugger_expr::add_var(var_expr* var, expr* arg) |
378 | +{ |
379 | + theVars.push_back(var); |
380 | + theArgs.push_back(arg); |
381 | +} |
382 | + |
383 | #endif |
384 | |
385 | |
386 | @@ -1142,10 +1157,10 @@ |
387 | static_context* sctx, |
388 | user_function* udf, |
389 | const QueryLoc& loc, |
390 | - expr* aChild) |
391 | + expr* input) |
392 | : |
393 | - expr(ccb, sctx, udf, loc, aChild->get_expr_kind()), |
394 | - theExpr(aChild), |
395 | + expr(ccb, sctx, udf, loc, function_trace_expr_kind), |
396 | + theInput(input), |
397 | theFunctionArity(0) |
398 | { |
399 | bool modified; |
400 | @@ -1154,14 +1169,14 @@ |
401 | } |
402 | |
403 | |
404 | -function_trace_expr::function_trace_expr(user_function* udf, expr* aExpr) |
405 | +function_trace_expr::function_trace_expr(user_function* udf, expr* input) |
406 | : |
407 | - expr(aExpr->get_ccb(), |
408 | - aExpr->get_sctx(), |
409 | + expr(input->get_ccb(), |
410 | + input->get_sctx(), |
411 | udf, |
412 | - aExpr->get_loc(), |
413 | + input->get_loc(), |
414 | function_trace_expr_kind), |
415 | - theExpr(aExpr), |
416 | + theInput(input), |
417 | theFunctionArity(0) |
418 | { |
419 | bool modified; |
420 | @@ -1177,7 +1192,7 @@ |
421 | |
422 | void function_trace_expr::compute_scripting_kind() |
423 | { |
424 | - theScriptingKind = theExpr->get_scripting_detail(); |
425 | + theScriptingKind = theInput->get_scripting_detail(); |
426 | } |
427 | |
428 | |
429 | |
430 | === modified file 'src/compiler/expression/expr.h' |
431 | --- src/compiler/expression/expr.h 2012-10-09 14:06:08 +0000 |
432 | +++ src/compiler/expression/expr.h 2012-10-24 11:34:21 +0000 |
433 | @@ -28,7 +28,7 @@ |
434 | |
435 | #include "functions/signature.h" |
436 | |
437 | -#include "compiler/expression/var_expr.h" |
438 | +#include "compiler/expression/expr_base.h" |
439 | |
440 | #include "context/static_context.h" |
441 | #include "context/namespace_context.h" |
442 | @@ -37,7 +37,6 @@ |
443 | |
444 | #include "store/api/item.h" |
445 | |
446 | -#include "runtime/core/sequencetypes.h" |
447 | |
448 | namespace zorba |
449 | { |
450 | @@ -48,6 +47,7 @@ |
451 | class signature; |
452 | class pragma; |
453 | |
454 | + |
455 | /******************************************************************************* |
456 | [68] IfExpr ::= "if" "(" Expr ")" "then" ExprSingle "else" ExprSingle |
457 | ********************************************************************************/ |
458 | @@ -96,16 +96,9 @@ |
459 | friend class ExprIterator; |
460 | friend class expr; |
461 | |
462 | -public: |
463 | - enum order_type_t |
464 | - { |
465 | - ordered, |
466 | - unordered |
467 | - }; |
468 | - |
469 | protected: |
470 | - order_type_t theType; |
471 | - expr * theExpr; |
472 | + expr * theInput; |
473 | + DocOrderMode theType; |
474 | |
475 | protected: |
476 | order_expr( |
477 | @@ -113,13 +106,13 @@ |
478 | static_context* sctx, |
479 | user_function* udf, |
480 | const QueryLoc&, |
481 | - order_type_t, |
482 | + DocOrderMode, |
483 | expr*); |
484 | |
485 | public: |
486 | - order_type_t get_type() const { return theType; } |
487 | + expr* get_input() const { return theInput; } |
488 | |
489 | - expr* get_expr() const { return theExpr; } |
490 | + DocOrderMode get_type() const { return theType; } |
491 | |
492 | void compute_scripting_kind(); |
493 | |
494 | @@ -139,10 +132,10 @@ |
495 | friend class expr; |
496 | |
497 | protected: |
498 | - ParseConstants::validation_mode_t theMode; |
499 | - store::Item_t theTypeName; |
500 | - rchandle<TypeManager> theTypeMgr; |
501 | - expr * theExpr; |
502 | + expr * theInput; |
503 | + ParseConstants::validation_mode_t theMode; |
504 | + store::Item_t theTypeName; |
505 | + rchandle<TypeManager> theTypeMgr; |
506 | |
507 | protected: |
508 | validate_expr( |
509 | @@ -156,7 +149,7 @@ |
510 | rchandle<TypeManager>); |
511 | |
512 | public: |
513 | - expr* get_expr() const { return theExpr; } |
514 | + expr* get_input() const { return theInput; } |
515 | |
516 | const store::Item* get_type_name() const { return theTypeName; } |
517 | |
518 | @@ -205,7 +198,7 @@ |
519 | friend class expr; |
520 | |
521 | protected: |
522 | - expr * theInputExpr; |
523 | + expr * theInput; |
524 | xqtref_t theTargetType; |
525 | |
526 | protected: |
527 | @@ -219,7 +212,7 @@ |
528 | const xqtref_t& type); |
529 | |
530 | public: |
531 | - expr* get_input() const { return theInputExpr; } |
532 | + expr* get_input() const { return theInput; } |
533 | |
534 | xqtref_t get_target_type() const; |
535 | |
536 | @@ -297,9 +290,9 @@ |
537 | friend class expr; |
538 | |
539 | protected: |
540 | - TreatIterator::ErrorKind theErrorKind; |
541 | - bool theCheckPrime; |
542 | - store::Item_t theQName; |
543 | + TreatErrorKind theErrorKind; |
544 | + bool theCheckPrime; |
545 | + store::Item_t theQName; |
546 | |
547 | protected: |
548 | treat_expr( |
549 | @@ -309,12 +302,12 @@ |
550 | const QueryLoc&, |
551 | expr*, |
552 | const xqtref_t&, |
553 | - TreatIterator::ErrorKind err, |
554 | + TreatErrorKind err, |
555 | bool check_prime = true, |
556 | store::Item* qname = NULL); |
557 | |
558 | public: |
559 | - TreatIterator::ErrorKind get_err() const { return theErrorKind; } |
560 | + TreatErrorKind get_err() const { return theErrorKind; } |
561 | |
562 | bool get_check_prime() const { return theCheckPrime; } |
563 | |
564 | @@ -375,8 +368,8 @@ |
565 | friend class expr; |
566 | |
567 | protected: |
568 | - PromoteIterator::ErrorKind theErrorKind; |
569 | - store::Item_t theQName; |
570 | + PromoteErrorKind theErrorKind; |
571 | + store::Item_t theQName; |
572 | |
573 | protected: |
574 | promote_expr( |
575 | @@ -386,11 +379,11 @@ |
576 | const QueryLoc& loc, |
577 | expr* input, |
578 | const xqtref_t& type, |
579 | - PromoteIterator::ErrorKind err, |
580 | + PromoteErrorKind err, |
581 | store::Item* qname); |
582 | |
583 | public: |
584 | - PromoteIterator::ErrorKind get_err() const { return theErrorKind; } |
585 | + PromoteErrorKind get_err() const { return theErrorKind; } |
586 | |
587 | void set_qname(const store::Item_t& qname) { theQName = qname; } |
588 | |
589 | @@ -504,8 +497,8 @@ |
590 | friend class expr; |
591 | |
592 | private: |
593 | - expr* theInputExpr; |
594 | - bool theIsAttrName; |
595 | + expr * theInputExpr; |
596 | + bool theIsAttrName; |
597 | |
598 | protected: |
599 | name_cast_expr( |
600 | @@ -541,7 +534,7 @@ |
601 | |
602 | protected: |
603 | expr * theContent; |
604 | - bool theCopyInputNodes; |
605 | + bool theCopyInputNodes; |
606 | |
607 | protected: |
608 | doc_expr( |
609 | @@ -713,16 +706,9 @@ |
610 | friend class ExprIterator; |
611 | friend class expr; |
612 | |
613 | -public: |
614 | - typedef enum |
615 | - { |
616 | - text_constructor, |
617 | - comment_constructor |
618 | - } text_constructor_type; |
619 | - |
620 | protected: |
621 | - text_constructor_type type; |
622 | - expr * theContentExpr; |
623 | + TextConstructorType type; |
624 | + expr * theContentExpr; |
625 | |
626 | protected: |
627 | text_expr( |
628 | @@ -730,13 +716,13 @@ |
629 | static_context* sctx, |
630 | user_function* udf, |
631 | const QueryLoc&, |
632 | - text_constructor_type, |
633 | + TextConstructorType, |
634 | expr*); |
635 | |
636 | public: |
637 | expr* get_text() const { return theContentExpr; } |
638 | |
639 | - text_constructor_type get_type() const { return type; } |
640 | + TextConstructorType get_type() const { return type; } |
641 | |
642 | void compute_scripting_kind(); |
643 | |
644 | @@ -1040,7 +1026,7 @@ |
645 | friend class ExprManager; |
646 | |
647 | protected: |
648 | - expr * theWrappedExpr; |
649 | + expr * theInput; |
650 | |
651 | protected: |
652 | wrapper_expr( |
653 | @@ -1051,9 +1037,9 @@ |
654 | expr* wrapped); |
655 | |
656 | public: |
657 | - expr* get_expr() const { return theWrappedExpr; } |
658 | + expr* get_input() const { return theInput; } |
659 | |
660 | - void set_expr(expr* e) { theWrappedExpr = e;} |
661 | + void set_expr(expr* e) { theInput = e;} |
662 | |
663 | void compute_scripting_kind(); |
664 | |
665 | @@ -1073,11 +1059,11 @@ |
666 | friend class ExprManager; |
667 | |
668 | protected: |
669 | - expr* theExpr; |
670 | - store::Item_t theFunctionName; |
671 | - QueryLoc theFunctionLocation; |
672 | - QueryLoc theFunctionCallLocation; |
673 | - unsigned int theFunctionArity; |
674 | + expr * theInput; |
675 | + store::Item_t theFunctionName; |
676 | + QueryLoc theFunctionLocation; |
677 | + QueryLoc theFunctionCallLocation; |
678 | + unsigned int theFunctionArity; |
679 | |
680 | protected: |
681 | function_trace_expr( |
682 | @@ -1094,14 +1080,14 @@ |
683 | public: |
684 | virtual ~function_trace_expr(); |
685 | |
686 | + expr* get_input() const { return theInput; } |
687 | + |
688 | void compute_scripting_kind(); |
689 | |
690 | void accept(expr_visitor&); |
691 | |
692 | std::ostream& put(std::ostream&) const; |
693 | |
694 | - expr* get_expr() const { return theExpr; } |
695 | - |
696 | void setFunctionName(store::Item_t aFunctionName) |
697 | { |
698 | theFunctionName = aFunctionName; |
699 | @@ -1215,12 +1201,7 @@ |
700 | |
701 | const std::vector<xqtref_t>& get_var_types() const { return theOuterVarTypes; } |
702 | |
703 | - void add_var(var_expr* var) |
704 | - { |
705 | - theOuterVarNames.push_back(var->get_name()); |
706 | - theOuterVarTypes.push_back(var->get_return_type()); |
707 | - theArgs.push_back(var); |
708 | - } |
709 | + void add_var(var_expr* var); |
710 | |
711 | expr_script_kind_t get_inner_scripting_kind() const; |
712 | |
713 | @@ -1288,11 +1269,7 @@ |
714 | |
715 | const var_expr* get_var(csize i) const { return theVars[i]; } |
716 | |
717 | - void add_var(var_expr* var, expr* arg) |
718 | - { |
719 | - theVars.push_back(var); |
720 | - theArgs.push_back(arg); |
721 | - } |
722 | + void add_var(var_expr* var, expr* arg); |
723 | |
724 | void compute_scripting_kind(); |
725 | }; |
726 | |
727 | === modified file 'src/compiler/expression/expr_base.cpp' |
728 | --- src/compiler/expression/expr_base.cpp 2012-10-22 15:10:23 +0000 |
729 | +++ src/compiler/expression/expr_base.cpp 2012-10-24 11:34:21 +0000 |
730 | @@ -20,6 +20,7 @@ |
731 | #include "compiler/expression/fo_expr.h" |
732 | #include "compiler/expression/flwor_expr.h" |
733 | #include "compiler/expression/path_expr.h" |
734 | +#include "compiler/expression/script_exprs.h" |
735 | #include "compiler/expression/expr_iter.h" |
736 | #include "compiler/expression/expr_visitor.h" |
737 | #include "compiler/expression/expr_manager.h" |
738 | @@ -155,6 +156,7 @@ |
739 | // This is the default. The constructors for certain exprs set different values. |
740 | setNonDiscardable(ANNOTATION_FALSE); |
741 | setUnfoldable(ANNOTATION_FALSE); |
742 | + setContainsRecursiveCall(ANNOTATION_FALSE); |
743 | setConstructsNodes(ANNOTATION_FALSE); |
744 | setDereferencesNodes(ANNOTATION_FALSE); |
745 | } |
746 | @@ -766,8 +768,7 @@ |
747 | |
748 | while (kind == wrapper_expr_kind) |
749 | { |
750 | - const wrapper_expr* wrapperExpr = static_cast<const wrapper_expr*>(currExpr); |
751 | - currExpr = wrapperExpr->get_expr(); |
752 | + currExpr = static_cast<const wrapper_expr*>(currExpr)->get_input(); |
753 | kind = currExpr->get_expr_kind(); |
754 | } |
755 | |
756 | @@ -834,14 +835,14 @@ |
757 | |
758 | case order_expr_kind: |
759 | { |
760 | - const order_expr* orderExpr = static_cast<const order_expr *>(this); |
761 | - return orderExpr->get_expr()->is_map_internal(e, found); |
762 | + return static_cast<const order_expr*>(this)->get_input()-> |
763 | + is_map_internal(e, found); |
764 | } |
765 | |
766 | case wrapper_expr_kind: |
767 | { |
768 | - const wrapper_expr* wrapperExpr = static_cast<const wrapper_expr *>(this); |
769 | - return wrapperExpr->get_expr()->is_map_internal(e, found); |
770 | + return static_cast<const wrapper_expr*>(this)->get_input()-> |
771 | + is_map_internal(e, found); |
772 | } |
773 | |
774 | case const_expr_kind: |
775 | @@ -896,7 +897,9 @@ |
776 | if (found) |
777 | break; |
778 | |
779 | - if (clause->get_expr()->is_map_internal(e, found) && found) |
780 | + const for_clause* fc = static_cast<const for_clause*>(clause); |
781 | + |
782 | + if (fc->get_expr()->is_map_internal(e, found) && found) |
783 | { |
784 | break; |
785 | } |
786 | @@ -908,12 +911,25 @@ |
787 | break; |
788 | } |
789 | case flwor_clause::let_clause: |
790 | + { |
791 | + if (found) |
792 | + break; |
793 | + |
794 | + const let_clause* lc = static_cast<const let_clause*>(clause); |
795 | + |
796 | + if (lc->get_expr()->contains_expr(e)) |
797 | + return false; |
798 | + |
799 | + break; |
800 | + } |
801 | case flwor_clause::where_clause: |
802 | { |
803 | if (found) |
804 | break; |
805 | |
806 | - if (clause->get_expr()->contains_expr(e)) |
807 | + const where_clause* wc = static_cast<const where_clause*>(clause); |
808 | + |
809 | + if (wc->get_expr()->contains_expr(e)) |
810 | return false; |
811 | |
812 | break; |
813 | @@ -923,10 +939,11 @@ |
814 | if (found) |
815 | break; |
816 | |
817 | - if (clause->get_expr()->contains_expr(e)) |
818 | - return false; |
819 | - |
820 | const window_clause* wc = static_cast<const window_clause*>(clause); |
821 | + |
822 | + if (wc->get_expr()->contains_expr(e)) |
823 | + return false; |
824 | + |
825 | flwor_wincond* startCond = wc->get_win_start(); |
826 | flwor_wincond* stopCond = wc->get_win_stop(); |
827 | |
828 | |
829 | === modified file 'src/compiler/expression/expr_base.h' |
830 | --- src/compiler/expression/expr_base.h 2012-10-22 15:10:23 +0000 |
831 | +++ src/compiler/expression/expr_base.h 2012-10-24 11:34:21 +0000 |
832 | @@ -124,7 +124,6 @@ |
833 | ********************************************************************************/ |
834 | class expr |
835 | { |
836 | - friend class expr_iterator_data; |
837 | friend class ExprIterator; |
838 | friend class forletwin_clause; |
839 | friend class for_clause; |
840 | |
841 | === modified file 'src/compiler/expression/expr_clone.cpp' |
842 | --- src/compiler/expression/expr_clone.cpp 2012-10-09 12:56:08 +0000 |
843 | +++ src/compiler/expression/expr_clone.cpp 2012-10-24 11:34:21 +0000 |
844 | @@ -24,6 +24,7 @@ |
845 | #include "compiler/expression/json_exprs.h" |
846 | #include "compiler/expression/function_item_expr.h" |
847 | #include "compiler/expression/ft_expr.h" |
848 | +#include "compiler/expression/ftnode.h" |
849 | #include "compiler/expression/expr_manager.h" |
850 | |
851 | #include "compiler/api/compilercb.h" |
852 | @@ -462,7 +463,7 @@ |
853 | theLoc, |
854 | e->get_valmode(), |
855 | const_cast<store::Item*>(e->get_type_name()), |
856 | - e->get_expr()->clone(udf, subst), |
857 | + e->get_input()->clone(udf, subst), |
858 | e->get_typemgr()); |
859 | |
860 | break; |
861 | @@ -502,7 +503,7 @@ |
862 | udf, |
863 | theLoc, |
864 | e->get_type(), |
865 | - e->get_expr()->clone(udf, subst)); |
866 | + e->get_input()->clone(udf, subst)); |
867 | break; |
868 | } |
869 | #ifndef ZORBA_NO_FULL_TEXT |
870 | @@ -734,9 +735,9 @@ |
871 | { |
872 | const wrapper_expr* e = static_cast<const wrapper_expr*>(this); |
873 | |
874 | - expr* wrappedClone = e->theWrappedExpr->clone(udf, subst); |
875 | + expr* wrappedClone = e->theInput->clone(udf, subst); |
876 | |
877 | - if (e->theWrappedExpr->get_expr_kind() == var_expr_kind && |
878 | + if (e->theInput->get_expr_kind() == var_expr_kind && |
879 | wrappedClone->get_expr_kind() != var_expr_kind) |
880 | { |
881 | newExpr = wrappedClone; |
882 | @@ -753,7 +754,7 @@ |
883 | const function_trace_expr* e = static_cast<const function_trace_expr*>(this); |
884 | |
885 | function_trace_expr* cloneExpr = theCCB->theEM-> |
886 | - create_function_trace_expr(udf, e->theExpr->clone(udf, subst)); |
887 | + create_function_trace_expr(udf, e->theInput->clone(udf, subst)); |
888 | |
889 | cloneExpr->theFunctionName = e->theFunctionName; |
890 | cloneExpr->theFunctionLocation = e->theFunctionLocation; |
891 | |
892 | === modified file 'src/compiler/expression/expr_consts.h' |
893 | --- src/compiler/expression/expr_consts.h 2012-09-19 21:16:15 +0000 |
894 | +++ src/compiler/expression/expr_consts.h 2012-10-24 11:34:21 +0000 |
895 | @@ -21,6 +21,65 @@ |
896 | { |
897 | |
898 | |
899 | +enum PromoteErrorKind |
900 | +{ |
901 | + PROMOTE_FUNC_RETURN, |
902 | + PROMOTE_FUNC_PARAM, |
903 | + PROMOTE_TYPE_PROMOTION, |
904 | + PROMOTE_JSONIQ_ARRAY_SELECTOR, |
905 | + PROMOTE_JSONIQ_OBJECT_SELECTOR, |
906 | + PROMOTE_JSONIQ_SELECTOR |
907 | +}; |
908 | + |
909 | + |
910 | +enum TreatErrorKind |
911 | +{ |
912 | + TREAT_FUNC_RETURN, |
913 | + TREAT_FUNC_PARAM, |
914 | + TREAT_TYPE_MATCH, |
915 | + TREAT_EXPR, |
916 | + TREAT_INDEX_DOMAIN, |
917 | + TREAT_INDEX_KEY, |
918 | + TREAT_PATH_STEP, |
919 | + TREAT_PATH_DOT, |
920 | + TREAT_MULTI_VALUED_GROUPING_KEY, |
921 | + TREAT_JSONIQ_VALUE, |
922 | + TREAT_JSONIQ_UPDATE_TARGET, |
923 | + TREAT_JSONIQ_OBJECT_UPDATE_TARGET, |
924 | + TREAT_JSONIQ_OBJECT_UPDATE_CONTENT, |
925 | + TREAT_JSONIQ_ARRAY_UPDATE_TARGET, |
926 | + TREAT_JSONIQ_OBJECT_UPDATE_VALUE |
927 | +}; |
928 | + |
929 | + |
930 | +enum WindowKind |
931 | +{ |
932 | + tumbling_window, |
933 | + sliding_window |
934 | +}; |
935 | + |
936 | + |
937 | +enum TextConstructorType |
938 | +{ |
939 | + text_constructor, |
940 | + comment_constructor |
941 | +}; |
942 | + |
943 | + |
944 | +enum FlowCtlAction |
945 | +{ |
946 | + FLOW_BREAK, |
947 | + FLOW_CONTINUE |
948 | +}; |
949 | + |
950 | + |
951 | +enum DocOrderMode |
952 | +{ |
953 | + doc_ordered, |
954 | + doc_unordered |
955 | +}; |
956 | + |
957 | + |
958 | enum axis_kind_t |
959 | { |
960 | axis_kind_self = 0, |
961 | |
962 | === modified file 'src/compiler/expression/expr_iter.cpp' |
963 | --- src/compiler/expression/expr_iter.cpp 2012-10-22 15:10:23 +0000 |
964 | +++ src/compiler/expression/expr_iter.cpp 2012-10-24 11:34:21 +0000 |
965 | @@ -94,12 +94,6 @@ |
966 | |
967 | void ExprIterator::next() |
968 | { |
969 | - flwor_clause* c = NULL; |
970 | - window_clause* wc = NULL; |
971 | - orderby_clause* oc = NULL; |
972 | - group_clause* gc = NULL; |
973 | - flwor_wincond* wincond = NULL; |
974 | - |
975 | switch (theExpr->get_expr_kind()) |
976 | { |
977 | case flwor_expr_kind: |
978 | @@ -107,6 +101,223 @@ |
979 | { |
980 | flwor_expr* flworExpr = static_cast<flwor_expr*>(theExpr); |
981 | |
982 | +#if 0 |
983 | + switch (theState) |
984 | + { |
985 | + case 0: |
986 | + { |
987 | + theClausesIter = flworExpr->theClauses.begin(); |
988 | + theClausesEnd = flworExpr->theClauses.end(); |
989 | + |
990 | + if (theClausesIter == theClausesEnd) |
991 | + { |
992 | + theIsDone = true; |
993 | + theState = 10; |
994 | + return; |
995 | + } |
996 | + |
997 | + flwor_clause* c = *theClausesIter; |
998 | + |
999 | + switch (c->get_kind()) |
1000 | + { |
1001 | + case flwor_clause::for_clause: |
1002 | + case flwor_clause::let_clause: |
1003 | + { |
1004 | + theCurrentChild = &(static_cast<forletwin_clause *>(c)->theDomainExpr); |
1005 | + |
1006 | + ++theClausesIter; |
1007 | + theState = 1; |
1008 | + return; |
1009 | + } |
1010 | + case flwor_clause::window_clause: |
1011 | + { |
1012 | + theCurrentChild = &(static_cast<forletwin_clause *>(c)->theDomainExpr); |
1013 | + |
1014 | + theWincondIter = 0; |
1015 | + theState = 2; |
1016 | + return; |
1017 | + } |
1018 | + case flwor_clause::where_clause: |
1019 | + { |
1020 | + theCurrentChild = &(static_cast<where_clause *>(c)->theWhereExpr); |
1021 | + |
1022 | + ++theClausesIter; |
1023 | + theState = 1; |
1024 | + return; |
1025 | + } |
1026 | + case flwor_clause::count_clause: |
1027 | + { |
1028 | + ++theClausesIter; |
1029 | + break; |
1030 | + } |
1031 | + default: |
1032 | + ZORBA_ASSERT(false); |
1033 | + } |
1034 | + } |
1035 | + case 1: |
1036 | + { |
1037 | +nextclause: |
1038 | + |
1039 | + while(theClausesIter != theClausesEnd) |
1040 | + { |
1041 | + flwor_clause* c = *theClausesIter; |
1042 | + |
1043 | + switch (c->get_kind()) |
1044 | + { |
1045 | + case flwor_clause::for_clause: |
1046 | + case flwor_clause::let_clause: |
1047 | + { |
1048 | + theCurrentChild = &(static_cast<forletwin_clause *>(c)->theDomainExpr); |
1049 | + ++theClausesIter; |
1050 | + return; |
1051 | + } |
1052 | + case flwor_clause::window_clause: |
1053 | + { |
1054 | + window_clause* wc = static_cast<window_clause *>(*theClausesIter); |
1055 | + |
1056 | + theCurrentChild = &(wc->theDomainExpr); |
1057 | + |
1058 | + theState = 2; |
1059 | + theWincondIter = 0; |
1060 | + return; |
1061 | + } |
1062 | + |
1063 | + case flwor_clause::where_clause: |
1064 | + { |
1065 | + theCurrentChild = &(static_cast<where_clause *>(c)->theWhereExpr); |
1066 | + ++theClausesIter; |
1067 | + return; |
1068 | + } |
1069 | + |
1070 | + case flwor_clause::order_clause: |
1071 | + { |
1072 | + orderby_clause* oc = static_cast<orderby_clause *>(c); |
1073 | + |
1074 | + theArgsIter = oc->theOrderingExprs.begin(); |
1075 | + theArgsEnd = oc->theOrderingExprs.end(); |
1076 | + |
1077 | + theCurrentChild = &(*theArgsIter); |
1078 | + |
1079 | + ++theArgsIter; |
1080 | + theState = 3; |
1081 | + return; |
1082 | + } |
1083 | + |
1084 | + case flwor_clause::group_clause: |
1085 | + { |
1086 | + group_clause* gc = static_cast<group_clause *>(c); |
1087 | + |
1088 | + theGroupVarsIter = gc->theGroupVars.begin(); |
1089 | + theGroupVarsEnd = gc->theGroupVars.end(); |
1090 | + theNonGroupVarsIter = gc->theNonGroupVars.begin(); |
1091 | + theNonGroupVarsEnd = gc->theNonGroupVars.end(); |
1092 | + |
1093 | + theCurrentChild = &((*theGroupVarsIter).first); |
1094 | + |
1095 | + ++theGroupVarsIter; |
1096 | + theState = 4; |
1097 | + return; |
1098 | + } |
1099 | + |
1100 | + case flwor_clause::count_clause: |
1101 | + { |
1102 | + ++theClausesIter; |
1103 | + break; |
1104 | + } |
1105 | + |
1106 | + default: |
1107 | + { |
1108 | + ZORBA_ASSERT(false); |
1109 | + } |
1110 | + } |
1111 | + } // while |
1112 | + |
1113 | + theCurrentChild = &(flworExpr->theReturnExpr); |
1114 | + theState = 10; |
1115 | + return; |
1116 | + } |
1117 | + |
1118 | + case 2: |
1119 | + { |
1120 | + while (theWincondIter < 2) |
1121 | + { |
1122 | + window_clause* wc = static_cast<window_clause *>(*theClausesIter); |
1123 | + |
1124 | + flwor_wincond* wincond = (theWincondIter == 0 ? |
1125 | + wc->theWinStartCond : |
1126 | + wc->theWinStopCond ); |
1127 | + if (wincond != 0) |
1128 | + { |
1129 | + theCurrentChild = &(wincond->theCondExpr); |
1130 | + ++theWincondIter; |
1131 | + return; |
1132 | + } |
1133 | + |
1134 | + ++theWincondIter; |
1135 | + } |
1136 | + |
1137 | + theState = 1; |
1138 | + ++theClausesIter; |
1139 | + goto nextclause; |
1140 | + } |
1141 | + |
1142 | + case 3: |
1143 | + { |
1144 | + while (theArgsIter != theArgsEnd) |
1145 | + { |
1146 | + theCurrentChild = &(*theArgsIter); |
1147 | + ++theArgsIter; |
1148 | + return; |
1149 | + } |
1150 | + |
1151 | + theState = 1; |
1152 | + ++theClausesIter; |
1153 | + goto nextclause; |
1154 | + } |
1155 | + |
1156 | + case 4: |
1157 | + { |
1158 | + while (theGroupVarsIter != theGroupVarsEnd) |
1159 | + { |
1160 | + theCurrentChild = &((*theGroupVarsIter).first); |
1161 | + |
1162 | + ++theGroupVarsIter; |
1163 | + return; |
1164 | + } |
1165 | + |
1166 | + theState = 5; |
1167 | + } |
1168 | + |
1169 | + case 5: |
1170 | + { |
1171 | + while (theNonGroupVarsIter != theNonGroupVarsEnd) |
1172 | + { |
1173 | + theCurrentChild = &((*theNonGroupVarsIter).first); |
1174 | + |
1175 | + ++theNonGroupVarsIter; |
1176 | + return; |
1177 | + } |
1178 | + |
1179 | + theState = 1; |
1180 | + ++theClausesIter; |
1181 | + goto nextclause; |
1182 | + } |
1183 | + |
1184 | + default: |
1185 | + { |
1186 | + theIsDone = true; |
1187 | + return; |
1188 | + } |
1189 | + } |
1190 | + |
1191 | +#else |
1192 | + |
1193 | + flwor_clause* c = NULL; |
1194 | + window_clause* wc = NULL; |
1195 | + orderby_clause* oc = NULL; |
1196 | + group_clause* gc = NULL; |
1197 | + flwor_wincond* wincond = NULL; |
1198 | + |
1199 | EXPR_ITER_BEGIN(); |
1200 | |
1201 | theClausesBegin = flworExpr->theClauses.begin(); |
1202 | @@ -127,6 +338,11 @@ |
1203 | EXPR_ITER_NEXT(static_cast<let_clause *>(c)->theDomainExpr); |
1204 | } |
1205 | |
1206 | + else if (c->get_kind() == flwor_clause::where_clause) |
1207 | + { |
1208 | + EXPR_ITER_NEXT(static_cast<where_clause *>(c)->theWhereExpr); |
1209 | + } |
1210 | + |
1211 | else if (c->get_kind() == flwor_clause::window_clause) |
1212 | { |
1213 | for (theWincondIter = 0; theWincondIter < 2; ++theWincondIter) |
1214 | @@ -146,11 +362,6 @@ |
1215 | EXPR_ITER_NEXT(wc->theDomainExpr); |
1216 | } |
1217 | |
1218 | - else if (c->get_kind() == flwor_clause::where_clause) |
1219 | - { |
1220 | - EXPR_ITER_NEXT(static_cast<where_clause *>(c)->theWhereExpr); |
1221 | - } |
1222 | - |
1223 | else if (c->get_kind() == flwor_clause::group_clause) |
1224 | { |
1225 | gc = static_cast<group_clause *>(c); |
1226 | @@ -188,7 +399,8 @@ |
1227 | |
1228 | if (theClausesEnd != flworExpr->theClauses.end()) |
1229 | { |
1230 | - ulong pos = (ulong)(theClausesIter - theClausesBegin); |
1231 | + ZORBA_ASSERT(0); |
1232 | + csize pos = (theClausesIter - theClausesBegin); |
1233 | if (pos >= flworExpr->num_clauses()) |
1234 | break; |
1235 | |
1236 | @@ -200,86 +412,55 @@ |
1237 | EXPR_ITER_NEXT(flworExpr->theReturnExpr); |
1238 | |
1239 | EXPR_ITER_END(); |
1240 | - break; |
1241 | +#endif |
1242 | + return; |
1243 | } |
1244 | |
1245 | case relpath_expr_kind: |
1246 | { |
1247 | EXPR_ITER_BEGIN(); |
1248 | |
1249 | - { |
1250 | - relpath_expr* pathExpr = static_cast<relpath_expr*>(theExpr); |
1251 | - theArgsIter = pathExpr->theSteps.begin(); |
1252 | - theArgsEnd = pathExpr->theSteps.end(); |
1253 | - } |
1254 | - |
1255 | + theArgsIter = static_cast<relpath_expr*>(theExpr)->theSteps.begin(); |
1256 | + theArgsEnd = static_cast<relpath_expr*>(theExpr)->theSteps.end(); |
1257 | for (; theArgsIter != theArgsEnd; ++theArgsIter) |
1258 | { |
1259 | EXPR_ITER_NEXT(*theArgsIter); |
1260 | } |
1261 | |
1262 | EXPR_ITER_END(); |
1263 | - break; |
1264 | + return; |
1265 | } |
1266 | |
1267 | case axis_step_expr_kind: |
1268 | { |
1269 | - axis_step_expr* axisExpr = static_cast<axis_step_expr*>(theExpr); |
1270 | - |
1271 | EXPR_ITER_BEGIN(); |
1272 | - |
1273 | - EXPR_ITER_NEXT(axisExpr->theNodeTest); |
1274 | - |
1275 | + EXPR_ITER_NEXT(static_cast<axis_step_expr*>(theExpr)->theNodeTest); |
1276 | EXPR_ITER_END(); |
1277 | - break; |
1278 | + return; |
1279 | } |
1280 | |
1281 | case match_expr_kind: |
1282 | - { |
1283 | - theIsDone = true; |
1284 | - break; |
1285 | - } |
1286 | - |
1287 | case var_expr_kind: |
1288 | - { |
1289 | - theIsDone = true; |
1290 | - break; |
1291 | - } |
1292 | - |
1293 | - case wrapper_expr_kind: |
1294 | - { |
1295 | - wrapper_expr* wrapperExpr = static_cast<wrapper_expr*>(theExpr); |
1296 | - |
1297 | - EXPR_ITER_BEGIN(); |
1298 | - |
1299 | - EXPR_ITER_NEXT(wrapperExpr->theWrappedExpr); |
1300 | - |
1301 | - EXPR_ITER_END(); |
1302 | - break; |
1303 | - } |
1304 | - |
1305 | case const_expr_kind: |
1306 | + case flowctl_expr_kind: |
1307 | { |
1308 | theIsDone = true; |
1309 | - break; |
1310 | + return; |
1311 | } |
1312 | |
1313 | - |
1314 | case fo_expr_kind: |
1315 | { |
1316 | - fo_expr* foExpr = static_cast<fo_expr*>(theExpr); |
1317 | - |
1318 | EXPR_ITER_BEGIN(); |
1319 | |
1320 | - theArgsIter = foExpr->theArgs.begin(); |
1321 | - theArgsEnd = foExpr->theArgs.end(); |
1322 | + theArgsIter = static_cast<fo_expr*>(theExpr)->theArgs.begin(); |
1323 | + theArgsEnd = static_cast<fo_expr*>(theExpr)->theArgs.end(); |
1324 | for (; theArgsIter != theArgsEnd; ++theArgsIter) |
1325 | { |
1326 | EXPR_ITER_NEXT(*theArgsIter); |
1327 | } |
1328 | |
1329 | EXPR_ITER_END(); |
1330 | - break; |
1331 | + return; |
1332 | } |
1333 | |
1334 | case cast_expr_kind: |
1335 | @@ -288,27 +469,55 @@ |
1336 | case instanceof_expr_kind: |
1337 | case castable_expr_kind: |
1338 | { |
1339 | - cast_or_castable_base_expr* castExpr = |
1340 | - static_cast<cast_or_castable_base_expr*>(theExpr); |
1341 | - |
1342 | - EXPR_ITER_BEGIN(); |
1343 | - |
1344 | - EXPR_ITER_NEXT(castExpr->theInputExpr); |
1345 | - |
1346 | - EXPR_ITER_END(); |
1347 | - break; |
1348 | + EXPR_ITER_BEGIN(); |
1349 | + EXPR_ITER_NEXT(static_cast<cast_or_castable_base_expr*>(theExpr)->theInput); |
1350 | + EXPR_ITER_END(); |
1351 | + return; |
1352 | + } |
1353 | + |
1354 | + case wrapper_expr_kind: |
1355 | + { |
1356 | + EXPR_ITER_BEGIN(); |
1357 | + EXPR_ITER_NEXT(static_cast<wrapper_expr*>(theExpr)->theInput); |
1358 | + EXPR_ITER_END(); |
1359 | + return; |
1360 | + } |
1361 | + |
1362 | + case function_trace_expr_kind: |
1363 | + { |
1364 | + EXPR_ITER_BEGIN(); |
1365 | + EXPR_ITER_NEXT(static_cast<function_trace_expr*>(theExpr)->theInput); |
1366 | + EXPR_ITER_END(); |
1367 | + return; |
1368 | + } |
1369 | + |
1370 | + case order_expr_kind: |
1371 | + { |
1372 | + if (theState == 0) |
1373 | + { |
1374 | + theCurrentChild = &(static_cast<order_expr*>(theExpr)->theInput); |
1375 | + theState = 1; |
1376 | + return; |
1377 | + } |
1378 | + |
1379 | + theIsDone = true; |
1380 | + return; |
1381 | + } |
1382 | + |
1383 | + case validate_expr_kind: |
1384 | + { |
1385 | + EXPR_ITER_BEGIN(); |
1386 | + EXPR_ITER_NEXT(static_cast<validate_expr*>(theExpr)->theInput); |
1387 | + EXPR_ITER_END(); |
1388 | + return; |
1389 | } |
1390 | |
1391 | case name_cast_expr_kind: |
1392 | { |
1393 | - name_cast_expr* nameCastExpr = static_cast<name_cast_expr*>(theExpr); |
1394 | - |
1395 | EXPR_ITER_BEGIN(); |
1396 | - |
1397 | - EXPR_ITER_NEXT(nameCastExpr->theInputExpr); |
1398 | - |
1399 | + EXPR_ITER_NEXT(static_cast<name_cast_expr*>(theExpr)->theInputExpr); |
1400 | EXPR_ITER_END(); |
1401 | - break; |
1402 | + return; |
1403 | } |
1404 | |
1405 | case doc_expr_kind: |
1406 | @@ -321,7 +530,7 @@ |
1407 | EXPR_ITER_NEXT(docExpr->theContent); |
1408 | |
1409 | EXPR_ITER_END(); |
1410 | - break; |
1411 | + return; |
1412 | } |
1413 | |
1414 | case elem_expr_kind: |
1415 | @@ -339,7 +548,7 @@ |
1416 | EXPR_ITER_NEXT(elemExpr->theContent); |
1417 | |
1418 | EXPR_ITER_END(); |
1419 | - break; |
1420 | + return; |
1421 | } |
1422 | |
1423 | case attr_expr_kind: |
1424 | @@ -354,7 +563,7 @@ |
1425 | EXPR_ITER_NEXT(attrExpr->theValueExpr); |
1426 | |
1427 | EXPR_ITER_END(); |
1428 | - break; |
1429 | + return; |
1430 | } |
1431 | |
1432 | case text_expr_kind: |
1433 | @@ -366,7 +575,7 @@ |
1434 | EXPR_ITER_NEXT(textExpr->theContentExpr); |
1435 | |
1436 | EXPR_ITER_END(); |
1437 | - break; |
1438 | + return; |
1439 | } |
1440 | |
1441 | case pi_expr_kind: |
1442 | @@ -374,12 +583,10 @@ |
1443 | pi_expr* piExpr = static_cast<pi_expr*>(theExpr); |
1444 | |
1445 | EXPR_ITER_BEGIN(); |
1446 | - |
1447 | EXPR_ITER_NEXT(piExpr->theTargetExpr); |
1448 | EXPR_ITER_NEXT(piExpr->theContentExpr); |
1449 | - |
1450 | EXPR_ITER_END(); |
1451 | - break; |
1452 | + return; |
1453 | } |
1454 | |
1455 | #ifdef ZORBA_WITH_JSON |
1456 | @@ -393,7 +600,7 @@ |
1457 | EXPR_ITER_NEXT(e->theContentExpr); |
1458 | |
1459 | EXPR_ITER_END(); |
1460 | - break; |
1461 | + return; |
1462 | } |
1463 | |
1464 | case json_object_expr_kind: |
1465 | @@ -406,7 +613,7 @@ |
1466 | EXPR_ITER_NEXT(e->theContentExpr); |
1467 | |
1468 | EXPR_ITER_END(); |
1469 | - break; |
1470 | + return; |
1471 | } |
1472 | |
1473 | case json_direct_object_expr_kind: |
1474 | @@ -430,7 +637,7 @@ |
1475 | } |
1476 | |
1477 | EXPR_ITER_END(); |
1478 | - break; |
1479 | + return; |
1480 | } |
1481 | |
1482 | #endif |
1483 | @@ -446,31 +653,7 @@ |
1484 | EXPR_ITER_NEXT(ifExpr->theElseExpr); |
1485 | |
1486 | EXPR_ITER_END(); |
1487 | - break; |
1488 | - } |
1489 | - |
1490 | - case order_expr_kind: |
1491 | - { |
1492 | - order_expr* ordExpr = static_cast<order_expr*>(theExpr); |
1493 | - |
1494 | - EXPR_ITER_BEGIN(); |
1495 | - |
1496 | - EXPR_ITER_NEXT(ordExpr->theExpr); |
1497 | - |
1498 | - EXPR_ITER_END(); |
1499 | - break; |
1500 | - } |
1501 | - |
1502 | - case validate_expr_kind: |
1503 | - { |
1504 | - validate_expr* valExpr = static_cast<validate_expr*>(theExpr); |
1505 | - |
1506 | - EXPR_ITER_BEGIN(); |
1507 | - |
1508 | - EXPR_ITER_NEXT(valExpr->theExpr); |
1509 | - |
1510 | - EXPR_ITER_END(); |
1511 | - break; |
1512 | + return; |
1513 | } |
1514 | |
1515 | case extension_expr_kind: |
1516 | @@ -478,11 +661,9 @@ |
1517 | extension_expr* extExpr = static_cast<extension_expr*>(theExpr); |
1518 | |
1519 | EXPR_ITER_BEGIN(); |
1520 | - |
1521 | EXPR_ITER_NEXT(extExpr->theExpr); |
1522 | - |
1523 | EXPR_ITER_END(); |
1524 | - break; |
1525 | + return; |
1526 | } |
1527 | |
1528 | case trycatch_expr_kind: |
1529 | @@ -501,7 +682,7 @@ |
1530 | } |
1531 | |
1532 | EXPR_ITER_END(); |
1533 | - break; |
1534 | + return; |
1535 | } |
1536 | |
1537 | case function_item_expr_kind: |
1538 | @@ -518,7 +699,7 @@ |
1539 | } |
1540 | |
1541 | EXPR_ITER_END(); |
1542 | - break; |
1543 | + return; |
1544 | } |
1545 | |
1546 | case dynamic_function_invocation_expr_kind: |
1547 | @@ -538,7 +719,7 @@ |
1548 | } |
1549 | |
1550 | EXPR_ITER_END(); |
1551 | - break; |
1552 | + return; |
1553 | } |
1554 | |
1555 | case insert_expr_kind: |
1556 | @@ -551,7 +732,7 @@ |
1557 | EXPR_ITER_NEXT(insExpr->theTargetExpr); |
1558 | |
1559 | EXPR_ITER_END(); |
1560 | - break; |
1561 | + return; |
1562 | } |
1563 | |
1564 | case delete_expr_kind: |
1565 | @@ -563,7 +744,7 @@ |
1566 | EXPR_ITER_NEXT(delExpr->theTargetExpr); |
1567 | |
1568 | EXPR_ITER_END(); |
1569 | - break; |
1570 | + return; |
1571 | } |
1572 | |
1573 | case replace_expr_kind: |
1574 | @@ -576,7 +757,7 @@ |
1575 | EXPR_ITER_NEXT(repExpr->theSourceExpr); |
1576 | |
1577 | EXPR_ITER_END(); |
1578 | - break; |
1579 | + return; |
1580 | } |
1581 | |
1582 | case rename_expr_kind: |
1583 | @@ -589,7 +770,7 @@ |
1584 | EXPR_ITER_NEXT(renExpr->theSourceExpr); |
1585 | |
1586 | EXPR_ITER_END(); |
1587 | - break; |
1588 | + return; |
1589 | } |
1590 | |
1591 | case transform_expr_kind: |
1592 | @@ -609,7 +790,7 @@ |
1593 | EXPR_ITER_NEXT(trfExpr->theReturnExpr); |
1594 | |
1595 | EXPR_ITER_END(); |
1596 | - break; |
1597 | + return; |
1598 | } |
1599 | |
1600 | case block_expr_kind: |
1601 | @@ -626,7 +807,7 @@ |
1602 | } |
1603 | |
1604 | EXPR_ITER_END(); |
1605 | - break; |
1606 | + return; |
1607 | } |
1608 | |
1609 | case apply_expr_kind: |
1610 | @@ -635,7 +816,7 @@ |
1611 | EXPR_ITER_BEGIN(); |
1612 | EXPR_ITER_NEXT(applyExpr->theExpr); |
1613 | EXPR_ITER_END(); |
1614 | - break; |
1615 | + return; |
1616 | } |
1617 | |
1618 | case var_decl_expr_kind: |
1619 | @@ -648,7 +829,7 @@ |
1620 | EXPR_ITER_NEXT(varDeclExpr->theInitExpr); |
1621 | |
1622 | EXPR_ITER_END(); |
1623 | - break; |
1624 | + return; |
1625 | } |
1626 | |
1627 | case var_set_expr_kind: |
1628 | @@ -657,13 +838,7 @@ |
1629 | EXPR_ITER_BEGIN(); |
1630 | EXPR_ITER_NEXT(varSetExpr->theExpr); |
1631 | EXPR_ITER_END(); |
1632 | - break; |
1633 | - } |
1634 | - |
1635 | - case flowctl_expr_kind: |
1636 | - { |
1637 | - theIsDone = true; |
1638 | - break; |
1639 | + return; |
1640 | } |
1641 | |
1642 | case while_expr_kind: |
1643 | @@ -671,11 +846,9 @@ |
1644 | while_expr* whileExpr = static_cast<while_expr*>(theExpr); |
1645 | |
1646 | EXPR_ITER_BEGIN(); |
1647 | - |
1648 | EXPR_ITER_NEXT(whileExpr->theBody); |
1649 | - |
1650 | EXPR_ITER_END(); |
1651 | - break; |
1652 | + return; |
1653 | } |
1654 | |
1655 | case exit_expr_kind: |
1656 | @@ -683,11 +856,9 @@ |
1657 | exit_expr* exitExpr = static_cast<exit_expr*>(theExpr); |
1658 | |
1659 | EXPR_ITER_BEGIN(); |
1660 | - |
1661 | EXPR_ITER_NEXT(exitExpr->theExpr); |
1662 | - |
1663 | EXPR_ITER_END(); |
1664 | - break; |
1665 | + return; |
1666 | } |
1667 | |
1668 | case exit_catcher_expr_kind: |
1669 | @@ -699,7 +870,7 @@ |
1670 | EXPR_ITER_NEXT(catcherExpr->theExpr); |
1671 | |
1672 | EXPR_ITER_END(); |
1673 | - break; |
1674 | + return; |
1675 | } |
1676 | |
1677 | #ifndef ZORBA_NO_FULL_TEXT |
1678 | @@ -723,7 +894,7 @@ |
1679 | EXPR_ITER_NEXT(ftExpr->ftignore_); |
1680 | |
1681 | EXPR_ITER_END(); |
1682 | - break; |
1683 | + return; |
1684 | } |
1685 | #endif /* ZORBA_NO_FULL_TEXT */ |
1686 | |
1687 | @@ -743,7 +914,7 @@ |
1688 | } |
1689 | |
1690 | EXPR_ITER_END(); |
1691 | - break; |
1692 | + return; |
1693 | } |
1694 | |
1695 | #ifdef ZORBA_WITH_DEBUGGER |
1696 | @@ -763,19 +934,10 @@ |
1697 | } |
1698 | |
1699 | EXPR_ITER_END(); |
1700 | - break; |
1701 | + return; |
1702 | } |
1703 | #endif |
1704 | |
1705 | - case function_trace_expr_kind: |
1706 | - { |
1707 | - function_trace_expr* dummyExpr = static_cast<function_trace_expr*>(theExpr); |
1708 | - EXPR_ITER_BEGIN(); |
1709 | - EXPR_ITER_NEXT(dummyExpr->theExpr); |
1710 | - EXPR_ITER_END(); |
1711 | - break; |
1712 | - } |
1713 | - |
1714 | default: |
1715 | { |
1716 | ZORBA_ASSERT(false); |
1717 | |
1718 | === modified file 'src/compiler/expression/expr_manager.cpp' |
1719 | --- src/compiler/expression/expr_manager.cpp 2012-10-09 14:06:08 +0000 |
1720 | +++ src/compiler/expression/expr_manager.cpp 2012-10-24 11:34:21 +0000 |
1721 | @@ -179,7 +179,7 @@ |
1722 | static_context* sctx, |
1723 | user_function* udf, |
1724 | const QueryLoc& loc, |
1725 | - order_expr::order_type_t order, |
1726 | + DocOrderMode order, |
1727 | expr* exp) |
1728 | { |
1729 | CREATE_AND_RETURN_EXPR(order_expr, sctx, udf, loc, order, exp); |
1730 | @@ -216,7 +216,7 @@ |
1731 | const QueryLoc& loc, |
1732 | expr* treated, |
1733 | const xqtref_t& type, |
1734 | - TreatIterator::ErrorKind err, |
1735 | + TreatErrorKind err, |
1736 | bool check_prime, |
1737 | store::Item* qname) |
1738 | { |
1739 | @@ -231,7 +231,7 @@ |
1740 | const QueryLoc& loc, |
1741 | expr* promoted, |
1742 | const xqtref_t& type, |
1743 | - PromoteIterator::ErrorKind err, |
1744 | + PromoteErrorKind err, |
1745 | store::Item* qname) |
1746 | { |
1747 | CREATE_AND_RETURN_EXPR(promote_expr, sctx, udf, loc, promoted, type, err, qname); |
1748 | @@ -329,7 +329,7 @@ |
1749 | static_context* sctx, |
1750 | user_function* udf, |
1751 | const QueryLoc& loc, |
1752 | - text_expr::text_constructor_type textType, |
1753 | + TextConstructorType textType, |
1754 | expr* text) |
1755 | { |
1756 | CREATE_AND_RETURN_EXPR(text_expr, sctx, udf, loc, textType, text); |
1757 | @@ -538,10 +538,15 @@ |
1758 | static_context* sctx, |
1759 | user_function* udf, |
1760 | const QueryLoc& loc, |
1761 | - var_expr::var_kind k, |
1762 | + ulong varKind, |
1763 | store::Item* name) |
1764 | { |
1765 | - CREATE_AND_RETURN_EXPR(var_expr, sctx, udf, loc, k, name); |
1766 | + CREATE_AND_RETURN_EXPR(var_expr, |
1767 | + sctx, |
1768 | + udf, |
1769 | + loc, |
1770 | + static_cast<var_expr::var_kind>(varKind), |
1771 | + name); |
1772 | } |
1773 | |
1774 | |
1775 | @@ -729,7 +734,7 @@ |
1776 | static_context* sctx, |
1777 | user_function* udf, |
1778 | const QueryLoc& loc, |
1779 | - flowctl_expr::action action) |
1780 | + FlowCtlAction action) |
1781 | { |
1782 | CREATE_AND_RETURN_EXPR(flowctl_expr, sctx, udf, loc, action); |
1783 | } |
1784 | @@ -908,7 +913,7 @@ |
1785 | window_clause* ExprManager::create_window_clause( |
1786 | static_context* sctx, |
1787 | const QueryLoc& loc, |
1788 | - window_clause::window_t winKind, |
1789 | + WindowKind winKind, |
1790 | var_expr* varExpr, |
1791 | expr* domainExpr, |
1792 | flwor_wincond* winStart, |
1793 | @@ -935,7 +940,7 @@ |
1794 | static_context* sctx, |
1795 | const QueryLoc& loc, |
1796 | const flwor_clause::rebind_list_t& gvars, |
1797 | - flwor_clause::rebind_list_t ngvars, |
1798 | + const flwor_clause::rebind_list_t& ngvars, |
1799 | const std::vector<std::string>& collations) |
1800 | { |
1801 | CREATE_AND_RETURN(group_clause, sctx, theCCB, loc, gvars, ngvars, collations); |
1802 | |
1803 | === modified file 'src/compiler/expression/expr_manager.h' |
1804 | --- src/compiler/expression/expr_manager.h 2012-10-09 14:06:08 +0000 |
1805 | +++ src/compiler/expression/expr_manager.h 2012-10-24 11:34:21 +0000 |
1806 | @@ -19,17 +19,37 @@ |
1807 | #define ZORBA_COMPILER_EXPRMANAGER_H |
1808 | |
1809 | #include "expr_classes.h" |
1810 | -#include "expr.h" |
1811 | -#include "script_exprs.h" |
1812 | -#include "flwor_expr.h" |
1813 | -#include "ftnode.h" |
1814 | - |
1815 | +#include "expr_consts.h" |
1816 | +#include "expr_utils.h" |
1817 | #include "mem_manager.h" |
1818 | |
1819 | +#include "compiler/parser/parse_constants.h" |
1820 | + |
1821 | +#include "zorbatypes/schema_types.h" |
1822 | + |
1823 | +#include "store/api/update_consts.h" |
1824 | + |
1825 | + |
1826 | namespace zorba |
1827 | { |
1828 | |
1829 | class CompilerCB; |
1830 | +class expr; |
1831 | +class var_expr; |
1832 | +class catch_clause; |
1833 | +class pragma; |
1834 | +class flwor_clause; |
1835 | +class flwor_wincond; |
1836 | +class copy_clause; |
1837 | +class window_clause; |
1838 | +class group_clause; |
1839 | +class where_clause; |
1840 | +class count_clause; |
1841 | +class orderby_clause; |
1842 | +class materialize_clause; |
1843 | +struct flwor_wincond_vars; |
1844 | +class ftnode; |
1845 | + |
1846 | |
1847 | |
1848 | class ExprManager |
1849 | @@ -86,7 +106,7 @@ |
1850 | static_context* sctx, |
1851 | user_function* udf, |
1852 | const QueryLoc& loc, |
1853 | - order_expr::order_type_t, |
1854 | + DocOrderMode, |
1855 | expr*); |
1856 | |
1857 | validate_expr* create_validate_expr( |
1858 | @@ -111,7 +131,7 @@ |
1859 | const QueryLoc& loc, |
1860 | expr* input, |
1861 | const xqtref_t& type, |
1862 | - TreatIterator::ErrorKind err, |
1863 | + TreatErrorKind err, |
1864 | bool check_prime = true, |
1865 | store::Item* qnname = NULL); |
1866 | |
1867 | @@ -122,7 +142,7 @@ |
1868 | const QueryLoc& loc, |
1869 | expr* input, |
1870 | const xqtref_t& type, |
1871 | - PromoteIterator::ErrorKind err, |
1872 | + PromoteErrorKind err, |
1873 | store::Item* qname); |
1874 | |
1875 | castable_expr* create_castable_expr( |
1876 | @@ -185,7 +205,7 @@ |
1877 | static_context* sctx, |
1878 | user_function* udf, |
1879 | const QueryLoc&, |
1880 | - text_expr::text_constructor_type, |
1881 | + TextConstructorType, |
1882 | expr*); |
1883 | |
1884 | pi_expr* create_pi_expr( |
1885 | @@ -312,7 +332,7 @@ |
1886 | static_context* sctx, |
1887 | user_function* udf, |
1888 | const QueryLoc& loc, |
1889 | - var_expr::var_kind k, |
1890 | + ulong varKind, |
1891 | store::Item* name); |
1892 | |
1893 | var_expr* create_var_expr(user_function* udf, const var_expr& source); |
1894 | @@ -427,7 +447,7 @@ |
1895 | static_context* sctx, |
1896 | user_function* udf, |
1897 | const QueryLoc& loc, |
1898 | - flowctl_expr::action action); |
1899 | + FlowCtlAction action); |
1900 | |
1901 | while_expr* create_while_expr( |
1902 | static_context* sctx, |
1903 | @@ -479,7 +499,7 @@ |
1904 | user_function* udf, |
1905 | QueryLoc const&, |
1906 | expr* range, |
1907 | - ftnode *ftselection, |
1908 | + ftnode* ftselection, |
1909 | expr* ftignore); |
1910 | |
1911 | //////////////////////////////////////////////////////////////////////////////// |
1912 | @@ -539,7 +559,7 @@ |
1913 | window_clause* create_window_clause( |
1914 | static_context* sctx, |
1915 | const QueryLoc& loc, |
1916 | - window_clause::window_t winKind, |
1917 | + WindowKind winKind, |
1918 | var_expr* varExpr, |
1919 | expr* domainExpr, |
1920 | flwor_wincond* winStart, |
1921 | @@ -549,15 +569,15 @@ |
1922 | flwor_wincond* create_flwor_wincond( |
1923 | static_context* sctx, |
1924 | bool isOnly, |
1925 | - const flwor_wincond::vars& in_vars, |
1926 | - const flwor_wincond::vars& out_vars, |
1927 | + const flwor_wincond_vars& in_vars, |
1928 | + const flwor_wincond_vars& out_vars, |
1929 | expr* cond); |
1930 | |
1931 | group_clause* create_group_clause( |
1932 | static_context* sctx, |
1933 | const QueryLoc& loc, |
1934 | - const flwor_clause::rebind_list_t& gvars, |
1935 | - flwor_clause::rebind_list_t ngvars, |
1936 | + const var_rebind_list_t& gvars, |
1937 | + const var_rebind_list_t& ngvars, |
1938 | const std::vector<std::string>& collations); |
1939 | |
1940 | orderby_clause * create_orderby_clause ( |
1941 | |
1942 | === modified file 'src/compiler/expression/expr_put.cpp' |
1943 | --- src/compiler/expression/expr_put.cpp 2012-10-08 12:09:36 +0000 |
1944 | +++ src/compiler/expression/expr_put.cpp 2012-10-24 11:34:21 +0000 |
1945 | @@ -154,9 +154,9 @@ |
1946 | get_expr()->put(os); |
1947 | return os; |
1948 | #else |
1949 | - if (get_expr()->get_expr_kind() == var_expr_kind) |
1950 | + if (get_input()->get_expr_kind() == var_expr_kind) |
1951 | { |
1952 | - const var_expr* varExpr = static_cast<const var_expr*>(get_expr()); |
1953 | + const var_expr* varExpr = static_cast<const var_expr*>(get_input()); |
1954 | |
1955 | BEGIN_PUT_NO_EOL(var_ref) ; |
1956 | put_qname(varExpr->get_name(), os); |
1957 | @@ -165,8 +165,8 @@ |
1958 | } |
1959 | else |
1960 | { |
1961 | - BEGIN_PUT( wrapper_expr ); |
1962 | - get_expr()->put(os); |
1963 | + BEGIN_PUT(wrapper_expr); |
1964 | + get_input()->put(os); |
1965 | END_PUT(); |
1966 | } |
1967 | #endif |
1968 | @@ -440,7 +440,7 @@ |
1969 | { |
1970 | os << indent << "promote_expr " << theTargetType->toString() |
1971 | << expr_addr (this) << " [\n" << inc_indent; |
1972 | - theInputExpr->put(os); |
1973 | + theInput->put(os); |
1974 | END_PUT(); |
1975 | } |
1976 | |
1977 | @@ -491,7 +491,7 @@ |
1978 | ostream& function_trace_expr::put(ostream& os) const |
1979 | { |
1980 | BEGIN_PUT(function_trace_expr); |
1981 | - theExpr->put(os); |
1982 | + theInput->put(os); |
1983 | END_PUT(); |
1984 | } |
1985 | |
1986 | @@ -599,28 +599,28 @@ |
1987 | ostream& instanceof_expr::put( ostream& os) const |
1988 | { |
1989 | BEGIN_PUT1( instanceof_expr, theTargetType->toString() ); |
1990 | - theInputExpr->put(os); |
1991 | + theInput->put(os); |
1992 | END_PUT(); |
1993 | } |
1994 | |
1995 | ostream& treat_expr::put( ostream& os) const |
1996 | { |
1997 | BEGIN_PUT1( treat_expr, theTargetType->toString() ); |
1998 | - theInputExpr->put(os); |
1999 | + theInput->put(os); |
2000 | END_PUT(); |
2001 | } |
2002 | |
2003 | ostream& castable_expr::put( ostream& os) const |
2004 | { |
2005 | BEGIN_PUT1( castable_expr, theTargetType->toString() ); |
2006 | - theInputExpr->put(os); |
2007 | + theInput->put(os); |
2008 | END_PUT(); |
2009 | } |
2010 | |
2011 | ostream& cast_expr::put( ostream& os) const |
2012 | { |
2013 | BEGIN_PUT1( cast_expr, theTargetType->toString() ); |
2014 | - theInputExpr->put(os); |
2015 | + theInput->put(os); |
2016 | END_PUT(); |
2017 | } |
2018 | |
2019 | @@ -643,7 +643,7 @@ |
2020 | case ParseConstants::val_typename: os << "typename\n"; break; |
2021 | default: os << "??\n"; |
2022 | } |
2023 | - theExpr->put(os) << endl; |
2024 | + theInput->put(os) << endl; |
2025 | END_PUT(); |
2026 | } |
2027 | |
2028 | @@ -796,16 +796,16 @@ |
2029 | |
2030 | ostream& order_expr::put(ostream& os) const |
2031 | { |
2032 | - os << indent << "order_expr" << expr_addr (this) << "\n" << inc_indent |
2033 | + os << indent << "order_expr" << expr_addr(this) << "\n" << inc_indent |
2034 | << indent << "[ "; |
2035 | |
2036 | switch (theType) |
2037 | { |
2038 | - case ordered: os << "ordered\n"; break; |
2039 | - case unordered: os << "unordered\n"; break; |
2040 | + case doc_ordered: os << "ordered\n"; break; |
2041 | + case doc_unordered: os << "unordered\n"; break; |
2042 | default: os << "??\n"; |
2043 | } |
2044 | - theExpr->put(os) << endl; |
2045 | + theInput->put(os) << endl; |
2046 | END_PUT(); |
2047 | } |
2048 | |
2049 | |
2050 | === modified file 'src/compiler/expression/expr_type.cpp' |
2051 | --- src/compiler/expression/expr_type.cpp 2012-10-16 13:08:12 +0000 |
2052 | +++ src/compiler/expression/expr_type.cpp 2012-10-24 11:34:21 +0000 |
2053 | @@ -105,14 +105,6 @@ |
2054 | break; |
2055 | } |
2056 | |
2057 | - case order_expr_kind: |
2058 | - { |
2059 | - order_expr* e = static_cast<order_expr*>(this); |
2060 | - |
2061 | - newType = e->theExpr->get_return_type(); |
2062 | - break; |
2063 | - } |
2064 | - |
2065 | case validate_expr_kind: |
2066 | { |
2067 | theType = rtm.ANY_NODE_TYPE_ONE; |
2068 | @@ -332,7 +324,7 @@ |
2069 | { |
2070 | cast_expr* e = static_cast<cast_expr*>(this); |
2071 | |
2072 | - xqtref_t argType = e->theInputExpr->get_return_type(); |
2073 | + xqtref_t argType = e->theInput->get_return_type(); |
2074 | TypeConstants::quantifier_t argQuant = argType->get_quantifier(); |
2075 | TypeConstants::quantifier_t targetQuant = e->theTargetType->get_quantifier(); |
2076 | |
2077 | @@ -378,7 +370,7 @@ |
2078 | { |
2079 | promote_expr* e = static_cast<promote_expr*>(this); |
2080 | |
2081 | - xqtref_t in_type = e->theInputExpr->get_return_type(); |
2082 | + xqtref_t in_type = e->theInput->get_return_type(); |
2083 | xqtref_t in_ptype = TypeOps::prime_type(tm, *in_type); |
2084 | xqtref_t target_ptype = TypeOps::prime_type(tm, *e->theTargetType); |
2085 | |
2086 | @@ -490,7 +482,7 @@ |
2087 | |
2088 | switch (e->type) |
2089 | { |
2090 | - case text_expr::text_constructor: |
2091 | + case text_constructor: |
2092 | { |
2093 | xqtref_t t = e->get_text()->get_return_type(); |
2094 | |
2095 | @@ -504,7 +496,7 @@ |
2096 | break; |
2097 | } |
2098 | |
2099 | - case text_expr::comment_constructor: |
2100 | + case comment_constructor: |
2101 | nodeKind = store::StoreConsts::commentNode; |
2102 | break; |
2103 | |
2104 | @@ -702,15 +694,19 @@ |
2105 | |
2106 | case function_trace_expr_kind: |
2107 | { |
2108 | - function_trace_expr* e = static_cast<function_trace_expr*>(this); |
2109 | - newType = e->theExpr->get_return_type(); |
2110 | + newType = static_cast<function_trace_expr*>(this)->theInput->get_return_type(); |
2111 | + break; |
2112 | + } |
2113 | + |
2114 | + case order_expr_kind: |
2115 | + { |
2116 | + newType = static_cast<order_expr*>(this)->theInput->get_return_type(); |
2117 | break; |
2118 | } |
2119 | |
2120 | case wrapper_expr_kind: |
2121 | { |
2122 | - wrapper_expr* e = static_cast<wrapper_expr*>(this); |
2123 | - newType = e->theWrappedExpr->get_return_type(); |
2124 | + newType = static_cast<wrapper_expr*>(this)->theInput->get_return_type(); |
2125 | break; |
2126 | } |
2127 | |
2128 | |
2129 | === modified file 'src/compiler/expression/expr_utils.h' |
2130 | --- src/compiler/expression/expr_utils.h 2012-09-19 21:16:15 +0000 |
2131 | +++ src/compiler/expression/expr_utils.h 2012-10-24 11:34:21 +0000 |
2132 | @@ -22,6 +22,9 @@ |
2133 | namespace zorba |
2134 | { |
2135 | |
2136 | +class expr; |
2137 | +class var_expr; |
2138 | + |
2139 | /****************************************************************************** |
2140 | Used by the orderspecs of an order by clause, and by the keyspecs of an |
2141 | index declaration. |
2142 | @@ -47,6 +50,11 @@ |
2143 | }; |
2144 | |
2145 | |
2146 | +/****************************************************************************** |
2147 | + |
2148 | +********************************************************************************/ |
2149 | +typedef std::vector<std::pair<expr*, var_expr*> > var_rebind_list_t; |
2150 | + |
2151 | } |
2152 | #endif |
2153 | |
2154 | |
2155 | === modified file 'src/compiler/expression/flwor_expr.cpp' |
2156 | --- src/compiler/expression/flwor_expr.cpp 2012-10-22 15:10:23 +0000 |
2157 | +++ src/compiler/expression/flwor_expr.cpp 2012-10-24 11:34:21 +0000 |
2158 | @@ -25,6 +25,7 @@ |
2159 | #include "compiler/expression/fo_expr.h" |
2160 | #include "compiler/expression/expr.h" |
2161 | #include "compiler/expression/expr_visitor.h" |
2162 | +#include "compiler/expression/expr_manager.h" |
2163 | |
2164 | #include "compiler/api/compilercb.h" |
2165 | |
2166 | @@ -111,7 +112,7 @@ |
2167 | theDomainExpr->get_loc(), |
2168 | theDomainExpr, |
2169 | varType, |
2170 | - TreatIterator::TYPE_MATCH); |
2171 | + TREAT_TYPE_MATCH); |
2172 | } |
2173 | } |
2174 | } |
2175 | @@ -180,7 +181,7 @@ |
2176 | loc, |
2177 | domainExpr, |
2178 | declaredType, |
2179 | - TreatIterator::TYPE_MATCH); |
2180 | + TREAT_TYPE_MATCH); |
2181 | |
2182 | set_expr(domainExpr); |
2183 | } |
2184 | @@ -307,7 +308,7 @@ |
2185 | loc, |
2186 | domainExpr, |
2187 | declaredType, |
2188 | - TreatIterator::TYPE_MATCH); |
2189 | + TREAT_TYPE_MATCH); |
2190 | |
2191 | set_expr(domainExpr); |
2192 | } |
2193 | @@ -370,7 +371,7 @@ |
2194 | static_context* sctx, |
2195 | CompilerCB* ccb, |
2196 | const QueryLoc& loc, |
2197 | - window_t winKind, |
2198 | + WindowKind winKind, |
2199 | var_expr* varExpr, |
2200 | expr* domainExpr, |
2201 | flwor_wincond* winStart, |
2202 | @@ -412,7 +413,7 @@ |
2203 | loc, |
2204 | domainExpr, |
2205 | varType, |
2206 | - TreatIterator::TYPE_MATCH); |
2207 | + TREAT_TYPE_MATCH); |
2208 | |
2209 | set_expr(domainExpr); |
2210 | } |
2211 | @@ -523,7 +524,7 @@ |
2212 | } |
2213 | |
2214 | |
2215 | -flwor_wincond::vars::vars() |
2216 | +flwor_wincond_vars::flwor_wincond_vars() |
2217 | : |
2218 | posvar(NULL), |
2219 | curr(NULL), |
2220 | @@ -533,13 +534,13 @@ |
2221 | } |
2222 | |
2223 | |
2224 | -flwor_wincond::vars::~vars() |
2225 | +flwor_wincond_vars::~flwor_wincond_vars() |
2226 | { |
2227 | // set_flwor_clause(NULL); |
2228 | } |
2229 | |
2230 | |
2231 | -void flwor_wincond::vars::set_flwor_clause(flwor_clause* c) |
2232 | +void flwor_wincond_vars::set_flwor_clause(flwor_clause* c) |
2233 | { |
2234 | if (posvar != NULL) posvar->set_flwor_clause(c); |
2235 | if (curr != NULL) curr->set_flwor_clause(c); |
2236 | @@ -548,7 +549,7 @@ |
2237 | } |
2238 | |
2239 | |
2240 | -void flwor_wincond::vars::clone( |
2241 | +void flwor_wincond_vars::clone( |
2242 | ExprManager* mgr, |
2243 | user_function* udf, |
2244 | flwor_wincond::vars& cloneVars, |
2245 | @@ -619,7 +620,7 @@ |
2246 | CompilerCB* ccb, |
2247 | const QueryLoc& loc, |
2248 | const rebind_list_t& gvars, |
2249 | - rebind_list_t ngvars, |
2250 | + const rebind_list_t& ngvars, |
2251 | const std::vector<std::string>& collations) |
2252 | : |
2253 | flwor_clause(sctx, ccb, loc, flwor_clause::group_clause), |
2254 | @@ -808,6 +809,8 @@ |
2255 | flwor_clause(sctx, ccb, loc, flwor_clause::count_clause), |
2256 | theVarExpr(var) |
2257 | { |
2258 | + if (theVarExpr != NULL) |
2259 | + theVarExpr->set_flwor_clause(this); |
2260 | } |
2261 | |
2262 | |
2263 | |
2264 | === modified file 'src/compiler/expression/flwor_expr.h' |
2265 | --- src/compiler/expression/flwor_expr.h 2012-10-22 15:10:23 +0000 |
2266 | +++ src/compiler/expression/flwor_expr.h 2012-10-24 11:34:21 +0000 |
2267 | @@ -51,7 +51,7 @@ |
2268 | friend class ExprManager; |
2269 | |
2270 | public: |
2271 | - typedef std::vector<std::pair<expr*, var_expr*> > rebind_list_t; |
2272 | + typedef var_rebind_list_t rebind_list_t; |
2273 | |
2274 | typedef enum |
2275 | { |
2276 | @@ -98,8 +98,6 @@ |
2277 | |
2278 | flwor_expr* get_flwor_expr() const { return theFlworExpr; } |
2279 | |
2280 | - virtual expr* get_expr() const { return NULL; } |
2281 | - |
2282 | virtual void set_expr(expr* v) { } |
2283 | |
2284 | virtual var_expr* get_pos_var() const { return NULL; } |
2285 | @@ -271,11 +269,8 @@ |
2286 | friend class ExprManager; |
2287 | friend class ExprIterator; |
2288 | |
2289 | -public: |
2290 | - typedef enum { tumbling_window, sliding_window } window_t; |
2291 | - |
2292 | protected: |
2293 | - window_t theWindowKind; |
2294 | + WindowKind theWindowKind; |
2295 | flwor_wincond * theWinStartCond; |
2296 | flwor_wincond * theWinStopCond; |
2297 | bool theLazyEval; |
2298 | @@ -285,7 +280,7 @@ |
2299 | static_context* sctx, |
2300 | CompilerCB* ccb, |
2301 | const QueryLoc& loc, |
2302 | - window_t winKind, |
2303 | + WindowKind winKind, |
2304 | var_expr* varExpr, |
2305 | expr* domainExpr, |
2306 | flwor_wincond* winStart, |
2307 | @@ -295,7 +290,7 @@ |
2308 | public: |
2309 | ~window_clause(); |
2310 | |
2311 | - window_t get_winkind() const { return theWindowKind; } |
2312 | + WindowKind get_winkind() const { return theWindowKind; } |
2313 | |
2314 | flwor_wincond* get_win_start() const { return theWinStartCond; } |
2315 | |
2316 | @@ -317,6 +312,32 @@ |
2317 | |
2318 | /***************************************************************************//** |
2319 | |
2320 | +********************************************************************************/ |
2321 | +struct flwor_wincond_vars |
2322 | +{ |
2323 | + var_expr* posvar; |
2324 | + var_expr* curr; |
2325 | + var_expr* prev; |
2326 | + var_expr* next; |
2327 | + |
2328 | + flwor_wincond_vars(); |
2329 | + |
2330 | + ~flwor_wincond_vars(); |
2331 | + |
2332 | + void set_flwor_clause(flwor_clause* c); |
2333 | + |
2334 | + void clone( |
2335 | + ExprManager* mgr, |
2336 | + user_function* udf, |
2337 | + flwor_wincond_vars& cloneVars, |
2338 | + expr::substitution_t& subst) const; |
2339 | + |
2340 | + std::ostream& put(std::ostream&) const; |
2341 | +}; |
2342 | + |
2343 | + |
2344 | +/***************************************************************************//** |
2345 | + |
2346 | Class flwor_wincond represents a start/stop condition of a window clause. |
2347 | |
2348 | - Syntax: |
2349 | @@ -353,27 +374,7 @@ |
2350 | friend class ExprIterator; |
2351 | |
2352 | public: |
2353 | - struct vars |
2354 | - { |
2355 | - var_expr* posvar; |
2356 | - var_expr* curr; |
2357 | - var_expr* prev; |
2358 | - var_expr* next; |
2359 | - |
2360 | - vars(); |
2361 | - |
2362 | - ~vars(); |
2363 | - |
2364 | - void set_flwor_clause(flwor_clause* c); |
2365 | - |
2366 | - void clone( |
2367 | - ExprManager* mgr, |
2368 | - user_function* udf, |
2369 | - vars& cloneVars, |
2370 | - expr::substitution_t& subst) const; |
2371 | - |
2372 | - std::ostream& put(std::ostream&) const; |
2373 | - }; |
2374 | + typedef flwor_wincond_vars vars; |
2375 | |
2376 | protected: |
2377 | bool theIsOnly; |
2378 | @@ -456,7 +457,7 @@ |
2379 | CompilerCB* ccb, |
2380 | const QueryLoc& loc, |
2381 | const rebind_list_t& gvars, |
2382 | - rebind_list_t ngvars, |
2383 | + const rebind_list_t& ngvars, |
2384 | const std::vector<std::string>& collations); |
2385 | |
2386 | public: |
2387 | |
2388 | === modified file 'src/compiler/expression/fo_expr.cpp' |
2389 | --- src/compiler/expression/fo_expr.cpp 2012-10-09 14:06:08 +0000 |
2390 | +++ src/compiler/expression/fo_expr.cpp 2012-10-24 11:34:21 +0000 |
2391 | @@ -19,6 +19,7 @@ |
2392 | |
2393 | #include "compiler/expression/fo_expr.h" |
2394 | #include "compiler/expression/expr_visitor.h" |
2395 | +#include "compiler/expression/expr_manager.h" |
2396 | |
2397 | #include "compiler/api/compilercb.h" |
2398 | |
2399 | |
2400 | === modified file 'src/compiler/expression/fo_expr.h' |
2401 | --- src/compiler/expression/fo_expr.h 2012-10-09 14:06:08 +0000 |
2402 | +++ src/compiler/expression/fo_expr.h 2012-10-24 11:34:21 +0000 |
2403 | @@ -118,30 +118,6 @@ |
2404 | }; |
2405 | |
2406 | |
2407 | -////////// The following expressions in the AST "decay" into an fo_expr /////// |
2408 | - |
2409 | -typedef fo_expr additive_expr; |
2410 | - |
2411 | -typedef fo_expr and_expr; |
2412 | - |
2413 | -typedef fo_expr comparison_expr; |
2414 | - |
2415 | -typedef fo_expr enclosed_expr; |
2416 | - |
2417 | -typedef fo_expr intersect_except_expr; |
2418 | - |
2419 | -typedef fo_expr multiplicative_expr; |
2420 | - |
2421 | -typedef fo_expr or_expr; |
2422 | - |
2423 | -typedef fo_expr quantified_expr; |
2424 | - |
2425 | -typedef fo_expr range_expr; |
2426 | - |
2427 | -typedef fo_expr unary_expr; |
2428 | - |
2429 | -typedef fo_expr union_expr; |
2430 | - |
2431 | } // namespace zorba |
2432 | |
2433 | #endif |
2434 | |
2435 | === modified file 'src/compiler/expression/ftnode.h' |
2436 | --- src/compiler/expression/ftnode.h 2012-10-09 14:06:08 +0000 |
2437 | +++ src/compiler/expression/ftnode.h 2012-10-24 11:34:21 +0000 |
2438 | @@ -20,13 +20,17 @@ |
2439 | #include <zorba/locale.h> |
2440 | |
2441 | #include "common/shared_types.h" |
2442 | + |
2443 | #include "compiler/expression/expr_base.h" |
2444 | #include "compiler/expression/ftnode_classes.h" |
2445 | #include "compiler/parser/ft_types.h" |
2446 | #include "compiler/parser/parse_constants.h" |
2447 | #include "compiler/parsetree/parsenodes.h" |
2448 | + |
2449 | #include "runtime/base/plan_iterator.h" |
2450 | + |
2451 | #include "util/cxx_util.h" |
2452 | + |
2453 | #include "zorbatypes/rchandle.h" |
2454 | #include "zorbatypes/zstring.h" |
2455 | |
2456 | |
2457 | === modified file 'src/compiler/expression/script_exprs.cpp' |
2458 | --- src/compiler/expression/script_exprs.cpp 2012-10-09 14:06:08 +0000 |
2459 | +++ src/compiler/expression/script_exprs.cpp 2012-10-24 11:34:21 +0000 |
2460 | @@ -26,7 +26,7 @@ |
2461 | #include "functions/function.h" |
2462 | |
2463 | #include "diagnostics/assert.h" |
2464 | - |
2465 | +#include "diagnostics/xquery_diagnostics.h" |
2466 | |
2467 | namespace zorba |
2468 | { |
2469 | @@ -401,7 +401,7 @@ |
2470 | static_context* sctx, |
2471 | user_function* udf, |
2472 | const QueryLoc& loc, |
2473 | - enum action action) |
2474 | + FlowCtlAction action) |
2475 | : |
2476 | expr(ccb, sctx, udf, loc, flowctl_expr_kind), |
2477 | theAction(action) |
2478 | |
2479 | === modified file 'src/compiler/expression/script_exprs.h' |
2480 | --- src/compiler/expression/script_exprs.h 2012-10-09 14:06:08 +0000 |
2481 | +++ src/compiler/expression/script_exprs.h 2012-10-24 11:34:21 +0000 |
2482 | @@ -390,11 +390,8 @@ |
2483 | friend class ExprIterator; |
2484 | friend class expr; |
2485 | |
2486 | -public: |
2487 | - enum action { BREAK, CONTINUE }; |
2488 | - |
2489 | protected: |
2490 | - enum action theAction; |
2491 | + FlowCtlAction theAction; |
2492 | |
2493 | protected: |
2494 | flowctl_expr( |
2495 | @@ -402,10 +399,10 @@ |
2496 | static_context* sctx, |
2497 | user_function* udf, |
2498 | const QueryLoc& loc, |
2499 | - enum action action); |
2500 | + FlowCtlAction action); |
2501 | |
2502 | public: |
2503 | - enum action get_action() const { return theAction; } |
2504 | + FlowCtlAction get_action() const { return theAction; } |
2505 | |
2506 | void compute_scripting_kind(); |
2507 | |
2508 | |
2509 | === modified file 'src/compiler/expression/update_exprs.cpp' |
2510 | --- src/compiler/expression/update_exprs.cpp 2012-10-22 15:10:23 +0000 |
2511 | +++ src/compiler/expression/update_exprs.cpp 2012-10-24 11:34:21 +0000 |
2512 | @@ -18,6 +18,7 @@ |
2513 | #include "compiler/expression/update_exprs.h" |
2514 | #include "compiler/expression/var_expr.h" |
2515 | #include "compiler/expression/expr_visitor.h" |
2516 | +#include "compiler/expression/expr_manager.h" |
2517 | |
2518 | #include "compiler/api/compilercb.h" |
2519 | |
2520 | |
2521 | === modified file 'src/compiler/rewriter/framework/rewriter.h' |
2522 | --- src/compiler/rewriter/framework/rewriter.h 2012-09-19 21:16:15 +0000 |
2523 | +++ src/compiler/rewriter/framework/rewriter.h 2012-10-24 11:34:21 +0000 |
2524 | @@ -29,12 +29,10 @@ |
2525 | { |
2526 | public: |
2527 | Rewriter() {} |
2528 | + |
2529 | virtual ~Rewriter() { } |
2530 | |
2531 | virtual bool rewrite(RewriterContext& rCtx) = 0; |
2532 | - |
2533 | -protected: |
2534 | - CompilerCB::config::opt_level_t theOptLevel; |
2535 | }; |
2536 | |
2537 | } |
2538 | |
2539 | === modified file 'src/compiler/rewriter/rewriters/default_optimizer.cpp' |
2540 | --- src/compiler/rewriter/rewriters/default_optimizer.cpp 2012-10-19 20:42:38 +0000 |
2541 | +++ src/compiler/rewriter/rewriters/default_optimizer.cpp 2012-10-24 11:34:21 +0000 |
2542 | @@ -36,8 +36,6 @@ |
2543 | public: |
2544 | FoldRules() |
2545 | { |
2546 | - //ADD_RULE(MarkExpensiveOps); |
2547 | - // Most rules try to update the freevars annotations, but for now let's stay on the safe side |
2548 | ADD_RULE(MarkExprs); |
2549 | ADD_RULE(MarkFreeVars); |
2550 | ADD_RULE(FoldConst(false)); |
2551 | @@ -65,7 +63,6 @@ |
2552 | |
2553 | SingletonRuleMajorDriver<EliminateTypeEnforcingOperations> driverTypeRules; |
2554 | SingletonRuleMajorDriver<EliminateExtraneousPathSteps> driverPathSimplify; |
2555 | - //SingletonRuleMajorDriver<ReplaceExprWithConstantOneWhenPossible> driverExprSimplify; |
2556 | RuleOnceDriver<EliminateUnusedLetVars> driverEliminateVars; |
2557 | RuleOnceDriver<MarkProducerNodeProps> driverMarkProducerNodeProps; |
2558 | RuleOnceDriver<MarkConsumerNodeProps> driverMarkConsumerNodeProps; |
2559 | |
2560 | === modified file 'src/compiler/rewriter/rules/flwor_rules.cpp' |
2561 | --- src/compiler/rewriter/rules/flwor_rules.cpp 2012-10-22 15:10:23 +0000 |
2562 | +++ src/compiler/rewriter/rules/flwor_rules.cpp 2012-10-24 11:34:21 +0000 |
2563 | @@ -23,6 +23,7 @@ |
2564 | #include "compiler/rewriter/tools/expr_tools.h" |
2565 | |
2566 | #include "compiler/expression/flwor_expr.h" |
2567 | +#include "compiler/expression/script_exprs.h" |
2568 | #include "compiler/expression/expr_iter.h" |
2569 | #include "compiler/expression/expr.h" |
2570 | |
2571 | @@ -239,19 +240,22 @@ |
2572 | |
2573 | if (clause->get_kind() == flwor_clause::where_clause) |
2574 | { |
2575 | - whereExpr = clause->get_expr(); |
2576 | + whereExpr = static_cast<where_clause*>(clause)->get_expr(); |
2577 | const expr::FreeVars& whereVars = whereExpr->getFreeVars(); |
2578 | |
2579 | - if (myVars.empty()) |
2580 | - flwor.get_vars(myVars); |
2581 | - |
2582 | - expr::FreeVars diff; |
2583 | - std::set_intersection(myVars.begin(), |
2584 | - myVars.end(), |
2585 | - whereVars.begin(), |
2586 | - whereVars.end(), |
2587 | - std::inserter(diff, diff.begin())); |
2588 | - if (diff.empty()) |
2589 | + csize k = 0; |
2590 | + expr::FreeVars::const_iterator ite = whereVars.begin(); |
2591 | + expr::FreeVars::const_iterator end = whereVars.end(); |
2592 | + for (; ite != end; ++ite) |
2593 | + { |
2594 | + flwor_clause* vc = (*ite)->get_flwor_clause(); |
2595 | + if (vc != NULL && vc->get_flwor_expr() == flworp) |
2596 | + break; |
2597 | + |
2598 | + ++k; |
2599 | + } |
2600 | + |
2601 | + if (k == whereVars.size()) |
2602 | { |
2603 | flwor.remove_clause(i); |
2604 | |
2605 | @@ -522,7 +526,7 @@ |
2606 | } |
2607 | else if (clause->get_kind() == flwor_clause::where_clause) |
2608 | { |
2609 | - expr* whereExpr = clause->get_expr(); |
2610 | + expr* whereExpr = static_cast<where_clause*>(clause)->get_expr(); |
2611 | |
2612 | //TODO: Consider case where both whereExpr and whereCond ar AND ops |
2613 | if (whereCond == NULL) |
2614 | @@ -638,7 +642,7 @@ |
2615 | } |
2616 | case wrapper_expr_kind: |
2617 | { |
2618 | - return is_trivial_expr(static_cast<const wrapper_expr*>(e)->get_expr()); |
2619 | + return is_trivial_expr(static_cast<const wrapper_expr*>(e)->get_input()); |
2620 | } |
2621 | default: |
2622 | return false; |
2623 | @@ -709,10 +713,6 @@ |
2624 | domExpr->get_return_type()->max_card() >= 2) |
2625 | return false; |
2626 | |
2627 | - // test rbkt/zorba/extern/5890.xq illustrates why this check is needed |
2628 | - //if (hasNodeConstr && fc.get_expr()->contains_node_construction()) |
2629 | - // return false; |
2630 | - |
2631 | break; |
2632 | } |
2633 | case flwor_clause::where_clause: |
2634 | @@ -722,9 +722,11 @@ |
2635 | |
2636 | assert(varQuant == TypeConstants::QUANT_ONE); |
2637 | |
2638 | - if (std::find(refpath.begin(), refpath.end(), clause->get_expr()) != refpath.end()) |
2639 | + expr* whereExpr = static_cast<const where_clause*>(clause)->get_expr(); |
2640 | + |
2641 | + if (std::find(refpath.begin(), refpath.end(), whereExpr) != refpath.end()) |
2642 | { |
2643 | - referencingExpr = clause->get_expr(); |
2644 | + referencingExpr = whereExpr; |
2645 | break; |
2646 | } |
2647 | |
2648 | @@ -1324,7 +1326,7 @@ |
2649 | if (clause->get_kind() != flwor_clause::where_clause) |
2650 | continue; |
2651 | |
2652 | - expr* whereExpr = clause->get_expr(); |
2653 | + expr* whereExpr = static_cast<where_clause*>(clause)->get_expr(); |
2654 | |
2655 | expr* posExpr = NULL; |
2656 | var_expr* posVar = NULL; |
2657 | @@ -1807,24 +1809,22 @@ |
2658 | { |
2659 | bool merge = false; |
2660 | flwor_expr* nestedFlwor = NULL; |
2661 | - ulong numNestedClauses; |
2662 | + csize numNestedClauses; |
2663 | |
2664 | flwor_clause* c = flwor->get_clause(i); |
2665 | |
2666 | - expr* domainExpr = c->get_expr(); |
2667 | - |
2668 | - if (domainExpr != NULL && |
2669 | - domainExpr->get_expr_kind() == flwor_expr_kind && |
2670 | - !domainExpr->is_sequential()) |
2671 | + if (c->get_kind() == flwor_clause::let_clause) |
2672 | { |
2673 | - nestedFlwor = static_cast<flwor_expr*>(c->get_expr()); |
2674 | - numNestedClauses = nestedFlwor->num_clauses(); |
2675 | + expr* domainExpr = static_cast<let_clause*>(c)->get_expr(); |
2676 | |
2677 | - if (c->get_kind() == flwor_clause::let_clause) |
2678 | + if (domainExpr->get_expr_kind() == flwor_expr_kind && |
2679 | + !domainExpr->is_sequential()) |
2680 | { |
2681 | + nestedFlwor = static_cast<flwor_expr*>(domainExpr); |
2682 | + numNestedClauses = nestedFlwor->num_clauses(); |
2683 | merge = true; |
2684 | |
2685 | - for (ulong j = 0; j < numNestedClauses; ++j) |
2686 | + for (csize j = 0; j < numNestedClauses; ++j) |
2687 | { |
2688 | flwor_clause* nestedClause = nestedFlwor->get_clause(j); |
2689 | flwor_clause::ClauseKind nestedClauseKind = nestedClause->get_kind(); |
2690 | @@ -1832,7 +1832,7 @@ |
2691 | if (nestedClauseKind == flwor_clause::for_clause) |
2692 | { |
2693 | xqtref_t nestedDomainType = |
2694 | - nestedClause->get_expr()->get_return_type(); |
2695 | + static_cast<for_clause*>(nestedClause)->get_expr()->get_return_type(); |
2696 | |
2697 | if (nestedDomainType->get_quantifier() != TypeConstants::QUANT_ONE) |
2698 | { |
2699 | @@ -1847,12 +1847,20 @@ |
2700 | } |
2701 | } |
2702 | } |
2703 | - else if (c->get_kind() == flwor_clause::for_clause && |
2704 | - c->get_pos_var() == NULL) |
2705 | + } |
2706 | + else if (c->get_kind() == flwor_clause::for_clause && |
2707 | + static_cast<for_clause*>(c)->get_pos_var() == NULL) |
2708 | + { |
2709 | + expr* domainExpr = static_cast<for_clause*>(c)->get_expr(); |
2710 | + |
2711 | + if (domainExpr->get_expr_kind() == flwor_expr_kind && |
2712 | + !domainExpr->is_sequential()) |
2713 | { |
2714 | + nestedFlwor = static_cast<flwor_expr*>(domainExpr); |
2715 | + numNestedClauses = nestedFlwor->num_clauses(); |
2716 | merge = true; |
2717 | |
2718 | - for (ulong j = 0; j < numNestedClauses; ++j) |
2719 | + for (csize j = 0; j < numNestedClauses; ++j) |
2720 | { |
2721 | flwor_clause* nestedClause = nestedFlwor->get_clause(j); |
2722 | flwor_clause::ClauseKind nestedClauseKind = nestedClause->get_kind(); |
2723 | |
2724 | === modified file 'src/compiler/rewriter/rules/fold_rules.cpp' |
2725 | --- src/compiler/rewriter/rules/fold_rules.cpp 2012-10-22 15:10:23 +0000 |
2726 | +++ src/compiler/rewriter/rules/fold_rules.cpp 2012-10-24 11:34:21 +0000 |
2727 | @@ -51,8 +51,6 @@ |
2728 | |
2729 | namespace zorba { |
2730 | |
2731 | -static void remove_wincond_vars(const flwor_wincond*, expr::FreeVars&); |
2732 | - |
2733 | static bool standalone_expr(expr*); |
2734 | |
2735 | static bool already_folded(expr*, RewriterContext&); |
2736 | @@ -236,84 +234,82 @@ |
2737 | iter.next(); |
2738 | } |
2739 | |
2740 | + switch (node->get_expr_kind()) |
2741 | + { |
2742 | + case fo_expr_kind: |
2743 | + { |
2744 | + fo_expr* fo = static_cast<fo_expr *>(node); |
2745 | + function* f = fo->get_func(); |
2746 | + |
2747 | + if (!f->isUdf()) |
2748 | + { |
2749 | + if (FunctionConsts::FN_ERROR_0 <= f->getKind() && |
2750 | + f->getKind() <= FunctionConsts::FN_TRACE_2) |
2751 | + { |
2752 | + curNonDiscardable = ANNOTATION_TRUE_FIXED; |
2753 | + curUnfoldable = ANNOTATION_TRUE_FIXED; |
2754 | + } |
2755 | + else if (f->getKind() == FunctionConsts::FN_ZORBA_REF_NODE_BY_REFERENCE_1) |
2756 | + { |
2757 | + curDereferencesNodes = ANNOTATION_TRUE; |
2758 | + } |
2759 | + |
2760 | + // Do not fold functions that always require access to the dynamic context, |
2761 | + // or may need to access the implicit timezone (which is also in the dynamic |
2762 | + // constext). |
2763 | + if (saveUnfoldable != ANNOTATION_TRUE_FIXED && |
2764 | + (f->accessesDynCtx() || |
2765 | + maybe_needs_implicit_timezone(fo) || |
2766 | + !f->isDeterministic())) |
2767 | + { |
2768 | + curUnfoldable = ANNOTATION_TRUE_FIXED; |
2769 | + } |
2770 | + } |
2771 | + else if (theIsLocal) |
2772 | + { |
2773 | + curUnfoldable = saveUnfoldable; |
2774 | + curDereferencesNodes = saveDereferencesNodes; |
2775 | + curConstructsNodes = saveConstructsNodes; |
2776 | + } |
2777 | + else |
2778 | + { |
2779 | + if (saveUnfoldable != ANNOTATION_TRUE_FIXED && |
2780 | + (f->accessesDynCtx() || !f->isDeterministic())) |
2781 | + { |
2782 | + curUnfoldable = ANNOTATION_TRUE_FIXED; |
2783 | + } |
2784 | + |
2785 | + if (static_cast<user_function*>(f)->dereferencesNodes()) |
2786 | + curDereferencesNodes = ANNOTATION_TRUE; |
2787 | + |
2788 | + if (static_cast<user_function*>(f)->constructsNodes()) |
2789 | + curConstructsNodes = ANNOTATION_TRUE; |
2790 | + } |
2791 | + |
2792 | + break; |
2793 | + } |
2794 | + |
2795 | + case var_expr_kind: |
2796 | + { |
2797 | + var_expr::var_kind varKind = static_cast<var_expr *>(node)->get_kind(); |
2798 | + |
2799 | + if (varKind == var_expr::prolog_var || varKind == var_expr::local_var) |
2800 | + curUnfoldable = ANNOTATION_TRUE_FIXED; |
2801 | + |
2802 | + break; |
2803 | + } |
2804 | + |
2805 | + default: |
2806 | + { |
2807 | + break; |
2808 | + } |
2809 | + } |
2810 | + |
2811 | if (node->is_sequential()) |
2812 | { |
2813 | curNonDiscardable = ANNOTATION_TRUE_FIXED; |
2814 | curUnfoldable = ANNOTATION_TRUE_FIXED; |
2815 | } |
2816 | - else |
2817 | - { |
2818 | - switch (node->get_expr_kind()) |
2819 | - { |
2820 | - case fo_expr_kind: |
2821 | - { |
2822 | - fo_expr* fo = static_cast<fo_expr *>(node); |
2823 | - function* f = fo->get_func(); |
2824 | - |
2825 | - if (!f->isUdf()) |
2826 | - { |
2827 | - if (FunctionConsts::FN_ERROR_0 <= f->getKind() && |
2828 | - f->getKind() <= FunctionConsts::FN_TRACE_2) |
2829 | - { |
2830 | - curNonDiscardable = ANNOTATION_TRUE_FIXED; |
2831 | - curUnfoldable = ANNOTATION_TRUE_FIXED; |
2832 | - } |
2833 | - else if (f->getKind() == FunctionConsts::FN_ZORBA_REF_NODE_BY_REFERENCE_1) |
2834 | - { |
2835 | - curDereferencesNodes = ANNOTATION_TRUE; |
2836 | - } |
2837 | - |
2838 | - // Do not fold functions that always require access to the dynamic context, |
2839 | - // or may need to access the implicit timezone (which is also in the dynamic |
2840 | - // constext). |
2841 | - if (saveUnfoldable != ANNOTATION_TRUE_FIXED && |
2842 | - (f->accessesDynCtx() || |
2843 | - maybe_needs_implicit_timezone(fo) || |
2844 | - !f->isDeterministic())) |
2845 | - { |
2846 | - curUnfoldable = ANNOTATION_TRUE_FIXED; |
2847 | - } |
2848 | - } |
2849 | - else if (theIsLocal) |
2850 | - { |
2851 | - curUnfoldable = saveUnfoldable; |
2852 | - curDereferencesNodes = saveDereferencesNodes; |
2853 | - curConstructsNodes = saveConstructsNodes; |
2854 | - } |
2855 | - else |
2856 | - { |
2857 | - if (saveUnfoldable != ANNOTATION_TRUE_FIXED && |
2858 | - (f->accessesDynCtx() || !f->isDeterministic())) |
2859 | - { |
2860 | - curUnfoldable = ANNOTATION_TRUE_FIXED; |
2861 | - } |
2862 | - |
2863 | - if (static_cast<user_function*>(f)->dereferencesNodes()) |
2864 | - curDereferencesNodes = ANNOTATION_TRUE; |
2865 | - |
2866 | - if (static_cast<user_function*>(f)->constructsNodes()) |
2867 | - curConstructsNodes = ANNOTATION_TRUE; |
2868 | - } |
2869 | - |
2870 | - break; |
2871 | - } |
2872 | - |
2873 | - case var_expr_kind: |
2874 | - { |
2875 | - var_expr::var_kind varKind = static_cast<var_expr *>(node)->get_kind(); |
2876 | - |
2877 | - if (varKind == var_expr::prolog_var || varKind == var_expr::local_var) |
2878 | - curUnfoldable = ANNOTATION_TRUE_FIXED; |
2879 | - |
2880 | - break; |
2881 | - } |
2882 | - |
2883 | - default: |
2884 | - { |
2885 | - break; |
2886 | - } |
2887 | - } |
2888 | - } |
2889 | |
2890 | if (saveNonDiscardable != curNonDiscardable && |
2891 | saveNonDiscardable != ANNOTATION_TRUE_FIXED) |
2892 | @@ -382,134 +378,79 @@ |
2893 | For each expr E, collect all the variables that are referenced directly by E |
2894 | and its subexpressions. |
2895 | ********************************************************************************/ |
2896 | - |
2897 | -RULE_REWRITE_PRE(MarkFreeVars) |
2898 | -{ |
2899 | - return NULL; |
2900 | -} |
2901 | - |
2902 | -RULE_REWRITE_POST(MarkFreeVars) |
2903 | +expr* MarkFreeVars::apply(RewriterContext& rCtx, expr* node, bool& modified) |
2904 | { |
2905 | expr::FreeVars& freevars = node->getFreeVars(); |
2906 | |
2907 | freevars.clear(); |
2908 | |
2909 | - if (node->get_expr_kind() == var_expr_kind) |
2910 | + switch (node->get_expr_kind()) |
2911 | + { |
2912 | + case var_expr_kind: |
2913 | { |
2914 | var_expr* v = static_cast<var_expr *>(node); |
2915 | freevars.insert(v); |
2916 | - } |
2917 | - else |
2918 | - { |
2919 | - // Get the free vars of each child expr and add them to the free vars of the |
2920 | - // parent. |
2921 | - ExprIterator iter(node); |
2922 | - while (!iter.done()) |
2923 | - { |
2924 | - expr* e = **iter; |
2925 | - |
2926 | + |
2927 | + break; |
2928 | + } |
2929 | + // Get the free vars of each child expr and add them to the free vars of the |
2930 | + // parent. But in case of a flwor expr, do not add any variables defined by |
2931 | + // the flwor expr itself |
2932 | + |
2933 | + case flwor_expr_kind: |
2934 | + case gflwor_expr_kind: |
2935 | + { |
2936 | + flwor_expr* flwor = static_cast<flwor_expr *> (node); |
2937 | + |
2938 | + ExprIterator iter(node); |
2939 | + while (!iter.done()) |
2940 | + { |
2941 | + expr* e = **iter; |
2942 | + |
2943 | + apply(rCtx, e, modified); |
2944 | + |
2945 | + const expr::FreeVars& kfv = e->getFreeVars(); |
2946 | + |
2947 | + expr::FreeVars::const_iterator ite = kfv.begin(); |
2948 | + expr::FreeVars::const_iterator end = kfv.end(); |
2949 | + for (; ite != end; ++ite) |
2950 | + { |
2951 | + flwor_clause* c = (*ite)->get_flwor_clause(); |
2952 | + if (c != NULL && c->get_flwor_expr() == flwor) |
2953 | + continue; |
2954 | + |
2955 | + freevars.insert(*ite); |
2956 | + } |
2957 | + |
2958 | + iter.next(); |
2959 | + } |
2960 | + |
2961 | + break; |
2962 | + } |
2963 | + default: |
2964 | + { |
2965 | + ExprIterator iter(node); |
2966 | + |
2967 | + while (!iter.done()) |
2968 | + { |
2969 | + expr* e = **iter; |
2970 | + |
2971 | + apply(rCtx, e, modified); |
2972 | + |
2973 | const expr::FreeVars& kfv = e->getFreeVars(); |
2974 | std::copy(kfv.begin(), |
2975 | kfv.end(), |
2976 | inserter(freevars, freevars.begin())); |
2977 | - |
2978 | + |
2979 | iter.next(); |
2980 | } |
2981 | - |
2982 | - // For a flwor expr, remove the vars defined by the flwor expr itself from |
2983 | - // the flwor free vars . |
2984 | - if (node->get_expr_kind() == flwor_expr_kind || |
2985 | - node->get_expr_kind() == gflwor_expr_kind) |
2986 | - { |
2987 | - flwor_expr* flwor = dynamic_cast<flwor_expr *> (node); |
2988 | - for (flwor_expr::clause_list_t::const_iterator i = flwor->clause_begin(); |
2989 | - i != flwor->clause_end(); |
2990 | - ++i) |
2991 | - { |
2992 | - const flwor_clause* c = *i; |
2993 | - |
2994 | - if (c->get_kind() == flwor_clause::for_clause) |
2995 | - { |
2996 | - const for_clause* fc = static_cast<const for_clause *>(c); |
2997 | - |
2998 | - freevars.erase(fc->get_var()); |
2999 | - if (fc->get_pos_var() != NULL) |
3000 | - freevars.erase(fc->get_pos_var()); |
3001 | - } |
3002 | - else if (c->get_kind() == flwor_clause::let_clause) |
3003 | - { |
3004 | - const let_clause* lc = static_cast<const let_clause *>(c); |
3005 | - |
3006 | - freevars.erase(lc->get_var()); |
3007 | - } |
3008 | - else if (c->get_kind() == flwor_clause::window_clause) |
3009 | - { |
3010 | - const window_clause* wc = static_cast<const window_clause *>(c); |
3011 | - |
3012 | - freevars.erase(wc->get_var()); |
3013 | - |
3014 | - flwor_wincond* startCond = wc->get_win_start(); |
3015 | - flwor_wincond* stopCond = wc->get_win_stop(); |
3016 | - |
3017 | - if (startCond != NULL) |
3018 | - remove_wincond_vars(startCond, freevars); |
3019 | - |
3020 | - if (stopCond != NULL) |
3021 | - remove_wincond_vars(stopCond, freevars); |
3022 | - } |
3023 | - else if (c->get_kind() == flwor_clause::group_clause) |
3024 | - { |
3025 | - const group_clause* gc = static_cast<const group_clause *>(c); |
3026 | - |
3027 | - const flwor_clause::rebind_list_t& gvars = gc->get_grouping_vars(); |
3028 | - csize numGroupVars = gvars.size(); |
3029 | - |
3030 | - for (csize i = 0; i < numGroupVars; ++i) |
3031 | - { |
3032 | - freevars.erase(gvars[i].second); |
3033 | - } |
3034 | - |
3035 | - const flwor_clause::rebind_list_t& ngvars = gc->get_nongrouping_vars(); |
3036 | - csize numNonGroupVars = ngvars.size(); |
3037 | - |
3038 | - for (csize i = 0; i < numNonGroupVars; ++i) |
3039 | - { |
3040 | - freevars.erase(ngvars[i].second); |
3041 | - } |
3042 | - } |
3043 | - else if (c->get_kind() == flwor_clause::count_clause) |
3044 | - { |
3045 | - const count_clause* cc = static_cast<const count_clause *>(c); |
3046 | - |
3047 | - freevars.erase(cc->get_var()); |
3048 | - } |
3049 | - } |
3050 | - } |
3051 | + } |
3052 | } |
3053 | |
3054 | return NULL; |
3055 | } |
3056 | |
3057 | |
3058 | -static void remove_wincond_vars( |
3059 | - const flwor_wincond* cond, |
3060 | - expr::FreeVars& freevars) |
3061 | -{ |
3062 | - const flwor_wincond::vars& inVars = cond->get_in_vars(); |
3063 | - const flwor_wincond::vars& outVars = cond->get_out_vars(); |
3064 | - |
3065 | - freevars.erase(inVars.posvar); |
3066 | - freevars.erase(inVars.curr); |
3067 | - freevars.erase(inVars.prev); |
3068 | - freevars.erase(inVars.next); |
3069 | - |
3070 | - freevars.erase(outVars.posvar); |
3071 | - freevars.erase(outVars.curr); |
3072 | - freevars.erase(outVars.prev); |
3073 | - freevars.erase(outVars.next); |
3074 | -} |
3075 | - |
3076 | - |
3077 | /******************************************************************************* |
3078 | Execute const exprs that return at most one item as a result. Replace such |
3079 | exprs by either a const_expr whose value is the returned item, or an empty |
3080 | @@ -1014,7 +955,7 @@ |
3081 | |
3082 | if (c->get_kind() == flwor_clause::for_clause) |
3083 | { |
3084 | - return c->get_expr(); |
3085 | + return static_cast<for_clause*>(c)->get_expr(); |
3086 | } |
3087 | else |
3088 | { |
3089 | |
3090 | === modified file 'src/compiler/rewriter/rules/hoist_rules.cpp' |
3091 | --- src/compiler/rewriter/rules/hoist_rules.cpp 2012-10-20 21:29:37 +0000 |
3092 | +++ src/compiler/rewriter/rules/hoist_rules.cpp 2012-10-24 11:34:21 +0000 |
3093 | @@ -564,7 +564,7 @@ |
3094 | k == axis_step_expr_kind || |
3095 | k == match_expr_kind || |
3096 | (k == wrapper_expr_kind && |
3097 | - non_hoistable(static_cast<const wrapper_expr*>(e)->get_expr())) || |
3098 | + non_hoistable(static_cast<const wrapper_expr*>(e)->get_input())) || |
3099 | is_already_hoisted(e) || |
3100 | is_enclosed_expr(e) || |
3101 | e->containsRecursiveCall() || |
3102 | |
3103 | === modified file 'src/compiler/rewriter/rules/index_join_rule.cpp' |
3104 | --- src/compiler/rewriter/rules/index_join_rule.cpp 2012-10-10 13:05:50 +0000 |
3105 | +++ src/compiler/rewriter/rules/index_join_rule.cpp 2012-10-24 11:34:21 +0000 |
3106 | @@ -736,9 +736,9 @@ |
3107 | { |
3108 | wrapper_expr* wrapper = reinterpret_cast<wrapper_expr*>(subExpr); |
3109 | |
3110 | - if (wrapper->get_expr()->get_expr_kind() == var_expr_kind) |
3111 | + if (wrapper->get_input()->get_expr_kind() == var_expr_kind) |
3112 | { |
3113 | - var_expr* var = reinterpret_cast<var_expr*>(wrapper->get_expr()); |
3114 | + var_expr* var = reinterpret_cast<var_expr*>(wrapper->get_input()); |
3115 | long varid = -1; |
3116 | |
3117 | if (rCtx.theVarIdMap->find(var) != rCtx.theVarIdMap->end()) |
3118 | |
3119 | === modified file 'src/compiler/rewriter/rules/nodeid_rules.cpp' |
3120 | --- src/compiler/rewriter/rules/nodeid_rules.cpp 2012-10-16 13:24:49 +0000 |
3121 | +++ src/compiler/rewriter/rules/nodeid_rules.cpp 2012-10-24 11:34:21 +0000 |
3122 | @@ -122,7 +122,7 @@ |
3123 | |
3124 | order_expr* orderExpr = static_cast<order_expr *>(node); |
3125 | |
3126 | - rCtx.theIsInOrderedMode = (orderExpr->get_type() == order_expr::ordered ? |
3127 | + rCtx.theIsInOrderedMode = (orderExpr->get_type() == doc_ordered ? |
3128 | true : false); |
3129 | break; |
3130 | } |
3131 | @@ -278,17 +278,17 @@ |
3132 | |
3133 | case wrapper_expr_kind : |
3134 | { |
3135 | - wrapper_expr* we = static_cast<wrapper_expr *>(node); |
3136 | - pushdown_ignores_sorted_nodes(node, we->get_expr()); |
3137 | - pushdown_ignores_duplicate_nodes(node, we->get_expr()); |
3138 | + wrapper_expr* e = static_cast<wrapper_expr *>(node); |
3139 | + pushdown_ignores_sorted_nodes(node, e->get_input()); |
3140 | + pushdown_ignores_duplicate_nodes(node, e->get_input()); |
3141 | break; |
3142 | } |
3143 | |
3144 | case function_trace_expr_kind : |
3145 | { |
3146 | - function_trace_expr* fte = static_cast<function_trace_expr*>(node); |
3147 | - pushdown_ignores_sorted_nodes(node, fte->get_expr()); |
3148 | - pushdown_ignores_duplicate_nodes(node, fte->get_expr()); |
3149 | + function_trace_expr* e = static_cast<function_trace_expr *>(node); |
3150 | + pushdown_ignores_sorted_nodes(node, e->get_input()); |
3151 | + pushdown_ignores_duplicate_nodes(node, e->get_input()); |
3152 | break; |
3153 | } |
3154 | |
3155 | @@ -892,7 +892,7 @@ |
3156 | { |
3157 | validate_expr* e = static_cast<validate_expr *>(node); |
3158 | std::vector<expr*> sources; |
3159 | - theSourceFinder->findNodeSources(e->get_expr(), sources); |
3160 | + theSourceFinder->findNodeSources(e->get_input(), sources); |
3161 | markSources(sources); |
3162 | break; |
3163 | } |
3164 | |
3165 | === modified file 'src/compiler/rewriter/rules/path_rules.cpp' |
3166 | --- src/compiler/rewriter/rules/path_rules.cpp 2012-09-19 21:16:15 +0000 |
3167 | +++ src/compiler/rewriter/rules/path_rules.cpp 2012-10-24 11:34:21 +0000 |
3168 | @@ -26,22 +26,22 @@ |
3169 | |
3170 | RULE_REWRITE_PRE(EliminateExtraneousPathSteps) |
3171 | { |
3172 | - relpath_expr* re = dynamic_cast<relpath_expr *>(node); |
3173 | - if (re != NULL) |
3174 | + if (node->get_expr_kind() == relpath_expr_kind) |
3175 | { |
3176 | + relpath_expr* re = static_cast<relpath_expr *>(node); |
3177 | csize numSteps = re->size(); |
3178 | |
3179 | - for (csize i = 0; i < numSteps - 1; i++) |
3180 | + for (csize i = 1; i < numSteps - 1; ++i) |
3181 | { |
3182 | - axis_step_expr* axisStep = dynamic_cast<axis_step_expr*>((*re)[i]); |
3183 | - |
3184 | - if (axisStep != NULL && |
3185 | - axisStep->getAxis() == axis_kind_descendant_or_self && |
3186 | + assert((*re)[i]->get_expr_kind() == axis_step_expr_kind); |
3187 | + |
3188 | + axis_step_expr* axisStep = static_cast<axis_step_expr*>((*re)[i]); |
3189 | + |
3190 | + if (axisStep->getAxis() == axis_kind_descendant_or_self && |
3191 | axisStep->getTest()->getTestKind() == match_anykind_test) |
3192 | { |
3193 | - axis_step_expr* nextStep = dynamic_cast<axis_step_expr*>((*re)[i+1]); |
3194 | - if (nextStep != NULL && |
3195 | - nextStep->getAxis() == axis_kind_child) |
3196 | + axis_step_expr* nextStep = static_cast<axis_step_expr*>((*re)[i+1]); |
3197 | + if (nextStep->getAxis() == axis_kind_child) |
3198 | { |
3199 | nextStep->setAxis(axis_kind_descendant); |
3200 | (*re).erase(i); |
3201 | @@ -53,7 +53,7 @@ |
3202 | |
3203 | if (numSteps == 1) |
3204 | { |
3205 | - return (*re) [0]; |
3206 | + return (*re)[0]; |
3207 | } |
3208 | } |
3209 | |
3210 | |
3211 | === modified file 'src/compiler/rewriter/rules/ruleset.h' |
3212 | --- src/compiler/rewriter/rules/ruleset.h 2012-10-19 20:42:38 +0000 |
3213 | +++ src/compiler/rewriter/rules/ruleset.h 2012-10-24 11:34:21 +0000 |
3214 | @@ -47,10 +47,10 @@ |
3215 | |
3216 | PREPOST_RULE(MergeFLWOR); |
3217 | |
3218 | + //PREPOST_RULE(MarkFreeVars); |
3219 | + |
3220 | PREPOST_RULE(EliminateExtraneousPathSteps); |
3221 | |
3222 | -PREPOST_RULE(MarkFreeVars); |
3223 | - |
3224 | PREPOST_RULE(InlineFunctions); |
3225 | |
3226 | PREPOST_RULE(PartialEval); |
3227 | @@ -100,6 +100,22 @@ |
3228 | expr* apply(RewriterContext& rCtx, expr* node, bool& modified); |
3229 | }; |
3230 | |
3231 | +#if 1 |
3232 | +/******************************************************************************* |
3233 | + |
3234 | +********************************************************************************/ |
3235 | +class MarkFreeVars : public RewriteRule |
3236 | +{ |
3237 | +public: |
3238 | + MarkFreeVars() |
3239 | + : |
3240 | + RewriteRule(RewriteRule::MarkFreeVars, "MarkFreeVars") |
3241 | + { |
3242 | + } |
3243 | + |
3244 | + expr* apply(RewriterContext& rCtx, expr* node, bool& modified); |
3245 | +}; |
3246 | +#endif |
3247 | |
3248 | /******************************************************************************* |
3249 | |
3250 | |
3251 | === modified file 'src/compiler/rewriter/rules/type_rules.cpp' |
3252 | --- src/compiler/rewriter/rules/type_rules.cpp 2012-10-10 13:05:50 +0000 |
3253 | +++ src/compiler/rewriter/rules/type_rules.cpp 2012-10-24 11:34:21 +0000 |
3254 | @@ -188,7 +188,7 @@ |
3255 | node->get_loc(), |
3256 | arg, |
3257 | target_type, |
3258 | - TreatIterator::TYPE_MATCH, |
3259 | + TREAT_TYPE_MATCH, |
3260 | false); // do not check the prime types |
3261 | } |
3262 | |
3263 | @@ -268,7 +268,7 @@ |
3264 | argExpr->get_loc(), |
3265 | argExpr, |
3266 | rtm.DOUBLE_TYPE_STAR, |
3267 | - PromoteIterator::FUNC_PARAM, |
3268 | + PROMOTE_FUNC_PARAM, |
3269 | replacement->getName()); |
3270 | |
3271 | fo->set_arg(0, promoteExpr); |
3272 | @@ -570,7 +570,7 @@ |
3273 | arg->get_loc(), |
3274 | arg, |
3275 | t, |
3276 | - PromoteIterator::FUNC_PARAM, |
3277 | + PROMOTE_FUNC_PARAM, |
3278 | fn->getName()); |
3279 | } |
3280 | |
3281 | |
3282 | === modified file 'src/compiler/rewriter/tools/dataflow_annotations.cpp' |
3283 | --- src/compiler/rewriter/tools/dataflow_annotations.cpp 2012-10-12 09:05:54 +0000 |
3284 | +++ src/compiler/rewriter/tools/dataflow_annotations.cpp 2012-10-24 11:34:21 +0000 |
3285 | @@ -110,16 +110,32 @@ |
3286 | case while_expr_kind: // TODO |
3287 | break; |
3288 | |
3289 | + case promote_expr_kind: |
3290 | + case castable_expr_kind: |
3291 | + case instanceof_expr_kind: |
3292 | + { |
3293 | + default_walk(e); |
3294 | + cast_or_castable_base_expr* ue = static_cast<cast_or_castable_base_expr*>(e); |
3295 | + PROPOGATE_SORTED_NODES(ue->get_input(), e); |
3296 | + PROPOGATE_DISTINCT_NODES(ue->get_input(), e); |
3297 | + break; |
3298 | + } |
3299 | + |
3300 | case wrapper_expr_kind: |
3301 | - compute_wrapper_expr(static_cast<wrapper_expr *>(e)); |
3302 | + { |
3303 | + default_walk(e); |
3304 | + wrapper_expr* ue = static_cast<wrapper_expr*>(e); |
3305 | + PROPOGATE_SORTED_NODES(ue->get_input(), e); |
3306 | + PROPOGATE_DISTINCT_NODES(ue->get_input(), e); |
3307 | break; |
3308 | + } |
3309 | |
3310 | case function_trace_expr_kind: |
3311 | { |
3312 | default_walk(e); |
3313 | - function_trace_expr* fte = static_cast<function_trace_expr*>(e); |
3314 | - PROPOGATE_SORTED_NODES(fte->get_expr(), e); |
3315 | - PROPOGATE_DISTINCT_NODES(fte->get_expr(), e); |
3316 | + function_trace_expr* ue = static_cast<function_trace_expr*>(e); |
3317 | + PROPOGATE_SORTED_NODES(ue->get_input(), e); |
3318 | + PROPOGATE_DISTINCT_NODES(ue->get_input(), e); |
3319 | break; |
3320 | } |
3321 | |
3322 | @@ -136,10 +152,6 @@ |
3323 | compute_trycatch_expr(static_cast<trycatch_expr *>(e)); |
3324 | break; |
3325 | |
3326 | - case promote_expr_kind: |
3327 | - compute_promote_expr(static_cast<promote_expr *>(e)); |
3328 | - break; |
3329 | - |
3330 | case if_expr_kind: |
3331 | compute_if_expr(static_cast<if_expr *>(e)); |
3332 | break; |
3333 | @@ -148,18 +160,10 @@ |
3334 | compute_fo_expr(static_cast<fo_expr *>(e)); |
3335 | break; |
3336 | |
3337 | - case instanceof_expr_kind: |
3338 | - compute_instanceof_expr(static_cast<instanceof_expr *>(e)); |
3339 | - break; |
3340 | - |
3341 | case treat_expr_kind: |
3342 | compute_treat_expr(static_cast<treat_expr *>(e)); |
3343 | break; |
3344 | |
3345 | - case castable_expr_kind: |
3346 | - compute_castable_expr(static_cast<castable_expr *>(e)); |
3347 | - break; |
3348 | - |
3349 | case cast_expr_kind: |
3350 | compute_cast_expr(static_cast<cast_expr *>(e)); |
3351 | break; |
3352 | @@ -336,17 +340,6 @@ |
3353 | /******************************************************************************* |
3354 | |
3355 | ********************************************************************************/ |
3356 | -void DataflowAnnotationsComputer::compute_wrapper_expr(wrapper_expr* e) |
3357 | -{ |
3358 | - default_walk(e); |
3359 | - PROPOGATE_SORTED_NODES(e->get_expr(), e); |
3360 | - PROPOGATE_DISTINCT_NODES(e->get_expr(), e); |
3361 | -} |
3362 | - |
3363 | - |
3364 | -/******************************************************************************* |
3365 | - |
3366 | -********************************************************************************/ |
3367 | void DataflowAnnotationsComputer::compute_var_expr(var_expr* e) |
3368 | { |
3369 | if (!generic_compute(e)) |
3370 | @@ -451,17 +444,6 @@ |
3371 | /******************************************************************************* |
3372 | |
3373 | ********************************************************************************/ |
3374 | -void DataflowAnnotationsComputer::compute_promote_expr(promote_expr* e) |
3375 | -{ |
3376 | - default_walk(e); |
3377 | - PROPOGATE_SORTED_NODES(e->get_input(), e); |
3378 | - PROPOGATE_DISTINCT_NODES(e->get_input(), e); |
3379 | -} |
3380 | - |
3381 | - |
3382 | -/******************************************************************************* |
3383 | - |
3384 | -********************************************************************************/ |
3385 | void DataflowAnnotationsComputer::compute_if_expr(if_expr* e) |
3386 | { |
3387 | default_walk(e); |
3388 | @@ -540,17 +522,6 @@ |
3389 | /******************************************************************************* |
3390 | |
3391 | ********************************************************************************/ |
3392 | -void DataflowAnnotationsComputer::compute_instanceof_expr(instanceof_expr *e) |
3393 | -{ |
3394 | - default_walk(e); |
3395 | - PROPOGATE_SORTED_NODES(e->get_input(), e); |
3396 | - PROPOGATE_DISTINCT_NODES(e->get_input(), e); |
3397 | -} |
3398 | - |
3399 | - |
3400 | -/******************************************************************************* |
3401 | - |
3402 | -********************************************************************************/ |
3403 | void DataflowAnnotationsComputer::compute_treat_expr(treat_expr *e) |
3404 | { |
3405 | default_walk(e); |
3406 | @@ -565,17 +536,6 @@ |
3407 | /******************************************************************************* |
3408 | |
3409 | ********************************************************************************/ |
3410 | -void DataflowAnnotationsComputer::compute_castable_expr(castable_expr *e) |
3411 | -{ |
3412 | - default_walk(e); |
3413 | - PROPOGATE_SORTED_NODES(e->get_input(), e); |
3414 | - PROPOGATE_DISTINCT_NODES(e->get_input(), e); |
3415 | -} |
3416 | - |
3417 | - |
3418 | -/******************************************************************************* |
3419 | - |
3420 | -********************************************************************************/ |
3421 | void DataflowAnnotationsComputer::compute_cast_expr(cast_expr* e) |
3422 | { |
3423 | default_walk(e); |
3424 | @@ -601,8 +561,8 @@ |
3425 | default_walk(e); |
3426 | if (!generic_compute(e)) |
3427 | { |
3428 | - PROPOGATE_SORTED_NODES(e->get_expr(), e); |
3429 | - PROPOGATE_DISTINCT_NODES(e->get_expr(), e); |
3430 | + PROPOGATE_SORTED_NODES(e->get_input(), e); |
3431 | + PROPOGATE_DISTINCT_NODES(e->get_input(), e); |
3432 | } |
3433 | } |
3434 | |
3435 | |
3436 | === modified file 'src/compiler/rewriter/tools/dataflow_annotations.h' |
3437 | --- src/compiler/rewriter/tools/dataflow_annotations.h 2012-10-12 09:05:54 +0000 |
3438 | +++ src/compiler/rewriter/tools/dataflow_annotations.h 2012-10-24 11:34:21 +0000 |
3439 | @@ -38,15 +38,12 @@ |
3440 | private: |
3441 | void compute_var_decl_expr(var_decl_expr* e); |
3442 | void compute_block_expr(block_expr* e); |
3443 | - void compute_wrapper_expr(wrapper_expr* e); |
3444 | void compute_var_expr(var_expr* e); |
3445 | void compute_var_set_expr(var_set_expr* e); |
3446 | void compute_flwor_expr(flwor_expr* e); |
3447 | void compute_trycatch_expr(trycatch_expr* e); |
3448 | - void compute_promote_expr(promote_expr* e); |
3449 | void compute_if_expr(if_expr* e); |
3450 | void compute_fo_expr(fo_expr* e); |
3451 | - void compute_instanceof_expr(instanceof_expr* e); |
3452 | void compute_treat_expr(treat_expr* e); |
3453 | void compute_castable_expr(castable_expr* e); |
3454 | void compute_cast_expr(cast_expr* e); |
3455 | |
3456 | === modified file 'src/compiler/rewriter/tools/expr_tools.cpp' |
3457 | --- src/compiler/rewriter/tools/expr_tools.cpp 2012-10-22 15:10:23 +0000 |
3458 | +++ src/compiler/rewriter/tools/expr_tools.cpp 2012-10-24 11:34:21 +0000 |
3459 | @@ -188,7 +188,7 @@ |
3460 | { |
3461 | wrapper_expr* wrapper = reinterpret_cast<wrapper_expr*>(e); |
3462 | |
3463 | - if (wrapper->get_expr() == oldVar) |
3464 | + if (wrapper->get_input() == oldVar) |
3465 | { |
3466 | wrapper->set_expr(newVar); |
3467 | return; |
3468 | |
3469 | === modified file 'src/compiler/translator/translator.cpp' |
3470 | --- src/compiler/translator/translator.cpp 2012-10-23 19:08:52 +0000 |
3471 | +++ src/compiler/translator/translator.cpp 2012-10-24 11:34:21 +0000 |
3472 | @@ -1463,7 +1463,7 @@ |
3473 | { |
3474 | argExpr = wrap_in_type_promotion(argExpr, |
3475 | paramType, |
3476 | - PromoteIterator::FUNC_PARAM, |
3477 | + PROMOTE_FUNC_PARAM, |
3478 | func->getName()); |
3479 | } |
3480 | else |
3481 | @@ -1471,7 +1471,7 @@ |
3482 | argExpr = wrap_in_type_match(argExpr, |
3483 | paramType, |
3484 | loc, |
3485 | - TreatIterator::FUNC_PARAM, |
3486 | + TREAT_FUNC_PARAM, |
3487 | func->getName()); |
3488 | } |
3489 | } |
3490 | @@ -1500,7 +1500,7 @@ |
3491 | expr* wrap_in_type_promotion( |
3492 | expr* e, |
3493 | const xqtref_t& type, |
3494 | - PromoteIterator::ErrorKind errorKind, |
3495 | + PromoteErrorKind errorKind, |
3496 | store::Item* qname = NULL) |
3497 | { |
3498 | e = wrap_in_atomization(e); |
3499 | @@ -1522,7 +1522,7 @@ |
3500 | expr* e, |
3501 | const xqtref_t& type, |
3502 | const QueryLoc& loc, |
3503 | - TreatIterator::ErrorKind errorKind, |
3504 | + TreatErrorKind errorKind, |
3505 | store::Item_t qname = NULL) |
3506 | { |
3507 | TypeManager* tm = e->get_type_manager(); |
3508 | @@ -2053,7 +2053,7 @@ |
3509 | loc, |
3510 | initExpr, |
3511 | varType, |
3512 | - TreatIterator::TYPE_MATCH); |
3513 | + TREAT_TYPE_MATCH); |
3514 | } |
3515 | |
3516 | expr* declExpr = theExprManager-> |
3517 | @@ -2073,7 +2073,7 @@ |
3518 | loc, |
3519 | getExpr, |
3520 | varType, |
3521 | - TreatIterator::TYPE_MATCH); |
3522 | + TREAT_TYPE_MATCH); |
3523 | |
3524 | stmts.push_back(treatExpr); |
3525 | } |
3526 | @@ -3823,7 +3823,7 @@ |
3527 | { |
3528 | body = wrap_in_type_promotion(body, |
3529 | returnType, |
3530 | - PromoteIterator::FUNC_RETURN, |
3531 | + PROMOTE_FUNC_RETURN, |
3532 | udf->getName()); |
3533 | |
3534 | body->set_loc(v.get_return_type()->get_location()); |
3535 | @@ -3833,7 +3833,7 @@ |
3536 | body = wrap_in_type_match(body, |
3537 | returnType, |
3538 | loc, |
3539 | - TreatIterator::FUNC_RETURN, |
3540 | + TREAT_FUNC_RETURN, |
3541 | udf->getName()); |
3542 | } |
3543 | |
3544 | @@ -4540,13 +4540,13 @@ |
3545 | domainExpr = wrap_in_type_match(domainExpr, |
3546 | theRTM.STRUCTURED_ITEM_TYPE_STAR, |
3547 | loc, |
3548 | - TreatIterator::INDEX_DOMAIN, |
3549 | + TREAT_INDEX_DOMAIN, |
3550 | index->getName()); |
3551 | #else |
3552 | domainExpr = wrap_in_type_match(domainExpr, |
3553 | theRTM.ANY_NODE_TYPE_STAR, |
3554 | loc, |
3555 | - TreatIterator::INDEX_DOMAIN, |
3556 | + TREAT_INDEX_DOMAIN, |
3557 | index->getName()); |
3558 | #endif |
3559 | |
3560 | @@ -4718,7 +4718,7 @@ |
3561 | keyExpr = wrap_in_type_match(keyExpr, |
3562 | type, |
3563 | loc, |
3564 | - TreatIterator::INDEX_KEY, |
3565 | + TREAT_INDEX_KEY, |
3566 | index->getName()); |
3567 | |
3568 | keyTypes[i] = ptype->getBaseBuiltinType(); |
3569 | @@ -5941,7 +5941,7 @@ |
3570 | loc, |
3571 | valueExpr, |
3572 | varType, |
3573 | - TreatIterator::TYPE_MATCH); |
3574 | + TREAT_TYPE_MATCH); |
3575 | |
3576 | push_nodestack(theExprManager->create_var_set_expr(theRootSctx, |
3577 | theUDF, |
3578 | @@ -6047,7 +6047,7 @@ |
3579 | expr* condExpr = pop_nodestack(); |
3580 | |
3581 | expr* breakExpr = theExprManager-> |
3582 | - create_flowctl_expr(theRootSctx, theUDF, loc, flowctl_expr::BREAK); |
3583 | + create_flowctl_expr(theRootSctx, theUDF, loc, FLOW_BREAK); |
3584 | |
3585 | condExpr = theExprManager-> |
3586 | create_if_expr(theRootSctx, theUDF, loc, condExpr, create_empty_seq(loc), breakExpr); |
3587 | @@ -6082,7 +6082,7 @@ |
3588 | { |
3589 | TRACE_VISIT_OUT(); |
3590 | |
3591 | - enum flowctl_expr::action a; |
3592 | + FlowCtlAction a; |
3593 | |
3594 | switch (v.get_action()) |
3595 | { |
3596 | @@ -6092,7 +6092,7 @@ |
3597 | { |
3598 | RAISE_ERROR_NO_PARAMS(zerr::XSST0009, loc); |
3599 | } |
3600 | - a = flowctl_expr::BREAK; |
3601 | + a = FLOW_BREAK; |
3602 | break; |
3603 | } |
3604 | case FlowCtlStatement::CONTINUE: |
3605 | @@ -6101,7 +6101,7 @@ |
3606 | { |
3607 | RAISE_ERROR_NO_PARAMS(zerr::XSST0010, loc); |
3608 | } |
3609 | - a = flowctl_expr::CONTINUE; |
3610 | + a = FLOW_CONTINUE; |
3611 | break; |
3612 | } |
3613 | default: |
3614 | @@ -6557,9 +6557,9 @@ |
3615 | // Pop the window the domain expr. |
3616 | expr* windowDomainExpr = pop_nodestack(); |
3617 | |
3618 | - window_clause::window_t winKind = (v.get_wintype() == WindowClause::tumbling_window ? |
3619 | - window_clause::tumbling_window : |
3620 | - window_clause::sliding_window); |
3621 | + WindowKind winKind = (v.get_wintype() == WindowClause::tumbling_window ? |
3622 | + tumbling_window : |
3623 | + sliding_window); |
3624 | |
3625 | window_clause* clause = theExprManager->create_window_clause(theRootSctx, |
3626 | v.get_location(), |
3627 | @@ -6943,7 +6943,7 @@ |
3628 | inputExpr = wrap_in_type_match(inputExpr, |
3629 | theRTM.ANY_ATOMIC_TYPE_QUESTION, |
3630 | specLoc, |
3631 | - TreatIterator::MULTI_VALUED_GROUPING_KEY); |
3632 | + TREAT_MULTI_VALUED_GROUPING_KEY); |
3633 | |
3634 | // We need to do this to handle grouping vars with same names but |
3635 | // different collations. |
3636 | @@ -7589,7 +7589,7 @@ |
3637 | loc, |
3638 | sv, |
3639 | type, |
3640 | - TreatIterator::TREAT_EXPR); |
3641 | + TREAT_EXPR); |
3642 | |
3643 | // clauseExpr = [let $caseVar := treat_as($sv, caseType) return NULL] |
3644 | clauseExpr = wrap_in_let_flwor(treatExpr, caseVar, NULL); |
3645 | @@ -8421,10 +8421,10 @@ |
3646 | { |
3647 | TRACE_VISIT_OUT(); |
3648 | |
3649 | - push_nodestack(theExprManager->create_instanceof_expr(theRootSctx, theUDF, |
3650 | - loc, |
3651 | - pop_nodestack(), |
3652 | - pop_tstack())); |
3653 | + push_nodestack(CREATE(instanceof)(theRootSctx, theUDF, |
3654 | + loc, |
3655 | + pop_nodestack(), |
3656 | + pop_tstack())); |
3657 | } |
3658 | |
3659 | |
3660 | @@ -8441,11 +8441,11 @@ |
3661 | { |
3662 | TRACE_VISIT_OUT(); |
3663 | |
3664 | - push_nodestack(theExprManager->create_treat_expr(theRootSctx, theUDF, |
3665 | - loc, |
3666 | - pop_nodestack(), |
3667 | - pop_tstack(), |
3668 | - TreatIterator::TREAT_EXPR)); |
3669 | + push_nodestack(CREATE(treat)(theRootSctx, theUDF, |
3670 | + loc, |
3671 | + pop_nodestack(), |
3672 | + pop_tstack(), |
3673 | + TREAT_EXPR)); |
3674 | } |
3675 | |
3676 | |
3677 | @@ -9003,22 +9003,23 @@ |
3678 | loc, |
3679 | DOT_REF, |
3680 | GENV_TYPESYSTEM.ANY_NODE_TYPE_ONE, |
3681 | - TreatIterator::PATH_DOT); |
3682 | + TREAT_PATH_DOT); |
3683 | |
3684 | ctx_path_expr->add_back(sourceExpr); |
3685 | |
3686 | - match_expr* me = theExprManager->create_match_expr(theRootSctx, theUDF, loc); |
3687 | + match_expr* me = CREATE(match)(theRootSctx, theUDF, loc); |
3688 | me->setTestKind(match_anykind_test); |
3689 | - axis_step_expr* ase = theExprManager->create_axis_step_expr(theRootSctx, theUDF, loc); |
3690 | + axis_step_expr* ase = CREATE(axis_step)(theRootSctx, theUDF, loc); |
3691 | ase->setAxis(axis_kind_self); |
3692 | ase->setTest(me); |
3693 | |
3694 | ctx_path_expr->add_back(&*ase); |
3695 | |
3696 | - fo_expr* fnroot = theExprManager->create_fo_expr(theRootSctx, theUDF, |
3697 | - loc, |
3698 | - BUILTIN_FUNC(FN_ROOT_1), |
3699 | - ctx_path_expr); |
3700 | + fo_expr* fnroot = CREATE(fo)(theRootSctx, |
3701 | + theUDF, |
3702 | + loc, |
3703 | + BUILTIN_FUNC(FN_ROOT_1), |
3704 | + ctx_path_expr); |
3705 | normalize_fo(fnroot); |
3706 | |
3707 | if (pathExpr != NULL) |
3708 | @@ -9032,11 +9033,12 @@ |
3709 | else |
3710 | { |
3711 | // case 1 |
3712 | - expr* result = theExprManager->create_treat_expr(theRootSctx, theUDF, |
3713 | - loc, |
3714 | - fnroot, |
3715 | - GENV_TYPESYSTEM.DOCUMENT_TYPE_ONE, |
3716 | - TreatIterator::TREAT_EXPR); |
3717 | + expr* result = CREATE(treat)(theRootSctx, |
3718 | + theUDF, |
3719 | + loc, |
3720 | + fnroot, |
3721 | + GENV_TYPESYSTEM.DOCUMENT_TYPE_ONE, |
3722 | + TREAT_EXPR); |
3723 | push_nodestack(result); |
3724 | } |
3725 | } |
3726 | @@ -9127,7 +9129,7 @@ |
3727 | loc, |
3728 | DOT_REF, |
3729 | GENV_TYPESYSTEM.ANY_NODE_TYPE_ONE, |
3730 | - TreatIterator::PATH_DOT); |
3731 | + TREAT_PATH_DOT); |
3732 | pathExpr->add_back(sourceExpr); |
3733 | |
3734 | if (axisStep->get_predicate_list() == NULL) |
3735 | @@ -9200,14 +9202,13 @@ |
3736 | #ifdef NODE_SORT_OPT |
3737 | if (pathExpr->size() == 0) |
3738 | { |
3739 | - TreatIterator::ErrorKind errKind = TreatIterator::PATH_STEP; |
3740 | + TreatErrorKind errKind = TREAT_PATH_STEP; |
3741 | |
3742 | if (stepExpr->get_expr_kind() == wrapper_expr_kind) |
3743 | { |
3744 | - wrapper_expr* tmp = static_cast<wrapper_expr*>(stepExpr); |
3745 | var_expr* dotVar = lookup_var(DOT_VARNAME, loc, zerr::ZXQP0000_NO_ERROR); |
3746 | - if (tmp->get_expr() == dotVar) |
3747 | - errKind = TreatIterator::PATH_DOT; |
3748 | + if (static_cast<wrapper_expr*>(stepExpr)->get_input() == dotVar) |
3749 | + errKind = TREAT_PATH_DOT; |
3750 | } |
3751 | |
3752 | expr* sourceExpr = theExprManager->create_treat_expr(theRootSctx, theUDF, |
3753 | @@ -10369,7 +10370,7 @@ |
3754 | |
3755 | push_nodestack(theExprManager->create_order_expr(theRootSctx, theUDF, |
3756 | loc, |
3757 | - order_expr::ordered, |
3758 | + doc_ordered, |
3759 | pop_nodestack())); |
3760 | } |
3761 | |
3762 | @@ -10390,7 +10391,7 @@ |
3763 | |
3764 | push_nodestack(theExprManager->create_order_expr(theRootSctx, theUDF, |
3765 | loc, |
3766 | - order_expr::unordered, |
3767 | + doc_unordered, |
3768 | pop_nodestack())); |
3769 | } |
3770 | |
3771 | @@ -10642,22 +10643,26 @@ |
3772 | |
3773 | var_expr* tv = create_temp_var(loc, var_expr::let_var); |
3774 | |
3775 | - expr* nanExpr = theExprManager->create_const_expr(theRootSctx, theUDF, loc, xs_double::nan()); |
3776 | + expr* nanExpr = CREATE(const)(theRootSctx, theUDF, loc, xs_double::nan()); |
3777 | |
3778 | - expr* condExpr = theExprManager->create_castable_expr(theRootSctx, theUDF, loc, &*tv, theRTM.DOUBLE_TYPE_ONE); |
3779 | + expr* condExpr = CREATE(castable)(theRootSctx, |
3780 | + theUDF, |
3781 | + loc, |
3782 | + tv, |
3783 | + theRTM.DOUBLE_TYPE_ONE); |
3784 | |
3785 | expr* castExpr = create_cast_expr(loc, tv, theRTM.DOUBLE_TYPE_ONE, true); |
3786 | |
3787 | - expr* ret = theExprManager->create_if_expr(theRootSctx, theUDF, loc, condExpr, castExpr, nanExpr); |
3788 | + expr* ret = CREATE(if)(theRootSctx, theUDF, loc, condExpr, castExpr, nanExpr); |
3789 | |
3790 | expr* data_expr = wrap_in_atomization(arguments[0]); |
3791 | |
3792 | - push_nodestack(wrap_in_let_flwor(theExprManager->create_treat_expr(theRootSctx, |
3793 | - theUDF, |
3794 | - loc, |
3795 | - data_expr, |
3796 | - theRTM.ANY_ATOMIC_TYPE_QUESTION, |
3797 | - TreatIterator::TYPE_MATCH), |
3798 | + push_nodestack(wrap_in_let_flwor(CREATE(treat)(theRootSctx, |
3799 | + theUDF, |
3800 | + loc, |
3801 | + data_expr, |
3802 | + theRTM.ANY_ATOMIC_TYPE_QUESTION, |
3803 | + TREAT_TYPE_MATCH), |
3804 | tv, |
3805 | ret)); |
3806 | return; |
3807 | @@ -10665,19 +10670,21 @@ |
3808 | case FunctionConsts::FN_STATIC_BASE_URI_0: |
3809 | { |
3810 | if (numArgs != 0) |
3811 | + { |
3812 | RAISE_ERROR(err::XPST0017, loc, |
3813 | ERROR_PARAMS("fn:static-base-uri", |
3814 | ZED(FunctionUndeclared_3), |
3815 | numArgs)); |
3816 | + } |
3817 | |
3818 | zstring baseuri = theSctx->get_base_uri(); |
3819 | if (baseuri.empty()) |
3820 | push_nodestack(create_empty_seq(loc)); |
3821 | else |
3822 | - push_nodestack(theExprManager->create_cast_expr(theRootSctx, theUDF, |
3823 | - loc, |
3824 | - theExprManager->create_const_expr(theRootSctx, theUDF, loc, baseuri), |
3825 | - theRTM.ANY_URI_TYPE_ONE)); |
3826 | + push_nodestack(CREATE(cast)(theRootSctx, theUDF, |
3827 | + loc, |
3828 | + CREATE(const)(theRootSctx, theUDF, loc, baseuri), |
3829 | + theRTM.ANY_URI_TYPE_ONE)); |
3830 | return; |
3831 | } |
3832 | case FunctionConsts::FN_ID_1: |
3833 | @@ -10890,7 +10897,7 @@ |
3834 | resultExpr = wrap_in_type_match(foExpr, |
3835 | resultType, |
3836 | loc, |
3837 | - TreatIterator::FUNC_RETURN, |
3838 | + TREAT_FUNC_RETURN, |
3839 | f->getName()); |
3840 | } |
3841 | |
3842 | @@ -11024,7 +11031,7 @@ |
3843 | // wrap function's QName |
3844 | expr* qnameExpr = wrap_in_type_promotion(arguments[0], |
3845 | theRTM.QNAME_TYPE_ONE, |
3846 | - PromoteIterator::TYPE_PROMOTION); |
3847 | + PROMOTE_TYPE_PROMOTION); |
3848 | |
3849 | for (csize i = 0; i < numArgs ; ++i) |
3850 | { |
3851 | @@ -11487,11 +11494,11 @@ |
3852 | // Wrap the body in appropriate type op. |
3853 | if (TypeOps::is_builtin_simple(CTX_TM, *returnType)) |
3854 | { |
3855 | - body = wrap_in_type_promotion(body, returnType, PromoteIterator::TYPE_PROMOTION); |
3856 | + body = wrap_in_type_promotion(body, returnType, PROMOTE_TYPE_PROMOTION); |
3857 | } |
3858 | else |
3859 | { |
3860 | - body = wrap_in_type_match(body, returnType, loc, TreatIterator::TYPE_MATCH); |
3861 | + body = wrap_in_type_match(body, returnType, loc, TREAT_TYPE_MATCH); |
3862 | } |
3863 | |
3864 | // Make the body be the return expr of the flwor that binds the function params. |
3865 | @@ -11608,19 +11615,21 @@ |
3866 | { |
3867 | contentExpr = pop_nodestack(); |
3868 | |
3869 | - contentExpr = theExprManager-> |
3870 | - create_treat_expr(theRootSctx, |
3871 | - theUDF, |
3872 | - contentExpr->get_loc(), |
3873 | - contentExpr, |
3874 | - GENV_TYPESYSTEM.JSON_OBJECT_TYPE_STAR, |
3875 | - TreatIterator::TYPE_MATCH, |
3876 | - true, |
3877 | - NULL); |
3878 | + contentExpr = CREATE(treat)(theRootSctx, |
3879 | + theUDF, |
3880 | + contentExpr->get_loc(), |
3881 | + contentExpr, |
3882 | + GENV_TYPESYSTEM.JSON_OBJECT_TYPE_STAR, |
3883 | + TREAT_TYPE_MATCH, |
3884 | + true, |
3885 | + NULL); |
3886 | } |
3887 | |
3888 | - expr* jo = theExprManager-> |
3889 | - create_json_object_expr(theRootSctx, theUDF, loc, contentExpr, v.get_accumulate()); |
3890 | + expr* jo = CREATE(json_object)(theRootSctx, |
3891 | + theUDF, |
3892 | + loc, |
3893 | + contentExpr, |
3894 | + v.get_accumulate()); |
3895 | |
3896 | push_nodestack(jo); |
3897 | #endif |
3898 | @@ -12114,11 +12123,9 @@ |
3899 | { |
3900 | if (!v.isStripped()) |
3901 | { |
3902 | - expr* content = theExprManager->create_const_expr(theRootSctx, theUDF, loc, v.get_elem_content().str()); |
3903 | + expr* content = CREATE(const)(theRootSctx, theUDF, loc, v.get_elem_content().str()); |
3904 | |
3905 | - push_nodestack(theExprManager->create_text_expr(theRootSctx, theUDF, loc, |
3906 | - text_expr::text_constructor, |
3907 | - content)); |
3908 | + push_nodestack(CREATE(text)(theRootSctx, theUDF, loc, text_constructor, content)); |
3909 | } |
3910 | } |
3911 | } |
3912 | @@ -12146,6 +12153,7 @@ |
3913 | void check_boundary_whitespace(const DirElemContent& v) |
3914 | { |
3915 | v.setIsStripped(false); |
3916 | + |
3917 | if (theSctx->boundary_space_mode() == StaticContextConsts::strip_space) |
3918 | { |
3919 | bool lPrevIsBoundary = translator_ns::pop_stack (theIsWSBoundaryStack); |
3920 | @@ -12220,8 +12228,8 @@ |
3921 | // Skip empty CDATA sections |
3922 | if(!lCDATA_content.empty()) |
3923 | { |
3924 | - expr* content = theExprManager->create_const_expr(theRootSctx, theUDF, loc, lCDATA_content); |
3925 | - push_nodestack(theExprManager->create_text_expr(theRootSctx, theUDF, loc, text_expr::text_constructor, content)); |
3926 | + expr* content = CREATE(const)(theRootSctx, theUDF, loc, lCDATA_content); |
3927 | + push_nodestack(CREATE(text)(theRootSctx, theUDF, loc, text_constructor, content)); |
3928 | } |
3929 | } |
3930 | |
3931 | @@ -12397,7 +12405,7 @@ |
3932 | // we always create a text node here because if we are in an attribute, we atomice |
3933 | // the text node into its string value |
3934 | zstring content("}"); |
3935 | - expr* lConstExpr = theExprManager->create_const_expr(theRootSctx, theUDF, loc, content); |
3936 | + expr* lConstExpr = CREATE(const)(theRootSctx, theUDF, loc, content); |
3937 | push_nodestack ( lConstExpr ); |
3938 | break; |
3939 | } |
3940 | @@ -12420,10 +12428,13 @@ |
3941 | TRACE_VISIT_OUT(); |
3942 | |
3943 | zstring str = v.get_comment().str(); |
3944 | - expr* content = theExprManager->create_const_expr (theRootSctx, theUDF, loc, str); |
3945 | - push_nodestack (theExprManager->create_text_expr(theRootSctx, theUDF, loc, |
3946 | - text_expr::comment_constructor, |
3947 | - content)); |
3948 | + expr* content = CREATE(const)(theRootSctx, theUDF, loc, str); |
3949 | + |
3950 | + push_nodestack (CREATE(text)(theRootSctx, |
3951 | + theUDF, |
3952 | + loc, |
3953 | + comment_constructor, |
3954 | + content)); |
3955 | } |
3956 | |
3957 | |
3958 | @@ -12589,8 +12600,8 @@ |
3959 | fo_expr* enclosedExpr = wrap_in_enclosed_expr(inputExpr, loc); |
3960 | |
3961 | expr* textExpr = theExprManager->create_text_expr(theRootSctx, theUDF, loc, |
3962 | - text_expr::comment_constructor, |
3963 | - enclosedExpr); |
3964 | + comment_constructor, |
3965 | + enclosedExpr); |
3966 | |
3967 | push_nodestack(textExpr); |
3968 | } |
3969 | @@ -12653,7 +12664,7 @@ |
3970 | |
3971 | expr* textExpr = theExprManager->create_text_expr(theRootSctx, theUDF, |
3972 | loc, |
3973 | - text_expr::text_constructor, |
3974 | + text_constructor, |
3975 | enclosedExpr); |
3976 | |
3977 | push_nodestack(textExpr); |
3978 | @@ -13454,29 +13465,24 @@ |
3979 | targetExpr = wrap_in_type_match(targetExpr, |
3980 | rtm.JSON_OBJECT_TYPE_ONE, |
3981 | loc, |
3982 | - TreatIterator::JSONIQ_OBJECT_UPDATE_TARGET, // JNUP0008 |
3983 | + TREAT_JSONIQ_OBJECT_UPDATE_TARGET, // JNUP0008 |
3984 | NULL); |
3985 | |
3986 | contentExpr = wrap_in_type_match(contentExpr, |
3987 | rtm.JSON_OBJECT_TYPE_STAR, |
3988 | loc, |
3989 | - TreatIterator::JSONIQ_OBJECT_UPDATE_CONTENT, // JNUP0019 |
3990 | + TREAT_JSONIQ_OBJECT_UPDATE_CONTENT, // JNUP0019 |
3991 | NULL); |
3992 | |
3993 | std::vector<expr*> args(2); |
3994 | args[0] = targetExpr; |
3995 | - args[1] = theExprManager->create_json_object_expr( |
3996 | - theRootSctx, |
3997 | - theUDF, |
3998 | - loc, |
3999 | - contentExpr, |
4000 | - false); |
4001 | + args[1] = CREATE(json_object)(theRootSctx, theUDF, loc, contentExpr, false); |
4002 | |
4003 | - expr* updExpr = theExprManager-> |
4004 | - create_fo_expr(theRootSctx, theUDF, |
4005 | - loc, |
4006 | - BUILTIN_FUNC(OP_ZORBA_JSON_OBJECT_INSERT_2), |
4007 | - args); |
4008 | + expr* updExpr = CREATE(fo)(theRootSctx, |
4009 | + theUDF, |
4010 | + loc, |
4011 | + BUILTIN_FUNC(OP_ZORBA_JSON_OBJECT_INSERT_2), |
4012 | + args); |
4013 | |
4014 | push_nodestack(updExpr); |
4015 | #endif |
4016 | @@ -13510,12 +13516,12 @@ |
4017 | |
4018 | posExpr = wrap_in_type_promotion(posExpr, |
4019 | rtm.INTEGER_TYPE_ONE, |
4020 | - PromoteIterator::JSONIQ_ARRAY_SELECTOR); // JNUP0007 |
4021 | + PROMOTE_JSONIQ_ARRAY_SELECTOR); // JNUP0007 |
4022 | |
4023 | targetExpr = wrap_in_type_match(targetExpr, |
4024 | rtm.JSON_ARRAY_TYPE_ONE, |
4025 | loc, |
4026 | - TreatIterator::JSONIQ_ARRAY_UPDATE_TARGET, // JNUP0008 |
4027 | + TREAT_JSONIQ_ARRAY_UPDATE_TARGET, // JNUP0008 |
4028 | NULL); |
4029 | |
4030 | std::vector<expr*> args(3); |
4031 | @@ -13560,15 +13566,15 @@ |
4032 | targetExpr = wrap_in_type_match(targetExpr, |
4033 | theRTM.JSON_ARRAY_TYPE_ONE, |
4034 | loc, |
4035 | - TreatIterator::JSONIQ_ARRAY_UPDATE_TARGET, // JNUP0008 |
4036 | + TREAT_JSONIQ_ARRAY_UPDATE_TARGET, // JNUP0008 |
4037 | NULL); |
4038 | |
4039 | - fo_expr* updExpr = theExprManager-> |
4040 | - create_fo_expr(theRootSctx, theUDF, |
4041 | - loc, |
4042 | - BUILTIN_FUNC(OP_ZORBA_JSON_ARRAY_APPEND_2), |
4043 | - targetExpr, |
4044 | - contentExpr); |
4045 | + fo_expr* updExpr = CREATE(fo)(theRootSctx, |
4046 | + theUDF, |
4047 | + loc, |
4048 | + BUILTIN_FUNC(OP_ZORBA_JSON_ARRAY_APPEND_2), |
4049 | + targetExpr, |
4050 | + contentExpr); |
4051 | |
4052 | normalize_fo(updExpr); |
4053 | |
4054 | @@ -13610,13 +13616,13 @@ |
4055 | |
4056 | selExpr = wrap_in_type_promotion(selExpr, |
4057 | theRTM.ANY_ATOMIC_TYPE_ONE, |
4058 | - PromoteIterator::JSONIQ_SELECTOR, // JNUP0007 |
4059 | + PROMOTE_JSONIQ_SELECTOR, // JNUP0007 |
4060 | NULL); |
4061 | |
4062 | targetExpr = wrap_in_type_match(targetExpr, |
4063 | theRTM.JSON_ITEM_TYPE_ONE, |
4064 | loc, |
4065 | - TreatIterator::JSONIQ_UPDATE_TARGET, // JNUP0008 |
4066 | + TREAT_JSONIQ_UPDATE_TARGET, // JNUP0008 |
4067 | NULL); |
4068 | |
4069 | fo_expr* updExpr = theExprManager-> |
4070 | @@ -13658,12 +13664,12 @@ |
4071 | args[0] = wrap_in_type_match(targetExpr, |
4072 | theRTM.JSON_ITEM_TYPE_ONE, |
4073 | loc, |
4074 | - TreatIterator::JSONIQ_UPDATE_TARGET, // JNUP0008 |
4075 | + TREAT_JSONIQ_UPDATE_TARGET, // JNUP0008 |
4076 | NULL); |
4077 | |
4078 | args[1] = wrap_in_type_promotion(selExpr, |
4079 | theRTM.ANY_ATOMIC_TYPE_ONE, |
4080 | - PromoteIterator::JSONIQ_SELECTOR, // JNUP0007 |
4081 | + PROMOTE_JSONIQ_SELECTOR, // JNUP0007 |
4082 | NULL); |
4083 | |
4084 | args[2] = theExprManager->create_fo_expr(theRootSctx, theUDF, |
4085 | @@ -13709,22 +13715,22 @@ |
4086 | args[0] = wrap_in_type_match(targetExpr, |
4087 | theRTM.JSON_OBJECT_TYPE_ONE, |
4088 | loc, |
4089 | - TreatIterator::JSONIQ_OBJECT_UPDATE_TARGET, // JNUP0008 |
4090 | + TREAT_JSONIQ_OBJECT_UPDATE_TARGET, // JNUP0008 |
4091 | NULL); |
4092 | |
4093 | args[1] = wrap_in_type_promotion(nameExpr, |
4094 | theRTM.STRING_TYPE_ONE, |
4095 | - PromoteIterator::JSONIQ_OBJECT_SELECTOR); // JNUP0007 |
4096 | + PROMOTE_JSONIQ_OBJECT_SELECTOR); // JNUP0007 |
4097 | |
4098 | args[2] = wrap_in_type_promotion(newNameExpr, |
4099 | theRTM.STRING_TYPE_ONE, |
4100 | - PromoteIterator::JSONIQ_OBJECT_SELECTOR); // JNUP0007 |
4101 | + PROMOTE_JSONIQ_OBJECT_SELECTOR); // JNUP0007 |
4102 | |
4103 | - fo_expr* updExpr = theExprManager-> |
4104 | - create_fo_expr(theRootSctx, theUDF, |
4105 | - loc, |
4106 | - BUILTIN_FUNC(OP_ZORBA_JSON_RENAME_3), |
4107 | - args); |
4108 | + fo_expr* updExpr = CREATE(fo)(theRootSctx, |
4109 | + theUDF, |
4110 | + loc, |
4111 | + BUILTIN_FUNC(OP_ZORBA_JSON_RENAME_3), |
4112 | + args); |
4113 | |
4114 | push_nodestack(updExpr); |
4115 | #endif |
4116 | @@ -14142,7 +14148,7 @@ |
4117 | push_nodestack( wrap_in_type_match(e, |
4118 | theRTM.ANY_NODE_TYPE_STAR, |
4119 | e->get_loc(), |
4120 | - TreatIterator::TYPE_MATCH)); |
4121 | + TREAT_TYPE_MATCH)); |
4122 | #endif /* ZORBA_NO_FULL_TEXT */ |
4123 | } |
4124 | |
4125 | @@ -14319,12 +14325,12 @@ |
4126 | if ( e1 ) { |
4127 | e1 = wrap_in_type_promotion(e1, |
4128 | theRTM.INTEGER_TYPE_ONE, |
4129 | - PromoteIterator::TYPE_PROMOTION); |
4130 | + PROMOTE_TYPE_PROMOTION); |
4131 | } |
4132 | if ( e2 ) { |
4133 | e2 = wrap_in_type_promotion(e2, |
4134 | theRTM.INTEGER_TYPE_ONE, |
4135 | - PromoteIterator::TYPE_PROMOTION); |
4136 | + PROMOTE_TYPE_PROMOTION); |
4137 | } |
4138 | |
4139 | ftrange *const r = new ftrange( loc, v.get_mode(), e1, e2 ); |
4140 | @@ -14584,7 +14590,7 @@ |
4141 | expr* e( pop_nodestack() ); |
4142 | e = wrap_in_type_promotion(e, |
4143 | theRTM.DOUBLE_TYPE_ONE, |
4144 | - PromoteIterator::TYPE_PROMOTION); |
4145 | + PROMOTE_TYPE_PROMOTION); |
4146 | push_ftstack( new ftweight( loc, e ) ); |
4147 | #endif /* ZORBA_NO_FULL_TEXT */ |
4148 | } |
4149 | @@ -14620,7 +14626,7 @@ |
4150 | expr* e( pop_nodestack() ); |
4151 | e = wrap_in_type_promotion(e, |
4152 | theRTM.INTEGER_TYPE_ONE, |
4153 | - PromoteIterator::TYPE_PROMOTION); |
4154 | + PROMOTE_TYPE_PROMOTION); |
4155 | push_ftstack( new ftwindow_filter( loc, e, v.get_unit()->get_unit() ) ); |
4156 | #endif /* ZORBA_NO_FULL_TEXT */ |
4157 | } |
4158 | @@ -14637,7 +14643,7 @@ |
4159 | expr* e( pop_nodestack() ); |
4160 | e = wrap_in_type_promotion(e, |
4161 | theRTM.STRING_TYPE_STAR, |
4162 | - PromoteIterator::TYPE_PROMOTION); |
4163 | + PROMOTE_TYPE_PROMOTION); |
4164 | push_ftstack( new ftwords( loc, e, v.get_any_all_option()->get_option() ) ); |
4165 | #endif /* ZORBA_NO_FULL_TEXT */ |
4166 | } |
4167 | |
4168 | === modified file 'src/compiler/xqddf/value_index.cpp' |
4169 | --- src/compiler/xqddf/value_index.cpp 2012-10-22 15:10:23 +0000 |
4170 | +++ src/compiler/xqddf/value_index.cpp 2012-10-24 11:34:21 +0000 |
4171 | @@ -29,6 +29,7 @@ |
4172 | #include "compiler/expression/script_exprs.h" |
4173 | #include "compiler/expression/expr.h" |
4174 | #include "compiler/expression/expr_iter.h" |
4175 | +#include "compiler/expression/expr_manager.h" |
4176 | #include "compiler/codegen/plan_visitor.h" |
4177 | |
4178 | #include "runtime/base/plan_iterator.h" |
4179 | |
4180 | === modified file 'src/functions/func_booleans_impl.cpp' |
4181 | --- src/functions/func_booleans_impl.cpp 2012-10-10 13:05:50 +0000 |
4182 | +++ src/functions/func_booleans_impl.cpp 2012-10-24 11:34:21 +0000 |
4183 | @@ -47,10 +47,9 @@ |
4184 | : |
4185 | function(sig, kind) |
4186 | { |
4187 | + setFlag(FunctionConsts::IsComparison); |
4188 | } |
4189 | |
4190 | - bool isComparisonFunction() const { return true; } |
4191 | - |
4192 | virtual const char* comparison_name() const { return ""; } |
4193 | |
4194 | virtual function* toValueComp(static_context *) const { return NULL; } |
4195 | |
4196 | === modified file 'src/functions/func_collections_impl.cpp' |
4197 | --- src/functions/func_collections_impl.cpp 2012-10-16 13:08:47 +0000 |
4198 | +++ src/functions/func_collections_impl.cpp 2012-10-24 11:34:21 +0000 |
4199 | @@ -25,6 +25,9 @@ |
4200 | #include "compiler/expression/pragma.h" |
4201 | #include "compiler/api/compilercb.h" |
4202 | |
4203 | +#include "zorbamisc/ns_consts.h" |
4204 | + |
4205 | + |
4206 | namespace zorba |
4207 | { |
4208 | |
4209 | |
4210 | === modified file 'src/functions/func_sequences_impl.cpp' |
4211 | --- src/functions/func_sequences_impl.cpp 2012-10-15 13:35:59 +0000 |
4212 | +++ src/functions/func_sequences_impl.cpp 2012-10-24 11:34:21 +0000 |
4213 | @@ -32,6 +32,7 @@ |
4214 | |
4215 | #include "compiler/expression/expr.h" |
4216 | #include "compiler/expression/fo_expr.h" |
4217 | +#include "compiler/expression/var_expr.h" |
4218 | #include "compiler/expression/path_expr.h" |
4219 | |
4220 | #include "types/typeops.h" |
4221 | @@ -43,6 +44,148 @@ |
4222 | /******************************************************************************* |
4223 | |
4224 | ********************************************************************************/ |
4225 | +xqtref_t fn_unordered::getReturnType(const fo_expr* caller) const |
4226 | +{ |
4227 | + return caller->get_arg(0)->get_return_type(); |
4228 | +} |
4229 | + |
4230 | + |
4231 | +BoolAnnotationValue fn_unordered::ignoresSortedNodes(expr* fo, csize input) const |
4232 | +{ |
4233 | + return ANNOTATION_TRUE; |
4234 | +} |
4235 | + |
4236 | + |
4237 | +BoolAnnotationValue fn_unordered::ignoresDuplicateNodes(expr* fo, csize input) const |
4238 | +{ |
4239 | + return fo->getIgnoresDuplicateNodes(); |
4240 | +} |
4241 | + |
4242 | + |
4243 | +PlanIter_t fn_unordered::codegen( |
4244 | + CompilerCB* /*cb*/, |
4245 | + static_context* sctx, |
4246 | + const QueryLoc& loc, |
4247 | + std::vector<PlanIter_t>& argv, |
4248 | + expr& ) const |
4249 | +{ |
4250 | + return argv[0]; |
4251 | +} |
4252 | + |
4253 | + |
4254 | +/******************************************************************************* |
4255 | + |
4256 | +********************************************************************************/ |
4257 | +xqtref_t fn_exactly_one_noraise::getReturnType(const fo_expr* caller) const |
4258 | +{ |
4259 | + TypeManager* tm = caller->get_type_manager(); |
4260 | + |
4261 | + xqtref_t srcType = caller->get_arg(0)->get_return_type(); |
4262 | + |
4263 | + if (theRaiseError) |
4264 | + return TypeOps::prime_type(tm, *srcType); |
4265 | + else |
4266 | + return function::getReturnType(caller); |
4267 | +} |
4268 | + |
4269 | + |
4270 | +PlanIter_t fn_exactly_one_noraise::codegen( |
4271 | + CompilerCB* aCb, |
4272 | + static_context* aSctx, |
4273 | + const QueryLoc& aLoc, |
4274 | + std::vector<PlanIter_t>& aArgs, |
4275 | + expr& aAnn) const |
4276 | +{ |
4277 | + return new FnExactlyOneIterator(aSctx, |
4278 | + aLoc, |
4279 | + aArgs, |
4280 | + theRaiseError, |
4281 | + testFlag(FunctionConsts::DoDistinct)); |
4282 | +} |
4283 | + |
4284 | + |
4285 | +/******************************************************************************* |
4286 | + |
4287 | +********************************************************************************/ |
4288 | +PlanIter_t fn_union::codegen( |
4289 | + CompilerCB* /*cb*/, |
4290 | + static_context* sctx, |
4291 | + const QueryLoc& loc, |
4292 | + std::vector<PlanIter_t>& argv, |
4293 | + expr& ann) const |
4294 | +{ |
4295 | + return new FnConcatIterator(sctx, loc, argv); |
4296 | +} |
4297 | + |
4298 | + |
4299 | +/******************************************************************************* |
4300 | + |
4301 | +********************************************************************************/ |
4302 | +BoolAnnotationValue fn_intersect::ignoresSortedNodes(expr* fo, csize input) const |
4303 | +{ |
4304 | + if (input == 0) |
4305 | + return fo->getIgnoresSortedNodes(); |
4306 | + |
4307 | + return ANNOTATION_TRUE; |
4308 | +} |
4309 | + |
4310 | + |
4311 | +BoolAnnotationValue fn_intersect::ignoresDuplicateNodes(expr* fo, csize input) const |
4312 | +{ |
4313 | + if (input == 0) |
4314 | + return fo->getIgnoresDuplicateNodes(); |
4315 | + |
4316 | + return ANNOTATION_TRUE; |
4317 | +} |
4318 | + |
4319 | + |
4320 | +PlanIter_t fn_intersect::codegen( |
4321 | + CompilerCB* /*cb*/, |
4322 | + static_context* sctx, |
4323 | + const QueryLoc& loc, |
4324 | + std::vector<PlanIter_t>& argv, |
4325 | + expr& ann) const |
4326 | +{ |
4327 | + return new HashSemiJoinIterator(sctx, loc, argv); |
4328 | +} |
4329 | + |
4330 | + |
4331 | +/******************************************************************************* |
4332 | + |
4333 | +********************************************************************************/ |
4334 | +BoolAnnotationValue fn_except::ignoresSortedNodes(expr* fo, csize input) const |
4335 | +{ |
4336 | + if (input == 0) |
4337 | + return fo->getIgnoresSortedNodes(); |
4338 | + |
4339 | + return ANNOTATION_TRUE; |
4340 | +} |
4341 | + |
4342 | + |
4343 | +BoolAnnotationValue fn_except::ignoresDuplicateNodes(expr* fo, csize input) const |
4344 | +{ |
4345 | + if (input == 0) |
4346 | + return fo->getIgnoresDuplicateNodes(); |
4347 | + |
4348 | + return ANNOTATION_TRUE; |
4349 | +} |
4350 | + |
4351 | + |
4352 | +PlanIter_t fn_except::codegen( |
4353 | + CompilerCB* /*cb*/, |
4354 | + static_context* sctx, |
4355 | + const QueryLoc& loc, |
4356 | + std::vector<PlanIter_t>& argv, |
4357 | + expr& ann) const |
4358 | +{ |
4359 | + // TODO: use SortAntiJoinIterator when available (trac ticket 254) |
4360 | + return new HashSemiJoinIterator(sctx, loc, argv, true); |
4361 | +} |
4362 | + |
4363 | + |
4364 | +/******************************************************************************* |
4365 | + |
4366 | +********************************************************************************/ |
4367 | xqtref_t op_concatenate::getReturnType(const fo_expr* caller) const |
4368 | { |
4369 | TypeManager* tm = caller->get_type_manager(); |
4370 | @@ -608,32 +751,6 @@ |
4371 | /******************************************************************************* |
4372 | |
4373 | ********************************************************************************/ |
4374 | -BoolAnnotationValue fn_unordered::ignoresSortedNodes(expr* fo, csize input) const |
4375 | -{ |
4376 | - return ANNOTATION_TRUE; |
4377 | -} |
4378 | - |
4379 | - |
4380 | -BoolAnnotationValue fn_unordered::ignoresDuplicateNodes(expr* fo, csize input) const |
4381 | -{ |
4382 | - return fo->getIgnoresDuplicateNodes(); |
4383 | -} |
4384 | - |
4385 | - |
4386 | -PlanIter_t fn_unordered::codegen( |
4387 | - CompilerCB* /*cb*/, |
4388 | - static_context* sctx, |
4389 | - const QueryLoc& loc, |
4390 | - std::vector<PlanIter_t>& argv, |
4391 | - expr& ) const |
4392 | -{ |
4393 | - return argv[0]; |
4394 | -} |
4395 | - |
4396 | - |
4397 | -/******************************************************************************* |
4398 | - |
4399 | -********************************************************************************/ |
4400 | xqtref_t fn_zero_or_one::getReturnType(const fo_expr* caller) const |
4401 | { |
4402 | TypeManager* tm = caller->get_type_manager(); |
4403 | @@ -693,37 +810,6 @@ |
4404 | /******************************************************************************* |
4405 | |
4406 | ********************************************************************************/ |
4407 | -xqtref_t fn_exactly_one_noraise::getReturnType(const fo_expr* caller) const |
4408 | -{ |
4409 | - TypeManager* tm = caller->get_type_manager(); |
4410 | - |
4411 | - xqtref_t srcType = caller->get_arg(0)->get_return_type(); |
4412 | - |
4413 | - if (theRaiseError) |
4414 | - return TypeOps::prime_type(tm, *srcType); |
4415 | - else |
4416 | - return function::getReturnType(caller); |
4417 | -} |
4418 | - |
4419 | - |
4420 | -PlanIter_t fn_exactly_one_noraise::codegen( |
4421 | - CompilerCB* aCb, |
4422 | - static_context* aSctx, |
4423 | - const QueryLoc& aLoc, |
4424 | - std::vector<PlanIter_t>& aArgs, |
4425 | - expr& aAnn) const |
4426 | -{ |
4427 | - return new FnExactlyOneIterator(aSctx, |
4428 | - aLoc, |
4429 | - aArgs, |
4430 | - theRaiseError, |
4431 | - testFlag(FunctionConsts::DoDistinct)); |
4432 | -} |
4433 | - |
4434 | - |
4435 | -/******************************************************************************* |
4436 | - |
4437 | -********************************************************************************/ |
4438 | bool fn_deep_equal::mustCopyInputNodes(expr* fo, csize producer) const |
4439 | { |
4440 | return (producer < 2 && |
4441 | @@ -734,60 +820,6 @@ |
4442 | /******************************************************************************* |
4443 | |
4444 | ********************************************************************************/ |
4445 | -PlanIter_t fn_union::codegen( |
4446 | - CompilerCB* /*cb*/, |
4447 | - static_context* sctx, |
4448 | - const QueryLoc& loc, |
4449 | - std::vector<PlanIter_t>& argv, |
4450 | - expr& ann) const |
4451 | -{ |
4452 | - return new FnConcatIterator(sctx, loc, argv); |
4453 | -} |
4454 | - |
4455 | - |
4456 | -/******************************************************************************* |
4457 | - |
4458 | -********************************************************************************/ |
4459 | -PlanIter_t fn_intersect::codegen( |
4460 | - CompilerCB* /*cb*/, |
4461 | - static_context* sctx, |
4462 | - const QueryLoc& loc, |
4463 | - std::vector<PlanIter_t>& argv, |
4464 | - expr& ann) const |
4465 | -{ |
4466 | -#if 0 // we can't access PRODUCES_* from the inputs, must rethink |
4467 | - bool distinct = ann.get_annotation (Annotations::IGNORES_DUP_NODES) != TSVAnnotationValue::TRUE_VAL; |
4468 | - bool sort = ann.get_annotation (Annotations::IGNORES_SORTED_NODES) != TSVAnnotationValue::TRUE_VAL; |
4469 | - |
4470 | - std::vector<PlanIter_t> inputs; |
4471 | - for (std::vector<PlanIter_t>::iterator i = argv.begin (); |
4472 | - i != argv.end (); i++) |
4473 | - inputs.push_back (new NodeSortIterator (loc, *i, true, distinct, false)); |
4474 | - return new SortSemiJoinIterator(loc, inputs); |
4475 | -#endif |
4476 | - |
4477 | - return new HashSemiJoinIterator(sctx, loc, argv); |
4478 | -} |
4479 | - |
4480 | - |
4481 | -/******************************************************************************* |
4482 | - |
4483 | -********************************************************************************/ |
4484 | -PlanIter_t fn_except::codegen( |
4485 | - CompilerCB* /*cb*/, |
4486 | - static_context* sctx, |
4487 | - const QueryLoc& loc, |
4488 | - std::vector<PlanIter_t>& argv, |
4489 | - expr& ann) const |
4490 | -{ |
4491 | - // TODO: use SortAntiJoinIterator when available (trac ticket 254) |
4492 | - return new HashSemiJoinIterator(sctx, loc, argv, true); |
4493 | -} |
4494 | - |
4495 | - |
4496 | -/******************************************************************************* |
4497 | - |
4498 | -********************************************************************************/ |
4499 | BoolAnnotationValue fn_count::ignoresSortedNodes(expr* fo, csize input) const |
4500 | { |
4501 | return ANNOTATION_TRUE; |
4502 | |
4503 | === modified file 'src/functions/func_sequences_impl.h' |
4504 | --- src/functions/func_sequences_impl.h 2012-09-19 21:16:15 +0000 |
4505 | +++ src/functions/func_sequences_impl.h 2012-10-24 11:34:21 +0000 |
4506 | @@ -21,9 +21,8 @@ |
4507 | |
4508 | #include "functions/function_impl.h" |
4509 | |
4510 | -#include "compiler/expression/fo_expr.h" |
4511 | - |
4512 | -namespace zorba { |
4513 | +namespace zorba |
4514 | +{ |
4515 | |
4516 | void populate_context_sequences_impl(static_context* sctx); |
4517 | |
4518 | @@ -40,10 +39,7 @@ |
4519 | { |
4520 | } |
4521 | |
4522 | - xqtref_t getReturnType(const fo_expr* caller) const |
4523 | - { |
4524 | - return caller->get_arg(0)->get_return_type(); |
4525 | - } |
4526 | + xqtref_t getReturnType(const fo_expr* caller) const; |
4527 | |
4528 | bool isMap(csize input) const |
4529 | { |
4530 | @@ -206,21 +202,9 @@ |
4531 | return producer == 0; |
4532 | } |
4533 | |
4534 | - BoolAnnotationValue ignoresSortedNodes(expr* fo, csize input) const |
4535 | - { |
4536 | - if (input == 0) |
4537 | - return fo->getIgnoresSortedNodes(); |
4538 | - |
4539 | - return ANNOTATION_TRUE; |
4540 | - } |
4541 | - |
4542 | - BoolAnnotationValue ignoresDuplicateNodes(expr* fo, csize input) const |
4543 | - { |
4544 | - if (input == 0) |
4545 | - return fo->getIgnoresDuplicateNodes(); |
4546 | - |
4547 | - return ANNOTATION_TRUE; |
4548 | - } |
4549 | + BoolAnnotationValue ignoresSortedNodes(expr* fo, csize input) const; |
4550 | + |
4551 | + BoolAnnotationValue ignoresDuplicateNodes(expr* fo, csize input) const; |
4552 | |
4553 | bool propagatesInputNodes(expr* fo, csize input) const |
4554 | { |
4555 | @@ -258,21 +242,9 @@ |
4556 | return producer == 0; |
4557 | } |
4558 | |
4559 | - BoolAnnotationValue ignoresSortedNodes(expr* fo, csize input) const |
4560 | - { |
4561 | - if (input == 0) |
4562 | - return fo->getIgnoresSortedNodes(); |
4563 | - |
4564 | - return ANNOTATION_TRUE; |
4565 | - } |
4566 | - |
4567 | - BoolAnnotationValue ignoresDuplicateNodes(expr* fo, csize input) const |
4568 | - { |
4569 | - if (input == 0) |
4570 | - return fo->getIgnoresDuplicateNodes(); |
4571 | - |
4572 | - return ANNOTATION_TRUE; |
4573 | - } |
4574 | + BoolAnnotationValue ignoresSortedNodes(expr* fo, csize input) const; |
4575 | + |
4576 | + BoolAnnotationValue ignoresDuplicateNodes(expr* fo, csize input) const; |
4577 | |
4578 | bool propagatesInputNodes(expr* fo, csize input) const |
4579 | { |
4580 | |
4581 | === modified file 'src/functions/function.h' |
4582 | --- src/functions/function.h 2012-10-08 12:09:36 +0000 |
4583 | +++ src/functions/function.h 2012-10-24 11:34:21 +0000 |
4584 | @@ -145,6 +145,8 @@ |
4585 | resetFlag(FunctionConsts::isPrivate); |
4586 | } |
4587 | |
4588 | + bool isComparisonFunction() const { return testFlag(FunctionConsts::IsComparison); } |
4589 | + |
4590 | bool isDeterministic() const |
4591 | { |
4592 | // Note: For udfs, the flag is set before the udf is optimized (see call |
4593 | @@ -201,8 +203,6 @@ |
4594 | return ArithmeticConsts::UNKNOWN; |
4595 | } |
4596 | |
4597 | - virtual bool isComparisonFunction() const { return false; } |
4598 | - |
4599 | virtual bool isValueComparisonFunction() const { return false; } |
4600 | |
4601 | virtual bool isGeneralComparisonFunction() const { return false; } |
4602 | |
4603 | === modified file 'src/functions/function_consts.h' |
4604 | --- src/functions/function_consts.h 2012-10-20 21:29:37 +0000 |
4605 | +++ src/functions/function_consts.h 2012-10-24 11:34:21 +0000 |
4606 | @@ -271,7 +271,8 @@ |
4607 | mustCopyInputNodes = 128, |
4608 | AccessesDynCtx = 256, |
4609 | ConstructsNodes = 512, |
4610 | - DereferencesNodes = 1024 |
4611 | + DereferencesNodes = 1024, |
4612 | + IsComparison = 2048 |
4613 | } AnnotationFlags; |
4614 | |
4615 | }; |
4616 | |
4617 | === modified file 'src/functions/udf.h' |
4618 | --- src/functions/udf.h 2012-10-20 21:29:37 +0000 |
4619 | +++ src/functions/udf.h 2012-10-24 11:34:21 +0000 |
4620 | @@ -19,12 +19,14 @@ |
4621 | |
4622 | #include "functions/function.h" |
4623 | |
4624 | -#include "compiler/expression/expr_base.h" |
4625 | +//#include "compiler/expression/expr_base.h" |
4626 | |
4627 | |
4628 | namespace zorba |
4629 | { |
4630 | |
4631 | + class expr; |
4632 | + |
4633 | namespace store |
4634 | { |
4635 | class Index; |
4636 | |
4637 | === modified file 'src/runtime/core/sequencetypes.cpp' |
4638 | --- src/runtime/core/sequencetypes.cpp 2012-10-08 12:09:36 +0000 |
4639 | +++ src/runtime/core/sequencetypes.cpp 2012-10-24 11:34:21 +0000 |
4640 | @@ -355,7 +355,7 @@ |
4641 | const QueryLoc& loc, |
4642 | PlanIter_t& child, |
4643 | const xqtref_t& promoteType, |
4644 | - ErrorKind err, |
4645 | + PromoteErrorKind err, |
4646 | store::Item_t qname) |
4647 | : |
4648 | UnaryBaseIterator<PromoteIterator, PlanIteratorState>(sctx, loc, child), |
4649 | @@ -379,7 +379,7 @@ |
4650 | |
4651 | ar & thePromoteType; |
4652 | SERIALIZE_ENUM(TypeConstants::quantifier_t, theQuantifier); |
4653 | - SERIALIZE_ENUM(ErrorKind, theErrorKind); |
4654 | + SERIALIZE_ENUM(PromoteErrorKind, theErrorKind); |
4655 | ar & theQName; |
4656 | } |
4657 | |
4658 | @@ -463,7 +463,7 @@ |
4659 | |
4660 | switch (theErrorKind) |
4661 | { |
4662 | - case FUNC_RETURN: |
4663 | + case PROMOTE_FUNC_RETURN: |
4664 | { |
4665 | assert(theQName != NULL); |
4666 | |
4667 | @@ -472,7 +472,7 @@ |
4668 | valueType, targetType, theQName->getStringValue())); |
4669 | break; |
4670 | } |
4671 | - case FUNC_PARAM: |
4672 | + case PROMOTE_FUNC_PARAM: |
4673 | { |
4674 | assert(theQName != NULL); |
4675 | |
4676 | @@ -481,26 +481,26 @@ |
4677 | valueType, targetType, theQName->getStringValue())); |
4678 | break; |
4679 | } |
4680 | - case TYPE_PROMOTION: |
4681 | + case PROMOTE_TYPE_PROMOTION: |
4682 | { |
4683 | RAISE_ERROR(err::XPTY0004, loc, |
4684 | ERROR_PARAMS(ZED(XPTY0004_TypePromotion), valueType, targetType)); |
4685 | break; |
4686 | } |
4687 | #ifdef ZORBA_WITH_JSON |
4688 | - case JSONIQ_ARRAY_SELECTOR: |
4689 | + case PROMOTE_JSONIQ_ARRAY_SELECTOR: |
4690 | { |
4691 | RAISE_ERROR(jerr::JNUP0007, loc, |
4692 | ERROR_PARAMS(ZED(JNUP0007_Array), valueType)); |
4693 | break; |
4694 | } |
4695 | - case JSONIQ_OBJECT_SELECTOR: |
4696 | + case PROMOTE_JSONIQ_OBJECT_SELECTOR: |
4697 | { |
4698 | RAISE_ERROR(jerr::JNUP0007, loc, |
4699 | ERROR_PARAMS(ZED(JNUP0007_Object), valueType)); |
4700 | break; |
4701 | } |
4702 | - case JSONIQ_SELECTOR: |
4703 | + case PROMOTE_JSONIQ_SELECTOR: |
4704 | { |
4705 | RAISE_ERROR(jerr::JNUP0007, loc, |
4706 | ERROR_PARAMS(ZED(JNUP0007_ObjectArray), valueType)); |
4707 | @@ -528,7 +528,7 @@ |
4708 | PlanIter_t& child, |
4709 | const xqtref_t& treatType, |
4710 | bool checkPrime, |
4711 | - ErrorKind errorKind, |
4712 | + TreatErrorKind errorKind, |
4713 | store::Item_t qname) |
4714 | : |
4715 | UnaryBaseIterator<TreatIterator, PlanIteratorState>(sctx, loc, child), |
4716 | @@ -549,7 +549,7 @@ |
4717 | ar & theTreatType; |
4718 | SERIALIZE_ENUM(TypeConstants::quantifier_t, theQuantifier); |
4719 | ar & theCheckPrime; |
4720 | - SERIALIZE_ENUM(ErrorKind, theErrorKind); |
4721 | + SERIALIZE_ENUM(TreatErrorKind, theErrorKind); |
4722 | ar & theQName; |
4723 | } |
4724 | |
4725 | @@ -665,7 +665,7 @@ |
4726 | |
4727 | switch (theErrorKind) |
4728 | { |
4729 | - case FUNC_RETURN: |
4730 | + case TREAT_FUNC_RETURN: |
4731 | { |
4732 | assert(theQName != NULL); |
4733 | |
4734 | @@ -674,7 +674,7 @@ |
4735 | valueType, targetType, theQName->getStringValue())); |
4736 | break; |
4737 | } |
4738 | - case FUNC_PARAM: |
4739 | + case TREAT_FUNC_PARAM: |
4740 | { |
4741 | assert(theQName != NULL); |
4742 | |
4743 | @@ -683,7 +683,7 @@ |
4744 | valueType, targetType, theQName->getStringValue())); |
4745 | break; |
4746 | } |
4747 | - case TYPE_MATCH: |
4748 | + case TREAT_TYPE_MATCH: |
4749 | { |
4750 | RAISE_ERROR(err::XPTY0004, loc, |
4751 | ERROR_PARAMS(ZED(XPTY0004_TypeMatch), valueType, targetType)); |
4752 | @@ -694,65 +694,65 @@ |
4753 | RAISE_ERROR(err::XPDY0050, loc, ERROR_PARAMS(valueType, targetType)); |
4754 | break; |
4755 | } |
4756 | - case INDEX_DOMAIN: |
4757 | + case TREAT_INDEX_DOMAIN: |
4758 | { |
4759 | RAISE_ERROR(zerr::ZDTY0010_INDEX_DOMAIN_TYPE_ERROR, loc, |
4760 | ERROR_PARAMS(theQName->getStringValue())); |
4761 | break; |
4762 | } |
4763 | - case INDEX_KEY: |
4764 | + case TREAT_INDEX_KEY: |
4765 | { |
4766 | RAISE_ERROR(zerr::ZDTY0011_INDEX_KEY_TYPE_ERROR, loc, |
4767 | ERROR_PARAMS(valueType, targetType, theQName->getStringValue())); |
4768 | break; |
4769 | } |
4770 | - case PATH_STEP: |
4771 | + case TREAT_PATH_STEP: |
4772 | { |
4773 | RAISE_ERROR_NO_PARAMS(err::XPTY0019, loc); |
4774 | break; |
4775 | } |
4776 | - case PATH_DOT: |
4777 | + case TREAT_PATH_DOT: |
4778 | { |
4779 | RAISE_ERROR_NO_PARAMS(err::XPTY0020, loc); |
4780 | break; |
4781 | } |
4782 | - case MULTI_VALUED_GROUPING_KEY: |
4783 | + case TREAT_MULTI_VALUED_GROUPING_KEY: |
4784 | { |
4785 | RAISE_ERROR(err::XPTY0004, loc, |
4786 | ERROR_PARAMS(ZED(XPTY0004_MultiValuedGroupingKey))); |
4787 | break; |
4788 | } |
4789 | #ifdef ZORBA_WITH_JSON |
4790 | - case JSONIQ_VALUE: |
4791 | + case TREAT_JSONIQ_VALUE: |
4792 | { |
4793 | RAISE_ERROR_NO_PARAMS(jerr::JNTY0002, loc); |
4794 | break; |
4795 | } |
4796 | - case JSONIQ_UPDATE_TARGET: |
4797 | + case TREAT_JSONIQ_UPDATE_TARGET: |
4798 | { |
4799 | RAISE_ERROR(jerr::JNUP0008, loc, |
4800 | ERROR_PARAMS(ZED(JNUP0008_ObjectArray), valueType)); |
4801 | break; |
4802 | } |
4803 | - case JSONIQ_OBJECT_UPDATE_TARGET: |
4804 | + case TREAT_JSONIQ_OBJECT_UPDATE_TARGET: |
4805 | { |
4806 | RAISE_ERROR(jerr::JNUP0008, loc, |
4807 | ERROR_PARAMS(ZED(JNUP0008_Object), valueType)); |
4808 | break; |
4809 | } |
4810 | - case JSONIQ_OBJECT_UPDATE_CONTENT: |
4811 | + case TREAT_JSONIQ_OBJECT_UPDATE_CONTENT: |
4812 | { |
4813 | RAISE_ERROR(jerr::JNUP0019, loc, |
4814 | ERROR_PARAMS(ZED(JNUP0019), valueType)); |
4815 | break; |
4816 | } |
4817 | - case JSONIQ_ARRAY_UPDATE_TARGET: |
4818 | + case TREAT_JSONIQ_ARRAY_UPDATE_TARGET: |
4819 | { |
4820 | RAISE_ERROR(jerr::JNUP0008, loc, |
4821 | ERROR_PARAMS(ZED(JNUP0008_Array), valueType)); |
4822 | break; |
4823 | } |
4824 | - case JSONIQ_OBJECT_UPDATE_VALUE: |
4825 | + case TREAT_JSONIQ_OBJECT_UPDATE_VALUE: |
4826 | { |
4827 | RAISE_ERROR_NO_PARAMS(jerr::JNUP0017, loc); |
4828 | break; |
4829 | |
4830 | === modified file 'src/runtime/core/sequencetypes.h' |
4831 | --- src/runtime/core/sequencetypes.h 2012-10-08 12:09:36 +0000 |
4832 | +++ src/runtime/core/sequencetypes.h 2012-10-24 11:34:21 +0000 |
4833 | @@ -24,6 +24,8 @@ |
4834 | |
4835 | #include "types/typeconstants.h" |
4836 | |
4837 | +#include "compiler/expression/expr_consts.h" |
4838 | + |
4839 | namespace zorba |
4840 | { |
4841 | |
4842 | @@ -143,21 +145,10 @@ |
4843 | { |
4844 | friend class PrinterVisitor; |
4845 | |
4846 | -public: |
4847 | - typedef enum |
4848 | - { |
4849 | - FUNC_RETURN, |
4850 | - FUNC_PARAM, |
4851 | - TYPE_PROMOTION, |
4852 | - JSONIQ_ARRAY_SELECTOR, |
4853 | - JSONIQ_OBJECT_SELECTOR, |
4854 | - JSONIQ_SELECTOR |
4855 | - } ErrorKind; |
4856 | - |
4857 | private: |
4858 | xqtref_t thePromoteType; |
4859 | TypeConstants::quantifier_t theQuantifier; |
4860 | - ErrorKind theErrorKind; |
4861 | + PromoteErrorKind theErrorKind; |
4862 | store::Item_t theQName; |
4863 | |
4864 | public: |
4865 | @@ -173,7 +164,7 @@ |
4866 | const QueryLoc& loc, |
4867 | PlanIter_t& child, |
4868 | const xqtref_t& promoteType, |
4869 | - ErrorKind err, |
4870 | + PromoteErrorKind err, |
4871 | store::Item_t qname = NULL); |
4872 | |
4873 | ~PromoteIterator(); |
4874 | @@ -202,31 +193,11 @@ |
4875 | { |
4876 | friend class PrinterVisitor; |
4877 | |
4878 | -public: |
4879 | - typedef enum |
4880 | - { |
4881 | - FUNC_RETURN, |
4882 | - FUNC_PARAM, |
4883 | - TYPE_MATCH, |
4884 | - TREAT_EXPR, |
4885 | - INDEX_DOMAIN, |
4886 | - INDEX_KEY, |
4887 | - PATH_STEP, |
4888 | - PATH_DOT, |
4889 | - MULTI_VALUED_GROUPING_KEY, |
4890 | - JSONIQ_VALUE, |
4891 | - JSONIQ_UPDATE_TARGET, |
4892 | - JSONIQ_OBJECT_UPDATE_TARGET, |
4893 | - JSONIQ_OBJECT_UPDATE_CONTENT, |
4894 | - JSONIQ_ARRAY_UPDATE_TARGET, |
4895 | - JSONIQ_OBJECT_UPDATE_VALUE |
4896 | - } ErrorKind; |
4897 | - |
4898 | private: |
4899 | xqtref_t theTreatType; |
4900 | TypeConstants::quantifier_t theQuantifier; |
4901 | bool theCheckPrime; |
4902 | - ErrorKind theErrorKind; |
4903 | + TreatErrorKind theErrorKind; |
4904 | store::Item_t theQName; |
4905 | |
4906 | public: |
4907 | @@ -243,7 +214,7 @@ |
4908 | PlanIter_t& child, |
4909 | const xqtref_t& treatType, |
4910 | bool check_prime, |
4911 | - ErrorKind errorKind, |
4912 | + TreatErrorKind errorKind, |
4913 | store::Item_t qname); |
4914 | |
4915 | void accept(PlanIterVisitor& v) const; |
4916 | |
4917 | === modified file 'src/runtime/eval/eval.cpp' |
4918 | --- src/runtime/eval/eval.cpp 2012-10-12 09:05:54 +0000 |
4919 | +++ src/runtime/eval/eval.cpp 2012-10-24 11:34:21 +0000 |
4920 | @@ -30,6 +30,7 @@ |
4921 | #include "compiler/api/compilercb.h" |
4922 | #include "compiler/api/compiler_api.h" |
4923 | #include "compiler/expression/var_expr.h" |
4924 | +#include "compiler/expression/expr_manager.h" |
4925 | |
4926 | #include "context/dynamic_context.h" |
4927 | #include "context/static_context.h" |
4928 | |
4929 | === modified file 'src/runtime/function_item/function_item.cpp' |
4930 | --- src/runtime/function_item/function_item.cpp 2012-10-09 14:06:08 +0000 |
4931 | +++ src/runtime/function_item/function_item.cpp 2012-10-24 11:34:21 +0000 |
4932 | @@ -21,6 +21,7 @@ |
4933 | |
4934 | #include "compiler/api/compilercb.h" |
4935 | #include "compiler/expression/function_item_expr.h" |
4936 | +#include "compiler/expression/expr_manager.h" |
4937 | |
4938 | #include "functions/signature.h" |
4939 | #include "functions/udf.h" |
4940 | |
4941 | === modified file 'src/runtime/json/jsoniq_functions_impl.cpp' |
4942 | --- src/runtime/json/jsoniq_functions_impl.cpp 2012-10-16 14:30:02 +0000 |
4943 | +++ src/runtime/json/jsoniq_functions_impl.cpp 2012-10-24 11:34:21 +0000 |
4944 | @@ -40,6 +40,7 @@ |
4945 | #include "zorba/internal/diagnostic.h" |
4946 | |
4947 | #include "context/static_context.h" |
4948 | +#include "context/namespace_context.h" |
4949 | |
4950 | #include "types/casting.h" |
4951 | #include "types/typeimpl.h" |
Validation queue starting for merge proposal. zorbatest. lambda. nu:8080/ remotequeue/ markos- scratch- 2012-10- 24T12-23- 01.282Z/ log.html
Log at: http://