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