Merge lp:~zorba-coders/zorba/hof-next into lp:zorba
- hof-next
- Merge into trunk
Proposed by
Markos Zaharioudakis
Status: | Merged |
---|---|
Approved by: | Markos Zaharioudakis |
Approved revision: | 11321 |
Merged at revision: | 11319 |
Proposed branch: | lp:~zorba-coders/zorba/hof-next |
Merge into: | lp:zorba |
Diff against target: |
3322 lines (+1594/-1593) 20 files modified
src/compiler/codegen/plan_visitor.cpp (+1/-1) src/functions/CMakeLists.txt (+1/-1) src/functions/func_fn_hof_functions_impl.cpp (+230/-0) src/functions/func_fn_hof_functions_impl.h (+38/-0) src/functions/func_hof_impl.cpp (+0/-230) src/functions/func_hof_impl.h (+0/-38) src/functions/library.cpp (+3/-3) src/functions/pregenerated/func_fn_hof_functions.cpp (+111/-0) src/functions/pregenerated/func_fn_hof_functions.h (+139/-0) src/functions/pregenerated/func_function_item_iter.cpp (+0/-111) src/functions/pregenerated/func_function_item_iter.h (+0/-139) src/runtime/function_item/function_item_iter_impl.cpp (+0/-450) src/runtime/function_item/pregenerated/function_item_iter.cpp (+0/-190) src/runtime/function_item/pregenerated/function_item_iter.h (+0/-256) src/runtime/hof/fn_hof_functions_impl.cpp (+451/-0) src/runtime/hof/pregenerated/fn_hof_functions.cpp (+190/-0) src/runtime/hof/pregenerated/fn_hof_functions.h (+256/-0) src/runtime/spec/function_item/function_item_iter.xml (+0/-173) src/runtime/spec/hof/fn_hof_functions.xml (+173/-0) src/runtime/visitors/pregenerated/printer_visitor.cpp (+1/-1) |
To merge this branch: | bzr merge lp:~zorba-coders/zorba/hof-next |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Markos Zaharioudakis | Approve | ||
Review via email: mp+155642@code.launchpad.net |
Commit message
renamed function_
Description of the change
renamed function_
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 hof-next-
All tests succeeded!
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/compiler/codegen/plan_visitor.cpp' |
2 | --- src/compiler/codegen/plan_visitor.cpp 2013-03-26 23:32:03 +0000 |
3 | +++ src/compiler/codegen/plan_visitor.cpp 2013-03-27 00:48:21 +0000 |
4 | @@ -93,7 +93,7 @@ |
5 | #endif |
6 | #include "runtime/eval/eval.h" |
7 | #include "runtime/hof/function_item.h" |
8 | -#include "runtime/function_item/function_item_iter.h" |
9 | +#include "runtime/hof/fn_hof_functions.h" |
10 | #include "runtime/hof/dynamic_fncall_iterator.h" |
11 | #include "runtime/misc/materialize.h" |
12 | |
13 | |
14 | === modified file 'src/functions/CMakeLists.txt' |
15 | --- src/functions/CMakeLists.txt 2013-03-04 21:00:58 +0000 |
16 | +++ src/functions/CMakeLists.txt 2013-03-27 00:48:21 +0000 |
17 | @@ -86,7 +86,7 @@ |
18 | func_serialize_impl.cpp |
19 | func_parse_fragment_impl.cpp |
20 | func_schema_impl.cpp |
21 | - func_hof_impl.cpp |
22 | + func_fn_hof_functions_impl.cpp |
23 | ) |
24 | |
25 | IF (ZORBA_WITH_JSON) |
26 | |
27 | === added file 'src/functions/func_fn_hof_functions_impl.cpp' |
28 | --- src/functions/func_fn_hof_functions_impl.cpp 1970-01-01 00:00:00 +0000 |
29 | +++ src/functions/func_fn_hof_functions_impl.cpp 2013-03-27 00:48:21 +0000 |
30 | @@ -0,0 +1,230 @@ |
31 | +/* |
32 | + * Copyright 2006-2008 The FLWOR Foundation. |
33 | + * |
34 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
35 | + * you may not use this file except in compliance with the License. |
36 | + * You may obtain a copy of the License at |
37 | + * |
38 | + * http://www.apache.org/licenses/LICENSE-2.0 |
39 | + * |
40 | + * Unless required by applicable law or agreed to in writing, software |
41 | + * distributed under the License is distributed on an "AS IS" BASIS, |
42 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
43 | + * See the License for the specific language governing permissions and |
44 | + * limitations under the License. |
45 | + */ |
46 | +#include "stdafx.h" |
47 | + |
48 | +#include "common/shared_types.h" |
49 | +#include "types/typeops.h" |
50 | + |
51 | +#include "functions/function.h" |
52 | +#include "functions/function_impl.h" |
53 | +#include "functions/func_fn_hof_functions.h" |
54 | + |
55 | +#include "runtime/hof/fn_hof_functions.h" |
56 | + |
57 | +#include "system/globalenv.h" |
58 | + |
59 | + |
60 | +namespace zorba |
61 | +{ |
62 | + |
63 | +/******************************************************************************* |
64 | + |
65 | +********************************************************************************/ |
66 | +class fn_map_3_0 : public function |
67 | +{ |
68 | +public: |
69 | + fn_map_3_0(const signature& sig, FunctionConsts::FunctionKind kind) |
70 | + : |
71 | + function(sig, kind) |
72 | + { |
73 | + theXQueryVersion = StaticContextConsts::xquery_version_3_0; |
74 | + } |
75 | + |
76 | + bool accessesDynCtx() const { return true; } |
77 | + |
78 | + PlanIter_t codegen(CompilerCB* cb, |
79 | + static_context* sctx, |
80 | + const QueryLoc& loc, |
81 | + std::vector<PlanIter_t>& argv, |
82 | + expr& ann) const |
83 | + { |
84 | + return NULL; |
85 | + } |
86 | +}; |
87 | + |
88 | + |
89 | +/******************************************************************************* |
90 | + |
91 | +********************************************************************************/ |
92 | +class fn_filter : public function |
93 | +{ |
94 | +public: |
95 | + fn_filter(const signature& sig, FunctionConsts::FunctionKind kind) |
96 | + : |
97 | + function(sig, kind) |
98 | + { |
99 | + theXQueryVersion = StaticContextConsts::xquery_version_3_0; |
100 | + } |
101 | + |
102 | + bool accessesDynCtx() const { return true; } |
103 | + |
104 | + PlanIter_t codegen(CompilerCB* ccb, |
105 | + static_context* sctx, |
106 | + const QueryLoc& loc, |
107 | + std::vector<PlanIter_t>& argv, |
108 | + expr& ann) const |
109 | + { |
110 | + return NULL; |
111 | + } |
112 | +}; |
113 | + |
114 | + |
115 | +/******************************************************************************* |
116 | + |
117 | +********************************************************************************/ |
118 | +PlanIter_t fn_fold_left_3_0::codegen( |
119 | + CompilerCB* ccb, |
120 | + static_context* sctx, |
121 | + const QueryLoc& loc, |
122 | + std::vector<PlanIter_t>& argv, |
123 | + expr& ann) const |
124 | +{ |
125 | + return new FnFoldLeftIterator(sctx, loc, argv, false); |
126 | +} |
127 | + |
128 | + |
129 | +/******************************************************************************* |
130 | + |
131 | +********************************************************************************/ |
132 | +PlanIter_t fn_fold_right_3_0::codegen( |
133 | + CompilerCB* ccb, |
134 | + static_context* sctx, |
135 | + const QueryLoc& loc, |
136 | + std::vector<PlanIter_t>& argv, |
137 | + expr& ann) const |
138 | +{ |
139 | + return new FnFoldLeftIterator(sctx, loc, argv, true); |
140 | +} |
141 | + |
142 | + |
143 | +/******************************************************************************* |
144 | + |
145 | +********************************************************************************/ |
146 | +PlanIter_t fn_function_lookup_3_0::codegen( |
147 | + CompilerCB* ccb, |
148 | + static_context* sctx, |
149 | + const QueryLoc& loc, |
150 | + std::vector<PlanIter_t>& argv, |
151 | + expr& ann) const |
152 | +{ |
153 | + return new FunctionLookupIterator(sctx, loc, argv, ccb); |
154 | +} |
155 | + |
156 | + |
157 | +/******************************************************************************* |
158 | + |
159 | +********************************************************************************/ |
160 | +void populate_context_hof_impl(static_context* sctx) |
161 | +{ |
162 | + { |
163 | + std::vector<xqtref_t> args; |
164 | + args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE); |
165 | + |
166 | + xqtref_t hofParamType = GENV_TYPESYSTEM.create_function_type( |
167 | + args, |
168 | + GENV_TYPESYSTEM.ITEM_TYPE_STAR, |
169 | + TypeConstants::QUANT_ONE); |
170 | + |
171 | + DECL_WITH_KIND(sctx, |
172 | + fn_map_3_0, |
173 | + (createQName(static_context::W3C_FN_NS, "", "map"), |
174 | + hofParamType, |
175 | + GENV_TYPESYSTEM.ITEM_TYPE_STAR, |
176 | + GENV_TYPESYSTEM.ITEM_TYPE_STAR), |
177 | + FunctionConsts::FN_MAP_2); |
178 | + } |
179 | + |
180 | + { |
181 | + std::vector<xqtref_t> args; |
182 | + args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE); |
183 | + |
184 | + xqtref_t hofParamType = GENV_TYPESYSTEM.create_function_type( |
185 | + args, |
186 | + GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE, |
187 | + TypeConstants::QUANT_ONE); |
188 | + |
189 | + DECL_WITH_KIND(sctx, |
190 | + fn_filter, |
191 | + (createQName(static_context::W3C_FN_NS, "", "filter"), |
192 | + hofParamType, |
193 | + GENV_TYPESYSTEM.ITEM_TYPE_STAR, |
194 | + GENV_TYPESYSTEM.ITEM_TYPE_STAR), |
195 | + FunctionConsts::FN_FILTER_2); |
196 | + } |
197 | + |
198 | + { |
199 | + std::vector<xqtref_t> args; |
200 | + args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE); |
201 | + args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE); |
202 | + |
203 | + xqtref_t hofParamType = GENV_TYPESYSTEM.create_function_type( |
204 | + args, |
205 | + GENV_TYPESYSTEM.ITEM_TYPE_STAR, |
206 | + TypeConstants::QUANT_ONE); |
207 | + |
208 | + DECL_WITH_KIND(sctx, |
209 | + fn_map_pairs_3_0, |
210 | + (createQName(static_context::W3C_FN_NS, "", "map-pairs"), |
211 | + hofParamType, |
212 | + GENV_TYPESYSTEM.ITEM_TYPE_STAR, |
213 | + GENV_TYPESYSTEM.ITEM_TYPE_STAR, |
214 | + GENV_TYPESYSTEM.ITEM_TYPE_STAR), |
215 | + FunctionConsts::FN_MAP_PAIRS_3); |
216 | + } |
217 | + |
218 | + { |
219 | + std::vector<xqtref_t> args; |
220 | + xqtref_t hofParamType; |
221 | + |
222 | + args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_STAR); |
223 | + args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE); |
224 | + hofParamType = GENV_TYPESYSTEM.create_function_type( |
225 | + args, |
226 | + GENV_TYPESYSTEM.ITEM_TYPE_STAR, |
227 | + TypeConstants::QUANT_ONE); |
228 | + |
229 | + DECL_WITH_KIND(sctx, |
230 | + fn_fold_left_3_0, |
231 | + (createQName(static_context::W3C_FN_NS, "", "fold-left"), |
232 | + hofParamType, |
233 | + GENV_TYPESYSTEM.ITEM_TYPE_STAR, |
234 | + GENV_TYPESYSTEM.ITEM_TYPE_STAR, |
235 | + GENV_TYPESYSTEM.ITEM_TYPE_STAR), |
236 | + FunctionConsts::FN_FOLD_LEFT_3); |
237 | + |
238 | + args.clear(); |
239 | + args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE); |
240 | + args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_STAR); |
241 | + hofParamType = GENV_TYPESYSTEM.create_function_type( |
242 | + args, |
243 | + GENV_TYPESYSTEM.ITEM_TYPE_STAR, |
244 | + TypeConstants::QUANT_ONE); |
245 | + |
246 | + DECL_WITH_KIND(sctx, |
247 | + fn_fold_right_3_0, |
248 | + (createQName(static_context::W3C_FN_NS, "", "fold-right"), |
249 | + hofParamType, |
250 | + GENV_TYPESYSTEM.ITEM_TYPE_STAR, |
251 | + GENV_TYPESYSTEM.ITEM_TYPE_STAR, |
252 | + GENV_TYPESYSTEM.ITEM_TYPE_STAR), |
253 | + FunctionConsts::FN_FOLD_RIGHT_3); |
254 | + } |
255 | + |
256 | +} |
257 | + |
258 | +} |
259 | + |
260 | +/* vim:set et sw=2 ts=2: */ |
261 | |
262 | === added file 'src/functions/func_fn_hof_functions_impl.h' |
263 | --- src/functions/func_fn_hof_functions_impl.h 1970-01-01 00:00:00 +0000 |
264 | +++ src/functions/func_fn_hof_functions_impl.h 2013-03-27 00:48:21 +0000 |
265 | @@ -0,0 +1,38 @@ |
266 | +/* |
267 | + * Copyright 2006-2012 The FLWOR Foundation. |
268 | + * |
269 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
270 | + * you may not use this file except in compliance with the License. |
271 | + * You may obtain a copy of the License at |
272 | + * |
273 | + * http://www.apache.org/licenses/LICENSE-2.0 |
274 | + * |
275 | + * Unless required by applicable law or agreed to in writing, software |
276 | + * distributed under the License is distributed on an "AS IS" BASIS, |
277 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
278 | + * See the License for the specific language governing permissions and |
279 | + * limitations under the License. |
280 | + */ |
281 | +#pragma once |
282 | +#ifndef ZORBA_FUNCTIONS_HOF_IMPL_H |
283 | +#define ZORBA_FUNCTIONS_HOF_IMPL_H |
284 | + |
285 | + |
286 | +#include "common/shared_types.h" |
287 | +#include "functions/function.h" |
288 | +#include "functions/function_impl.h" |
289 | +#include "functions/function_consts.h" |
290 | + |
291 | + |
292 | +namespace zorba { |
293 | + |
294 | + |
295 | +void populate_context_hof_impl(static_context* sctx); |
296 | + |
297 | + |
298 | +} //namespace zorba |
299 | + |
300 | + |
301 | +#endif |
302 | +/* vim:set et sw=2 ts=2: */ |
303 | + |
304 | |
305 | === removed file 'src/functions/func_hof_impl.cpp' |
306 | --- src/functions/func_hof_impl.cpp 2013-03-13 04:02:45 +0000 |
307 | +++ src/functions/func_hof_impl.cpp 1970-01-01 00:00:00 +0000 |
308 | @@ -1,230 +0,0 @@ |
309 | -/* |
310 | - * Copyright 2006-2008 The FLWOR Foundation. |
311 | - * |
312 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
313 | - * you may not use this file except in compliance with the License. |
314 | - * You may obtain a copy of the License at |
315 | - * |
316 | - * http://www.apache.org/licenses/LICENSE-2.0 |
317 | - * |
318 | - * Unless required by applicable law or agreed to in writing, software |
319 | - * distributed under the License is distributed on an "AS IS" BASIS, |
320 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
321 | - * See the License for the specific language governing permissions and |
322 | - * limitations under the License. |
323 | - */ |
324 | -#include "stdafx.h" |
325 | - |
326 | -#include "common/shared_types.h" |
327 | -#include "types/typeops.h" |
328 | - |
329 | -#include "functions/function.h" |
330 | -#include "functions/function_impl.h" |
331 | -#include "functions/func_function_item_iter.h" |
332 | - |
333 | -#include "runtime/function_item/function_item_iter.h" |
334 | - |
335 | -#include "system/globalenv.h" |
336 | - |
337 | - |
338 | -namespace zorba |
339 | -{ |
340 | - |
341 | -/******************************************************************************* |
342 | - |
343 | -********************************************************************************/ |
344 | -class fn_map_3_0 : public function |
345 | -{ |
346 | -public: |
347 | - fn_map_3_0(const signature& sig, FunctionConsts::FunctionKind kind) |
348 | - : |
349 | - function(sig, kind) |
350 | - { |
351 | - theXQueryVersion = StaticContextConsts::xquery_version_3_0; |
352 | - } |
353 | - |
354 | - bool accessesDynCtx() const { return true; } |
355 | - |
356 | - PlanIter_t codegen(CompilerCB* cb, |
357 | - static_context* sctx, |
358 | - const QueryLoc& loc, |
359 | - std::vector<PlanIter_t>& argv, |
360 | - expr& ann) const |
361 | - { |
362 | - return NULL; |
363 | - } |
364 | -}; |
365 | - |
366 | - |
367 | -/******************************************************************************* |
368 | - |
369 | -********************************************************************************/ |
370 | -class fn_filter : public function |
371 | -{ |
372 | -public: |
373 | - fn_filter(const signature& sig, FunctionConsts::FunctionKind kind) |
374 | - : |
375 | - function(sig, kind) |
376 | - { |
377 | - theXQueryVersion = StaticContextConsts::xquery_version_3_0; |
378 | - } |
379 | - |
380 | - bool accessesDynCtx() const { return true; } |
381 | - |
382 | - PlanIter_t codegen(CompilerCB* ccb, |
383 | - static_context* sctx, |
384 | - const QueryLoc& loc, |
385 | - std::vector<PlanIter_t>& argv, |
386 | - expr& ann) const |
387 | - { |
388 | - return NULL; |
389 | - } |
390 | -}; |
391 | - |
392 | - |
393 | -/******************************************************************************* |
394 | - |
395 | -********************************************************************************/ |
396 | -PlanIter_t fn_fold_left_3_0::codegen( |
397 | - CompilerCB* ccb, |
398 | - static_context* sctx, |
399 | - const QueryLoc& loc, |
400 | - std::vector<PlanIter_t>& argv, |
401 | - expr& ann) const |
402 | -{ |
403 | - return new FnFoldLeftIterator(sctx, loc, argv, false); |
404 | -} |
405 | - |
406 | - |
407 | -/******************************************************************************* |
408 | - |
409 | -********************************************************************************/ |
410 | -PlanIter_t fn_fold_right_3_0::codegen( |
411 | - CompilerCB* ccb, |
412 | - static_context* sctx, |
413 | - const QueryLoc& loc, |
414 | - std::vector<PlanIter_t>& argv, |
415 | - expr& ann) const |
416 | -{ |
417 | - return new FnFoldLeftIterator(sctx, loc, argv, true); |
418 | -} |
419 | - |
420 | - |
421 | -/******************************************************************************* |
422 | - |
423 | -********************************************************************************/ |
424 | -PlanIter_t fn_function_lookup_3_0::codegen( |
425 | - CompilerCB* ccb, |
426 | - static_context* sctx, |
427 | - const QueryLoc& loc, |
428 | - std::vector<PlanIter_t>& argv, |
429 | - expr& ann) const |
430 | -{ |
431 | - return new FunctionLookupIterator(sctx, loc, argv, ccb); |
432 | -} |
433 | - |
434 | - |
435 | -/******************************************************************************* |
436 | - |
437 | -********************************************************************************/ |
438 | -void populate_context_hof_impl(static_context* sctx) |
439 | -{ |
440 | - { |
441 | - std::vector<xqtref_t> args; |
442 | - args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE); |
443 | - |
444 | - xqtref_t hofParamType = GENV_TYPESYSTEM.create_function_type( |
445 | - args, |
446 | - GENV_TYPESYSTEM.ITEM_TYPE_STAR, |
447 | - TypeConstants::QUANT_ONE); |
448 | - |
449 | - DECL_WITH_KIND(sctx, |
450 | - fn_map_3_0, |
451 | - (createQName(static_context::W3C_FN_NS, "", "map"), |
452 | - hofParamType, |
453 | - GENV_TYPESYSTEM.ITEM_TYPE_STAR, |
454 | - GENV_TYPESYSTEM.ITEM_TYPE_STAR), |
455 | - FunctionConsts::FN_MAP_2); |
456 | - } |
457 | - |
458 | - { |
459 | - std::vector<xqtref_t> args; |
460 | - args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE); |
461 | - |
462 | - xqtref_t hofParamType = GENV_TYPESYSTEM.create_function_type( |
463 | - args, |
464 | - GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE, |
465 | - TypeConstants::QUANT_ONE); |
466 | - |
467 | - DECL_WITH_KIND(sctx, |
468 | - fn_filter, |
469 | - (createQName(static_context::W3C_FN_NS, "", "filter"), |
470 | - hofParamType, |
471 | - GENV_TYPESYSTEM.ITEM_TYPE_STAR, |
472 | - GENV_TYPESYSTEM.ITEM_TYPE_STAR), |
473 | - FunctionConsts::FN_FILTER_2); |
474 | - } |
475 | - |
476 | - { |
477 | - std::vector<xqtref_t> args; |
478 | - args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE); |
479 | - args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE); |
480 | - |
481 | - xqtref_t hofParamType = GENV_TYPESYSTEM.create_function_type( |
482 | - args, |
483 | - GENV_TYPESYSTEM.ITEM_TYPE_STAR, |
484 | - TypeConstants::QUANT_ONE); |
485 | - |
486 | - DECL_WITH_KIND(sctx, |
487 | - fn_map_pairs_3_0, |
488 | - (createQName(static_context::W3C_FN_NS, "", "map-pairs"), |
489 | - hofParamType, |
490 | - GENV_TYPESYSTEM.ITEM_TYPE_STAR, |
491 | - GENV_TYPESYSTEM.ITEM_TYPE_STAR, |
492 | - GENV_TYPESYSTEM.ITEM_TYPE_STAR), |
493 | - FunctionConsts::FN_MAP_PAIRS_3); |
494 | - } |
495 | - |
496 | - { |
497 | - std::vector<xqtref_t> args; |
498 | - xqtref_t hofParamType; |
499 | - |
500 | - args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_STAR); |
501 | - args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE); |
502 | - hofParamType = GENV_TYPESYSTEM.create_function_type( |
503 | - args, |
504 | - GENV_TYPESYSTEM.ITEM_TYPE_STAR, |
505 | - TypeConstants::QUANT_ONE); |
506 | - |
507 | - DECL_WITH_KIND(sctx, |
508 | - fn_fold_left_3_0, |
509 | - (createQName(static_context::W3C_FN_NS, "", "fold-left"), |
510 | - hofParamType, |
511 | - GENV_TYPESYSTEM.ITEM_TYPE_STAR, |
512 | - GENV_TYPESYSTEM.ITEM_TYPE_STAR, |
513 | - GENV_TYPESYSTEM.ITEM_TYPE_STAR), |
514 | - FunctionConsts::FN_FOLD_LEFT_3); |
515 | - |
516 | - args.clear(); |
517 | - args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE); |
518 | - args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_STAR); |
519 | - hofParamType = GENV_TYPESYSTEM.create_function_type( |
520 | - args, |
521 | - GENV_TYPESYSTEM.ITEM_TYPE_STAR, |
522 | - TypeConstants::QUANT_ONE); |
523 | - |
524 | - DECL_WITH_KIND(sctx, |
525 | - fn_fold_right_3_0, |
526 | - (createQName(static_context::W3C_FN_NS, "", "fold-right"), |
527 | - hofParamType, |
528 | - GENV_TYPESYSTEM.ITEM_TYPE_STAR, |
529 | - GENV_TYPESYSTEM.ITEM_TYPE_STAR, |
530 | - GENV_TYPESYSTEM.ITEM_TYPE_STAR), |
531 | - FunctionConsts::FN_FOLD_RIGHT_3); |
532 | - } |
533 | - |
534 | -} |
535 | - |
536 | -} |
537 | - |
538 | -/* vim:set et sw=2 ts=2: */ |
539 | |
540 | === removed file 'src/functions/func_hof_impl.h' |
541 | --- src/functions/func_hof_impl.h 2012-11-26 21:22:19 +0000 |
542 | +++ src/functions/func_hof_impl.h 1970-01-01 00:00:00 +0000 |
543 | @@ -1,38 +0,0 @@ |
544 | -/* |
545 | - * Copyright 2006-2012 The FLWOR Foundation. |
546 | - * |
547 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
548 | - * you may not use this file except in compliance with the License. |
549 | - * You may obtain a copy of the License at |
550 | - * |
551 | - * http://www.apache.org/licenses/LICENSE-2.0 |
552 | - * |
553 | - * Unless required by applicable law or agreed to in writing, software |
554 | - * distributed under the License is distributed on an "AS IS" BASIS, |
555 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
556 | - * See the License for the specific language governing permissions and |
557 | - * limitations under the License. |
558 | - */ |
559 | -#pragma once |
560 | -#ifndef ZORBA_FUNCTIONS_HOF_IMPL_H |
561 | -#define ZORBA_FUNCTIONS_HOF_IMPL_H |
562 | - |
563 | - |
564 | -#include "common/shared_types.h" |
565 | -#include "functions/function.h" |
566 | -#include "functions/function_impl.h" |
567 | -#include "functions/function_consts.h" |
568 | - |
569 | - |
570 | -namespace zorba { |
571 | - |
572 | - |
573 | -void populate_context_hof_impl(static_context* sctx); |
574 | - |
575 | - |
576 | -} //namespace zorba |
577 | - |
578 | - |
579 | -#endif |
580 | -/* vim:set et sw=2 ts=2: */ |
581 | - |
582 | |
583 | === modified file 'src/functions/library.cpp' |
584 | --- src/functions/library.cpp 2013-03-04 21:00:58 +0000 |
585 | +++ src/functions/library.cpp 2013-03-27 00:48:21 +0000 |
586 | @@ -79,8 +79,8 @@ |
587 | #include "runtime/full_text/ft_module_impl.h" |
588 | #endif /* ZORBA_NO_FULL_TEXT */ |
589 | |
590 | -#include "functions/func_function_item_iter.h" |
591 | -#include "functions/func_hof_impl.h" |
592 | +#include "functions/func_fn_hof_functions.h" |
593 | +#include "functions/func_fn_hof_functions_impl.h" |
594 | |
595 | #include "zorbaserialization/archiver.h" |
596 | |
597 | @@ -152,7 +152,7 @@ |
598 | populate_context_sequences(sctx); |
599 | populate_context_sequences_impl(sctx); |
600 | populate_context_xqdoc(sctx); |
601 | - populate_context_function_item_iter(sctx); |
602 | + populate_context_fn_hof_functions(sctx); |
603 | populate_context_hof_impl(sctx); |
604 | populate_context_documents(sctx); |
605 | populate_context_maps(sctx); |
606 | |
607 | === added file 'src/functions/pregenerated/func_fn_hof_functions.cpp' |
608 | --- src/functions/pregenerated/func_fn_hof_functions.cpp 1970-01-01 00:00:00 +0000 |
609 | +++ src/functions/pregenerated/func_fn_hof_functions.cpp 2013-03-27 00:48:21 +0000 |
610 | @@ -0,0 +1,111 @@ |
611 | +/* |
612 | + * Copyright 2006-2012 The FLWOR Foundation. |
613 | + * |
614 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
615 | + * you may not use this file except in compliance with the License. |
616 | + * You may obtain a copy of the License at |
617 | + * |
618 | + * http://www.apache.org/licenses/LICENSE-2.0 |
619 | + * |
620 | + * Unless required by applicable law or agreed to in writing, software |
621 | + * distributed under the License is distributed on an "AS IS" BASIS, |
622 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
623 | + * See the License for the specific language governing permissions and |
624 | + * limitations under the License. |
625 | + */ |
626 | + |
627 | +// ****************************************** |
628 | +// * * |
629 | +// * THIS IS A GENERATED FILE. DO NOT EDIT! * |
630 | +// * SEE .xml FILE WITH SAME NAME * |
631 | +// * * |
632 | +// ****************************************** |
633 | + |
634 | + |
635 | +#include "stdafx.h" |
636 | +#include "runtime/hof/fn_hof_functions.h" |
637 | +#include "functions/func_fn_hof_functions.h" |
638 | + |
639 | + |
640 | +namespace zorba{ |
641 | + |
642 | + |
643 | + |
644 | + |
645 | +PlanIter_t fn_function_name_3_0::codegen( |
646 | + CompilerCB*, |
647 | + static_context* sctx, |
648 | + const QueryLoc& loc, |
649 | + std::vector<PlanIter_t>& argv, |
650 | + expr& ann) const |
651 | +{ |
652 | + return new FunctionNameIterator(sctx, loc, argv); |
653 | +} |
654 | + |
655 | +PlanIter_t fn_function_arity_3_0::codegen( |
656 | + CompilerCB*, |
657 | + static_context* sctx, |
658 | + const QueryLoc& loc, |
659 | + std::vector<PlanIter_t>& argv, |
660 | + expr& ann) const |
661 | +{ |
662 | + return new FunctionArityIterator(sctx, loc, argv); |
663 | +} |
664 | + |
665 | +PlanIter_t fn_map_pairs_3_0::codegen( |
666 | + CompilerCB*, |
667 | + static_context* sctx, |
668 | + const QueryLoc& loc, |
669 | + std::vector<PlanIter_t>& argv, |
670 | + expr& ann) const |
671 | +{ |
672 | + return new FnMapPairsIterator(sctx, loc, argv); |
673 | +} |
674 | + |
675 | + |
676 | + |
677 | +void populate_context_fn_hof_functions(static_context* sctx) |
678 | +{ |
679 | + |
680 | + |
681 | + { |
682 | + DECL_WITH_KIND(sctx, fn_function_lookup_3_0, |
683 | + (createQName("http://www.w3.org/2005/xpath-functions","","function-lookup"), |
684 | + GENV_TYPESYSTEM.QNAME_TYPE_ONE, |
685 | + GENV_TYPESYSTEM.INTEGER_TYPE_ONE, |
686 | + GENV_TYPESYSTEM.ANY_FUNCTION_TYPE_QUESTION), |
687 | + FunctionConsts::FN_FUNCTION_LOOKUP_2); |
688 | + |
689 | + } |
690 | + |
691 | + |
692 | + |
693 | + |
694 | + { |
695 | + DECL_WITH_KIND(sctx, fn_function_name_3_0, |
696 | + (createQName("http://www.w3.org/2005/xpath-functions","","function-name"), |
697 | + GENV_TYPESYSTEM.ANY_FUNCTION_TYPE_ONE, |
698 | + GENV_TYPESYSTEM.QNAME_TYPE_QUESTION), |
699 | + FunctionConsts::FN_FUNCTION_NAME_1); |
700 | + |
701 | + } |
702 | + |
703 | + |
704 | + |
705 | + |
706 | + { |
707 | + DECL_WITH_KIND(sctx, fn_function_arity_3_0, |
708 | + (createQName("http://www.w3.org/2005/xpath-functions","","function-arity"), |
709 | + GENV_TYPESYSTEM.ANY_FUNCTION_TYPE_ONE, |
710 | + GENV_TYPESYSTEM.INTEGER_TYPE_ONE), |
711 | + FunctionConsts::FN_FUNCTION_ARITY_1); |
712 | + |
713 | + } |
714 | + |
715 | +} |
716 | + |
717 | + |
718 | +} |
719 | + |
720 | + |
721 | + |
722 | |
723 | === added file 'src/functions/pregenerated/func_fn_hof_functions.h' |
724 | --- src/functions/pregenerated/func_fn_hof_functions.h 1970-01-01 00:00:00 +0000 |
725 | +++ src/functions/pregenerated/func_fn_hof_functions.h 2013-03-27 00:48:21 +0000 |
726 | @@ -0,0 +1,139 @@ |
727 | +/* |
728 | + * Copyright 2006-2012 The FLWOR Foundation. |
729 | + * |
730 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
731 | + * you may not use this file except in compliance with the License. |
732 | + * You may obtain a copy of the License at |
733 | + * |
734 | + * http://www.apache.org/licenses/LICENSE-2.0 |
735 | + * |
736 | + * Unless required by applicable law or agreed to in writing, software |
737 | + * distributed under the License is distributed on an "AS IS" BASIS, |
738 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
739 | + * See the License for the specific language governing permissions and |
740 | + * limitations under the License. |
741 | + */ |
742 | + |
743 | +// ****************************************** |
744 | +// * * |
745 | +// * THIS IS A GENERATED FILE. DO NOT EDIT! * |
746 | +// * SEE .xml FILE WITH SAME NAME * |
747 | +// * * |
748 | +// ****************************************** |
749 | + |
750 | + |
751 | +#ifndef ZORBA_FUNCTIONS_FN_HOF_FUNCTIONS_H |
752 | +#define ZORBA_FUNCTIONS_FN_HOF_FUNCTIONS_H |
753 | + |
754 | + |
755 | +#include "common/shared_types.h" |
756 | +#include "functions/function_impl.h" |
757 | + |
758 | + |
759 | +namespace zorba { |
760 | + |
761 | + |
762 | +void populate_context_fn_hof_functions(static_context* sctx); |
763 | + |
764 | + |
765 | + |
766 | + |
767 | +//fn:function-lookup |
768 | +class fn_function_lookup_3_0 : public function |
769 | +{ |
770 | +public: |
771 | + fn_function_lookup_3_0(const signature& sig, FunctionConsts::FunctionKind kind) |
772 | + : |
773 | + function(sig, kind) |
774 | + { |
775 | +theXQueryVersion = StaticContextConsts::xquery_version_3_0; |
776 | + } |
777 | + |
778 | + CODEGEN_DECL(); |
779 | +}; |
780 | + |
781 | + |
782 | +//fn:function-name |
783 | +class fn_function_name_3_0 : public function |
784 | +{ |
785 | +public: |
786 | + fn_function_name_3_0(const signature& sig, FunctionConsts::FunctionKind kind) |
787 | + : |
788 | + function(sig, kind) |
789 | + { |
790 | +theXQueryVersion = StaticContextConsts::xquery_version_3_0; |
791 | + } |
792 | + |
793 | + CODEGEN_DECL(); |
794 | +}; |
795 | + |
796 | + |
797 | +//fn:function-arity |
798 | +class fn_function_arity_3_0 : public function |
799 | +{ |
800 | +public: |
801 | + fn_function_arity_3_0(const signature& sig, FunctionConsts::FunctionKind kind) |
802 | + : |
803 | + function(sig, kind) |
804 | + { |
805 | +theXQueryVersion = StaticContextConsts::xquery_version_3_0; |
806 | + } |
807 | + |
808 | + CODEGEN_DECL(); |
809 | +}; |
810 | + |
811 | + |
812 | +//fn:map-pairs |
813 | +class fn_map_pairs_3_0 : public function |
814 | +{ |
815 | +public: |
816 | + fn_map_pairs_3_0(const signature& sig, FunctionConsts::FunctionKind kind) |
817 | + : |
818 | + function(sig, kind) |
819 | + { |
820 | +theXQueryVersion = StaticContextConsts::xquery_version_3_0; |
821 | + } |
822 | + |
823 | + CODEGEN_DECL(); |
824 | +}; |
825 | + |
826 | + |
827 | +//fn:fold-left |
828 | +class fn_fold_left_3_0 : public function |
829 | +{ |
830 | +public: |
831 | + fn_fold_left_3_0(const signature& sig, FunctionConsts::FunctionKind kind) |
832 | + : |
833 | + function(sig, kind) |
834 | + { |
835 | +theXQueryVersion = StaticContextConsts::xquery_version_3_0; |
836 | + } |
837 | + |
838 | + CODEGEN_DECL(); |
839 | +}; |
840 | + |
841 | + |
842 | +//fn:fold-right |
843 | +class fn_fold_right_3_0 : public function |
844 | +{ |
845 | +public: |
846 | + fn_fold_right_3_0(const signature& sig, FunctionConsts::FunctionKind kind) |
847 | + : |
848 | + function(sig, kind) |
849 | + { |
850 | +theXQueryVersion = StaticContextConsts::xquery_version_3_0; |
851 | + } |
852 | + |
853 | + CODEGEN_DECL(); |
854 | +}; |
855 | + |
856 | + |
857 | +} //namespace zorba |
858 | + |
859 | + |
860 | +#endif |
861 | +/* |
862 | + * Local variables: |
863 | + * mode: c++ |
864 | + * End: |
865 | + */ |
866 | |
867 | === removed file 'src/functions/pregenerated/func_function_item_iter.cpp' |
868 | --- src/functions/pregenerated/func_function_item_iter.cpp 2013-03-15 08:22:41 +0000 |
869 | +++ src/functions/pregenerated/func_function_item_iter.cpp 1970-01-01 00:00:00 +0000 |
870 | @@ -1,111 +0,0 @@ |
871 | -/* |
872 | - * Copyright 2006-2012 The FLWOR Foundation. |
873 | - * |
874 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
875 | - * you may not use this file except in compliance with the License. |
876 | - * You may obtain a copy of the License at |
877 | - * |
878 | - * http://www.apache.org/licenses/LICENSE-2.0 |
879 | - * |
880 | - * Unless required by applicable law or agreed to in writing, software |
881 | - * distributed under the License is distributed on an "AS IS" BASIS, |
882 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
883 | - * See the License for the specific language governing permissions and |
884 | - * limitations under the License. |
885 | - */ |
886 | - |
887 | -// ****************************************** |
888 | -// * * |
889 | -// * THIS IS A GENERATED FILE. DO NOT EDIT! * |
890 | -// * SEE .xml FILE WITH SAME NAME * |
891 | -// * * |
892 | -// ****************************************** |
893 | - |
894 | - |
895 | -#include "stdafx.h" |
896 | -#include "runtime/function_item/function_item_iter.h" |
897 | -#include "functions/func_function_item_iter.h" |
898 | - |
899 | - |
900 | -namespace zorba{ |
901 | - |
902 | - |
903 | - |
904 | - |
905 | -PlanIter_t fn_function_name_3_0::codegen( |
906 | - CompilerCB*, |
907 | - static_context* sctx, |
908 | - const QueryLoc& loc, |
909 | - std::vector<PlanIter_t>& argv, |
910 | - expr& ann) const |
911 | -{ |
912 | - return new FunctionNameIterator(sctx, loc, argv); |
913 | -} |
914 | - |
915 | -PlanIter_t fn_function_arity_3_0::codegen( |
916 | - CompilerCB*, |
917 | - static_context* sctx, |
918 | - const QueryLoc& loc, |
919 | - std::vector<PlanIter_t>& argv, |
920 | - expr& ann) const |
921 | -{ |
922 | - return new FunctionArityIterator(sctx, loc, argv); |
923 | -} |
924 | - |
925 | -PlanIter_t fn_map_pairs_3_0::codegen( |
926 | - CompilerCB*, |
927 | - static_context* sctx, |
928 | - const QueryLoc& loc, |
929 | - std::vector<PlanIter_t>& argv, |
930 | - expr& ann) const |
931 | -{ |
932 | - return new FnMapPairsIterator(sctx, loc, argv); |
933 | -} |
934 | - |
935 | - |
936 | - |
937 | -void populate_context_function_item_iter(static_context* sctx) |
938 | -{ |
939 | - |
940 | - |
941 | - { |
942 | - DECL_WITH_KIND(sctx, fn_function_lookup_3_0, |
943 | - (createQName("http://www.w3.org/2005/xpath-functions","","function-lookup"), |
944 | - GENV_TYPESYSTEM.QNAME_TYPE_ONE, |
945 | - GENV_TYPESYSTEM.INTEGER_TYPE_ONE, |
946 | - GENV_TYPESYSTEM.ANY_FUNCTION_TYPE_QUESTION), |
947 | - FunctionConsts::FN_FUNCTION_LOOKUP_2); |
948 | - |
949 | - } |
950 | - |
951 | - |
952 | - |
953 | - |
954 | - { |
955 | - DECL_WITH_KIND(sctx, fn_function_name_3_0, |
956 | - (createQName("http://www.w3.org/2005/xpath-functions","","function-name"), |
957 | - GENV_TYPESYSTEM.ANY_FUNCTION_TYPE_ONE, |
958 | - GENV_TYPESYSTEM.QNAME_TYPE_QUESTION), |
959 | - FunctionConsts::FN_FUNCTION_NAME_1); |
960 | - |
961 | - } |
962 | - |
963 | - |
964 | - |
965 | - |
966 | - { |
967 | - DECL_WITH_KIND(sctx, fn_function_arity_3_0, |
968 | - (createQName("http://www.w3.org/2005/xpath-functions","","function-arity"), |
969 | - GENV_TYPESYSTEM.ANY_FUNCTION_TYPE_ONE, |
970 | - GENV_TYPESYSTEM.INTEGER_TYPE_ONE), |
971 | - FunctionConsts::FN_FUNCTION_ARITY_1); |
972 | - |
973 | - } |
974 | - |
975 | -} |
976 | - |
977 | - |
978 | -} |
979 | - |
980 | - |
981 | - |
982 | |
983 | === removed file 'src/functions/pregenerated/func_function_item_iter.h' |
984 | --- src/functions/pregenerated/func_function_item_iter.h 2013-03-15 08:22:41 +0000 |
985 | +++ src/functions/pregenerated/func_function_item_iter.h 1970-01-01 00:00:00 +0000 |
986 | @@ -1,139 +0,0 @@ |
987 | -/* |
988 | - * Copyright 2006-2012 The FLWOR Foundation. |
989 | - * |
990 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
991 | - * you may not use this file except in compliance with the License. |
992 | - * You may obtain a copy of the License at |
993 | - * |
994 | - * http://www.apache.org/licenses/LICENSE-2.0 |
995 | - * |
996 | - * Unless required by applicable law or agreed to in writing, software |
997 | - * distributed under the License is distributed on an "AS IS" BASIS, |
998 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
999 | - * See the License for the specific language governing permissions and |
1000 | - * limitations under the License. |
1001 | - */ |
1002 | - |
1003 | -// ****************************************** |
1004 | -// * * |
1005 | -// * THIS IS A GENERATED FILE. DO NOT EDIT! * |
1006 | -// * SEE .xml FILE WITH SAME NAME * |
1007 | -// * * |
1008 | -// ****************************************** |
1009 | - |
1010 | - |
1011 | -#ifndef ZORBA_FUNCTIONS_FUNCTION_ITEM_ITER_H |
1012 | -#define ZORBA_FUNCTIONS_FUNCTION_ITEM_ITER_H |
1013 | - |
1014 | - |
1015 | -#include "common/shared_types.h" |
1016 | -#include "functions/function_impl.h" |
1017 | - |
1018 | - |
1019 | -namespace zorba { |
1020 | - |
1021 | - |
1022 | -void populate_context_function_item_iter(static_context* sctx); |
1023 | - |
1024 | - |
1025 | - |
1026 | - |
1027 | -//fn:function-lookup |
1028 | -class fn_function_lookup_3_0 : public function |
1029 | -{ |
1030 | -public: |
1031 | - fn_function_lookup_3_0(const signature& sig, FunctionConsts::FunctionKind kind) |
1032 | - : |
1033 | - function(sig, kind) |
1034 | - { |
1035 | -theXQueryVersion = StaticContextConsts::xquery_version_3_0; |
1036 | - } |
1037 | - |
1038 | - CODEGEN_DECL(); |
1039 | -}; |
1040 | - |
1041 | - |
1042 | -//fn:function-name |
1043 | -class fn_function_name_3_0 : public function |
1044 | -{ |
1045 | -public: |
1046 | - fn_function_name_3_0(const signature& sig, FunctionConsts::FunctionKind kind) |
1047 | - : |
1048 | - function(sig, kind) |
1049 | - { |
1050 | -theXQueryVersion = StaticContextConsts::xquery_version_3_0; |
1051 | - } |
1052 | - |
1053 | - CODEGEN_DECL(); |
1054 | -}; |
1055 | - |
1056 | - |
1057 | -//fn:function-arity |
1058 | -class fn_function_arity_3_0 : public function |
1059 | -{ |
1060 | -public: |
1061 | - fn_function_arity_3_0(const signature& sig, FunctionConsts::FunctionKind kind) |
1062 | - : |
1063 | - function(sig, kind) |
1064 | - { |
1065 | -theXQueryVersion = StaticContextConsts::xquery_version_3_0; |
1066 | - } |
1067 | - |
1068 | - CODEGEN_DECL(); |
1069 | -}; |
1070 | - |
1071 | - |
1072 | -//fn:map-pairs |
1073 | -class fn_map_pairs_3_0 : public function |
1074 | -{ |
1075 | -public: |
1076 | - fn_map_pairs_3_0(const signature& sig, FunctionConsts::FunctionKind kind) |
1077 | - : |
1078 | - function(sig, kind) |
1079 | - { |
1080 | -theXQueryVersion = StaticContextConsts::xquery_version_3_0; |
1081 | - } |
1082 | - |
1083 | - CODEGEN_DECL(); |
1084 | -}; |
1085 | - |
1086 | - |
1087 | -//fn:fold-left |
1088 | -class fn_fold_left_3_0 : public function |
1089 | -{ |
1090 | -public: |
1091 | - fn_fold_left_3_0(const signature& sig, FunctionConsts::FunctionKind kind) |
1092 | - : |
1093 | - function(sig, kind) |
1094 | - { |
1095 | -theXQueryVersion = StaticContextConsts::xquery_version_3_0; |
1096 | - } |
1097 | - |
1098 | - CODEGEN_DECL(); |
1099 | -}; |
1100 | - |
1101 | - |
1102 | -//fn:fold-right |
1103 | -class fn_fold_right_3_0 : public function |
1104 | -{ |
1105 | -public: |
1106 | - fn_fold_right_3_0(const signature& sig, FunctionConsts::FunctionKind kind) |
1107 | - : |
1108 | - function(sig, kind) |
1109 | - { |
1110 | -theXQueryVersion = StaticContextConsts::xquery_version_3_0; |
1111 | - } |
1112 | - |
1113 | - CODEGEN_DECL(); |
1114 | -}; |
1115 | - |
1116 | - |
1117 | -} //namespace zorba |
1118 | - |
1119 | - |
1120 | -#endif |
1121 | -/* |
1122 | - * Local variables: |
1123 | - * mode: c++ |
1124 | - * End: |
1125 | - */ |
1126 | |
1127 | === removed directory 'src/runtime/function_item' |
1128 | === removed file 'src/runtime/function_item/function_item_iter_impl.cpp' |
1129 | --- src/runtime/function_item/function_item_iter_impl.cpp 2013-03-26 23:32:03 +0000 |
1130 | +++ src/runtime/function_item/function_item_iter_impl.cpp 1970-01-01 00:00:00 +0000 |
1131 | @@ -1,450 +0,0 @@ |
1132 | -/* |
1133 | - * Copyright 2006-2008 The FLWOR Foundation. |
1134 | - * |
1135 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
1136 | - * you may not use this file except in compliance with the License. |
1137 | - * You may obtain a copy of the License at |
1138 | - * |
1139 | - * http://www.apache.org/licenses/LICENSE-2.0 |
1140 | - * |
1141 | - * Unless required by applicable law or agreed to in writing, software |
1142 | - * distributed under the License is distributed on an "AS IS" BASIS, |
1143 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
1144 | - * See the License for the specific language governing permissions and |
1145 | - * limitations under the License. |
1146 | - */ |
1147 | - |
1148 | -#include "stdafx.h" |
1149 | - |
1150 | -#include "compiler/expression/function_item_expr.h" |
1151 | -#include "compiler/api/compilercb.h" |
1152 | -#include "compiler/translator/translator.h" |
1153 | - |
1154 | -#include "functions/udf.h" |
1155 | - |
1156 | -#include "runtime/function_item/function_item_iter.h" |
1157 | -#include "runtime/api/plan_iterator_wrapper.h" |
1158 | -#include "runtime/util/iterator_impl.h" |
1159 | -#include "runtime/hof/function_item.h" |
1160 | -#include "runtime/core/fncall_iterator.h" |
1161 | - |
1162 | -#include "context/dynamic_context.h" |
1163 | -#include "context/static_context.h" |
1164 | - |
1165 | -#include "types/typeops.h" |
1166 | - |
1167 | -#include "store/api/item_factory.h" |
1168 | -#include "store/api/store.h" |
1169 | -#include "store/api/temp_seq.h" |
1170 | - |
1171 | -#include "diagnostics/util_macros.h" |
1172 | - |
1173 | -#include "system/globalenv.h" |
1174 | - |
1175 | -#include "zorbamisc/ns_consts.h" |
1176 | - |
1177 | - |
1178 | -using namespace std; |
1179 | - |
1180 | -namespace zorba { |
1181 | - |
1182 | - |
1183 | -/******************************************************************************* |
1184 | - |
1185 | -********************************************************************************/ |
1186 | -bool FunctionLookupIterator::nextImpl( |
1187 | - store::Item_t& result, |
1188 | - PlanState& planState) const |
1189 | -{ |
1190 | - store::Item_t qname; |
1191 | - store::Item_t arityItem; |
1192 | - uint32_t arity; |
1193 | - result = NULL; |
1194 | - |
1195 | - PlanIteratorState* state; |
1196 | - DEFAULT_STACK_INIT(PlanIteratorState, state, planState); |
1197 | - |
1198 | - consumeNext(qname, theChildren[0], planState); |
1199 | - consumeNext(arityItem, theChildren[1], planState); |
1200 | - |
1201 | - try |
1202 | - { |
1203 | - arity = to_xs_unsignedInt(arityItem->getIntegerValue()); |
1204 | - } |
1205 | - catch ( std::range_error const& ) |
1206 | - { |
1207 | - RAISE_ERROR(err::XPST0017, loc, |
1208 | - ERROR_PARAMS(arityItem->getIntegerValue(), ZED(NoParseFnArity))); |
1209 | - } |
1210 | - |
1211 | - try |
1212 | - { |
1213 | - expr* fiExpr = Translator::translate_literal_function(qname, arity, theCompilerCB, loc, true); |
1214 | - |
1215 | - FunctionItemInfo_t dynFnInfo = static_cast<function_item_expr*>(fiExpr)->get_dynamic_fn_info(); |
1216 | - dynFnInfo->theCCB = theCompilerCB; |
1217 | - // dynFnInfo->theClosureSctx = NULL; |
1218 | - |
1219 | - result = new FunctionItem(dynFnInfo, NULL /* new dynamic_context(planState.theGlobalDynCtx) */); |
1220 | - } |
1221 | - catch (ZorbaException const& e) |
1222 | - { |
1223 | - if (e.diagnostic() != err::XPST0017) |
1224 | - throw; |
1225 | - } |
1226 | - |
1227 | - if (result.getp() != NULL) |
1228 | - STACK_PUSH(true, state); |
1229 | - |
1230 | - STACK_END(state); |
1231 | -} |
1232 | - |
1233 | - |
1234 | -/******************************************************************************* |
1235 | - |
1236 | -********************************************************************************/ |
1237 | -bool FunctionNameIterator::nextImpl( |
1238 | - store::Item_t& r, |
1239 | - PlanState& planState) const |
1240 | -{ |
1241 | - store::Item_t lFItem; |
1242 | - FunctionItem* lFunctionItem = 0; |
1243 | - |
1244 | - PlanIteratorState* state; |
1245 | - DEFAULT_STACK_INIT(PlanIteratorState, state, planState); |
1246 | - |
1247 | - consumeNext(lFItem, theChildren[0], planState); |
1248 | - |
1249 | - // function signature guarantees that |
1250 | - ZORBA_ASSERT(lFItem->isFunction()); |
1251 | - |
1252 | - lFunctionItem = static_cast<FunctionItem*>(lFItem.getp()); |
1253 | - |
1254 | - if ((!lFunctionItem->isInline() || lFunctionItem->isCoercion()) |
1255 | - && |
1256 | - lFunctionItem->getFunctionName() |
1257 | - && |
1258 | - (lFunctionItem->getArity() == lFunctionItem->getStartArity())) |
1259 | - { |
1260 | - // non-inline function |
1261 | - r = lFunctionItem->getFunctionName(); |
1262 | - STACK_PUSH(true, state); |
1263 | - } |
1264 | - |
1265 | - STACK_END(state); |
1266 | -} |
1267 | - |
1268 | - |
1269 | -/******************************************************************************* |
1270 | - |
1271 | -********************************************************************************/ |
1272 | -bool FunctionArityIterator::nextImpl( |
1273 | - store::Item_t& r, |
1274 | - PlanState& planState) const |
1275 | -{ |
1276 | - store::Item_t lFItem; |
1277 | - FunctionItem* lFunctionItem = 0; |
1278 | - xs_integer lInt; |
1279 | - |
1280 | - PlanIteratorState* state; |
1281 | - DEFAULT_STACK_INIT(PlanIteratorState, state, planState); |
1282 | - |
1283 | - consumeNext(lFItem, theChildren[0], planState); |
1284 | - |
1285 | - // function signature guarantees that |
1286 | - ZORBA_ASSERT(lFItem->isFunction()); |
1287 | - |
1288 | - lFunctionItem = static_cast<FunctionItem*>(lFItem.getp()); |
1289 | - |
1290 | - lInt = Integer(lFunctionItem->getArity()); |
1291 | - |
1292 | - STACK_PUSH(GENV_ITEMFACTORY->createInteger(r, lInt), state); |
1293 | - |
1294 | - STACK_END(state); |
1295 | -} |
1296 | - |
1297 | - |
1298 | -/******************************************************************************* |
1299 | - |
1300 | -********************************************************************************/ |
1301 | -FnMapPairsIteratorState::~FnMapPairsIteratorState() |
1302 | -{ |
1303 | - if (theIsOpen) |
1304 | - { |
1305 | - thePlan->close(*thePlanState); |
1306 | - } |
1307 | -} |
1308 | - |
1309 | - |
1310 | -void FnMapPairsIteratorState::init(PlanState& planState) |
1311 | -{ |
1312 | - PlanIteratorState::init(planState); |
1313 | - thePlanState = &planState; |
1314 | - thePlan = NULL; |
1315 | - theIsOpen = false; |
1316 | -} |
1317 | - |
1318 | - |
1319 | -void FnMapPairsIteratorState::reset(PlanState& planState) |
1320 | -{ |
1321 | - PlanIteratorState::reset(planState); |
1322 | - if (theIsOpen) |
1323 | - { |
1324 | - thePlan->reset(planState); |
1325 | - } |
1326 | -} |
1327 | - |
1328 | - |
1329 | -uint32_t FnMapPairsIterator::getStateSizeOfSubtree() const |
1330 | -{ |
1331 | - uint32_t size = NaryBaseIterator<FnMapPairsIterator, FnMapPairsIteratorState>:: |
1332 | - getStateSizeOfSubtree(); |
1333 | - |
1334 | - return size + sizeof(UDFunctionCallIteratorState); |
1335 | -} |
1336 | - |
1337 | - |
1338 | -void FnMapPairsIterator::openImpl(PlanState& planState, uint32_t& offset) |
1339 | -{ |
1340 | - StateTraitsImpl<FnMapPairsIteratorState>::createState(planState, |
1341 | - theStateOffset, |
1342 | - offset); |
1343 | - |
1344 | - StateTraitsImpl<FnMapPairsIteratorState>::initState(planState, theStateOffset); |
1345 | - |
1346 | - FnMapPairsIteratorState* state = |
1347 | - StateTraitsImpl<FnMapPairsIteratorState>::getState(planState, theStateOffset); |
1348 | - |
1349 | - state->theUDFStateOffset = offset; |
1350 | - |
1351 | - offset += sizeof(UDFunctionCallIteratorState); |
1352 | - |
1353 | - std::vector<PlanIter_t>::iterator lIter = theChildren.begin(); |
1354 | - std::vector<PlanIter_t>::iterator lEnd = theChildren.end(); |
1355 | - for ( ; lIter != lEnd; ++lIter ) |
1356 | - { |
1357 | - (*lIter)->open(planState, offset); |
1358 | - } |
1359 | -} |
1360 | - |
1361 | - |
1362 | -bool FnMapPairsIterator::nextImpl( |
1363 | - store::Item_t& result, |
1364 | - PlanState& planState) const |
1365 | -{ |
1366 | - store::Item_t child1, child2; |
1367 | - std::vector<PlanIter_t> arguments; |
1368 | - |
1369 | - FnMapPairsIteratorState* state; |
1370 | - DEFAULT_STACK_INIT(FnMapPairsIteratorState, state, planState); |
1371 | - |
1372 | - consumeNext(state->theFnItem, theChildren[0], planState); |
1373 | - |
1374 | - // function signature guarantees that |
1375 | - ZORBA_ASSERT(state->theFnItem->isFunction()); |
1376 | - |
1377 | - while (true) |
1378 | - { |
1379 | - if (!consumeNext(child1, theChildren[1], planState) || |
1380 | - !consumeNext(child2, theChildren[2], planState)) |
1381 | - break; |
1382 | - |
1383 | - if (child1.getp() && child2.getp()) |
1384 | - { |
1385 | - { |
1386 | - store::TempSeq_t seq1, seq2; |
1387 | - seq1 = GENV_STORE.createTempSeq(child1); |
1388 | - seq2 = GENV_STORE.createTempSeq(child2); |
1389 | - store::Iterator_t seqIter1 = seq1->getIterator(); |
1390 | - store::Iterator_t seqIter2 = seq2->getIterator(); |
1391 | - seqIter1->open(); |
1392 | - seqIter2->open(); |
1393 | - |
1394 | - arguments.push_back(NULL); // the first argument is expected to be the function item and it is not used |
1395 | - arguments.push_back(new PlanStateIteratorWrapper(seqIter1)); |
1396 | - arguments.push_back(new PlanStateIteratorWrapper(seqIter2)); |
1397 | - } |
1398 | - |
1399 | - state->thePlan = static_cast<FunctionItem*>(state->theFnItem.getp())->getImplementation(arguments, planState.theCompilerCB); |
1400 | - // must be opened after vars and params are set |
1401 | - state->thePlan->open(planState, state->theUDFStateOffset); |
1402 | - state->theIsOpen = true; |
1403 | - |
1404 | - while (consumeNext(result, state->thePlan, planState)) |
1405 | - { |
1406 | - STACK_PUSH(true, state); |
1407 | - } |
1408 | - |
1409 | - // need to close here early in case the plan is completely |
1410 | - // consumed. Otherwise, the plan would still be opened |
1411 | - // if destroyed from the state's destructor. |
1412 | - state->thePlan->close(planState); |
1413 | - state->theIsOpen = false; |
1414 | - } |
1415 | - else |
1416 | - { |
1417 | - result = NULL; |
1418 | - STACK_PUSH(true, state); |
1419 | - } |
1420 | - } |
1421 | - |
1422 | - STACK_END(state); |
1423 | -} |
1424 | - |
1425 | - |
1426 | -/******************************************************************************* |
1427 | - |
1428 | -********************************************************************************/ |
1429 | -FnFoldLeftIteratorState::~FnFoldLeftIteratorState() |
1430 | -{ |
1431 | - if (theIsOpen) |
1432 | - { |
1433 | - thePlan->close(*thePlanState); |
1434 | - } |
1435 | -} |
1436 | - |
1437 | - |
1438 | -void FnFoldLeftIteratorState::init(PlanState& planState) |
1439 | -{ |
1440 | - PlanIteratorState::init(planState); |
1441 | - thePlanState = &planState; |
1442 | - thePlan = NULL; |
1443 | - theIsOpen = false; |
1444 | -} |
1445 | - |
1446 | - |
1447 | -void FnFoldLeftIteratorState::reset(PlanState& planState) |
1448 | -{ |
1449 | - PlanIteratorState::reset(planState); |
1450 | - if (theIsOpen) |
1451 | - { |
1452 | - thePlan->reset(planState); |
1453 | - } |
1454 | -} |
1455 | - |
1456 | - |
1457 | -uint32_t FnFoldLeftIterator::getStateSizeOfSubtree() const |
1458 | -{ |
1459 | - uint32_t size = NaryBaseIterator<FnFoldLeftIterator, FnFoldLeftIteratorState>:: |
1460 | - getStateSizeOfSubtree(); |
1461 | - |
1462 | - return size + sizeof(UDFunctionCallIteratorState); |
1463 | -} |
1464 | - |
1465 | - |
1466 | -void FnFoldLeftIterator::openImpl(PlanState& planState, uint32_t& offset) |
1467 | -{ |
1468 | - StateTraitsImpl<FnFoldLeftIteratorState>::createState(planState, |
1469 | - theStateOffset, |
1470 | - offset); |
1471 | - |
1472 | - StateTraitsImpl<FnFoldLeftIteratorState>::initState(planState, theStateOffset); |
1473 | - |
1474 | - FnFoldLeftIteratorState* state = |
1475 | - StateTraitsImpl<FnFoldLeftIteratorState>::getState(planState, theStateOffset); |
1476 | - |
1477 | - state->theUDFStateOffset = offset; |
1478 | - |
1479 | - offset += sizeof(UDFunctionCallIteratorState); |
1480 | - |
1481 | - std::vector<PlanIter_t>::iterator lIter = theChildren.begin(); |
1482 | - std::vector<PlanIter_t>::iterator lEnd = theChildren.end(); |
1483 | - for ( ; lIter != lEnd; ++lIter ) |
1484 | - { |
1485 | - (*lIter)->open(planState, offset); |
1486 | - } |
1487 | -} |
1488 | - |
1489 | - |
1490 | -bool FnFoldLeftIterator::nextImpl( |
1491 | - store::Item_t& result, |
1492 | - PlanState& planState) const |
1493 | -{ |
1494 | - store::Item_t curSeqItem, nextSeqItem, tempItem; |
1495 | - std::vector<store::Item_t> zero; |
1496 | - bool haveSeqItems; |
1497 | - |
1498 | - FnFoldLeftIteratorState* state; |
1499 | - DEFAULT_STACK_INIT(FnFoldLeftIteratorState, state, planState); |
1500 | - |
1501 | - consumeNext(state->theFnItem, theChildren[0], planState); |
1502 | - |
1503 | - // function signature guarantees that |
1504 | - ZORBA_ASSERT(state->theFnItem->isFunction()); |
1505 | - |
1506 | - if ((haveSeqItems = consumeNext(curSeqItem, theChildren[2], planState))) |
1507 | - haveSeqItems = consumeNext(nextSeqItem, theChildren[2], planState); |
1508 | - |
1509 | - if (curSeqItem.getp() == NULL && nextSeqItem.getp() == NULL) |
1510 | - { |
1511 | - // consume and return the "zero" argument |
1512 | - while (consumeNext(result, theChildren[1], planState)) |
1513 | - { |
1514 | - STACK_PUSH(true, state); |
1515 | - } |
1516 | - } |
1517 | - else |
1518 | - { |
1519 | - // read in the "zero" argument to be able to pass it to the hof |
1520 | - while (consumeNext(tempItem, theChildren[1], planState)) |
1521 | - { |
1522 | - zero.push_back(tempItem); |
1523 | - } |
1524 | - |
1525 | - while (true) |
1526 | - { |
1527 | - { |
1528 | - store::TempSeq_t zeroSeq = GENV_STORE.createTempSeq(zero); |
1529 | - tempItem = curSeqItem; // because createTempSeq calls .release() on the item rchandle |
1530 | - store::TempSeq_t seq = GENV_STORE.createTempSeq(tempItem); |
1531 | - store::Iterator_t seqIter1 = zeroSeq->getIterator(); |
1532 | - store::Iterator_t seqIter2 = seq->getIterator(); |
1533 | - seqIter1->open(); |
1534 | - seqIter2->open(); |
1535 | - |
1536 | - std::vector<PlanIter_t> arguments; |
1537 | - arguments.push_back(NULL); |
1538 | - arguments.push_back(new PlanStateIteratorWrapper(seqIter1)); |
1539 | - arguments.push_back(new PlanStateIteratorWrapper(seqIter2)); |
1540 | - if (theIsFoldRight) |
1541 | - std::reverse(++arguments.begin(), arguments.end()); |
1542 | - |
1543 | - state->thePlan = static_cast<FunctionItem*>(state->theFnItem.getp())->getImplementation(arguments, planState.theCompilerCB); |
1544 | - state->thePlan->open(planState, state->theUDFStateOffset); |
1545 | - state->theIsOpen = true; |
1546 | - } |
1547 | - |
1548 | - if (curSeqItem.isNull() || nextSeqItem.isNull()) |
1549 | - break; |
1550 | - |
1551 | - zero.clear(); |
1552 | - while (consumeNext(tempItem, state->thePlan, planState)) |
1553 | - { |
1554 | - zero.push_back(tempItem); |
1555 | - } |
1556 | - |
1557 | - state->thePlan->close(planState); |
1558 | - state->theIsOpen = false; |
1559 | - |
1560 | - curSeqItem = nextSeqItem; |
1561 | - nextSeqItem = NULL; |
1562 | - if (haveSeqItems) |
1563 | - haveSeqItems = consumeNext(nextSeqItem, theChildren[2], planState); |
1564 | - |
1565 | - } // while (true) |
1566 | - |
1567 | - while (consumeNext(result, state->thePlan, planState)) |
1568 | - { |
1569 | - STACK_PUSH(true, state); |
1570 | - } |
1571 | - |
1572 | - state->thePlan->close(planState); |
1573 | - state->theIsOpen = false; |
1574 | - |
1575 | - } // else |
1576 | - |
1577 | - STACK_END(state); |
1578 | -} |
1579 | - |
1580 | -} // namespace zorba |
1581 | -/* vim:set et sw=2 ts=2: */ |
1582 | |
1583 | === removed directory 'src/runtime/function_item/pregenerated' |
1584 | === removed file 'src/runtime/function_item/pregenerated/function_item_iter.cpp' |
1585 | --- src/runtime/function_item/pregenerated/function_item_iter.cpp 2013-03-15 08:22:41 +0000 |
1586 | +++ src/runtime/function_item/pregenerated/function_item_iter.cpp 1970-01-01 00:00:00 +0000 |
1587 | @@ -1,190 +0,0 @@ |
1588 | -/* |
1589 | - * Copyright 2006-2012 The FLWOR Foundation. |
1590 | - * |
1591 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
1592 | - * you may not use this file except in compliance with the License. |
1593 | - * You may obtain a copy of the License at |
1594 | - * |
1595 | - * http://www.apache.org/licenses/LICENSE-2.0 |
1596 | - * |
1597 | - * Unless required by applicable law or agreed to in writing, software |
1598 | - * distributed under the License is distributed on an "AS IS" BASIS, |
1599 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
1600 | - * See the License for the specific language governing permissions and |
1601 | - * limitations under the License. |
1602 | - */ |
1603 | - |
1604 | -// ****************************************** |
1605 | -// * * |
1606 | -// * THIS IS A GENERATED FILE. DO NOT EDIT! * |
1607 | -// * SEE .xml FILE WITH SAME NAME * |
1608 | -// * * |
1609 | -// ****************************************** |
1610 | - |
1611 | -#include "stdafx.h" |
1612 | -#include "zorbatypes/rchandle.h" |
1613 | -#include "zorbatypes/zstring.h" |
1614 | -#include "runtime/visitors/planiter_visitor.h" |
1615 | -#include "runtime/function_item/function_item_iter.h" |
1616 | -#include "system/globalenv.h" |
1617 | - |
1618 | - |
1619 | -#include "context/static_context.h" |
1620 | -#include "compiler/api/compilercb.h" |
1621 | -#include "context/dynamic_context.h" |
1622 | -#include "store/api/temp_seq.h" |
1623 | - |
1624 | -namespace zorba { |
1625 | - |
1626 | -// <FunctionLookupIterator> |
1627 | -SERIALIZABLE_CLASS_VERSIONS(FunctionLookupIterator) |
1628 | - |
1629 | -void FunctionLookupIterator::serialize(::zorba::serialization::Archiver& ar) |
1630 | -{ |
1631 | - serialize_baseclass(ar, |
1632 | - (NaryBaseIterator<FunctionLookupIterator, PlanIteratorState>*)this); |
1633 | - |
1634 | - ar & theCompilerCB; |
1635 | -} |
1636 | - |
1637 | - |
1638 | -void FunctionLookupIterator::accept(PlanIterVisitor& v) const |
1639 | -{ |
1640 | - v.beginVisit(*this); |
1641 | - |
1642 | - std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin(); |
1643 | - std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end(); |
1644 | - for ( ; lIter != lEnd; ++lIter ){ |
1645 | - (*lIter)->accept(v); |
1646 | - } |
1647 | - |
1648 | - v.endVisit(*this); |
1649 | -} |
1650 | - |
1651 | -FunctionLookupIterator::~FunctionLookupIterator() {} |
1652 | - |
1653 | -// </FunctionLookupIterator> |
1654 | - |
1655 | - |
1656 | -// <FunctionNameIterator> |
1657 | -SERIALIZABLE_CLASS_VERSIONS(FunctionNameIterator) |
1658 | - |
1659 | -void FunctionNameIterator::serialize(::zorba::serialization::Archiver& ar) |
1660 | -{ |
1661 | - serialize_baseclass(ar, |
1662 | - (NaryBaseIterator<FunctionNameIterator, PlanIteratorState>*)this); |
1663 | -} |
1664 | - |
1665 | - |
1666 | -void FunctionNameIterator::accept(PlanIterVisitor& v) const |
1667 | -{ |
1668 | - v.beginVisit(*this); |
1669 | - |
1670 | - std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin(); |
1671 | - std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end(); |
1672 | - for ( ; lIter != lEnd; ++lIter ){ |
1673 | - (*lIter)->accept(v); |
1674 | - } |
1675 | - |
1676 | - v.endVisit(*this); |
1677 | -} |
1678 | - |
1679 | -FunctionNameIterator::~FunctionNameIterator() {} |
1680 | - |
1681 | -// </FunctionNameIterator> |
1682 | - |
1683 | - |
1684 | -// <FunctionArityIterator> |
1685 | -SERIALIZABLE_CLASS_VERSIONS(FunctionArityIterator) |
1686 | - |
1687 | -void FunctionArityIterator::serialize(::zorba::serialization::Archiver& ar) |
1688 | -{ |
1689 | - serialize_baseclass(ar, |
1690 | - (NaryBaseIterator<FunctionArityIterator, PlanIteratorState>*)this); |
1691 | -} |
1692 | - |
1693 | - |
1694 | -void FunctionArityIterator::accept(PlanIterVisitor& v) const |
1695 | -{ |
1696 | - v.beginVisit(*this); |
1697 | - |
1698 | - std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin(); |
1699 | - std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end(); |
1700 | - for ( ; lIter != lEnd; ++lIter ){ |
1701 | - (*lIter)->accept(v); |
1702 | - } |
1703 | - |
1704 | - v.endVisit(*this); |
1705 | -} |
1706 | - |
1707 | -FunctionArityIterator::~FunctionArityIterator() {} |
1708 | - |
1709 | -// </FunctionArityIterator> |
1710 | - |
1711 | - |
1712 | -// <FnMapPairsIterator> |
1713 | -SERIALIZABLE_CLASS_VERSIONS(FnMapPairsIterator) |
1714 | - |
1715 | -void FnMapPairsIterator::serialize(::zorba::serialization::Archiver& ar) |
1716 | -{ |
1717 | - serialize_baseclass(ar, |
1718 | - (NaryBaseIterator<FnMapPairsIterator, FnMapPairsIteratorState>*)this); |
1719 | -} |
1720 | - |
1721 | - |
1722 | -void FnMapPairsIterator::accept(PlanIterVisitor& v) const |
1723 | -{ |
1724 | - v.beginVisit(*this); |
1725 | - |
1726 | - std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin(); |
1727 | - std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end(); |
1728 | - for ( ; lIter != lEnd; ++lIter ){ |
1729 | - (*lIter)->accept(v); |
1730 | - } |
1731 | - |
1732 | - v.endVisit(*this); |
1733 | -} |
1734 | - |
1735 | -FnMapPairsIterator::~FnMapPairsIterator() {} |
1736 | - |
1737 | -FnMapPairsIteratorState::FnMapPairsIteratorState() {} |
1738 | - |
1739 | -// </FnMapPairsIterator> |
1740 | - |
1741 | - |
1742 | -// <FnFoldLeftIterator> |
1743 | -SERIALIZABLE_CLASS_VERSIONS(FnFoldLeftIterator) |
1744 | - |
1745 | -void FnFoldLeftIterator::serialize(::zorba::serialization::Archiver& ar) |
1746 | -{ |
1747 | - serialize_baseclass(ar, |
1748 | - (NaryBaseIterator<FnFoldLeftIterator, FnFoldLeftIteratorState>*)this); |
1749 | - |
1750 | - ar & theIsFoldRight; |
1751 | -} |
1752 | - |
1753 | - |
1754 | -void FnFoldLeftIterator::accept(PlanIterVisitor& v) const |
1755 | -{ |
1756 | - v.beginVisit(*this); |
1757 | - |
1758 | - std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin(); |
1759 | - std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end(); |
1760 | - for ( ; lIter != lEnd; ++lIter ){ |
1761 | - (*lIter)->accept(v); |
1762 | - } |
1763 | - |
1764 | - v.endVisit(*this); |
1765 | -} |
1766 | - |
1767 | -FnFoldLeftIterator::~FnFoldLeftIterator() {} |
1768 | - |
1769 | -FnFoldLeftIteratorState::FnFoldLeftIteratorState() {} |
1770 | - |
1771 | -// </FnFoldLeftIterator> |
1772 | - |
1773 | - |
1774 | - |
1775 | -} |
1776 | - |
1777 | - |
1778 | |
1779 | === removed file 'src/runtime/function_item/pregenerated/function_item_iter.h' |
1780 | --- src/runtime/function_item/pregenerated/function_item_iter.h 2013-03-15 08:22:41 +0000 |
1781 | +++ src/runtime/function_item/pregenerated/function_item_iter.h 1970-01-01 00:00:00 +0000 |
1782 | @@ -1,256 +0,0 @@ |
1783 | -/* |
1784 | - * Copyright 2006-2012 The FLWOR Foundation. |
1785 | - * |
1786 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
1787 | - * you may not use this file except in compliance with the License. |
1788 | - * You may obtain a copy of the License at |
1789 | - * |
1790 | - * http://www.apache.org/licenses/LICENSE-2.0 |
1791 | - * |
1792 | - * Unless required by applicable law or agreed to in writing, software |
1793 | - * distributed under the License is distributed on an "AS IS" BASIS, |
1794 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
1795 | - * See the License for the specific language governing permissions and |
1796 | - * limitations under the License. |
1797 | - */ |
1798 | - |
1799 | -// ****************************************** |
1800 | -// * * |
1801 | -// * THIS IS A GENERATED FILE. DO NOT EDIT! * |
1802 | -// * SEE .xml FILE WITH SAME NAME * |
1803 | -// * * |
1804 | -// ****************************************** |
1805 | -#ifndef ZORBA_RUNTIME_FUNCTION_ITEM_FUNCTION_ITEM_ITER_H |
1806 | -#define ZORBA_RUNTIME_FUNCTION_ITEM_FUNCTION_ITEM_ITER_H |
1807 | - |
1808 | - |
1809 | -#include "common/shared_types.h" |
1810 | - |
1811 | - |
1812 | - |
1813 | -#include "runtime/base/narybase.h" |
1814 | -#include "compiler/expression/expr_base.h" |
1815 | -#include "runtime/util/plan_wrapper_holder.h" |
1816 | -#include "types/typeimpl.h" |
1817 | -#include "functions/function.h" |
1818 | - |
1819 | - |
1820 | -namespace zorba { |
1821 | - |
1822 | -/** |
1823 | - * |
1824 | - * Returns the function having a given name and arity, if there is one. |
1825 | - * |
1826 | - * Author: Zorba Team |
1827 | - */ |
1828 | -class FunctionLookupIterator : public NaryBaseIterator<FunctionLookupIterator, PlanIteratorState> |
1829 | -{ |
1830 | -protected: |
1831 | - CompilerCB* theCompilerCB; // |
1832 | -public: |
1833 | - SERIALIZABLE_CLASS(FunctionLookupIterator); |
1834 | - |
1835 | - SERIALIZABLE_CLASS_CONSTRUCTOR2T(FunctionLookupIterator, |
1836 | - NaryBaseIterator<FunctionLookupIterator, PlanIteratorState>); |
1837 | - |
1838 | - void serialize( ::zorba::serialization::Archiver& ar); |
1839 | - |
1840 | - FunctionLookupIterator( |
1841 | - static_context* sctx, |
1842 | - const QueryLoc& loc, |
1843 | - std::vector<PlanIter_t>& children, |
1844 | - CompilerCB* aCompilerCB) |
1845 | - : |
1846 | - NaryBaseIterator<FunctionLookupIterator, PlanIteratorState>(sctx, loc, children), |
1847 | - theCompilerCB(aCompilerCB) |
1848 | - {} |
1849 | - |
1850 | - virtual ~FunctionLookupIterator(); |
1851 | - |
1852 | - void accept(PlanIterVisitor& v) const; |
1853 | - |
1854 | - bool nextImpl(store::Item_t& result, PlanState& aPlanState) const; |
1855 | -}; |
1856 | - |
1857 | - |
1858 | -/** |
1859 | - * |
1860 | - * Returns the name of the function identified by a function item. |
1861 | - * |
1862 | - * Author: Zorba Team |
1863 | - */ |
1864 | -class FunctionNameIterator : public NaryBaseIterator<FunctionNameIterator, PlanIteratorState> |
1865 | -{ |
1866 | -public: |
1867 | - SERIALIZABLE_CLASS(FunctionNameIterator); |
1868 | - |
1869 | - SERIALIZABLE_CLASS_CONSTRUCTOR2T(FunctionNameIterator, |
1870 | - NaryBaseIterator<FunctionNameIterator, PlanIteratorState>); |
1871 | - |
1872 | - void serialize( ::zorba::serialization::Archiver& ar); |
1873 | - |
1874 | - FunctionNameIterator( |
1875 | - static_context* sctx, |
1876 | - const QueryLoc& loc, |
1877 | - std::vector<PlanIter_t>& children) |
1878 | - : |
1879 | - NaryBaseIterator<FunctionNameIterator, PlanIteratorState>(sctx, loc, children) |
1880 | - {} |
1881 | - |
1882 | - virtual ~FunctionNameIterator(); |
1883 | - |
1884 | - void accept(PlanIterVisitor& v) const; |
1885 | - |
1886 | - bool nextImpl(store::Item_t& result, PlanState& aPlanState) const; |
1887 | -}; |
1888 | - |
1889 | - |
1890 | -/** |
1891 | - * |
1892 | - * Returns the arity of the function identified by a function item. |
1893 | - * |
1894 | - * Author: Zorba Team |
1895 | - */ |
1896 | -class FunctionArityIterator : public NaryBaseIterator<FunctionArityIterator, PlanIteratorState> |
1897 | -{ |
1898 | -public: |
1899 | - SERIALIZABLE_CLASS(FunctionArityIterator); |
1900 | - |
1901 | - SERIALIZABLE_CLASS_CONSTRUCTOR2T(FunctionArityIterator, |
1902 | - NaryBaseIterator<FunctionArityIterator, PlanIteratorState>); |
1903 | - |
1904 | - void serialize( ::zorba::serialization::Archiver& ar); |
1905 | - |
1906 | - FunctionArityIterator( |
1907 | - static_context* sctx, |
1908 | - const QueryLoc& loc, |
1909 | - std::vector<PlanIter_t>& children) |
1910 | - : |
1911 | - NaryBaseIterator<FunctionArityIterator, PlanIteratorState>(sctx, loc, children) |
1912 | - {} |
1913 | - |
1914 | - virtual ~FunctionArityIterator(); |
1915 | - |
1916 | - void accept(PlanIterVisitor& v) const; |
1917 | - |
1918 | - bool nextImpl(store::Item_t& result, PlanState& aPlanState) const; |
1919 | -}; |
1920 | - |
1921 | - |
1922 | -/** |
1923 | - * |
1924 | - * Applies the function item $f to successive pairs of items taken one from $seq1 and one from $seq2, returning the concatenation of the resulting sequences in order. |
1925 | - * |
1926 | - * Author: Zorba Team |
1927 | - */ |
1928 | -class FnMapPairsIteratorState : public PlanIteratorState |
1929 | -{ |
1930 | -public: |
1931 | - PlanState* thePlanState; // |
1932 | - PlanIter_t thePlan; // |
1933 | - bool theIsOpen; // |
1934 | - uint32_t theUDFStateOffset; // |
1935 | - store::Item_t theFnItem; // |
1936 | - |
1937 | - FnMapPairsIteratorState(); |
1938 | - |
1939 | - ~FnMapPairsIteratorState(); |
1940 | - |
1941 | - void init(PlanState&); |
1942 | - void reset(PlanState&); |
1943 | -}; |
1944 | - |
1945 | -class FnMapPairsIterator : public NaryBaseIterator<FnMapPairsIterator, FnMapPairsIteratorState> |
1946 | -{ |
1947 | -public: |
1948 | - SERIALIZABLE_CLASS(FnMapPairsIterator); |
1949 | - |
1950 | - SERIALIZABLE_CLASS_CONSTRUCTOR2T(FnMapPairsIterator, |
1951 | - NaryBaseIterator<FnMapPairsIterator, FnMapPairsIteratorState>); |
1952 | - |
1953 | - void serialize( ::zorba::serialization::Archiver& ar); |
1954 | - |
1955 | - FnMapPairsIterator( |
1956 | - static_context* sctx, |
1957 | - const QueryLoc& loc, |
1958 | - std::vector<PlanIter_t>& children) |
1959 | - : |
1960 | - NaryBaseIterator<FnMapPairsIterator, FnMapPairsIteratorState>(sctx, loc, children) |
1961 | - {} |
1962 | - |
1963 | - virtual ~FnMapPairsIterator(); |
1964 | - |
1965 | - uint32_t getStateSizeOfSubtree() const; |
1966 | - |
1967 | - void accept(PlanIterVisitor& v) const; |
1968 | - |
1969 | - bool nextImpl(store::Item_t& result, PlanState& aPlanState) const; |
1970 | - |
1971 | - void openImpl(PlanState&, uint32_t&); |
1972 | -}; |
1973 | - |
1974 | - |
1975 | -/** |
1976 | - * |
1977 | - * Processes the supplied sequence from left to right or right to left, applying the supplied function repeatedly to each item in turn, together with an accumulated result value. |
1978 | - * |
1979 | - * Author: Zorba Team |
1980 | - */ |
1981 | -class FnFoldLeftIteratorState : public PlanIteratorState |
1982 | -{ |
1983 | -public: |
1984 | - PlanState* thePlanState; // |
1985 | - PlanIter_t thePlan; // |
1986 | - bool theIsOpen; // |
1987 | - uint32_t theUDFStateOffset; // |
1988 | - store::Item_t theFnItem; // |
1989 | - |
1990 | - FnFoldLeftIteratorState(); |
1991 | - |
1992 | - ~FnFoldLeftIteratorState(); |
1993 | - |
1994 | - void init(PlanState&); |
1995 | - void reset(PlanState&); |
1996 | -}; |
1997 | - |
1998 | -class FnFoldLeftIterator : public NaryBaseIterator<FnFoldLeftIterator, FnFoldLeftIteratorState> |
1999 | -{ |
2000 | -protected: |
2001 | - bool theIsFoldRight; // |
2002 | -public: |
2003 | - SERIALIZABLE_CLASS(FnFoldLeftIterator); |
2004 | - |
2005 | - SERIALIZABLE_CLASS_CONSTRUCTOR2T(FnFoldLeftIterator, |
2006 | - NaryBaseIterator<FnFoldLeftIterator, FnFoldLeftIteratorState>); |
2007 | - |
2008 | - void serialize( ::zorba::serialization::Archiver& ar); |
2009 | - |
2010 | - FnFoldLeftIterator( |
2011 | - static_context* sctx, |
2012 | - const QueryLoc& loc, |
2013 | - std::vector<PlanIter_t>& children, |
2014 | - bool aIsFoldRight) |
2015 | - : |
2016 | - NaryBaseIterator<FnFoldLeftIterator, FnFoldLeftIteratorState>(sctx, loc, children), |
2017 | - theIsFoldRight(aIsFoldRight) |
2018 | - {} |
2019 | - |
2020 | - virtual ~FnFoldLeftIterator(); |
2021 | - |
2022 | - uint32_t getStateSizeOfSubtree() const; |
2023 | - |
2024 | - void accept(PlanIterVisitor& v) const; |
2025 | - |
2026 | - bool nextImpl(store::Item_t& result, PlanState& aPlanState) const; |
2027 | - |
2028 | - void openImpl(PlanState&, uint32_t&); |
2029 | -}; |
2030 | - |
2031 | - |
2032 | -} |
2033 | -#endif |
2034 | -/* |
2035 | - * Local variables: |
2036 | - * mode: c++ |
2037 | - * End: |
2038 | - */ |
2039 | |
2040 | === added file 'src/runtime/hof/fn_hof_functions_impl.cpp' |
2041 | --- src/runtime/hof/fn_hof_functions_impl.cpp 1970-01-01 00:00:00 +0000 |
2042 | +++ src/runtime/hof/fn_hof_functions_impl.cpp 2013-03-27 00:48:21 +0000 |
2043 | @@ -0,0 +1,451 @@ |
2044 | +/* |
2045 | + * Copyright 2006-2008 The FLWOR Foundation. |
2046 | + * |
2047 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
2048 | + * you may not use this file except in compliance with the License. |
2049 | + * You may obtain a copy of the License at |
2050 | + * |
2051 | + * http://www.apache.org/licenses/LICENSE-2.0 |
2052 | + * |
2053 | + * Unless required by applicable law or agreed to in writing, software |
2054 | + * distributed under the License is distributed on an "AS IS" BASIS, |
2055 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
2056 | + * See the License for the specific language governing permissions and |
2057 | + * limitations under the License. |
2058 | + */ |
2059 | + |
2060 | +#include "stdafx.h" |
2061 | + |
2062 | +#include "compiler/expression/function_item_expr.h" |
2063 | +#include "compiler/api/compilercb.h" |
2064 | +#include "compiler/translator/translator.h" |
2065 | + |
2066 | +#include "functions/udf.h" |
2067 | + |
2068 | +#include "runtime/api/plan_iterator_wrapper.h" |
2069 | +#include "runtime/util/iterator_impl.h" |
2070 | +#include "runtime/hof/fn_hof_functions.h" |
2071 | +#include "runtime/hof/function_item.h" |
2072 | +#include "runtime/core/fncall_iterator.h" |
2073 | + |
2074 | +#include "context/dynamic_context.h" |
2075 | +#include "context/static_context.h" |
2076 | + |
2077 | +#include "types/typeops.h" |
2078 | + |
2079 | +#include "store/api/item_factory.h" |
2080 | +#include "store/api/store.h" |
2081 | +#include "store/api/temp_seq.h" |
2082 | + |
2083 | +#include "diagnostics/util_macros.h" |
2084 | + |
2085 | +#include "system/globalenv.h" |
2086 | + |
2087 | +#include "zorbamisc/ns_consts.h" |
2088 | + |
2089 | + |
2090 | +using namespace std; |
2091 | + |
2092 | +namespace zorba { |
2093 | + |
2094 | + |
2095 | +/******************************************************************************* |
2096 | + |
2097 | +********************************************************************************/ |
2098 | +bool FunctionLookupIterator::nextImpl( |
2099 | + store::Item_t& result, |
2100 | + PlanState& planState) const |
2101 | +{ |
2102 | + store::Item_t qname; |
2103 | + store::Item_t arityItem; |
2104 | + uint32_t arity; |
2105 | + result = NULL; |
2106 | + |
2107 | + PlanIteratorState* state; |
2108 | + DEFAULT_STACK_INIT(PlanIteratorState, state, planState); |
2109 | + |
2110 | + consumeNext(qname, theChildren[0], planState); |
2111 | + consumeNext(arityItem, theChildren[1], planState); |
2112 | + |
2113 | + try |
2114 | + { |
2115 | + arity = to_xs_unsignedInt(arityItem->getIntegerValue()); |
2116 | + } |
2117 | + catch ( std::range_error const& ) |
2118 | + { |
2119 | + RAISE_ERROR(err::XPST0017, loc, |
2120 | + ERROR_PARAMS(arityItem->getIntegerValue(), ZED(NoParseFnArity))); |
2121 | + } |
2122 | + |
2123 | + try |
2124 | + { |
2125 | + expr* fiExpr = Translator::translate_literal_function(qname, arity, theCompilerCB, loc, true); |
2126 | + |
2127 | + FunctionItemInfo_t dynFnInfo = |
2128 | + static_cast<function_item_expr*>(fiExpr)->get_dynamic_fn_info(); |
2129 | + |
2130 | + dynFnInfo->theCCB = theCompilerCB; |
2131 | + |
2132 | + result = new FunctionItem(dynFnInfo, NULL); |
2133 | + } |
2134 | + catch (ZorbaException const& e) |
2135 | + { |
2136 | + if (e.diagnostic() != err::XPST0017) |
2137 | + throw; |
2138 | + } |
2139 | + |
2140 | + if (result.getp() != NULL) |
2141 | + STACK_PUSH(true, state); |
2142 | + |
2143 | + STACK_END(state); |
2144 | +} |
2145 | + |
2146 | + |
2147 | +/******************************************************************************* |
2148 | + |
2149 | +********************************************************************************/ |
2150 | +bool FunctionNameIterator::nextImpl( |
2151 | + store::Item_t& r, |
2152 | + PlanState& planState) const |
2153 | +{ |
2154 | + store::Item_t lFItem; |
2155 | + FunctionItem* lFunctionItem = 0; |
2156 | + |
2157 | + PlanIteratorState* state; |
2158 | + DEFAULT_STACK_INIT(PlanIteratorState, state, planState); |
2159 | + |
2160 | + consumeNext(lFItem, theChildren[0], planState); |
2161 | + |
2162 | + // function signature guarantees that |
2163 | + ZORBA_ASSERT(lFItem->isFunction()); |
2164 | + |
2165 | + lFunctionItem = static_cast<FunctionItem*>(lFItem.getp()); |
2166 | + |
2167 | + if ((!lFunctionItem->isInline() || lFunctionItem->isCoercion()) |
2168 | + && |
2169 | + lFunctionItem->getFunctionName() |
2170 | + && |
2171 | + (lFunctionItem->getArity() == lFunctionItem->getStartArity())) |
2172 | + { |
2173 | + // non-inline function |
2174 | + r = lFunctionItem->getFunctionName(); |
2175 | + STACK_PUSH(true, state); |
2176 | + } |
2177 | + |
2178 | + STACK_END(state); |
2179 | +} |
2180 | + |
2181 | + |
2182 | +/******************************************************************************* |
2183 | + |
2184 | +********************************************************************************/ |
2185 | +bool FunctionArityIterator::nextImpl( |
2186 | + store::Item_t& r, |
2187 | + PlanState& planState) const |
2188 | +{ |
2189 | + store::Item_t lFItem; |
2190 | + FunctionItem* lFunctionItem = 0; |
2191 | + xs_integer lInt; |
2192 | + |
2193 | + PlanIteratorState* state; |
2194 | + DEFAULT_STACK_INIT(PlanIteratorState, state, planState); |
2195 | + |
2196 | + consumeNext(lFItem, theChildren[0], planState); |
2197 | + |
2198 | + // function signature guarantees that |
2199 | + ZORBA_ASSERT(lFItem->isFunction()); |
2200 | + |
2201 | + lFunctionItem = static_cast<FunctionItem*>(lFItem.getp()); |
2202 | + |
2203 | + lInt = Integer(lFunctionItem->getArity()); |
2204 | + |
2205 | + STACK_PUSH(GENV_ITEMFACTORY->createInteger(r, lInt), state); |
2206 | + |
2207 | + STACK_END(state); |
2208 | +} |
2209 | + |
2210 | + |
2211 | +/******************************************************************************* |
2212 | + |
2213 | +********************************************************************************/ |
2214 | +FnMapPairsIteratorState::~FnMapPairsIteratorState() |
2215 | +{ |
2216 | + if (theIsOpen) |
2217 | + { |
2218 | + thePlan->close(*thePlanState); |
2219 | + } |
2220 | +} |
2221 | + |
2222 | + |
2223 | +void FnMapPairsIteratorState::init(PlanState& planState) |
2224 | +{ |
2225 | + PlanIteratorState::init(planState); |
2226 | + thePlanState = &planState; |
2227 | + thePlan = NULL; |
2228 | + theIsOpen = false; |
2229 | +} |
2230 | + |
2231 | + |
2232 | +void FnMapPairsIteratorState::reset(PlanState& planState) |
2233 | +{ |
2234 | + PlanIteratorState::reset(planState); |
2235 | + if (theIsOpen) |
2236 | + { |
2237 | + thePlan->reset(planState); |
2238 | + } |
2239 | +} |
2240 | + |
2241 | + |
2242 | +uint32_t FnMapPairsIterator::getStateSizeOfSubtree() const |
2243 | +{ |
2244 | + uint32_t size = NaryBaseIterator<FnMapPairsIterator, FnMapPairsIteratorState>:: |
2245 | + getStateSizeOfSubtree(); |
2246 | + |
2247 | + return size + sizeof(UDFunctionCallIteratorState); |
2248 | +} |
2249 | + |
2250 | + |
2251 | +void FnMapPairsIterator::openImpl(PlanState& planState, uint32_t& offset) |
2252 | +{ |
2253 | + StateTraitsImpl<FnMapPairsIteratorState>::createState(planState, |
2254 | + theStateOffset, |
2255 | + offset); |
2256 | + |
2257 | + StateTraitsImpl<FnMapPairsIteratorState>::initState(planState, theStateOffset); |
2258 | + |
2259 | + FnMapPairsIteratorState* state = |
2260 | + StateTraitsImpl<FnMapPairsIteratorState>::getState(planState, theStateOffset); |
2261 | + |
2262 | + state->theUDFStateOffset = offset; |
2263 | + |
2264 | + offset += sizeof(UDFunctionCallIteratorState); |
2265 | + |
2266 | + std::vector<PlanIter_t>::iterator lIter = theChildren.begin(); |
2267 | + std::vector<PlanIter_t>::iterator lEnd = theChildren.end(); |
2268 | + for ( ; lIter != lEnd; ++lIter ) |
2269 | + { |
2270 | + (*lIter)->open(planState, offset); |
2271 | + } |
2272 | +} |
2273 | + |
2274 | + |
2275 | +bool FnMapPairsIterator::nextImpl( |
2276 | + store::Item_t& result, |
2277 | + PlanState& planState) const |
2278 | +{ |
2279 | + store::Item_t child1, child2; |
2280 | + std::vector<PlanIter_t> arguments; |
2281 | + |
2282 | + FnMapPairsIteratorState* state; |
2283 | + DEFAULT_STACK_INIT(FnMapPairsIteratorState, state, planState); |
2284 | + |
2285 | + consumeNext(state->theFnItem, theChildren[0], planState); |
2286 | + |
2287 | + // function signature guarantees that |
2288 | + ZORBA_ASSERT(state->theFnItem->isFunction()); |
2289 | + |
2290 | + while (true) |
2291 | + { |
2292 | + if (!consumeNext(child1, theChildren[1], planState) || |
2293 | + !consumeNext(child2, theChildren[2], planState)) |
2294 | + break; |
2295 | + |
2296 | + if (child1.getp() && child2.getp()) |
2297 | + { |
2298 | + { |
2299 | + store::TempSeq_t seq1, seq2; |
2300 | + seq1 = GENV_STORE.createTempSeq(child1); |
2301 | + seq2 = GENV_STORE.createTempSeq(child2); |
2302 | + store::Iterator_t seqIter1 = seq1->getIterator(); |
2303 | + store::Iterator_t seqIter2 = seq2->getIterator(); |
2304 | + seqIter1->open(); |
2305 | + seqIter2->open(); |
2306 | + |
2307 | + arguments.push_back(NULL); // the first argument is expected to be the function item and it is not used |
2308 | + arguments.push_back(new PlanStateIteratorWrapper(seqIter1)); |
2309 | + arguments.push_back(new PlanStateIteratorWrapper(seqIter2)); |
2310 | + } |
2311 | + |
2312 | + state->thePlan = static_cast<FunctionItem*>(state->theFnItem.getp())->getImplementation(arguments, planState.theCompilerCB); |
2313 | + // must be opened after vars and params are set |
2314 | + state->thePlan->open(planState, state->theUDFStateOffset); |
2315 | + state->theIsOpen = true; |
2316 | + |
2317 | + while (consumeNext(result, state->thePlan, planState)) |
2318 | + { |
2319 | + STACK_PUSH(true, state); |
2320 | + } |
2321 | + |
2322 | + // need to close here early in case the plan is completely |
2323 | + // consumed. Otherwise, the plan would still be opened |
2324 | + // if destroyed from the state's destructor. |
2325 | + state->thePlan->close(planState); |
2326 | + state->theIsOpen = false; |
2327 | + } |
2328 | + else |
2329 | + { |
2330 | + result = NULL; |
2331 | + STACK_PUSH(true, state); |
2332 | + } |
2333 | + } |
2334 | + |
2335 | + STACK_END(state); |
2336 | +} |
2337 | + |
2338 | + |
2339 | +/******************************************************************************* |
2340 | + |
2341 | +********************************************************************************/ |
2342 | +FnFoldLeftIteratorState::~FnFoldLeftIteratorState() |
2343 | +{ |
2344 | + if (theIsOpen) |
2345 | + { |
2346 | + thePlan->close(*thePlanState); |
2347 | + } |
2348 | +} |
2349 | + |
2350 | + |
2351 | +void FnFoldLeftIteratorState::init(PlanState& planState) |
2352 | +{ |
2353 | + PlanIteratorState::init(planState); |
2354 | + thePlanState = &planState; |
2355 | + thePlan = NULL; |
2356 | + theIsOpen = false; |
2357 | +} |
2358 | + |
2359 | + |
2360 | +void FnFoldLeftIteratorState::reset(PlanState& planState) |
2361 | +{ |
2362 | + PlanIteratorState::reset(planState); |
2363 | + if (theIsOpen) |
2364 | + { |
2365 | + thePlan->reset(planState); |
2366 | + } |
2367 | +} |
2368 | + |
2369 | + |
2370 | +uint32_t FnFoldLeftIterator::getStateSizeOfSubtree() const |
2371 | +{ |
2372 | + uint32_t size = NaryBaseIterator<FnFoldLeftIterator, FnFoldLeftIteratorState>:: |
2373 | + getStateSizeOfSubtree(); |
2374 | + |
2375 | + return size + sizeof(UDFunctionCallIteratorState); |
2376 | +} |
2377 | + |
2378 | + |
2379 | +void FnFoldLeftIterator::openImpl(PlanState& planState, uint32_t& offset) |
2380 | +{ |
2381 | + StateTraitsImpl<FnFoldLeftIteratorState>::createState(planState, |
2382 | + theStateOffset, |
2383 | + offset); |
2384 | + |
2385 | + StateTraitsImpl<FnFoldLeftIteratorState>::initState(planState, theStateOffset); |
2386 | + |
2387 | + FnFoldLeftIteratorState* state = |
2388 | + StateTraitsImpl<FnFoldLeftIteratorState>::getState(planState, theStateOffset); |
2389 | + |
2390 | + state->theUDFStateOffset = offset; |
2391 | + |
2392 | + offset += sizeof(UDFunctionCallIteratorState); |
2393 | + |
2394 | + std::vector<PlanIter_t>::iterator lIter = theChildren.begin(); |
2395 | + std::vector<PlanIter_t>::iterator lEnd = theChildren.end(); |
2396 | + for ( ; lIter != lEnd; ++lIter ) |
2397 | + { |
2398 | + (*lIter)->open(planState, offset); |
2399 | + } |
2400 | +} |
2401 | + |
2402 | + |
2403 | +bool FnFoldLeftIterator::nextImpl( |
2404 | + store::Item_t& result, |
2405 | + PlanState& planState) const |
2406 | +{ |
2407 | + store::Item_t curSeqItem, nextSeqItem, tempItem; |
2408 | + std::vector<store::Item_t> zero; |
2409 | + bool haveSeqItems; |
2410 | + |
2411 | + FnFoldLeftIteratorState* state; |
2412 | + DEFAULT_STACK_INIT(FnFoldLeftIteratorState, state, planState); |
2413 | + |
2414 | + consumeNext(state->theFnItem, theChildren[0], planState); |
2415 | + |
2416 | + // function signature guarantees that |
2417 | + ZORBA_ASSERT(state->theFnItem->isFunction()); |
2418 | + |
2419 | + if ((haveSeqItems = consumeNext(curSeqItem, theChildren[2], planState))) |
2420 | + haveSeqItems = consumeNext(nextSeqItem, theChildren[2], planState); |
2421 | + |
2422 | + if (curSeqItem.getp() == NULL && nextSeqItem.getp() == NULL) |
2423 | + { |
2424 | + // consume and return the "zero" argument |
2425 | + while (consumeNext(result, theChildren[1], planState)) |
2426 | + { |
2427 | + STACK_PUSH(true, state); |
2428 | + } |
2429 | + } |
2430 | + else |
2431 | + { |
2432 | + // read in the "zero" argument to be able to pass it to the hof |
2433 | + while (consumeNext(tempItem, theChildren[1], planState)) |
2434 | + { |
2435 | + zero.push_back(tempItem); |
2436 | + } |
2437 | + |
2438 | + while (true) |
2439 | + { |
2440 | + { |
2441 | + store::TempSeq_t zeroSeq = GENV_STORE.createTempSeq(zero); |
2442 | + tempItem = curSeqItem; // because createTempSeq calls .release() on the item rchandle |
2443 | + store::TempSeq_t seq = GENV_STORE.createTempSeq(tempItem); |
2444 | + store::Iterator_t seqIter1 = zeroSeq->getIterator(); |
2445 | + store::Iterator_t seqIter2 = seq->getIterator(); |
2446 | + seqIter1->open(); |
2447 | + seqIter2->open(); |
2448 | + |
2449 | + std::vector<PlanIter_t> arguments; |
2450 | + arguments.push_back(NULL); |
2451 | + arguments.push_back(new PlanStateIteratorWrapper(seqIter1)); |
2452 | + arguments.push_back(new PlanStateIteratorWrapper(seqIter2)); |
2453 | + if (theIsFoldRight) |
2454 | + std::reverse(++arguments.begin(), arguments.end()); |
2455 | + |
2456 | + state->thePlan = static_cast<FunctionItem*>(state->theFnItem.getp())->getImplementation(arguments, planState.theCompilerCB); |
2457 | + state->thePlan->open(planState, state->theUDFStateOffset); |
2458 | + state->theIsOpen = true; |
2459 | + } |
2460 | + |
2461 | + if (curSeqItem.isNull() || nextSeqItem.isNull()) |
2462 | + break; |
2463 | + |
2464 | + zero.clear(); |
2465 | + while (consumeNext(tempItem, state->thePlan, planState)) |
2466 | + { |
2467 | + zero.push_back(tempItem); |
2468 | + } |
2469 | + |
2470 | + state->thePlan->close(planState); |
2471 | + state->theIsOpen = false; |
2472 | + |
2473 | + curSeqItem = nextSeqItem; |
2474 | + nextSeqItem = NULL; |
2475 | + if (haveSeqItems) |
2476 | + haveSeqItems = consumeNext(nextSeqItem, theChildren[2], planState); |
2477 | + |
2478 | + } // while (true) |
2479 | + |
2480 | + while (consumeNext(result, state->thePlan, planState)) |
2481 | + { |
2482 | + STACK_PUSH(true, state); |
2483 | + } |
2484 | + |
2485 | + state->thePlan->close(planState); |
2486 | + state->theIsOpen = false; |
2487 | + |
2488 | + } // else |
2489 | + |
2490 | + STACK_END(state); |
2491 | +} |
2492 | + |
2493 | +} // namespace zorba |
2494 | +/* vim:set et sw=2 ts=2: */ |
2495 | |
2496 | === added directory 'src/runtime/hof/pregenerated' |
2497 | === added file 'src/runtime/hof/pregenerated/fn_hof_functions.cpp' |
2498 | --- src/runtime/hof/pregenerated/fn_hof_functions.cpp 1970-01-01 00:00:00 +0000 |
2499 | +++ src/runtime/hof/pregenerated/fn_hof_functions.cpp 2013-03-27 00:48:21 +0000 |
2500 | @@ -0,0 +1,190 @@ |
2501 | +/* |
2502 | + * Copyright 2006-2012 The FLWOR Foundation. |
2503 | + * |
2504 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
2505 | + * you may not use this file except in compliance with the License. |
2506 | + * You may obtain a copy of the License at |
2507 | + * |
2508 | + * http://www.apache.org/licenses/LICENSE-2.0 |
2509 | + * |
2510 | + * Unless required by applicable law or agreed to in writing, software |
2511 | + * distributed under the License is distributed on an "AS IS" BASIS, |
2512 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
2513 | + * See the License for the specific language governing permissions and |
2514 | + * limitations under the License. |
2515 | + */ |
2516 | + |
2517 | +// ****************************************** |
2518 | +// * * |
2519 | +// * THIS IS A GENERATED FILE. DO NOT EDIT! * |
2520 | +// * SEE .xml FILE WITH SAME NAME * |
2521 | +// * * |
2522 | +// ****************************************** |
2523 | + |
2524 | +#include "stdafx.h" |
2525 | +#include "zorbatypes/rchandle.h" |
2526 | +#include "zorbatypes/zstring.h" |
2527 | +#include "runtime/visitors/planiter_visitor.h" |
2528 | +#include "runtime/hof/fn_hof_functions.h" |
2529 | +#include "system/globalenv.h" |
2530 | + |
2531 | + |
2532 | +#include "context/static_context.h" |
2533 | +#include "compiler/api/compilercb.h" |
2534 | +#include "context/dynamic_context.h" |
2535 | +#include "store/api/temp_seq.h" |
2536 | + |
2537 | +namespace zorba { |
2538 | + |
2539 | +// <FunctionLookupIterator> |
2540 | +SERIALIZABLE_CLASS_VERSIONS(FunctionLookupIterator) |
2541 | + |
2542 | +void FunctionLookupIterator::serialize(::zorba::serialization::Archiver& ar) |
2543 | +{ |
2544 | + serialize_baseclass(ar, |
2545 | + (NaryBaseIterator<FunctionLookupIterator, PlanIteratorState>*)this); |
2546 | + |
2547 | + ar & theCompilerCB; |
2548 | +} |
2549 | + |
2550 | + |
2551 | +void FunctionLookupIterator::accept(PlanIterVisitor& v) const |
2552 | +{ |
2553 | + v.beginVisit(*this); |
2554 | + |
2555 | + std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin(); |
2556 | + std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end(); |
2557 | + for ( ; lIter != lEnd; ++lIter ){ |
2558 | + (*lIter)->accept(v); |
2559 | + } |
2560 | + |
2561 | + v.endVisit(*this); |
2562 | +} |
2563 | + |
2564 | +FunctionLookupIterator::~FunctionLookupIterator() {} |
2565 | + |
2566 | +// </FunctionLookupIterator> |
2567 | + |
2568 | + |
2569 | +// <FunctionNameIterator> |
2570 | +SERIALIZABLE_CLASS_VERSIONS(FunctionNameIterator) |
2571 | + |
2572 | +void FunctionNameIterator::serialize(::zorba::serialization::Archiver& ar) |
2573 | +{ |
2574 | + serialize_baseclass(ar, |
2575 | + (NaryBaseIterator<FunctionNameIterator, PlanIteratorState>*)this); |
2576 | +} |
2577 | + |
2578 | + |
2579 | +void FunctionNameIterator::accept(PlanIterVisitor& v) const |
2580 | +{ |
2581 | + v.beginVisit(*this); |
2582 | + |
2583 | + std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin(); |
2584 | + std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end(); |
2585 | + for ( ; lIter != lEnd; ++lIter ){ |
2586 | + (*lIter)->accept(v); |
2587 | + } |
2588 | + |
2589 | + v.endVisit(*this); |
2590 | +} |
2591 | + |
2592 | +FunctionNameIterator::~FunctionNameIterator() {} |
2593 | + |
2594 | +// </FunctionNameIterator> |
2595 | + |
2596 | + |
2597 | +// <FunctionArityIterator> |
2598 | +SERIALIZABLE_CLASS_VERSIONS(FunctionArityIterator) |
2599 | + |
2600 | +void FunctionArityIterator::serialize(::zorba::serialization::Archiver& ar) |
2601 | +{ |
2602 | + serialize_baseclass(ar, |
2603 | + (NaryBaseIterator<FunctionArityIterator, PlanIteratorState>*)this); |
2604 | +} |
2605 | + |
2606 | + |
2607 | +void FunctionArityIterator::accept(PlanIterVisitor& v) const |
2608 | +{ |
2609 | + v.beginVisit(*this); |
2610 | + |
2611 | + std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin(); |
2612 | + std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end(); |
2613 | + for ( ; lIter != lEnd; ++lIter ){ |
2614 | + (*lIter)->accept(v); |
2615 | + } |
2616 | + |
2617 | + v.endVisit(*this); |
2618 | +} |
2619 | + |
2620 | +FunctionArityIterator::~FunctionArityIterator() {} |
2621 | + |
2622 | +// </FunctionArityIterator> |
2623 | + |
2624 | + |
2625 | +// <FnMapPairsIterator> |
2626 | +SERIALIZABLE_CLASS_VERSIONS(FnMapPairsIterator) |
2627 | + |
2628 | +void FnMapPairsIterator::serialize(::zorba::serialization::Archiver& ar) |
2629 | +{ |
2630 | + serialize_baseclass(ar, |
2631 | + (NaryBaseIterator<FnMapPairsIterator, FnMapPairsIteratorState>*)this); |
2632 | +} |
2633 | + |
2634 | + |
2635 | +void FnMapPairsIterator::accept(PlanIterVisitor& v) const |
2636 | +{ |
2637 | + v.beginVisit(*this); |
2638 | + |
2639 | + std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin(); |
2640 | + std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end(); |
2641 | + for ( ; lIter != lEnd; ++lIter ){ |
2642 | + (*lIter)->accept(v); |
2643 | + } |
2644 | + |
2645 | + v.endVisit(*this); |
2646 | +} |
2647 | + |
2648 | +FnMapPairsIterator::~FnMapPairsIterator() {} |
2649 | + |
2650 | +FnMapPairsIteratorState::FnMapPairsIteratorState() {} |
2651 | + |
2652 | +// </FnMapPairsIterator> |
2653 | + |
2654 | + |
2655 | +// <FnFoldLeftIterator> |
2656 | +SERIALIZABLE_CLASS_VERSIONS(FnFoldLeftIterator) |
2657 | + |
2658 | +void FnFoldLeftIterator::serialize(::zorba::serialization::Archiver& ar) |
2659 | +{ |
2660 | + serialize_baseclass(ar, |
2661 | + (NaryBaseIterator<FnFoldLeftIterator, FnFoldLeftIteratorState>*)this); |
2662 | + |
2663 | + ar & theIsFoldRight; |
2664 | +} |
2665 | + |
2666 | + |
2667 | +void FnFoldLeftIterator::accept(PlanIterVisitor& v) const |
2668 | +{ |
2669 | + v.beginVisit(*this); |
2670 | + |
2671 | + std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin(); |
2672 | + std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end(); |
2673 | + for ( ; lIter != lEnd; ++lIter ){ |
2674 | + (*lIter)->accept(v); |
2675 | + } |
2676 | + |
2677 | + v.endVisit(*this); |
2678 | +} |
2679 | + |
2680 | +FnFoldLeftIterator::~FnFoldLeftIterator() {} |
2681 | + |
2682 | +FnFoldLeftIteratorState::FnFoldLeftIteratorState() {} |
2683 | + |
2684 | +// </FnFoldLeftIterator> |
2685 | + |
2686 | + |
2687 | + |
2688 | +} |
2689 | + |
2690 | + |
2691 | |
2692 | === added file 'src/runtime/hof/pregenerated/fn_hof_functions.h' |
2693 | --- src/runtime/hof/pregenerated/fn_hof_functions.h 1970-01-01 00:00:00 +0000 |
2694 | +++ src/runtime/hof/pregenerated/fn_hof_functions.h 2013-03-27 00:48:21 +0000 |
2695 | @@ -0,0 +1,256 @@ |
2696 | +/* |
2697 | + * Copyright 2006-2012 The FLWOR Foundation. |
2698 | + * |
2699 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
2700 | + * you may not use this file except in compliance with the License. |
2701 | + * You may obtain a copy of the License at |
2702 | + * |
2703 | + * http://www.apache.org/licenses/LICENSE-2.0 |
2704 | + * |
2705 | + * Unless required by applicable law or agreed to in writing, software |
2706 | + * distributed under the License is distributed on an "AS IS" BASIS, |
2707 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
2708 | + * See the License for the specific language governing permissions and |
2709 | + * limitations under the License. |
2710 | + */ |
2711 | + |
2712 | +// ****************************************** |
2713 | +// * * |
2714 | +// * THIS IS A GENERATED FILE. DO NOT EDIT! * |
2715 | +// * SEE .xml FILE WITH SAME NAME * |
2716 | +// * * |
2717 | +// ****************************************** |
2718 | +#ifndef ZORBA_RUNTIME_HOF_FN_HOF_FUNCTIONS_H |
2719 | +#define ZORBA_RUNTIME_HOF_FN_HOF_FUNCTIONS_H |
2720 | + |
2721 | + |
2722 | +#include "common/shared_types.h" |
2723 | + |
2724 | + |
2725 | + |
2726 | +#include "runtime/base/narybase.h" |
2727 | +#include "compiler/expression/expr_base.h" |
2728 | +#include "runtime/util/plan_wrapper_holder.h" |
2729 | +#include "types/typeimpl.h" |
2730 | +#include "functions/function.h" |
2731 | + |
2732 | + |
2733 | +namespace zorba { |
2734 | + |
2735 | +/** |
2736 | + * |
2737 | + * Returns the function having a given name and arity, if there is one. |
2738 | + * |
2739 | + * Author: Zorba Team |
2740 | + */ |
2741 | +class FunctionLookupIterator : public NaryBaseIterator<FunctionLookupIterator, PlanIteratorState> |
2742 | +{ |
2743 | +protected: |
2744 | + CompilerCB* theCompilerCB; // |
2745 | +public: |
2746 | + SERIALIZABLE_CLASS(FunctionLookupIterator); |
2747 | + |
2748 | + SERIALIZABLE_CLASS_CONSTRUCTOR2T(FunctionLookupIterator, |
2749 | + NaryBaseIterator<FunctionLookupIterator, PlanIteratorState>); |
2750 | + |
2751 | + void serialize( ::zorba::serialization::Archiver& ar); |
2752 | + |
2753 | + FunctionLookupIterator( |
2754 | + static_context* sctx, |
2755 | + const QueryLoc& loc, |
2756 | + std::vector<PlanIter_t>& children, |
2757 | + CompilerCB* aCompilerCB) |
2758 | + : |
2759 | + NaryBaseIterator<FunctionLookupIterator, PlanIteratorState>(sctx, loc, children), |
2760 | + theCompilerCB(aCompilerCB) |
2761 | + {} |
2762 | + |
2763 | + virtual ~FunctionLookupIterator(); |
2764 | + |
2765 | + void accept(PlanIterVisitor& v) const; |
2766 | + |
2767 | + bool nextImpl(store::Item_t& result, PlanState& aPlanState) const; |
2768 | +}; |
2769 | + |
2770 | + |
2771 | +/** |
2772 | + * |
2773 | + * Returns the name of the function identified by a function item. |
2774 | + * |
2775 | + * Author: Zorba Team |
2776 | + */ |
2777 | +class FunctionNameIterator : public NaryBaseIterator<FunctionNameIterator, PlanIteratorState> |
2778 | +{ |
2779 | +public: |
2780 | + SERIALIZABLE_CLASS(FunctionNameIterator); |
2781 | + |
2782 | + SERIALIZABLE_CLASS_CONSTRUCTOR2T(FunctionNameIterator, |
2783 | + NaryBaseIterator<FunctionNameIterator, PlanIteratorState>); |
2784 | + |
2785 | + void serialize( ::zorba::serialization::Archiver& ar); |
2786 | + |
2787 | + FunctionNameIterator( |
2788 | + static_context* sctx, |
2789 | + const QueryLoc& loc, |
2790 | + std::vector<PlanIter_t>& children) |
2791 | + : |
2792 | + NaryBaseIterator<FunctionNameIterator, PlanIteratorState>(sctx, loc, children) |
2793 | + {} |
2794 | + |
2795 | + virtual ~FunctionNameIterator(); |
2796 | + |
2797 | + void accept(PlanIterVisitor& v) const; |
2798 | + |
2799 | + bool nextImpl(store::Item_t& result, PlanState& aPlanState) const; |
2800 | +}; |
2801 | + |
2802 | + |
2803 | +/** |
2804 | + * |
2805 | + * Returns the arity of the function identified by a function item. |
2806 | + * |
2807 | + * Author: Zorba Team |
2808 | + */ |
2809 | +class FunctionArityIterator : public NaryBaseIterator<FunctionArityIterator, PlanIteratorState> |
2810 | +{ |
2811 | +public: |
2812 | + SERIALIZABLE_CLASS(FunctionArityIterator); |
2813 | + |
2814 | + SERIALIZABLE_CLASS_CONSTRUCTOR2T(FunctionArityIterator, |
2815 | + NaryBaseIterator<FunctionArityIterator, PlanIteratorState>); |
2816 | + |
2817 | + void serialize( ::zorba::serialization::Archiver& ar); |
2818 | + |
2819 | + FunctionArityIterator( |
2820 | + static_context* sctx, |
2821 | + const QueryLoc& loc, |
2822 | + std::vector<PlanIter_t>& children) |
2823 | + : |
2824 | + NaryBaseIterator<FunctionArityIterator, PlanIteratorState>(sctx, loc, children) |
2825 | + {} |
2826 | + |
2827 | + virtual ~FunctionArityIterator(); |
2828 | + |
2829 | + void accept(PlanIterVisitor& v) const; |
2830 | + |
2831 | + bool nextImpl(store::Item_t& result, PlanState& aPlanState) const; |
2832 | +}; |
2833 | + |
2834 | + |
2835 | +/** |
2836 | + * |
2837 | + * Applies the function item $f to successive pairs of items taken one from $seq1 and one from $seq2, returning the concatenation of the resulting sequences in order. |
2838 | + * |
2839 | + * Author: Zorba Team |
2840 | + */ |
2841 | +class FnMapPairsIteratorState : public PlanIteratorState |
2842 | +{ |
2843 | +public: |
2844 | + PlanState* thePlanState; // |
2845 | + PlanIter_t thePlan; // |
2846 | + bool theIsOpen; // |
2847 | + uint32_t theUDFStateOffset; // |
2848 | + store::Item_t theFnItem; // |
2849 | + |
2850 | + FnMapPairsIteratorState(); |
2851 | + |
2852 | + ~FnMapPairsIteratorState(); |
2853 | + |
2854 | + void init(PlanState&); |
2855 | + void reset(PlanState&); |
2856 | +}; |
2857 | + |
2858 | +class FnMapPairsIterator : public NaryBaseIterator<FnMapPairsIterator, FnMapPairsIteratorState> |
2859 | +{ |
2860 | +public: |
2861 | + SERIALIZABLE_CLASS(FnMapPairsIterator); |
2862 | + |
2863 | + SERIALIZABLE_CLASS_CONSTRUCTOR2T(FnMapPairsIterator, |
2864 | + NaryBaseIterator<FnMapPairsIterator, FnMapPairsIteratorState>); |
2865 | + |
2866 | + void serialize( ::zorba::serialization::Archiver& ar); |
2867 | + |
2868 | + FnMapPairsIterator( |
2869 | + static_context* sctx, |
2870 | + const QueryLoc& loc, |
2871 | + std::vector<PlanIter_t>& children) |
2872 | + : |
2873 | + NaryBaseIterator<FnMapPairsIterator, FnMapPairsIteratorState>(sctx, loc, children) |
2874 | + {} |
2875 | + |
2876 | + virtual ~FnMapPairsIterator(); |
2877 | + |
2878 | + uint32_t getStateSizeOfSubtree() const; |
2879 | + |
2880 | + void accept(PlanIterVisitor& v) const; |
2881 | + |
2882 | + bool nextImpl(store::Item_t& result, PlanState& aPlanState) const; |
2883 | + |
2884 | + void openImpl(PlanState&, uint32_t&); |
2885 | +}; |
2886 | + |
2887 | + |
2888 | +/** |
2889 | + * |
2890 | + * Processes the supplied sequence from left to right or right to left, applying the supplied function repeatedly to each item in turn, together with an accumulated result value. |
2891 | + * |
2892 | + * Author: Zorba Team |
2893 | + */ |
2894 | +class FnFoldLeftIteratorState : public PlanIteratorState |
2895 | +{ |
2896 | +public: |
2897 | + PlanState* thePlanState; // |
2898 | + PlanIter_t thePlan; // |
2899 | + bool theIsOpen; // |
2900 | + uint32_t theUDFStateOffset; // |
2901 | + store::Item_t theFnItem; // |
2902 | + |
2903 | + FnFoldLeftIteratorState(); |
2904 | + |
2905 | + ~FnFoldLeftIteratorState(); |
2906 | + |
2907 | + void init(PlanState&); |
2908 | + void reset(PlanState&); |
2909 | +}; |
2910 | + |
2911 | +class FnFoldLeftIterator : public NaryBaseIterator<FnFoldLeftIterator, FnFoldLeftIteratorState> |
2912 | +{ |
2913 | +protected: |
2914 | + bool theIsFoldRight; // |
2915 | +public: |
2916 | + SERIALIZABLE_CLASS(FnFoldLeftIterator); |
2917 | + |
2918 | + SERIALIZABLE_CLASS_CONSTRUCTOR2T(FnFoldLeftIterator, |
2919 | + NaryBaseIterator<FnFoldLeftIterator, FnFoldLeftIteratorState>); |
2920 | + |
2921 | + void serialize( ::zorba::serialization::Archiver& ar); |
2922 | + |
2923 | + FnFoldLeftIterator( |
2924 | + static_context* sctx, |
2925 | + const QueryLoc& loc, |
2926 | + std::vector<PlanIter_t>& children, |
2927 | + bool aIsFoldRight) |
2928 | + : |
2929 | + NaryBaseIterator<FnFoldLeftIterator, FnFoldLeftIteratorState>(sctx, loc, children), |
2930 | + theIsFoldRight(aIsFoldRight) |
2931 | + {} |
2932 | + |
2933 | + virtual ~FnFoldLeftIterator(); |
2934 | + |
2935 | + uint32_t getStateSizeOfSubtree() const; |
2936 | + |
2937 | + void accept(PlanIterVisitor& v) const; |
2938 | + |
2939 | + bool nextImpl(store::Item_t& result, PlanState& aPlanState) const; |
2940 | + |
2941 | + void openImpl(PlanState&, uint32_t&); |
2942 | +}; |
2943 | + |
2944 | + |
2945 | +} |
2946 | +#endif |
2947 | +/* |
2948 | + * Local variables: |
2949 | + * mode: c++ |
2950 | + * End: |
2951 | + */ |
2952 | |
2953 | === removed directory 'src/runtime/spec/function_item' |
2954 | === removed file 'src/runtime/spec/function_item/function_item_iter.xml' |
2955 | --- src/runtime/spec/function_item/function_item_iter.xml 2013-03-13 04:02:45 +0000 |
2956 | +++ src/runtime/spec/function_item/function_item_iter.xml 1970-01-01 00:00:00 +0000 |
2957 | @@ -1,173 +0,0 @@ |
2958 | -<?xml version="1.0" encoding="UTF-8"?> |
2959 | - |
2960 | -<!-- |
2961 | -///////////////////////////////////////////////////////////////////////////////// |
2962 | -// Zorba Function Item // |
2963 | -///////////////////////////////////////////////////////////////////////////////// |
2964 | ---> |
2965 | -<zorba:iterators |
2966 | - xmlns:zorba="http://www.zorba-xquery.com" |
2967 | - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
2968 | - xsi:schemaLocation="http://www.zorba-xquery.com ../runtime.xsd"> |
2969 | - |
2970 | -<zorba:header> |
2971 | - <zorba:include form="Quoted">compiler/expression/expr_base.h</zorba:include> |
2972 | - <zorba:include form="Quoted">runtime/util/plan_wrapper_holder.h</zorba:include> |
2973 | - <zorba:include form="Quoted">types/typeimpl.h</zorba:include> |
2974 | - <zorba:include form="Quoted">functions/function.h</zorba:include> |
2975 | -</zorba:header> |
2976 | - |
2977 | -<zorba:source> |
2978 | - <zorba:include form="Quoted">context/static_context.h</zorba:include> |
2979 | - <zorba:include form="Quoted">compiler/api/compilercb.h</zorba:include> |
2980 | - <zorba:include form="Quoted">context/dynamic_context.h</zorba:include> |
2981 | - <zorba:include form="Quoted">store/api/temp_seq.h</zorba:include> |
2982 | -</zorba:source> |
2983 | - |
2984 | - |
2985 | - <!-- |
2986 | - /******************************************************************************* |
2987 | - fn:function-lookup |
2988 | - ********************************************************************************/ |
2989 | - --> |
2990 | - <zorba:iterator name="FunctionLookupIterator"> |
2991 | - <zorba:description author="Zorba Team"> |
2992 | - Returns the function having a given name and arity, if there is one. |
2993 | - </zorba:description> |
2994 | - |
2995 | - <zorba:member type="CompilerCB*" name="theCompilerCB"/> |
2996 | - |
2997 | - <zorba:constructor> |
2998 | - <zorba:parameter type="CompilerCB*" name="aCompilerCB"/> |
2999 | - </zorba:constructor> |
3000 | - |
3001 | - <zorba:function generateCodegen="false"> |
3002 | - |
3003 | - <zorba:signature localname="function-lookup" prefix="fn" version="3.0"> |
3004 | - <zorba:param>xs:QName</zorba:param> |
3005 | - <zorba:param>xs:integer</zorba:param> |
3006 | - <zorba:output>function()?</zorba:output> |
3007 | - </zorba:signature> |
3008 | - |
3009 | - </zorba:function> |
3010 | - |
3011 | - </zorba:iterator> |
3012 | - |
3013 | - |
3014 | - <!-- |
3015 | - /******************************************************************************* |
3016 | - fn:function-name |
3017 | - ********************************************************************************/ |
3018 | - --> |
3019 | - <zorba:iterator name="FunctionNameIterator"> |
3020 | - <zorba:description author="Zorba Team"> |
3021 | - Returns the name of the function identified by a function item. |
3022 | - </zorba:description> |
3023 | - |
3024 | - <zorba:function > |
3025 | - |
3026 | - <zorba:signature localname="function-name" prefix="fn" version="3.0"> |
3027 | - <zorba:param>function()</zorba:param> |
3028 | - <zorba:output>xs:QName?</zorba:output> |
3029 | - </zorba:signature> |
3030 | - |
3031 | - </zorba:function> |
3032 | - |
3033 | - </zorba:iterator> |
3034 | - |
3035 | - <!-- |
3036 | - /******************************************************************************* |
3037 | - fn:function-arity |
3038 | - ********************************************************************************/ |
3039 | - --> |
3040 | - <zorba:iterator name="FunctionArityIterator"> |
3041 | - <zorba:description author="Zorba Team"> |
3042 | - Returns the arity of the function identified by a function item. |
3043 | - </zorba:description> |
3044 | - |
3045 | - <zorba:function > |
3046 | - |
3047 | - <zorba:signature localname="function-arity" prefix="fn" version="3.0"> |
3048 | - <zorba:param>function()</zorba:param> |
3049 | - <zorba:output>xs:integer</zorba:output> |
3050 | - </zorba:signature> |
3051 | - |
3052 | - </zorba:function> |
3053 | - |
3054 | - </zorba:iterator> |
3055 | - |
3056 | - <!-- |
3057 | - /******************************************************************************* |
3058 | - fn:map-pairs |
3059 | - ********************************************************************************/ |
3060 | - --> |
3061 | - <zorba:iterator name="FnMapPairsIterator" generateOpenImpl="true" generateGetStateSize="true"> |
3062 | - <zorba:description author="Zorba Team"> |
3063 | - Applies the function item $f to successive pairs of items taken one from $seq1 and one from $seq2, returning the concatenation of the resulting sequences in order. |
3064 | - </zorba:description> |
3065 | - |
3066 | - <zorba:function generateDECL="false"> |
3067 | - <zorba:signature localname="map-pairs" prefix="fn" version="3.0"> |
3068 | - <zorba:param>function()*</zorba:param> |
3069 | - <zorba:param>item()*</zorba:param> |
3070 | - <zorba:param>item()*</zorba:param> |
3071 | - <zorba:output>item()*</zorba:output> |
3072 | - </zorba:signature> |
3073 | - </zorba:function> |
3074 | - |
3075 | - <zorba:state generateInit="false" generateReset="false" generateDestructor="false"> |
3076 | - <zorba:member type="PlanState*" name="thePlanState"/> |
3077 | - <zorba:member type="PlanIter_t" name="thePlan"/> |
3078 | - <zorba:member type="bool" name="theIsOpen"/> |
3079 | - <zorba:member type="uint32_t" name="theUDFStateOffset"/> |
3080 | - <zorba:member type="store::Item_t" name="theFnItem"/> |
3081 | - </zorba:state> |
3082 | - |
3083 | - </zorba:iterator> |
3084 | - |
3085 | - <!-- |
3086 | - /******************************************************************************* |
3087 | - fn:fold-left |
3088 | - fn:fold-right |
3089 | - ********************************************************************************/ |
3090 | - --> |
3091 | - <zorba:iterator name="FnFoldLeftIterator" generateOpenImpl="true" generateGetStateSize="true"> |
3092 | - <zorba:description author="Zorba Team"> |
3093 | - Processes the supplied sequence from left to right or right to left, applying the supplied function repeatedly to each item in turn, together with an accumulated result value. |
3094 | - </zorba:description> |
3095 | - |
3096 | - <zorba:member type="bool" name="theIsFoldRight"/> |
3097 | - |
3098 | - <zorba:constructor> |
3099 | - <zorba:parameter type="bool" name="aIsFoldRight"/> |
3100 | - </zorba:constructor> |
3101 | - |
3102 | - <zorba:function generateDECL="false" generateCodegen="false"> |
3103 | - <zorba:signature localname="fold-left" prefix="fn" version="3.0"> |
3104 | - <zorba:param>function()*</zorba:param> |
3105 | - <zorba:param>item()*</zorba:param> |
3106 | - <zorba:param>item()*</zorba:param> |
3107 | - <zorba:output>item()*</zorba:output> |
3108 | - </zorba:signature> |
3109 | - </zorba:function> |
3110 | - |
3111 | - <zorba:function generateDECL="false" generateCodegen="false"> |
3112 | - <zorba:signature localname="fold-right" prefix="fn" version="3.0"> |
3113 | - <zorba:param>function()*</zorba:param> |
3114 | - <zorba:param>item()*</zorba:param> |
3115 | - <zorba:param>item()*</zorba:param> |
3116 | - <zorba:output>item()*</zorba:output> |
3117 | - </zorba:signature> |
3118 | - </zorba:function> |
3119 | - |
3120 | - <zorba:state generateInit="false" generateReset="false" generateDestructor="false"> |
3121 | - <zorba:member type="PlanState*" name="thePlanState"/> |
3122 | - <zorba:member type="PlanIter_t" name="thePlan"/> |
3123 | - <zorba:member type="bool" name="theIsOpen"/> |
3124 | - <zorba:member type="uint32_t" name="theUDFStateOffset"/> |
3125 | - <zorba:member type="store::Item_t" name="theFnItem"/> |
3126 | - </zorba:state> |
3127 | - |
3128 | - </zorba:iterator> |
3129 | - |
3130 | -</zorba:iterators> |
3131 | |
3132 | === added directory 'src/runtime/spec/hof' |
3133 | === added file 'src/runtime/spec/hof/fn_hof_functions.xml' |
3134 | --- src/runtime/spec/hof/fn_hof_functions.xml 1970-01-01 00:00:00 +0000 |
3135 | +++ src/runtime/spec/hof/fn_hof_functions.xml 2013-03-27 00:48:21 +0000 |
3136 | @@ -0,0 +1,173 @@ |
3137 | +<?xml version="1.0" encoding="UTF-8"?> |
3138 | + |
3139 | +<!-- |
3140 | +///////////////////////////////////////////////////////////////////////////////// |
3141 | +// Zorba Function Item // |
3142 | +///////////////////////////////////////////////////////////////////////////////// |
3143 | +--> |
3144 | +<zorba:iterators |
3145 | + xmlns:zorba="http://www.zorba-xquery.com" |
3146 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
3147 | + xsi:schemaLocation="http://www.zorba-xquery.com ../runtime.xsd"> |
3148 | + |
3149 | +<zorba:header> |
3150 | + <zorba:include form="Quoted">compiler/expression/expr_base.h</zorba:include> |
3151 | + <zorba:include form="Quoted">runtime/util/plan_wrapper_holder.h</zorba:include> |
3152 | + <zorba:include form="Quoted">types/typeimpl.h</zorba:include> |
3153 | + <zorba:include form="Quoted">functions/function.h</zorba:include> |
3154 | +</zorba:header> |
3155 | + |
3156 | +<zorba:source> |
3157 | + <zorba:include form="Quoted">context/static_context.h</zorba:include> |
3158 | + <zorba:include form="Quoted">compiler/api/compilercb.h</zorba:include> |
3159 | + <zorba:include form="Quoted">context/dynamic_context.h</zorba:include> |
3160 | + <zorba:include form="Quoted">store/api/temp_seq.h</zorba:include> |
3161 | +</zorba:source> |
3162 | + |
3163 | + |
3164 | + <!-- |
3165 | + /******************************************************************************* |
3166 | + fn:function-lookup |
3167 | + ********************************************************************************/ |
3168 | + --> |
3169 | + <zorba:iterator name="FunctionLookupIterator"> |
3170 | + <zorba:description author="Zorba Team"> |
3171 | + Returns the function having a given name and arity, if there is one. |
3172 | + </zorba:description> |
3173 | + |
3174 | + <zorba:member type="CompilerCB*" name="theCompilerCB"/> |
3175 | + |
3176 | + <zorba:constructor> |
3177 | + <zorba:parameter type="CompilerCB*" name="aCompilerCB"/> |
3178 | + </zorba:constructor> |
3179 | + |
3180 | + <zorba:function generateCodegen="false"> |
3181 | + |
3182 | + <zorba:signature localname="function-lookup" prefix="fn" version="3.0"> |
3183 | + <zorba:param>xs:QName</zorba:param> |
3184 | + <zorba:param>xs:integer</zorba:param> |
3185 | + <zorba:output>function()?</zorba:output> |
3186 | + </zorba:signature> |
3187 | + |
3188 | + </zorba:function> |
3189 | + |
3190 | + </zorba:iterator> |
3191 | + |
3192 | + |
3193 | + <!-- |
3194 | + /******************************************************************************* |
3195 | + fn:function-name |
3196 | + ********************************************************************************/ |
3197 | + --> |
3198 | + <zorba:iterator name="FunctionNameIterator"> |
3199 | + <zorba:description author="Zorba Team"> |
3200 | + Returns the name of the function identified by a function item. |
3201 | + </zorba:description> |
3202 | + |
3203 | + <zorba:function > |
3204 | + |
3205 | + <zorba:signature localname="function-name" prefix="fn" version="3.0"> |
3206 | + <zorba:param>function()</zorba:param> |
3207 | + <zorba:output>xs:QName?</zorba:output> |
3208 | + </zorba:signature> |
3209 | + |
3210 | + </zorba:function> |
3211 | + |
3212 | + </zorba:iterator> |
3213 | + |
3214 | + <!-- |
3215 | + /******************************************************************************* |
3216 | + fn:function-arity |
3217 | + ********************************************************************************/ |
3218 | + --> |
3219 | + <zorba:iterator name="FunctionArityIterator"> |
3220 | + <zorba:description author="Zorba Team"> |
3221 | + Returns the arity of the function identified by a function item. |
3222 | + </zorba:description> |
3223 | + |
3224 | + <zorba:function > |
3225 | + |
3226 | + <zorba:signature localname="function-arity" prefix="fn" version="3.0"> |
3227 | + <zorba:param>function()</zorba:param> |
3228 | + <zorba:output>xs:integer</zorba:output> |
3229 | + </zorba:signature> |
3230 | + |
3231 | + </zorba:function> |
3232 | + |
3233 | + </zorba:iterator> |
3234 | + |
3235 | + <!-- |
3236 | + /******************************************************************************* |
3237 | + fn:map-pairs |
3238 | + ********************************************************************************/ |
3239 | + --> |
3240 | + <zorba:iterator name="FnMapPairsIterator" generateOpenImpl="true" generateGetStateSize="true"> |
3241 | + <zorba:description author="Zorba Team"> |
3242 | + Applies the function item $f to successive pairs of items taken one from $seq1 and one from $seq2, returning the concatenation of the resulting sequences in order. |
3243 | + </zorba:description> |
3244 | + |
3245 | + <zorba:function generateDECL="false"> |
3246 | + <zorba:signature localname="map-pairs" prefix="fn" version="3.0"> |
3247 | + <zorba:param>function()*</zorba:param> |
3248 | + <zorba:param>item()*</zorba:param> |
3249 | + <zorba:param>item()*</zorba:param> |
3250 | + <zorba:output>item()*</zorba:output> |
3251 | + </zorba:signature> |
3252 | + </zorba:function> |
3253 | + |
3254 | + <zorba:state generateInit="false" generateReset="false" generateDestructor="false"> |
3255 | + <zorba:member type="PlanState*" name="thePlanState"/> |
3256 | + <zorba:member type="PlanIter_t" name="thePlan"/> |
3257 | + <zorba:member type="bool" name="theIsOpen"/> |
3258 | + <zorba:member type="uint32_t" name="theUDFStateOffset"/> |
3259 | + <zorba:member type="store::Item_t" name="theFnItem"/> |
3260 | + </zorba:state> |
3261 | + |
3262 | + </zorba:iterator> |
3263 | + |
3264 | + <!-- |
3265 | + /******************************************************************************* |
3266 | + fn:fold-left |
3267 | + fn:fold-right |
3268 | + ********************************************************************************/ |
3269 | + --> |
3270 | + <zorba:iterator name="FnFoldLeftIterator" generateOpenImpl="true" generateGetStateSize="true"> |
3271 | + <zorba:description author="Zorba Team"> |
3272 | + Processes the supplied sequence from left to right or right to left, applying the supplied function repeatedly to each item in turn, together with an accumulated result value. |
3273 | + </zorba:description> |
3274 | + |
3275 | + <zorba:member type="bool" name="theIsFoldRight"/> |
3276 | + |
3277 | + <zorba:constructor> |
3278 | + <zorba:parameter type="bool" name="aIsFoldRight"/> |
3279 | + </zorba:constructor> |
3280 | + |
3281 | + <zorba:function generateDECL="false" generateCodegen="false"> |
3282 | + <zorba:signature localname="fold-left" prefix="fn" version="3.0"> |
3283 | + <zorba:param>function()*</zorba:param> |
3284 | + <zorba:param>item()*</zorba:param> |
3285 | + <zorba:param>item()*</zorba:param> |
3286 | + <zorba:output>item()*</zorba:output> |
3287 | + </zorba:signature> |
3288 | + </zorba:function> |
3289 | + |
3290 | + <zorba:function generateDECL="false" generateCodegen="false"> |
3291 | + <zorba:signature localname="fold-right" prefix="fn" version="3.0"> |
3292 | + <zorba:param>function()*</zorba:param> |
3293 | + <zorba:param>item()*</zorba:param> |
3294 | + <zorba:param>item()*</zorba:param> |
3295 | + <zorba:output>item()*</zorba:output> |
3296 | + </zorba:signature> |
3297 | + </zorba:function> |
3298 | + |
3299 | + <zorba:state generateInit="false" generateReset="false" generateDestructor="false"> |
3300 | + <zorba:member type="PlanState*" name="thePlanState"/> |
3301 | + <zorba:member type="PlanIter_t" name="thePlan"/> |
3302 | + <zorba:member type="bool" name="theIsOpen"/> |
3303 | + <zorba:member type="uint32_t" name="theUDFStateOffset"/> |
3304 | + <zorba:member type="store::Item_t" name="theFnItem"/> |
3305 | + </zorba:state> |
3306 | + |
3307 | + </zorba:iterator> |
3308 | + |
3309 | +</zorba:iterators> |
3310 | |
3311 | === modified file 'src/runtime/visitors/pregenerated/printer_visitor.cpp' |
3312 | --- src/runtime/visitors/pregenerated/printer_visitor.cpp 2013-03-15 08:22:41 +0000 |
3313 | +++ src/runtime/visitors/pregenerated/printer_visitor.cpp 2013-03-27 00:48:21 +0000 |
3314 | @@ -49,7 +49,7 @@ |
3315 | #include "runtime/fetch/fetch.h" |
3316 | #include "runtime/fnput/fnput.h" |
3317 | #include "runtime/full_text/ft_module.h" |
3318 | -#include "runtime/function_item/function_item_iter.h" |
3319 | +#include "runtime/hof/fn_hof_functions.h" |
3320 | #include "runtime/indexing/ic_ddl.h" |
3321 | #include "runtime/indexing/index_func.h" |
3322 | #include "runtime/introspection/sctx.h" |
Validation queue starting for merge proposal. zorbatest. lambda. nu:8080/ remotequeue/ hof-next- 2013-03- 27T01-06- 21.343Z/ log.html
Log at: http://