zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #19573
[Merge] lp:~zorba-coders/zorba/hof-next into lp:zorba
Markos Zaharioudakis has proposed merging lp:~zorba-coders/zorba/hof-next into lp:zorba.
Commit message:
renamed function_item_iter.xml to fn_hof_functions.xml and moved to the hof dir
Requested reviews:
Markos Zaharioudakis (markos-za)
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/hof-next/+merge/155642
renamed function_item_iter.xml to fn_hof_functions.xml and moved to the hof dir
--
https://code.launchpad.net/~zorba-coders/zorba/hof-next/+merge/155642
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/compiler/codegen/plan_visitor.cpp'
--- src/compiler/codegen/plan_visitor.cpp 2013-03-26 23:32:03 +0000
+++ src/compiler/codegen/plan_visitor.cpp 2013-03-27 00:48:21 +0000
@@ -93,7 +93,7 @@
#endif
#include "runtime/eval/eval.h"
#include "runtime/hof/function_item.h"
-#include "runtime/function_item/function_item_iter.h"
+#include "runtime/hof/fn_hof_functions.h"
#include "runtime/hof/dynamic_fncall_iterator.h"
#include "runtime/misc/materialize.h"
=== modified file 'src/functions/CMakeLists.txt'
--- src/functions/CMakeLists.txt 2013-03-04 21:00:58 +0000
+++ src/functions/CMakeLists.txt 2013-03-27 00:48:21 +0000
@@ -86,7 +86,7 @@
func_serialize_impl.cpp
func_parse_fragment_impl.cpp
func_schema_impl.cpp
- func_hof_impl.cpp
+ func_fn_hof_functions_impl.cpp
)
IF (ZORBA_WITH_JSON)
=== added file 'src/functions/func_fn_hof_functions_impl.cpp'
--- src/functions/func_fn_hof_functions_impl.cpp 1970-01-01 00:00:00 +0000
+++ src/functions/func_fn_hof_functions_impl.cpp 2013-03-27 00:48:21 +0000
@@ -0,0 +1,230 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "stdafx.h"
+
+#include "common/shared_types.h"
+#include "types/typeops.h"
+
+#include "functions/function.h"
+#include "functions/function_impl.h"
+#include "functions/func_fn_hof_functions.h"
+
+#include "runtime/hof/fn_hof_functions.h"
+
+#include "system/globalenv.h"
+
+
+namespace zorba
+{
+
+/*******************************************************************************
+
+********************************************************************************/
+class fn_map_3_0 : public function
+{
+public:
+ fn_map_3_0(const signature& sig, FunctionConsts::FunctionKind kind)
+ :
+ function(sig, kind)
+ {
+ theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+ }
+
+ bool accessesDynCtx() const { return true; }
+
+ PlanIter_t codegen(CompilerCB* cb,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ expr& ann) const
+ {
+ return NULL;
+ }
+};
+
+
+/*******************************************************************************
+
+********************************************************************************/
+class fn_filter : public function
+{
+public:
+ fn_filter(const signature& sig, FunctionConsts::FunctionKind kind)
+ :
+ function(sig, kind)
+ {
+ theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+ }
+
+ bool accessesDynCtx() const { return true; }
+
+ PlanIter_t codegen(CompilerCB* ccb,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ expr& ann) const
+ {
+ return NULL;
+ }
+};
+
+
+/*******************************************************************************
+
+********************************************************************************/
+PlanIter_t fn_fold_left_3_0::codegen(
+ CompilerCB* ccb,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ expr& ann) const
+{
+ return new FnFoldLeftIterator(sctx, loc, argv, false);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+PlanIter_t fn_fold_right_3_0::codegen(
+ CompilerCB* ccb,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ expr& ann) const
+{
+ return new FnFoldLeftIterator(sctx, loc, argv, true);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+PlanIter_t fn_function_lookup_3_0::codegen(
+ CompilerCB* ccb,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ expr& ann) const
+{
+ return new FunctionLookupIterator(sctx, loc, argv, ccb);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+void populate_context_hof_impl(static_context* sctx)
+{
+ {
+ std::vector<xqtref_t> args;
+ args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE);
+
+ xqtref_t hofParamType = GENV_TYPESYSTEM.create_function_type(
+ args,
+ GENV_TYPESYSTEM.ITEM_TYPE_STAR,
+ TypeConstants::QUANT_ONE);
+
+ DECL_WITH_KIND(sctx,
+ fn_map_3_0,
+ (createQName(static_context::W3C_FN_NS, "", "map"),
+ hofParamType,
+ GENV_TYPESYSTEM.ITEM_TYPE_STAR,
+ GENV_TYPESYSTEM.ITEM_TYPE_STAR),
+ FunctionConsts::FN_MAP_2);
+ }
+
+ {
+ std::vector<xqtref_t> args;
+ args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE);
+
+ xqtref_t hofParamType = GENV_TYPESYSTEM.create_function_type(
+ args,
+ GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE,
+ TypeConstants::QUANT_ONE);
+
+ DECL_WITH_KIND(sctx,
+ fn_filter,
+ (createQName(static_context::W3C_FN_NS, "", "filter"),
+ hofParamType,
+ GENV_TYPESYSTEM.ITEM_TYPE_STAR,
+ GENV_TYPESYSTEM.ITEM_TYPE_STAR),
+ FunctionConsts::FN_FILTER_2);
+ }
+
+ {
+ std::vector<xqtref_t> args;
+ args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE);
+ args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE);
+
+ xqtref_t hofParamType = GENV_TYPESYSTEM.create_function_type(
+ args,
+ GENV_TYPESYSTEM.ITEM_TYPE_STAR,
+ TypeConstants::QUANT_ONE);
+
+ DECL_WITH_KIND(sctx,
+ fn_map_pairs_3_0,
+ (createQName(static_context::W3C_FN_NS, "", "map-pairs"),
+ hofParamType,
+ GENV_TYPESYSTEM.ITEM_TYPE_STAR,
+ GENV_TYPESYSTEM.ITEM_TYPE_STAR,
+ GENV_TYPESYSTEM.ITEM_TYPE_STAR),
+ FunctionConsts::FN_MAP_PAIRS_3);
+ }
+
+ {
+ std::vector<xqtref_t> args;
+ xqtref_t hofParamType;
+
+ args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_STAR);
+ args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE);
+ hofParamType = GENV_TYPESYSTEM.create_function_type(
+ args,
+ GENV_TYPESYSTEM.ITEM_TYPE_STAR,
+ TypeConstants::QUANT_ONE);
+
+ DECL_WITH_KIND(sctx,
+ fn_fold_left_3_0,
+ (createQName(static_context::W3C_FN_NS, "", "fold-left"),
+ hofParamType,
+ GENV_TYPESYSTEM.ITEM_TYPE_STAR,
+ GENV_TYPESYSTEM.ITEM_TYPE_STAR,
+ GENV_TYPESYSTEM.ITEM_TYPE_STAR),
+ FunctionConsts::FN_FOLD_LEFT_3);
+
+ args.clear();
+ args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE);
+ args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_STAR);
+ hofParamType = GENV_TYPESYSTEM.create_function_type(
+ args,
+ GENV_TYPESYSTEM.ITEM_TYPE_STAR,
+ TypeConstants::QUANT_ONE);
+
+ DECL_WITH_KIND(sctx,
+ fn_fold_right_3_0,
+ (createQName(static_context::W3C_FN_NS, "", "fold-right"),
+ hofParamType,
+ GENV_TYPESYSTEM.ITEM_TYPE_STAR,
+ GENV_TYPESYSTEM.ITEM_TYPE_STAR,
+ GENV_TYPESYSTEM.ITEM_TYPE_STAR),
+ FunctionConsts::FN_FOLD_RIGHT_3);
+ }
+
+}
+
+}
+
+/* vim:set et sw=2 ts=2: */
=== added file 'src/functions/func_fn_hof_functions_impl.h'
--- src/functions/func_fn_hof_functions_impl.h 1970-01-01 00:00:00 +0000
+++ src/functions/func_fn_hof_functions_impl.h 2013-03-27 00:48:21 +0000
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+#ifndef ZORBA_FUNCTIONS_HOF_IMPL_H
+#define ZORBA_FUNCTIONS_HOF_IMPL_H
+
+
+#include "common/shared_types.h"
+#include "functions/function.h"
+#include "functions/function_impl.h"
+#include "functions/function_consts.h"
+
+
+namespace zorba {
+
+
+void populate_context_hof_impl(static_context* sctx);
+
+
+} //namespace zorba
+
+
+#endif
+/* vim:set et sw=2 ts=2: */
+
=== removed file 'src/functions/func_hof_impl.cpp'
--- src/functions/func_hof_impl.cpp 2013-03-13 04:02:45 +0000
+++ src/functions/func_hof_impl.cpp 1970-01-01 00:00:00 +0000
@@ -1,230 +0,0 @@
-/*
- * Copyright 2006-2008 The FLWOR Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "stdafx.h"
-
-#include "common/shared_types.h"
-#include "types/typeops.h"
-
-#include "functions/function.h"
-#include "functions/function_impl.h"
-#include "functions/func_function_item_iter.h"
-
-#include "runtime/function_item/function_item_iter.h"
-
-#include "system/globalenv.h"
-
-
-namespace zorba
-{
-
-/*******************************************************************************
-
-********************************************************************************/
-class fn_map_3_0 : public function
-{
-public:
- fn_map_3_0(const signature& sig, FunctionConsts::FunctionKind kind)
- :
- function(sig, kind)
- {
- theXQueryVersion = StaticContextConsts::xquery_version_3_0;
- }
-
- bool accessesDynCtx() const { return true; }
-
- PlanIter_t codegen(CompilerCB* cb,
- static_context* sctx,
- const QueryLoc& loc,
- std::vector<PlanIter_t>& argv,
- expr& ann) const
- {
- return NULL;
- }
-};
-
-
-/*******************************************************************************
-
-********************************************************************************/
-class fn_filter : public function
-{
-public:
- fn_filter(const signature& sig, FunctionConsts::FunctionKind kind)
- :
- function(sig, kind)
- {
- theXQueryVersion = StaticContextConsts::xquery_version_3_0;
- }
-
- bool accessesDynCtx() const { return true; }
-
- PlanIter_t codegen(CompilerCB* ccb,
- static_context* sctx,
- const QueryLoc& loc,
- std::vector<PlanIter_t>& argv,
- expr& ann) const
- {
- return NULL;
- }
-};
-
-
-/*******************************************************************************
-
-********************************************************************************/
-PlanIter_t fn_fold_left_3_0::codegen(
- CompilerCB* ccb,
- static_context* sctx,
- const QueryLoc& loc,
- std::vector<PlanIter_t>& argv,
- expr& ann) const
-{
- return new FnFoldLeftIterator(sctx, loc, argv, false);
-}
-
-
-/*******************************************************************************
-
-********************************************************************************/
-PlanIter_t fn_fold_right_3_0::codegen(
- CompilerCB* ccb,
- static_context* sctx,
- const QueryLoc& loc,
- std::vector<PlanIter_t>& argv,
- expr& ann) const
-{
- return new FnFoldLeftIterator(sctx, loc, argv, true);
-}
-
-
-/*******************************************************************************
-
-********************************************************************************/
-PlanIter_t fn_function_lookup_3_0::codegen(
- CompilerCB* ccb,
- static_context* sctx,
- const QueryLoc& loc,
- std::vector<PlanIter_t>& argv,
- expr& ann) const
-{
- return new FunctionLookupIterator(sctx, loc, argv, ccb);
-}
-
-
-/*******************************************************************************
-
-********************************************************************************/
-void populate_context_hof_impl(static_context* sctx)
-{
- {
- std::vector<xqtref_t> args;
- args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE);
-
- xqtref_t hofParamType = GENV_TYPESYSTEM.create_function_type(
- args,
- GENV_TYPESYSTEM.ITEM_TYPE_STAR,
- TypeConstants::QUANT_ONE);
-
- DECL_WITH_KIND(sctx,
- fn_map_3_0,
- (createQName(static_context::W3C_FN_NS, "", "map"),
- hofParamType,
- GENV_TYPESYSTEM.ITEM_TYPE_STAR,
- GENV_TYPESYSTEM.ITEM_TYPE_STAR),
- FunctionConsts::FN_MAP_2);
- }
-
- {
- std::vector<xqtref_t> args;
- args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE);
-
- xqtref_t hofParamType = GENV_TYPESYSTEM.create_function_type(
- args,
- GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE,
- TypeConstants::QUANT_ONE);
-
- DECL_WITH_KIND(sctx,
- fn_filter,
- (createQName(static_context::W3C_FN_NS, "", "filter"),
- hofParamType,
- GENV_TYPESYSTEM.ITEM_TYPE_STAR,
- GENV_TYPESYSTEM.ITEM_TYPE_STAR),
- FunctionConsts::FN_FILTER_2);
- }
-
- {
- std::vector<xqtref_t> args;
- args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE);
- args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE);
-
- xqtref_t hofParamType = GENV_TYPESYSTEM.create_function_type(
- args,
- GENV_TYPESYSTEM.ITEM_TYPE_STAR,
- TypeConstants::QUANT_ONE);
-
- DECL_WITH_KIND(sctx,
- fn_map_pairs_3_0,
- (createQName(static_context::W3C_FN_NS, "", "map-pairs"),
- hofParamType,
- GENV_TYPESYSTEM.ITEM_TYPE_STAR,
- GENV_TYPESYSTEM.ITEM_TYPE_STAR,
- GENV_TYPESYSTEM.ITEM_TYPE_STAR),
- FunctionConsts::FN_MAP_PAIRS_3);
- }
-
- {
- std::vector<xqtref_t> args;
- xqtref_t hofParamType;
-
- args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_STAR);
- args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE);
- hofParamType = GENV_TYPESYSTEM.create_function_type(
- args,
- GENV_TYPESYSTEM.ITEM_TYPE_STAR,
- TypeConstants::QUANT_ONE);
-
- DECL_WITH_KIND(sctx,
- fn_fold_left_3_0,
- (createQName(static_context::W3C_FN_NS, "", "fold-left"),
- hofParamType,
- GENV_TYPESYSTEM.ITEM_TYPE_STAR,
- GENV_TYPESYSTEM.ITEM_TYPE_STAR,
- GENV_TYPESYSTEM.ITEM_TYPE_STAR),
- FunctionConsts::FN_FOLD_LEFT_3);
-
- args.clear();
- args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE);
- args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_STAR);
- hofParamType = GENV_TYPESYSTEM.create_function_type(
- args,
- GENV_TYPESYSTEM.ITEM_TYPE_STAR,
- TypeConstants::QUANT_ONE);
-
- DECL_WITH_KIND(sctx,
- fn_fold_right_3_0,
- (createQName(static_context::W3C_FN_NS, "", "fold-right"),
- hofParamType,
- GENV_TYPESYSTEM.ITEM_TYPE_STAR,
- GENV_TYPESYSTEM.ITEM_TYPE_STAR,
- GENV_TYPESYSTEM.ITEM_TYPE_STAR),
- FunctionConsts::FN_FOLD_RIGHT_3);
- }
-
-}
-
-}
-
-/* vim:set et sw=2 ts=2: */
=== removed file 'src/functions/func_hof_impl.h'
--- src/functions/func_hof_impl.h 2012-11-26 21:22:19 +0000
+++ src/functions/func_hof_impl.h 1970-01-01 00:00:00 +0000
@@ -1,38 +0,0 @@
-/*
- * Copyright 2006-2012 The FLWOR Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-#ifndef ZORBA_FUNCTIONS_HOF_IMPL_H
-#define ZORBA_FUNCTIONS_HOF_IMPL_H
-
-
-#include "common/shared_types.h"
-#include "functions/function.h"
-#include "functions/function_impl.h"
-#include "functions/function_consts.h"
-
-
-namespace zorba {
-
-
-void populate_context_hof_impl(static_context* sctx);
-
-
-} //namespace zorba
-
-
-#endif
-/* vim:set et sw=2 ts=2: */
-
=== modified file 'src/functions/library.cpp'
--- src/functions/library.cpp 2013-03-04 21:00:58 +0000
+++ src/functions/library.cpp 2013-03-27 00:48:21 +0000
@@ -79,8 +79,8 @@
#include "runtime/full_text/ft_module_impl.h"
#endif /* ZORBA_NO_FULL_TEXT */
-#include "functions/func_function_item_iter.h"
-#include "functions/func_hof_impl.h"
+#include "functions/func_fn_hof_functions.h"
+#include "functions/func_fn_hof_functions_impl.h"
#include "zorbaserialization/archiver.h"
@@ -152,7 +152,7 @@
populate_context_sequences(sctx);
populate_context_sequences_impl(sctx);
populate_context_xqdoc(sctx);
- populate_context_function_item_iter(sctx);
+ populate_context_fn_hof_functions(sctx);
populate_context_hof_impl(sctx);
populate_context_documents(sctx);
populate_context_maps(sctx);
=== added file 'src/functions/pregenerated/func_fn_hof_functions.cpp'
--- src/functions/pregenerated/func_fn_hof_functions.cpp 1970-01-01 00:00:00 +0000
+++ src/functions/pregenerated/func_fn_hof_functions.cpp 2013-03-27 00:48:21 +0000
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// ******************************************
+// * *
+// * THIS IS A GENERATED FILE. DO NOT EDIT! *
+// * SEE .xml FILE WITH SAME NAME *
+// * *
+// ******************************************
+
+
+#include "stdafx.h"
+#include "runtime/hof/fn_hof_functions.h"
+#include "functions/func_fn_hof_functions.h"
+
+
+namespace zorba{
+
+
+
+
+PlanIter_t fn_function_name_3_0::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ expr& ann) const
+{
+ return new FunctionNameIterator(sctx, loc, argv);
+}
+
+PlanIter_t fn_function_arity_3_0::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ expr& ann) const
+{
+ return new FunctionArityIterator(sctx, loc, argv);
+}
+
+PlanIter_t fn_map_pairs_3_0::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ expr& ann) const
+{
+ return new FnMapPairsIterator(sctx, loc, argv);
+}
+
+
+
+void populate_context_fn_hof_functions(static_context* sctx)
+{
+
+
+ {
+ DECL_WITH_KIND(sctx, fn_function_lookup_3_0,
+ (createQName("http://www.w3.org/2005/xpath-functions","","function-lookup"),
+ GENV_TYPESYSTEM.QNAME_TYPE_ONE,
+ GENV_TYPESYSTEM.INTEGER_TYPE_ONE,
+ GENV_TYPESYSTEM.ANY_FUNCTION_TYPE_QUESTION),
+ FunctionConsts::FN_FUNCTION_LOOKUP_2);
+
+ }
+
+
+
+
+ {
+ DECL_WITH_KIND(sctx, fn_function_name_3_0,
+ (createQName("http://www.w3.org/2005/xpath-functions","","function-name"),
+ GENV_TYPESYSTEM.ANY_FUNCTION_TYPE_ONE,
+ GENV_TYPESYSTEM.QNAME_TYPE_QUESTION),
+ FunctionConsts::FN_FUNCTION_NAME_1);
+
+ }
+
+
+
+
+ {
+ DECL_WITH_KIND(sctx, fn_function_arity_3_0,
+ (createQName("http://www.w3.org/2005/xpath-functions","","function-arity"),
+ GENV_TYPESYSTEM.ANY_FUNCTION_TYPE_ONE,
+ GENV_TYPESYSTEM.INTEGER_TYPE_ONE),
+ FunctionConsts::FN_FUNCTION_ARITY_1);
+
+ }
+
+}
+
+
+}
+
+
+
=== added file 'src/functions/pregenerated/func_fn_hof_functions.h'
--- src/functions/pregenerated/func_fn_hof_functions.h 1970-01-01 00:00:00 +0000
+++ src/functions/pregenerated/func_fn_hof_functions.h 2013-03-27 00:48:21 +0000
@@ -0,0 +1,139 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// ******************************************
+// * *
+// * THIS IS A GENERATED FILE. DO NOT EDIT! *
+// * SEE .xml FILE WITH SAME NAME *
+// * *
+// ******************************************
+
+
+#ifndef ZORBA_FUNCTIONS_FN_HOF_FUNCTIONS_H
+#define ZORBA_FUNCTIONS_FN_HOF_FUNCTIONS_H
+
+
+#include "common/shared_types.h"
+#include "functions/function_impl.h"
+
+
+namespace zorba {
+
+
+void populate_context_fn_hof_functions(static_context* sctx);
+
+
+
+
+//fn:function-lookup
+class fn_function_lookup_3_0 : public function
+{
+public:
+ fn_function_lookup_3_0(const signature& sig, FunctionConsts::FunctionKind kind)
+ :
+ function(sig, kind)
+ {
+theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+ }
+
+ CODEGEN_DECL();
+};
+
+
+//fn:function-name
+class fn_function_name_3_0 : public function
+{
+public:
+ fn_function_name_3_0(const signature& sig, FunctionConsts::FunctionKind kind)
+ :
+ function(sig, kind)
+ {
+theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+ }
+
+ CODEGEN_DECL();
+};
+
+
+//fn:function-arity
+class fn_function_arity_3_0 : public function
+{
+public:
+ fn_function_arity_3_0(const signature& sig, FunctionConsts::FunctionKind kind)
+ :
+ function(sig, kind)
+ {
+theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+ }
+
+ CODEGEN_DECL();
+};
+
+
+//fn:map-pairs
+class fn_map_pairs_3_0 : public function
+{
+public:
+ fn_map_pairs_3_0(const signature& sig, FunctionConsts::FunctionKind kind)
+ :
+ function(sig, kind)
+ {
+theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+ }
+
+ CODEGEN_DECL();
+};
+
+
+//fn:fold-left
+class fn_fold_left_3_0 : public function
+{
+public:
+ fn_fold_left_3_0(const signature& sig, FunctionConsts::FunctionKind kind)
+ :
+ function(sig, kind)
+ {
+theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+ }
+
+ CODEGEN_DECL();
+};
+
+
+//fn:fold-right
+class fn_fold_right_3_0 : public function
+{
+public:
+ fn_fold_right_3_0(const signature& sig, FunctionConsts::FunctionKind kind)
+ :
+ function(sig, kind)
+ {
+theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+ }
+
+ CODEGEN_DECL();
+};
+
+
+} //namespace zorba
+
+
+#endif
+/*
+ * Local variables:
+ * mode: c++
+ * End:
+ */
=== removed file 'src/functions/pregenerated/func_function_item_iter.cpp'
--- src/functions/pregenerated/func_function_item_iter.cpp 2013-03-15 08:22:41 +0000
+++ src/functions/pregenerated/func_function_item_iter.cpp 1970-01-01 00:00:00 +0000
@@ -1,111 +0,0 @@
-/*
- * Copyright 2006-2012 The FLWOR Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// ******************************************
-// * *
-// * THIS IS A GENERATED FILE. DO NOT EDIT! *
-// * SEE .xml FILE WITH SAME NAME *
-// * *
-// ******************************************
-
-
-#include "stdafx.h"
-#include "runtime/function_item/function_item_iter.h"
-#include "functions/func_function_item_iter.h"
-
-
-namespace zorba{
-
-
-
-
-PlanIter_t fn_function_name_3_0::codegen(
- CompilerCB*,
- static_context* sctx,
- const QueryLoc& loc,
- std::vector<PlanIter_t>& argv,
- expr& ann) const
-{
- return new FunctionNameIterator(sctx, loc, argv);
-}
-
-PlanIter_t fn_function_arity_3_0::codegen(
- CompilerCB*,
- static_context* sctx,
- const QueryLoc& loc,
- std::vector<PlanIter_t>& argv,
- expr& ann) const
-{
- return new FunctionArityIterator(sctx, loc, argv);
-}
-
-PlanIter_t fn_map_pairs_3_0::codegen(
- CompilerCB*,
- static_context* sctx,
- const QueryLoc& loc,
- std::vector<PlanIter_t>& argv,
- expr& ann) const
-{
- return new FnMapPairsIterator(sctx, loc, argv);
-}
-
-
-
-void populate_context_function_item_iter(static_context* sctx)
-{
-
-
- {
- DECL_WITH_KIND(sctx, fn_function_lookup_3_0,
- (createQName("http://www.w3.org/2005/xpath-functions","","function-lookup"),
- GENV_TYPESYSTEM.QNAME_TYPE_ONE,
- GENV_TYPESYSTEM.INTEGER_TYPE_ONE,
- GENV_TYPESYSTEM.ANY_FUNCTION_TYPE_QUESTION),
- FunctionConsts::FN_FUNCTION_LOOKUP_2);
-
- }
-
-
-
-
- {
- DECL_WITH_KIND(sctx, fn_function_name_3_0,
- (createQName("http://www.w3.org/2005/xpath-functions","","function-name"),
- GENV_TYPESYSTEM.ANY_FUNCTION_TYPE_ONE,
- GENV_TYPESYSTEM.QNAME_TYPE_QUESTION),
- FunctionConsts::FN_FUNCTION_NAME_1);
-
- }
-
-
-
-
- {
- DECL_WITH_KIND(sctx, fn_function_arity_3_0,
- (createQName("http://www.w3.org/2005/xpath-functions","","function-arity"),
- GENV_TYPESYSTEM.ANY_FUNCTION_TYPE_ONE,
- GENV_TYPESYSTEM.INTEGER_TYPE_ONE),
- FunctionConsts::FN_FUNCTION_ARITY_1);
-
- }
-
-}
-
-
-}
-
-
-
=== removed file 'src/functions/pregenerated/func_function_item_iter.h'
--- src/functions/pregenerated/func_function_item_iter.h 2013-03-15 08:22:41 +0000
+++ src/functions/pregenerated/func_function_item_iter.h 1970-01-01 00:00:00 +0000
@@ -1,139 +0,0 @@
-/*
- * Copyright 2006-2012 The FLWOR Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// ******************************************
-// * *
-// * THIS IS A GENERATED FILE. DO NOT EDIT! *
-// * SEE .xml FILE WITH SAME NAME *
-// * *
-// ******************************************
-
-
-#ifndef ZORBA_FUNCTIONS_FUNCTION_ITEM_ITER_H
-#define ZORBA_FUNCTIONS_FUNCTION_ITEM_ITER_H
-
-
-#include "common/shared_types.h"
-#include "functions/function_impl.h"
-
-
-namespace zorba {
-
-
-void populate_context_function_item_iter(static_context* sctx);
-
-
-
-
-//fn:function-lookup
-class fn_function_lookup_3_0 : public function
-{
-public:
- fn_function_lookup_3_0(const signature& sig, FunctionConsts::FunctionKind kind)
- :
- function(sig, kind)
- {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
- }
-
- CODEGEN_DECL();
-};
-
-
-//fn:function-name
-class fn_function_name_3_0 : public function
-{
-public:
- fn_function_name_3_0(const signature& sig, FunctionConsts::FunctionKind kind)
- :
- function(sig, kind)
- {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
- }
-
- CODEGEN_DECL();
-};
-
-
-//fn:function-arity
-class fn_function_arity_3_0 : public function
-{
-public:
- fn_function_arity_3_0(const signature& sig, FunctionConsts::FunctionKind kind)
- :
- function(sig, kind)
- {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
- }
-
- CODEGEN_DECL();
-};
-
-
-//fn:map-pairs
-class fn_map_pairs_3_0 : public function
-{
-public:
- fn_map_pairs_3_0(const signature& sig, FunctionConsts::FunctionKind kind)
- :
- function(sig, kind)
- {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
- }
-
- CODEGEN_DECL();
-};
-
-
-//fn:fold-left
-class fn_fold_left_3_0 : public function
-{
-public:
- fn_fold_left_3_0(const signature& sig, FunctionConsts::FunctionKind kind)
- :
- function(sig, kind)
- {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
- }
-
- CODEGEN_DECL();
-};
-
-
-//fn:fold-right
-class fn_fold_right_3_0 : public function
-{
-public:
- fn_fold_right_3_0(const signature& sig, FunctionConsts::FunctionKind kind)
- :
- function(sig, kind)
- {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
- }
-
- CODEGEN_DECL();
-};
-
-
-} //namespace zorba
-
-
-#endif
-/*
- * Local variables:
- * mode: c++
- * End:
- */
=== removed directory 'src/runtime/function_item'
=== removed file 'src/runtime/function_item/function_item_iter_impl.cpp'
--- src/runtime/function_item/function_item_iter_impl.cpp 2013-03-26 23:32:03 +0000
+++ src/runtime/function_item/function_item_iter_impl.cpp 1970-01-01 00:00:00 +0000
@@ -1,450 +0,0 @@
-/*
- * Copyright 2006-2008 The FLWOR Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "stdafx.h"
-
-#include "compiler/expression/function_item_expr.h"
-#include "compiler/api/compilercb.h"
-#include "compiler/translator/translator.h"
-
-#include "functions/udf.h"
-
-#include "runtime/function_item/function_item_iter.h"
-#include "runtime/api/plan_iterator_wrapper.h"
-#include "runtime/util/iterator_impl.h"
-#include "runtime/hof/function_item.h"
-#include "runtime/core/fncall_iterator.h"
-
-#include "context/dynamic_context.h"
-#include "context/static_context.h"
-
-#include "types/typeops.h"
-
-#include "store/api/item_factory.h"
-#include "store/api/store.h"
-#include "store/api/temp_seq.h"
-
-#include "diagnostics/util_macros.h"
-
-#include "system/globalenv.h"
-
-#include "zorbamisc/ns_consts.h"
-
-
-using namespace std;
-
-namespace zorba {
-
-
-/*******************************************************************************
-
-********************************************************************************/
-bool FunctionLookupIterator::nextImpl(
- store::Item_t& result,
- PlanState& planState) const
-{
- store::Item_t qname;
- store::Item_t arityItem;
- uint32_t arity;
- result = NULL;
-
- PlanIteratorState* state;
- DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
-
- consumeNext(qname, theChildren[0], planState);
- consumeNext(arityItem, theChildren[1], planState);
-
- try
- {
- arity = to_xs_unsignedInt(arityItem->getIntegerValue());
- }
- catch ( std::range_error const& )
- {
- RAISE_ERROR(err::XPST0017, loc,
- ERROR_PARAMS(arityItem->getIntegerValue(), ZED(NoParseFnArity)));
- }
-
- try
- {
- expr* fiExpr = Translator::translate_literal_function(qname, arity, theCompilerCB, loc, true);
-
- FunctionItemInfo_t dynFnInfo = static_cast<function_item_expr*>(fiExpr)->get_dynamic_fn_info();
- dynFnInfo->theCCB = theCompilerCB;
- // dynFnInfo->theClosureSctx = NULL;
-
- result = new FunctionItem(dynFnInfo, NULL /* new dynamic_context(planState.theGlobalDynCtx) */);
- }
- catch (ZorbaException const& e)
- {
- if (e.diagnostic() != err::XPST0017)
- throw;
- }
-
- if (result.getp() != NULL)
- STACK_PUSH(true, state);
-
- STACK_END(state);
-}
-
-
-/*******************************************************************************
-
-********************************************************************************/
-bool FunctionNameIterator::nextImpl(
- store::Item_t& r,
- PlanState& planState) const
-{
- store::Item_t lFItem;
- FunctionItem* lFunctionItem = 0;
-
- PlanIteratorState* state;
- DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
-
- consumeNext(lFItem, theChildren[0], planState);
-
- // function signature guarantees that
- ZORBA_ASSERT(lFItem->isFunction());
-
- lFunctionItem = static_cast<FunctionItem*>(lFItem.getp());
-
- if ((!lFunctionItem->isInline() || lFunctionItem->isCoercion())
- &&
- lFunctionItem->getFunctionName()
- &&
- (lFunctionItem->getArity() == lFunctionItem->getStartArity()))
- {
- // non-inline function
- r = lFunctionItem->getFunctionName();
- STACK_PUSH(true, state);
- }
-
- STACK_END(state);
-}
-
-
-/*******************************************************************************
-
-********************************************************************************/
-bool FunctionArityIterator::nextImpl(
- store::Item_t& r,
- PlanState& planState) const
-{
- store::Item_t lFItem;
- FunctionItem* lFunctionItem = 0;
- xs_integer lInt;
-
- PlanIteratorState* state;
- DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
-
- consumeNext(lFItem, theChildren[0], planState);
-
- // function signature guarantees that
- ZORBA_ASSERT(lFItem->isFunction());
-
- lFunctionItem = static_cast<FunctionItem*>(lFItem.getp());
-
- lInt = Integer(lFunctionItem->getArity());
-
- STACK_PUSH(GENV_ITEMFACTORY->createInteger(r, lInt), state);
-
- STACK_END(state);
-}
-
-
-/*******************************************************************************
-
-********************************************************************************/
-FnMapPairsIteratorState::~FnMapPairsIteratorState()
-{
- if (theIsOpen)
- {
- thePlan->close(*thePlanState);
- }
-}
-
-
-void FnMapPairsIteratorState::init(PlanState& planState)
-{
- PlanIteratorState::init(planState);
- thePlanState = &planState;
- thePlan = NULL;
- theIsOpen = false;
-}
-
-
-void FnMapPairsIteratorState::reset(PlanState& planState)
-{
- PlanIteratorState::reset(planState);
- if (theIsOpen)
- {
- thePlan->reset(planState);
- }
-}
-
-
-uint32_t FnMapPairsIterator::getStateSizeOfSubtree() const
-{
- uint32_t size = NaryBaseIterator<FnMapPairsIterator, FnMapPairsIteratorState>::
- getStateSizeOfSubtree();
-
- return size + sizeof(UDFunctionCallIteratorState);
-}
-
-
-void FnMapPairsIterator::openImpl(PlanState& planState, uint32_t& offset)
-{
- StateTraitsImpl<FnMapPairsIteratorState>::createState(planState,
- theStateOffset,
- offset);
-
- StateTraitsImpl<FnMapPairsIteratorState>::initState(planState, theStateOffset);
-
- FnMapPairsIteratorState* state =
- StateTraitsImpl<FnMapPairsIteratorState>::getState(planState, theStateOffset);
-
- state->theUDFStateOffset = offset;
-
- offset += sizeof(UDFunctionCallIteratorState);
-
- std::vector<PlanIter_t>::iterator lIter = theChildren.begin();
- std::vector<PlanIter_t>::iterator lEnd = theChildren.end();
- for ( ; lIter != lEnd; ++lIter )
- {
- (*lIter)->open(planState, offset);
- }
-}
-
-
-bool FnMapPairsIterator::nextImpl(
- store::Item_t& result,
- PlanState& planState) const
-{
- store::Item_t child1, child2;
- std::vector<PlanIter_t> arguments;
-
- FnMapPairsIteratorState* state;
- DEFAULT_STACK_INIT(FnMapPairsIteratorState, state, planState);
-
- consumeNext(state->theFnItem, theChildren[0], planState);
-
- // function signature guarantees that
- ZORBA_ASSERT(state->theFnItem->isFunction());
-
- while (true)
- {
- if (!consumeNext(child1, theChildren[1], planState) ||
- !consumeNext(child2, theChildren[2], planState))
- break;
-
- if (child1.getp() && child2.getp())
- {
- {
- store::TempSeq_t seq1, seq2;
- seq1 = GENV_STORE.createTempSeq(child1);
- seq2 = GENV_STORE.createTempSeq(child2);
- store::Iterator_t seqIter1 = seq1->getIterator();
- store::Iterator_t seqIter2 = seq2->getIterator();
- seqIter1->open();
- seqIter2->open();
-
- arguments.push_back(NULL); // the first argument is expected to be the function item and it is not used
- arguments.push_back(new PlanStateIteratorWrapper(seqIter1));
- arguments.push_back(new PlanStateIteratorWrapper(seqIter2));
- }
-
- state->thePlan = static_cast<FunctionItem*>(state->theFnItem.getp())->getImplementation(arguments, planState.theCompilerCB);
- // must be opened after vars and params are set
- state->thePlan->open(planState, state->theUDFStateOffset);
- state->theIsOpen = true;
-
- while (consumeNext(result, state->thePlan, planState))
- {
- STACK_PUSH(true, state);
- }
-
- // need to close here early in case the plan is completely
- // consumed. Otherwise, the plan would still be opened
- // if destroyed from the state's destructor.
- state->thePlan->close(planState);
- state->theIsOpen = false;
- }
- else
- {
- result = NULL;
- STACK_PUSH(true, state);
- }
- }
-
- STACK_END(state);
-}
-
-
-/*******************************************************************************
-
-********************************************************************************/
-FnFoldLeftIteratorState::~FnFoldLeftIteratorState()
-{
- if (theIsOpen)
- {
- thePlan->close(*thePlanState);
- }
-}
-
-
-void FnFoldLeftIteratorState::init(PlanState& planState)
-{
- PlanIteratorState::init(planState);
- thePlanState = &planState;
- thePlan = NULL;
- theIsOpen = false;
-}
-
-
-void FnFoldLeftIteratorState::reset(PlanState& planState)
-{
- PlanIteratorState::reset(planState);
- if (theIsOpen)
- {
- thePlan->reset(planState);
- }
-}
-
-
-uint32_t FnFoldLeftIterator::getStateSizeOfSubtree() const
-{
- uint32_t size = NaryBaseIterator<FnFoldLeftIterator, FnFoldLeftIteratorState>::
- getStateSizeOfSubtree();
-
- return size + sizeof(UDFunctionCallIteratorState);
-}
-
-
-void FnFoldLeftIterator::openImpl(PlanState& planState, uint32_t& offset)
-{
- StateTraitsImpl<FnFoldLeftIteratorState>::createState(planState,
- theStateOffset,
- offset);
-
- StateTraitsImpl<FnFoldLeftIteratorState>::initState(planState, theStateOffset);
-
- FnFoldLeftIteratorState* state =
- StateTraitsImpl<FnFoldLeftIteratorState>::getState(planState, theStateOffset);
-
- state->theUDFStateOffset = offset;
-
- offset += sizeof(UDFunctionCallIteratorState);
-
- std::vector<PlanIter_t>::iterator lIter = theChildren.begin();
- std::vector<PlanIter_t>::iterator lEnd = theChildren.end();
- for ( ; lIter != lEnd; ++lIter )
- {
- (*lIter)->open(planState, offset);
- }
-}
-
-
-bool FnFoldLeftIterator::nextImpl(
- store::Item_t& result,
- PlanState& planState) const
-{
- store::Item_t curSeqItem, nextSeqItem, tempItem;
- std::vector<store::Item_t> zero;
- bool haveSeqItems;
-
- FnFoldLeftIteratorState* state;
- DEFAULT_STACK_INIT(FnFoldLeftIteratorState, state, planState);
-
- consumeNext(state->theFnItem, theChildren[0], planState);
-
- // function signature guarantees that
- ZORBA_ASSERT(state->theFnItem->isFunction());
-
- if ((haveSeqItems = consumeNext(curSeqItem, theChildren[2], planState)))
- haveSeqItems = consumeNext(nextSeqItem, theChildren[2], planState);
-
- if (curSeqItem.getp() == NULL && nextSeqItem.getp() == NULL)
- {
- // consume and return the "zero" argument
- while (consumeNext(result, theChildren[1], planState))
- {
- STACK_PUSH(true, state);
- }
- }
- else
- {
- // read in the "zero" argument to be able to pass it to the hof
- while (consumeNext(tempItem, theChildren[1], planState))
- {
- zero.push_back(tempItem);
- }
-
- while (true)
- {
- {
- store::TempSeq_t zeroSeq = GENV_STORE.createTempSeq(zero);
- tempItem = curSeqItem; // because createTempSeq calls .release() on the item rchandle
- store::TempSeq_t seq = GENV_STORE.createTempSeq(tempItem);
- store::Iterator_t seqIter1 = zeroSeq->getIterator();
- store::Iterator_t seqIter2 = seq->getIterator();
- seqIter1->open();
- seqIter2->open();
-
- std::vector<PlanIter_t> arguments;
- arguments.push_back(NULL);
- arguments.push_back(new PlanStateIteratorWrapper(seqIter1));
- arguments.push_back(new PlanStateIteratorWrapper(seqIter2));
- if (theIsFoldRight)
- std::reverse(++arguments.begin(), arguments.end());
-
- state->thePlan = static_cast<FunctionItem*>(state->theFnItem.getp())->getImplementation(arguments, planState.theCompilerCB);
- state->thePlan->open(planState, state->theUDFStateOffset);
- state->theIsOpen = true;
- }
-
- if (curSeqItem.isNull() || nextSeqItem.isNull())
- break;
-
- zero.clear();
- while (consumeNext(tempItem, state->thePlan, planState))
- {
- zero.push_back(tempItem);
- }
-
- state->thePlan->close(planState);
- state->theIsOpen = false;
-
- curSeqItem = nextSeqItem;
- nextSeqItem = NULL;
- if (haveSeqItems)
- haveSeqItems = consumeNext(nextSeqItem, theChildren[2], planState);
-
- } // while (true)
-
- while (consumeNext(result, state->thePlan, planState))
- {
- STACK_PUSH(true, state);
- }
-
- state->thePlan->close(planState);
- state->theIsOpen = false;
-
- } // else
-
- STACK_END(state);
-}
-
-} // namespace zorba
-/* vim:set et sw=2 ts=2: */
=== removed directory 'src/runtime/function_item/pregenerated'
=== removed file 'src/runtime/function_item/pregenerated/function_item_iter.cpp'
--- src/runtime/function_item/pregenerated/function_item_iter.cpp 2013-03-15 08:22:41 +0000
+++ src/runtime/function_item/pregenerated/function_item_iter.cpp 1970-01-01 00:00:00 +0000
@@ -1,190 +0,0 @@
-/*
- * Copyright 2006-2012 The FLWOR Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// ******************************************
-// * *
-// * THIS IS A GENERATED FILE. DO NOT EDIT! *
-// * SEE .xml FILE WITH SAME NAME *
-// * *
-// ******************************************
-
-#include "stdafx.h"
-#include "zorbatypes/rchandle.h"
-#include "zorbatypes/zstring.h"
-#include "runtime/visitors/planiter_visitor.h"
-#include "runtime/function_item/function_item_iter.h"
-#include "system/globalenv.h"
-
-
-#include "context/static_context.h"
-#include "compiler/api/compilercb.h"
-#include "context/dynamic_context.h"
-#include "store/api/temp_seq.h"
-
-namespace zorba {
-
-// <FunctionLookupIterator>
-SERIALIZABLE_CLASS_VERSIONS(FunctionLookupIterator)
-
-void FunctionLookupIterator::serialize(::zorba::serialization::Archiver& ar)
-{
- serialize_baseclass(ar,
- (NaryBaseIterator<FunctionLookupIterator, PlanIteratorState>*)this);
-
- ar & theCompilerCB;
-}
-
-
-void FunctionLookupIterator::accept(PlanIterVisitor& v) const
-{
- v.beginVisit(*this);
-
- std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
- std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
- for ( ; lIter != lEnd; ++lIter ){
- (*lIter)->accept(v);
- }
-
- v.endVisit(*this);
-}
-
-FunctionLookupIterator::~FunctionLookupIterator() {}
-
-// </FunctionLookupIterator>
-
-
-// <FunctionNameIterator>
-SERIALIZABLE_CLASS_VERSIONS(FunctionNameIterator)
-
-void FunctionNameIterator::serialize(::zorba::serialization::Archiver& ar)
-{
- serialize_baseclass(ar,
- (NaryBaseIterator<FunctionNameIterator, PlanIteratorState>*)this);
-}
-
-
-void FunctionNameIterator::accept(PlanIterVisitor& v) const
-{
- v.beginVisit(*this);
-
- std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
- std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
- for ( ; lIter != lEnd; ++lIter ){
- (*lIter)->accept(v);
- }
-
- v.endVisit(*this);
-}
-
-FunctionNameIterator::~FunctionNameIterator() {}
-
-// </FunctionNameIterator>
-
-
-// <FunctionArityIterator>
-SERIALIZABLE_CLASS_VERSIONS(FunctionArityIterator)
-
-void FunctionArityIterator::serialize(::zorba::serialization::Archiver& ar)
-{
- serialize_baseclass(ar,
- (NaryBaseIterator<FunctionArityIterator, PlanIteratorState>*)this);
-}
-
-
-void FunctionArityIterator::accept(PlanIterVisitor& v) const
-{
- v.beginVisit(*this);
-
- std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
- std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
- for ( ; lIter != lEnd; ++lIter ){
- (*lIter)->accept(v);
- }
-
- v.endVisit(*this);
-}
-
-FunctionArityIterator::~FunctionArityIterator() {}
-
-// </FunctionArityIterator>
-
-
-// <FnMapPairsIterator>
-SERIALIZABLE_CLASS_VERSIONS(FnMapPairsIterator)
-
-void FnMapPairsIterator::serialize(::zorba::serialization::Archiver& ar)
-{
- serialize_baseclass(ar,
- (NaryBaseIterator<FnMapPairsIterator, FnMapPairsIteratorState>*)this);
-}
-
-
-void FnMapPairsIterator::accept(PlanIterVisitor& v) const
-{
- v.beginVisit(*this);
-
- std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
- std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
- for ( ; lIter != lEnd; ++lIter ){
- (*lIter)->accept(v);
- }
-
- v.endVisit(*this);
-}
-
-FnMapPairsIterator::~FnMapPairsIterator() {}
-
-FnMapPairsIteratorState::FnMapPairsIteratorState() {}
-
-// </FnMapPairsIterator>
-
-
-// <FnFoldLeftIterator>
-SERIALIZABLE_CLASS_VERSIONS(FnFoldLeftIterator)
-
-void FnFoldLeftIterator::serialize(::zorba::serialization::Archiver& ar)
-{
- serialize_baseclass(ar,
- (NaryBaseIterator<FnFoldLeftIterator, FnFoldLeftIteratorState>*)this);
-
- ar & theIsFoldRight;
-}
-
-
-void FnFoldLeftIterator::accept(PlanIterVisitor& v) const
-{
- v.beginVisit(*this);
-
- std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
- std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
- for ( ; lIter != lEnd; ++lIter ){
- (*lIter)->accept(v);
- }
-
- v.endVisit(*this);
-}
-
-FnFoldLeftIterator::~FnFoldLeftIterator() {}
-
-FnFoldLeftIteratorState::FnFoldLeftIteratorState() {}
-
-// </FnFoldLeftIterator>
-
-
-
-}
-
-
=== removed file 'src/runtime/function_item/pregenerated/function_item_iter.h'
--- src/runtime/function_item/pregenerated/function_item_iter.h 2013-03-15 08:22:41 +0000
+++ src/runtime/function_item/pregenerated/function_item_iter.h 1970-01-01 00:00:00 +0000
@@ -1,256 +0,0 @@
-/*
- * Copyright 2006-2012 The FLWOR Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// ******************************************
-// * *
-// * THIS IS A GENERATED FILE. DO NOT EDIT! *
-// * SEE .xml FILE WITH SAME NAME *
-// * *
-// ******************************************
-#ifndef ZORBA_RUNTIME_FUNCTION_ITEM_FUNCTION_ITEM_ITER_H
-#define ZORBA_RUNTIME_FUNCTION_ITEM_FUNCTION_ITEM_ITER_H
-
-
-#include "common/shared_types.h"
-
-
-
-#include "runtime/base/narybase.h"
-#include "compiler/expression/expr_base.h"
-#include "runtime/util/plan_wrapper_holder.h"
-#include "types/typeimpl.h"
-#include "functions/function.h"
-
-
-namespace zorba {
-
-/**
- *
- * Returns the function having a given name and arity, if there is one.
- *
- * Author: Zorba Team
- */
-class FunctionLookupIterator : public NaryBaseIterator<FunctionLookupIterator, PlanIteratorState>
-{
-protected:
- CompilerCB* theCompilerCB; //
-public:
- SERIALIZABLE_CLASS(FunctionLookupIterator);
-
- SERIALIZABLE_CLASS_CONSTRUCTOR2T(FunctionLookupIterator,
- NaryBaseIterator<FunctionLookupIterator, PlanIteratorState>);
-
- void serialize( ::zorba::serialization::Archiver& ar);
-
- FunctionLookupIterator(
- static_context* sctx,
- const QueryLoc& loc,
- std::vector<PlanIter_t>& children,
- CompilerCB* aCompilerCB)
- :
- NaryBaseIterator<FunctionLookupIterator, PlanIteratorState>(sctx, loc, children),
- theCompilerCB(aCompilerCB)
- {}
-
- virtual ~FunctionLookupIterator();
-
- void accept(PlanIterVisitor& v) const;
-
- bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
-};
-
-
-/**
- *
- * Returns the name of the function identified by a function item.
- *
- * Author: Zorba Team
- */
-class FunctionNameIterator : public NaryBaseIterator<FunctionNameIterator, PlanIteratorState>
-{
-public:
- SERIALIZABLE_CLASS(FunctionNameIterator);
-
- SERIALIZABLE_CLASS_CONSTRUCTOR2T(FunctionNameIterator,
- NaryBaseIterator<FunctionNameIterator, PlanIteratorState>);
-
- void serialize( ::zorba::serialization::Archiver& ar);
-
- FunctionNameIterator(
- static_context* sctx,
- const QueryLoc& loc,
- std::vector<PlanIter_t>& children)
- :
- NaryBaseIterator<FunctionNameIterator, PlanIteratorState>(sctx, loc, children)
- {}
-
- virtual ~FunctionNameIterator();
-
- void accept(PlanIterVisitor& v) const;
-
- bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
-};
-
-
-/**
- *
- * Returns the arity of the function identified by a function item.
- *
- * Author: Zorba Team
- */
-class FunctionArityIterator : public NaryBaseIterator<FunctionArityIterator, PlanIteratorState>
-{
-public:
- SERIALIZABLE_CLASS(FunctionArityIterator);
-
- SERIALIZABLE_CLASS_CONSTRUCTOR2T(FunctionArityIterator,
- NaryBaseIterator<FunctionArityIterator, PlanIteratorState>);
-
- void serialize( ::zorba::serialization::Archiver& ar);
-
- FunctionArityIterator(
- static_context* sctx,
- const QueryLoc& loc,
- std::vector<PlanIter_t>& children)
- :
- NaryBaseIterator<FunctionArityIterator, PlanIteratorState>(sctx, loc, children)
- {}
-
- virtual ~FunctionArityIterator();
-
- void accept(PlanIterVisitor& v) const;
-
- bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
-};
-
-
-/**
- *
- * 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.
- *
- * Author: Zorba Team
- */
-class FnMapPairsIteratorState : public PlanIteratorState
-{
-public:
- PlanState* thePlanState; //
- PlanIter_t thePlan; //
- bool theIsOpen; //
- uint32_t theUDFStateOffset; //
- store::Item_t theFnItem; //
-
- FnMapPairsIteratorState();
-
- ~FnMapPairsIteratorState();
-
- void init(PlanState&);
- void reset(PlanState&);
-};
-
-class FnMapPairsIterator : public NaryBaseIterator<FnMapPairsIterator, FnMapPairsIteratorState>
-{
-public:
- SERIALIZABLE_CLASS(FnMapPairsIterator);
-
- SERIALIZABLE_CLASS_CONSTRUCTOR2T(FnMapPairsIterator,
- NaryBaseIterator<FnMapPairsIterator, FnMapPairsIteratorState>);
-
- void serialize( ::zorba::serialization::Archiver& ar);
-
- FnMapPairsIterator(
- static_context* sctx,
- const QueryLoc& loc,
- std::vector<PlanIter_t>& children)
- :
- NaryBaseIterator<FnMapPairsIterator, FnMapPairsIteratorState>(sctx, loc, children)
- {}
-
- virtual ~FnMapPairsIterator();
-
- uint32_t getStateSizeOfSubtree() const;
-
- void accept(PlanIterVisitor& v) const;
-
- bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
-
- void openImpl(PlanState&, uint32_t&);
-};
-
-
-/**
- *
- * 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.
- *
- * Author: Zorba Team
- */
-class FnFoldLeftIteratorState : public PlanIteratorState
-{
-public:
- PlanState* thePlanState; //
- PlanIter_t thePlan; //
- bool theIsOpen; //
- uint32_t theUDFStateOffset; //
- store::Item_t theFnItem; //
-
- FnFoldLeftIteratorState();
-
- ~FnFoldLeftIteratorState();
-
- void init(PlanState&);
- void reset(PlanState&);
-};
-
-class FnFoldLeftIterator : public NaryBaseIterator<FnFoldLeftIterator, FnFoldLeftIteratorState>
-{
-protected:
- bool theIsFoldRight; //
-public:
- SERIALIZABLE_CLASS(FnFoldLeftIterator);
-
- SERIALIZABLE_CLASS_CONSTRUCTOR2T(FnFoldLeftIterator,
- NaryBaseIterator<FnFoldLeftIterator, FnFoldLeftIteratorState>);
-
- void serialize( ::zorba::serialization::Archiver& ar);
-
- FnFoldLeftIterator(
- static_context* sctx,
- const QueryLoc& loc,
- std::vector<PlanIter_t>& children,
- bool aIsFoldRight)
- :
- NaryBaseIterator<FnFoldLeftIterator, FnFoldLeftIteratorState>(sctx, loc, children),
- theIsFoldRight(aIsFoldRight)
- {}
-
- virtual ~FnFoldLeftIterator();
-
- uint32_t getStateSizeOfSubtree() const;
-
- void accept(PlanIterVisitor& v) const;
-
- bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
-
- void openImpl(PlanState&, uint32_t&);
-};
-
-
-}
-#endif
-/*
- * Local variables:
- * mode: c++
- * End:
- */
=== added file 'src/runtime/hof/fn_hof_functions_impl.cpp'
--- src/runtime/hof/fn_hof_functions_impl.cpp 1970-01-01 00:00:00 +0000
+++ src/runtime/hof/fn_hof_functions_impl.cpp 2013-03-27 00:48:21 +0000
@@ -0,0 +1,451 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "stdafx.h"
+
+#include "compiler/expression/function_item_expr.h"
+#include "compiler/api/compilercb.h"
+#include "compiler/translator/translator.h"
+
+#include "functions/udf.h"
+
+#include "runtime/api/plan_iterator_wrapper.h"
+#include "runtime/util/iterator_impl.h"
+#include "runtime/hof/fn_hof_functions.h"
+#include "runtime/hof/function_item.h"
+#include "runtime/core/fncall_iterator.h"
+
+#include "context/dynamic_context.h"
+#include "context/static_context.h"
+
+#include "types/typeops.h"
+
+#include "store/api/item_factory.h"
+#include "store/api/store.h"
+#include "store/api/temp_seq.h"
+
+#include "diagnostics/util_macros.h"
+
+#include "system/globalenv.h"
+
+#include "zorbamisc/ns_consts.h"
+
+
+using namespace std;
+
+namespace zorba {
+
+
+/*******************************************************************************
+
+********************************************************************************/
+bool FunctionLookupIterator::nextImpl(
+ store::Item_t& result,
+ PlanState& planState) const
+{
+ store::Item_t qname;
+ store::Item_t arityItem;
+ uint32_t arity;
+ result = NULL;
+
+ PlanIteratorState* state;
+ DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
+
+ consumeNext(qname, theChildren[0], planState);
+ consumeNext(arityItem, theChildren[1], planState);
+
+ try
+ {
+ arity = to_xs_unsignedInt(arityItem->getIntegerValue());
+ }
+ catch ( std::range_error const& )
+ {
+ RAISE_ERROR(err::XPST0017, loc,
+ ERROR_PARAMS(arityItem->getIntegerValue(), ZED(NoParseFnArity)));
+ }
+
+ try
+ {
+ expr* fiExpr = Translator::translate_literal_function(qname, arity, theCompilerCB, loc, true);
+
+ FunctionItemInfo_t dynFnInfo =
+ static_cast<function_item_expr*>(fiExpr)->get_dynamic_fn_info();
+
+ dynFnInfo->theCCB = theCompilerCB;
+
+ result = new FunctionItem(dynFnInfo, NULL);
+ }
+ catch (ZorbaException const& e)
+ {
+ if (e.diagnostic() != err::XPST0017)
+ throw;
+ }
+
+ if (result.getp() != NULL)
+ STACK_PUSH(true, state);
+
+ STACK_END(state);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+bool FunctionNameIterator::nextImpl(
+ store::Item_t& r,
+ PlanState& planState) const
+{
+ store::Item_t lFItem;
+ FunctionItem* lFunctionItem = 0;
+
+ PlanIteratorState* state;
+ DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
+
+ consumeNext(lFItem, theChildren[0], planState);
+
+ // function signature guarantees that
+ ZORBA_ASSERT(lFItem->isFunction());
+
+ lFunctionItem = static_cast<FunctionItem*>(lFItem.getp());
+
+ if ((!lFunctionItem->isInline() || lFunctionItem->isCoercion())
+ &&
+ lFunctionItem->getFunctionName()
+ &&
+ (lFunctionItem->getArity() == lFunctionItem->getStartArity()))
+ {
+ // non-inline function
+ r = lFunctionItem->getFunctionName();
+ STACK_PUSH(true, state);
+ }
+
+ STACK_END(state);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+bool FunctionArityIterator::nextImpl(
+ store::Item_t& r,
+ PlanState& planState) const
+{
+ store::Item_t lFItem;
+ FunctionItem* lFunctionItem = 0;
+ xs_integer lInt;
+
+ PlanIteratorState* state;
+ DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
+
+ consumeNext(lFItem, theChildren[0], planState);
+
+ // function signature guarantees that
+ ZORBA_ASSERT(lFItem->isFunction());
+
+ lFunctionItem = static_cast<FunctionItem*>(lFItem.getp());
+
+ lInt = Integer(lFunctionItem->getArity());
+
+ STACK_PUSH(GENV_ITEMFACTORY->createInteger(r, lInt), state);
+
+ STACK_END(state);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+FnMapPairsIteratorState::~FnMapPairsIteratorState()
+{
+ if (theIsOpen)
+ {
+ thePlan->close(*thePlanState);
+ }
+}
+
+
+void FnMapPairsIteratorState::init(PlanState& planState)
+{
+ PlanIteratorState::init(planState);
+ thePlanState = &planState;
+ thePlan = NULL;
+ theIsOpen = false;
+}
+
+
+void FnMapPairsIteratorState::reset(PlanState& planState)
+{
+ PlanIteratorState::reset(planState);
+ if (theIsOpen)
+ {
+ thePlan->reset(planState);
+ }
+}
+
+
+uint32_t FnMapPairsIterator::getStateSizeOfSubtree() const
+{
+ uint32_t size = NaryBaseIterator<FnMapPairsIterator, FnMapPairsIteratorState>::
+ getStateSizeOfSubtree();
+
+ return size + sizeof(UDFunctionCallIteratorState);
+}
+
+
+void FnMapPairsIterator::openImpl(PlanState& planState, uint32_t& offset)
+{
+ StateTraitsImpl<FnMapPairsIteratorState>::createState(planState,
+ theStateOffset,
+ offset);
+
+ StateTraitsImpl<FnMapPairsIteratorState>::initState(planState, theStateOffset);
+
+ FnMapPairsIteratorState* state =
+ StateTraitsImpl<FnMapPairsIteratorState>::getState(planState, theStateOffset);
+
+ state->theUDFStateOffset = offset;
+
+ offset += sizeof(UDFunctionCallIteratorState);
+
+ std::vector<PlanIter_t>::iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter )
+ {
+ (*lIter)->open(planState, offset);
+ }
+}
+
+
+bool FnMapPairsIterator::nextImpl(
+ store::Item_t& result,
+ PlanState& planState) const
+{
+ store::Item_t child1, child2;
+ std::vector<PlanIter_t> arguments;
+
+ FnMapPairsIteratorState* state;
+ DEFAULT_STACK_INIT(FnMapPairsIteratorState, state, planState);
+
+ consumeNext(state->theFnItem, theChildren[0], planState);
+
+ // function signature guarantees that
+ ZORBA_ASSERT(state->theFnItem->isFunction());
+
+ while (true)
+ {
+ if (!consumeNext(child1, theChildren[1], planState) ||
+ !consumeNext(child2, theChildren[2], planState))
+ break;
+
+ if (child1.getp() && child2.getp())
+ {
+ {
+ store::TempSeq_t seq1, seq2;
+ seq1 = GENV_STORE.createTempSeq(child1);
+ seq2 = GENV_STORE.createTempSeq(child2);
+ store::Iterator_t seqIter1 = seq1->getIterator();
+ store::Iterator_t seqIter2 = seq2->getIterator();
+ seqIter1->open();
+ seqIter2->open();
+
+ arguments.push_back(NULL); // the first argument is expected to be the function item and it is not used
+ arguments.push_back(new PlanStateIteratorWrapper(seqIter1));
+ arguments.push_back(new PlanStateIteratorWrapper(seqIter2));
+ }
+
+ state->thePlan = static_cast<FunctionItem*>(state->theFnItem.getp())->getImplementation(arguments, planState.theCompilerCB);
+ // must be opened after vars and params are set
+ state->thePlan->open(planState, state->theUDFStateOffset);
+ state->theIsOpen = true;
+
+ while (consumeNext(result, state->thePlan, planState))
+ {
+ STACK_PUSH(true, state);
+ }
+
+ // need to close here early in case the plan is completely
+ // consumed. Otherwise, the plan would still be opened
+ // if destroyed from the state's destructor.
+ state->thePlan->close(planState);
+ state->theIsOpen = false;
+ }
+ else
+ {
+ result = NULL;
+ STACK_PUSH(true, state);
+ }
+ }
+
+ STACK_END(state);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+FnFoldLeftIteratorState::~FnFoldLeftIteratorState()
+{
+ if (theIsOpen)
+ {
+ thePlan->close(*thePlanState);
+ }
+}
+
+
+void FnFoldLeftIteratorState::init(PlanState& planState)
+{
+ PlanIteratorState::init(planState);
+ thePlanState = &planState;
+ thePlan = NULL;
+ theIsOpen = false;
+}
+
+
+void FnFoldLeftIteratorState::reset(PlanState& planState)
+{
+ PlanIteratorState::reset(planState);
+ if (theIsOpen)
+ {
+ thePlan->reset(planState);
+ }
+}
+
+
+uint32_t FnFoldLeftIterator::getStateSizeOfSubtree() const
+{
+ uint32_t size = NaryBaseIterator<FnFoldLeftIterator, FnFoldLeftIteratorState>::
+ getStateSizeOfSubtree();
+
+ return size + sizeof(UDFunctionCallIteratorState);
+}
+
+
+void FnFoldLeftIterator::openImpl(PlanState& planState, uint32_t& offset)
+{
+ StateTraitsImpl<FnFoldLeftIteratorState>::createState(planState,
+ theStateOffset,
+ offset);
+
+ StateTraitsImpl<FnFoldLeftIteratorState>::initState(planState, theStateOffset);
+
+ FnFoldLeftIteratorState* state =
+ StateTraitsImpl<FnFoldLeftIteratorState>::getState(planState, theStateOffset);
+
+ state->theUDFStateOffset = offset;
+
+ offset += sizeof(UDFunctionCallIteratorState);
+
+ std::vector<PlanIter_t>::iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter )
+ {
+ (*lIter)->open(planState, offset);
+ }
+}
+
+
+bool FnFoldLeftIterator::nextImpl(
+ store::Item_t& result,
+ PlanState& planState) const
+{
+ store::Item_t curSeqItem, nextSeqItem, tempItem;
+ std::vector<store::Item_t> zero;
+ bool haveSeqItems;
+
+ FnFoldLeftIteratorState* state;
+ DEFAULT_STACK_INIT(FnFoldLeftIteratorState, state, planState);
+
+ consumeNext(state->theFnItem, theChildren[0], planState);
+
+ // function signature guarantees that
+ ZORBA_ASSERT(state->theFnItem->isFunction());
+
+ if ((haveSeqItems = consumeNext(curSeqItem, theChildren[2], planState)))
+ haveSeqItems = consumeNext(nextSeqItem, theChildren[2], planState);
+
+ if (curSeqItem.getp() == NULL && nextSeqItem.getp() == NULL)
+ {
+ // consume and return the "zero" argument
+ while (consumeNext(result, theChildren[1], planState))
+ {
+ STACK_PUSH(true, state);
+ }
+ }
+ else
+ {
+ // read in the "zero" argument to be able to pass it to the hof
+ while (consumeNext(tempItem, theChildren[1], planState))
+ {
+ zero.push_back(tempItem);
+ }
+
+ while (true)
+ {
+ {
+ store::TempSeq_t zeroSeq = GENV_STORE.createTempSeq(zero);
+ tempItem = curSeqItem; // because createTempSeq calls .release() on the item rchandle
+ store::TempSeq_t seq = GENV_STORE.createTempSeq(tempItem);
+ store::Iterator_t seqIter1 = zeroSeq->getIterator();
+ store::Iterator_t seqIter2 = seq->getIterator();
+ seqIter1->open();
+ seqIter2->open();
+
+ std::vector<PlanIter_t> arguments;
+ arguments.push_back(NULL);
+ arguments.push_back(new PlanStateIteratorWrapper(seqIter1));
+ arguments.push_back(new PlanStateIteratorWrapper(seqIter2));
+ if (theIsFoldRight)
+ std::reverse(++arguments.begin(), arguments.end());
+
+ state->thePlan = static_cast<FunctionItem*>(state->theFnItem.getp())->getImplementation(arguments, planState.theCompilerCB);
+ state->thePlan->open(planState, state->theUDFStateOffset);
+ state->theIsOpen = true;
+ }
+
+ if (curSeqItem.isNull() || nextSeqItem.isNull())
+ break;
+
+ zero.clear();
+ while (consumeNext(tempItem, state->thePlan, planState))
+ {
+ zero.push_back(tempItem);
+ }
+
+ state->thePlan->close(planState);
+ state->theIsOpen = false;
+
+ curSeqItem = nextSeqItem;
+ nextSeqItem = NULL;
+ if (haveSeqItems)
+ haveSeqItems = consumeNext(nextSeqItem, theChildren[2], planState);
+
+ } // while (true)
+
+ while (consumeNext(result, state->thePlan, planState))
+ {
+ STACK_PUSH(true, state);
+ }
+
+ state->thePlan->close(planState);
+ state->theIsOpen = false;
+
+ } // else
+
+ STACK_END(state);
+}
+
+} // namespace zorba
+/* vim:set et sw=2 ts=2: */
=== added directory 'src/runtime/hof/pregenerated'
=== added file 'src/runtime/hof/pregenerated/fn_hof_functions.cpp'
--- src/runtime/hof/pregenerated/fn_hof_functions.cpp 1970-01-01 00:00:00 +0000
+++ src/runtime/hof/pregenerated/fn_hof_functions.cpp 2013-03-27 00:48:21 +0000
@@ -0,0 +1,190 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// ******************************************
+// * *
+// * THIS IS A GENERATED FILE. DO NOT EDIT! *
+// * SEE .xml FILE WITH SAME NAME *
+// * *
+// ******************************************
+
+#include "stdafx.h"
+#include "zorbatypes/rchandle.h"
+#include "zorbatypes/zstring.h"
+#include "runtime/visitors/planiter_visitor.h"
+#include "runtime/hof/fn_hof_functions.h"
+#include "system/globalenv.h"
+
+
+#include "context/static_context.h"
+#include "compiler/api/compilercb.h"
+#include "context/dynamic_context.h"
+#include "store/api/temp_seq.h"
+
+namespace zorba {
+
+// <FunctionLookupIterator>
+SERIALIZABLE_CLASS_VERSIONS(FunctionLookupIterator)
+
+void FunctionLookupIterator::serialize(::zorba::serialization::Archiver& ar)
+{
+ serialize_baseclass(ar,
+ (NaryBaseIterator<FunctionLookupIterator, PlanIteratorState>*)this);
+
+ ar & theCompilerCB;
+}
+
+
+void FunctionLookupIterator::accept(PlanIterVisitor& v) const
+{
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+FunctionLookupIterator::~FunctionLookupIterator() {}
+
+// </FunctionLookupIterator>
+
+
+// <FunctionNameIterator>
+SERIALIZABLE_CLASS_VERSIONS(FunctionNameIterator)
+
+void FunctionNameIterator::serialize(::zorba::serialization::Archiver& ar)
+{
+ serialize_baseclass(ar,
+ (NaryBaseIterator<FunctionNameIterator, PlanIteratorState>*)this);
+}
+
+
+void FunctionNameIterator::accept(PlanIterVisitor& v) const
+{
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+FunctionNameIterator::~FunctionNameIterator() {}
+
+// </FunctionNameIterator>
+
+
+// <FunctionArityIterator>
+SERIALIZABLE_CLASS_VERSIONS(FunctionArityIterator)
+
+void FunctionArityIterator::serialize(::zorba::serialization::Archiver& ar)
+{
+ serialize_baseclass(ar,
+ (NaryBaseIterator<FunctionArityIterator, PlanIteratorState>*)this);
+}
+
+
+void FunctionArityIterator::accept(PlanIterVisitor& v) const
+{
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+FunctionArityIterator::~FunctionArityIterator() {}
+
+// </FunctionArityIterator>
+
+
+// <FnMapPairsIterator>
+SERIALIZABLE_CLASS_VERSIONS(FnMapPairsIterator)
+
+void FnMapPairsIterator::serialize(::zorba::serialization::Archiver& ar)
+{
+ serialize_baseclass(ar,
+ (NaryBaseIterator<FnMapPairsIterator, FnMapPairsIteratorState>*)this);
+}
+
+
+void FnMapPairsIterator::accept(PlanIterVisitor& v) const
+{
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+FnMapPairsIterator::~FnMapPairsIterator() {}
+
+FnMapPairsIteratorState::FnMapPairsIteratorState() {}
+
+// </FnMapPairsIterator>
+
+
+// <FnFoldLeftIterator>
+SERIALIZABLE_CLASS_VERSIONS(FnFoldLeftIterator)
+
+void FnFoldLeftIterator::serialize(::zorba::serialization::Archiver& ar)
+{
+ serialize_baseclass(ar,
+ (NaryBaseIterator<FnFoldLeftIterator, FnFoldLeftIteratorState>*)this);
+
+ ar & theIsFoldRight;
+}
+
+
+void FnFoldLeftIterator::accept(PlanIterVisitor& v) const
+{
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+FnFoldLeftIterator::~FnFoldLeftIterator() {}
+
+FnFoldLeftIteratorState::FnFoldLeftIteratorState() {}
+
+// </FnFoldLeftIterator>
+
+
+
+}
+
+
=== added file 'src/runtime/hof/pregenerated/fn_hof_functions.h'
--- src/runtime/hof/pregenerated/fn_hof_functions.h 1970-01-01 00:00:00 +0000
+++ src/runtime/hof/pregenerated/fn_hof_functions.h 2013-03-27 00:48:21 +0000
@@ -0,0 +1,256 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// ******************************************
+// * *
+// * THIS IS A GENERATED FILE. DO NOT EDIT! *
+// * SEE .xml FILE WITH SAME NAME *
+// * *
+// ******************************************
+#ifndef ZORBA_RUNTIME_HOF_FN_HOF_FUNCTIONS_H
+#define ZORBA_RUNTIME_HOF_FN_HOF_FUNCTIONS_H
+
+
+#include "common/shared_types.h"
+
+
+
+#include "runtime/base/narybase.h"
+#include "compiler/expression/expr_base.h"
+#include "runtime/util/plan_wrapper_holder.h"
+#include "types/typeimpl.h"
+#include "functions/function.h"
+
+
+namespace zorba {
+
+/**
+ *
+ * Returns the function having a given name and arity, if there is one.
+ *
+ * Author: Zorba Team
+ */
+class FunctionLookupIterator : public NaryBaseIterator<FunctionLookupIterator, PlanIteratorState>
+{
+protected:
+ CompilerCB* theCompilerCB; //
+public:
+ SERIALIZABLE_CLASS(FunctionLookupIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(FunctionLookupIterator,
+ NaryBaseIterator<FunctionLookupIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar);
+
+ FunctionLookupIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children,
+ CompilerCB* aCompilerCB)
+ :
+ NaryBaseIterator<FunctionLookupIterator, PlanIteratorState>(sctx, loc, children),
+ theCompilerCB(aCompilerCB)
+ {}
+
+ virtual ~FunctionLookupIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ * Returns the name of the function identified by a function item.
+ *
+ * Author: Zorba Team
+ */
+class FunctionNameIterator : public NaryBaseIterator<FunctionNameIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(FunctionNameIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(FunctionNameIterator,
+ NaryBaseIterator<FunctionNameIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar);
+
+ FunctionNameIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<FunctionNameIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~FunctionNameIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ * Returns the arity of the function identified by a function item.
+ *
+ * Author: Zorba Team
+ */
+class FunctionArityIterator : public NaryBaseIterator<FunctionArityIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(FunctionArityIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(FunctionArityIterator,
+ NaryBaseIterator<FunctionArityIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar);
+
+ FunctionArityIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<FunctionArityIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~FunctionArityIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ * 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.
+ *
+ * Author: Zorba Team
+ */
+class FnMapPairsIteratorState : public PlanIteratorState
+{
+public:
+ PlanState* thePlanState; //
+ PlanIter_t thePlan; //
+ bool theIsOpen; //
+ uint32_t theUDFStateOffset; //
+ store::Item_t theFnItem; //
+
+ FnMapPairsIteratorState();
+
+ ~FnMapPairsIteratorState();
+
+ void init(PlanState&);
+ void reset(PlanState&);
+};
+
+class FnMapPairsIterator : public NaryBaseIterator<FnMapPairsIterator, FnMapPairsIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(FnMapPairsIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(FnMapPairsIterator,
+ NaryBaseIterator<FnMapPairsIterator, FnMapPairsIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar);
+
+ FnMapPairsIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<FnMapPairsIterator, FnMapPairsIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~FnMapPairsIterator();
+
+ uint32_t getStateSizeOfSubtree() const;
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+
+ void openImpl(PlanState&, uint32_t&);
+};
+
+
+/**
+ *
+ * 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.
+ *
+ * Author: Zorba Team
+ */
+class FnFoldLeftIteratorState : public PlanIteratorState
+{
+public:
+ PlanState* thePlanState; //
+ PlanIter_t thePlan; //
+ bool theIsOpen; //
+ uint32_t theUDFStateOffset; //
+ store::Item_t theFnItem; //
+
+ FnFoldLeftIteratorState();
+
+ ~FnFoldLeftIteratorState();
+
+ void init(PlanState&);
+ void reset(PlanState&);
+};
+
+class FnFoldLeftIterator : public NaryBaseIterator<FnFoldLeftIterator, FnFoldLeftIteratorState>
+{
+protected:
+ bool theIsFoldRight; //
+public:
+ SERIALIZABLE_CLASS(FnFoldLeftIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(FnFoldLeftIterator,
+ NaryBaseIterator<FnFoldLeftIterator, FnFoldLeftIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar);
+
+ FnFoldLeftIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children,
+ bool aIsFoldRight)
+ :
+ NaryBaseIterator<FnFoldLeftIterator, FnFoldLeftIteratorState>(sctx, loc, children),
+ theIsFoldRight(aIsFoldRight)
+ {}
+
+ virtual ~FnFoldLeftIterator();
+
+ uint32_t getStateSizeOfSubtree() const;
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+
+ void openImpl(PlanState&, uint32_t&);
+};
+
+
+}
+#endif
+/*
+ * Local variables:
+ * mode: c++
+ * End:
+ */
=== removed directory 'src/runtime/spec/function_item'
=== removed file 'src/runtime/spec/function_item/function_item_iter.xml'
--- src/runtime/spec/function_item/function_item_iter.xml 2013-03-13 04:02:45 +0000
+++ src/runtime/spec/function_item/function_item_iter.xml 1970-01-01 00:00:00 +0000
@@ -1,173 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-/////////////////////////////////////////////////////////////////////////////////
-// Zorba Function Item //
-/////////////////////////////////////////////////////////////////////////////////
--->
-<zorba:iterators
- xmlns:zorba="http://www.zorba-xquery.com"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.zorba-xquery.com ../runtime.xsd">
-
-<zorba:header>
- <zorba:include form="Quoted">compiler/expression/expr_base.h</zorba:include>
- <zorba:include form="Quoted">runtime/util/plan_wrapper_holder.h</zorba:include>
- <zorba:include form="Quoted">types/typeimpl.h</zorba:include>
- <zorba:include form="Quoted">functions/function.h</zorba:include>
-</zorba:header>
-
-<zorba:source>
- <zorba:include form="Quoted">context/static_context.h</zorba:include>
- <zorba:include form="Quoted">compiler/api/compilercb.h</zorba:include>
- <zorba:include form="Quoted">context/dynamic_context.h</zorba:include>
- <zorba:include form="Quoted">store/api/temp_seq.h</zorba:include>
-</zorba:source>
-
-
- <!--
- /*******************************************************************************
- fn:function-lookup
- ********************************************************************************/
- -->
- <zorba:iterator name="FunctionLookupIterator">
- <zorba:description author="Zorba Team">
- Returns the function having a given name and arity, if there is one.
- </zorba:description>
-
- <zorba:member type="CompilerCB*" name="theCompilerCB"/>
-
- <zorba:constructor>
- <zorba:parameter type="CompilerCB*" name="aCompilerCB"/>
- </zorba:constructor>
-
- <zorba:function generateCodegen="false">
-
- <zorba:signature localname="function-lookup" prefix="fn" version="3.0">
- <zorba:param>xs:QName</zorba:param>
- <zorba:param>xs:integer</zorba:param>
- <zorba:output>function()?</zorba:output>
- </zorba:signature>
-
- </zorba:function>
-
- </zorba:iterator>
-
-
- <!--
- /*******************************************************************************
- fn:function-name
- ********************************************************************************/
- -->
- <zorba:iterator name="FunctionNameIterator">
- <zorba:description author="Zorba Team">
- Returns the name of the function identified by a function item.
- </zorba:description>
-
- <zorba:function >
-
- <zorba:signature localname="function-name" prefix="fn" version="3.0">
- <zorba:param>function()</zorba:param>
- <zorba:output>xs:QName?</zorba:output>
- </zorba:signature>
-
- </zorba:function>
-
- </zorba:iterator>
-
- <!--
- /*******************************************************************************
- fn:function-arity
- ********************************************************************************/
- -->
- <zorba:iterator name="FunctionArityIterator">
- <zorba:description author="Zorba Team">
- Returns the arity of the function identified by a function item.
- </zorba:description>
-
- <zorba:function >
-
- <zorba:signature localname="function-arity" prefix="fn" version="3.0">
- <zorba:param>function()</zorba:param>
- <zorba:output>xs:integer</zorba:output>
- </zorba:signature>
-
- </zorba:function>
-
- </zorba:iterator>
-
- <!--
- /*******************************************************************************
- fn:map-pairs
- ********************************************************************************/
- -->
- <zorba:iterator name="FnMapPairsIterator" generateOpenImpl="true" generateGetStateSize="true">
- <zorba:description author="Zorba Team">
- 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.
- </zorba:description>
-
- <zorba:function generateDECL="false">
- <zorba:signature localname="map-pairs" prefix="fn" version="3.0">
- <zorba:param>function()*</zorba:param>
- <zorba:param>item()*</zorba:param>
- <zorba:param>item()*</zorba:param>
- <zorba:output>item()*</zorba:output>
- </zorba:signature>
- </zorba:function>
-
- <zorba:state generateInit="false" generateReset="false" generateDestructor="false">
- <zorba:member type="PlanState*" name="thePlanState"/>
- <zorba:member type="PlanIter_t" name="thePlan"/>
- <zorba:member type="bool" name="theIsOpen"/>
- <zorba:member type="uint32_t" name="theUDFStateOffset"/>
- <zorba:member type="store::Item_t" name="theFnItem"/>
- </zorba:state>
-
- </zorba:iterator>
-
- <!--
- /*******************************************************************************
- fn:fold-left
- fn:fold-right
- ********************************************************************************/
- -->
- <zorba:iterator name="FnFoldLeftIterator" generateOpenImpl="true" generateGetStateSize="true">
- <zorba:description author="Zorba Team">
- 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.
- </zorba:description>
-
- <zorba:member type="bool" name="theIsFoldRight"/>
-
- <zorba:constructor>
- <zorba:parameter type="bool" name="aIsFoldRight"/>
- </zorba:constructor>
-
- <zorba:function generateDECL="false" generateCodegen="false">
- <zorba:signature localname="fold-left" prefix="fn" version="3.0">
- <zorba:param>function()*</zorba:param>
- <zorba:param>item()*</zorba:param>
- <zorba:param>item()*</zorba:param>
- <zorba:output>item()*</zorba:output>
- </zorba:signature>
- </zorba:function>
-
- <zorba:function generateDECL="false" generateCodegen="false">
- <zorba:signature localname="fold-right" prefix="fn" version="3.0">
- <zorba:param>function()*</zorba:param>
- <zorba:param>item()*</zorba:param>
- <zorba:param>item()*</zorba:param>
- <zorba:output>item()*</zorba:output>
- </zorba:signature>
- </zorba:function>
-
- <zorba:state generateInit="false" generateReset="false" generateDestructor="false">
- <zorba:member type="PlanState*" name="thePlanState"/>
- <zorba:member type="PlanIter_t" name="thePlan"/>
- <zorba:member type="bool" name="theIsOpen"/>
- <zorba:member type="uint32_t" name="theUDFStateOffset"/>
- <zorba:member type="store::Item_t" name="theFnItem"/>
- </zorba:state>
-
- </zorba:iterator>
-
-</zorba:iterators>
=== added directory 'src/runtime/spec/hof'
=== added file 'src/runtime/spec/hof/fn_hof_functions.xml'
--- src/runtime/spec/hof/fn_hof_functions.xml 1970-01-01 00:00:00 +0000
+++ src/runtime/spec/hof/fn_hof_functions.xml 2013-03-27 00:48:21 +0000
@@ -0,0 +1,173 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+/////////////////////////////////////////////////////////////////////////////////
+// Zorba Function Item //
+/////////////////////////////////////////////////////////////////////////////////
+-->
+<zorba:iterators
+ xmlns:zorba="http://www.zorba-xquery.com"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.zorba-xquery.com ../runtime.xsd">
+
+<zorba:header>
+ <zorba:include form="Quoted">compiler/expression/expr_base.h</zorba:include>
+ <zorba:include form="Quoted">runtime/util/plan_wrapper_holder.h</zorba:include>
+ <zorba:include form="Quoted">types/typeimpl.h</zorba:include>
+ <zorba:include form="Quoted">functions/function.h</zorba:include>
+</zorba:header>
+
+<zorba:source>
+ <zorba:include form="Quoted">context/static_context.h</zorba:include>
+ <zorba:include form="Quoted">compiler/api/compilercb.h</zorba:include>
+ <zorba:include form="Quoted">context/dynamic_context.h</zorba:include>
+ <zorba:include form="Quoted">store/api/temp_seq.h</zorba:include>
+</zorba:source>
+
+
+ <!--
+ /*******************************************************************************
+ fn:function-lookup
+ ********************************************************************************/
+ -->
+ <zorba:iterator name="FunctionLookupIterator">
+ <zorba:description author="Zorba Team">
+ Returns the function having a given name and arity, if there is one.
+ </zorba:description>
+
+ <zorba:member type="CompilerCB*" name="theCompilerCB"/>
+
+ <zorba:constructor>
+ <zorba:parameter type="CompilerCB*" name="aCompilerCB"/>
+ </zorba:constructor>
+
+ <zorba:function generateCodegen="false">
+
+ <zorba:signature localname="function-lookup" prefix="fn" version="3.0">
+ <zorba:param>xs:QName</zorba:param>
+ <zorba:param>xs:integer</zorba:param>
+ <zorba:output>function()?</zorba:output>
+ </zorba:signature>
+
+ </zorba:function>
+
+ </zorba:iterator>
+
+
+ <!--
+ /*******************************************************************************
+ fn:function-name
+ ********************************************************************************/
+ -->
+ <zorba:iterator name="FunctionNameIterator">
+ <zorba:description author="Zorba Team">
+ Returns the name of the function identified by a function item.
+ </zorba:description>
+
+ <zorba:function >
+
+ <zorba:signature localname="function-name" prefix="fn" version="3.0">
+ <zorba:param>function()</zorba:param>
+ <zorba:output>xs:QName?</zorba:output>
+ </zorba:signature>
+
+ </zorba:function>
+
+ </zorba:iterator>
+
+ <!--
+ /*******************************************************************************
+ fn:function-arity
+ ********************************************************************************/
+ -->
+ <zorba:iterator name="FunctionArityIterator">
+ <zorba:description author="Zorba Team">
+ Returns the arity of the function identified by a function item.
+ </zorba:description>
+
+ <zorba:function >
+
+ <zorba:signature localname="function-arity" prefix="fn" version="3.0">
+ <zorba:param>function()</zorba:param>
+ <zorba:output>xs:integer</zorba:output>
+ </zorba:signature>
+
+ </zorba:function>
+
+ </zorba:iterator>
+
+ <!--
+ /*******************************************************************************
+ fn:map-pairs
+ ********************************************************************************/
+ -->
+ <zorba:iterator name="FnMapPairsIterator" generateOpenImpl="true" generateGetStateSize="true">
+ <zorba:description author="Zorba Team">
+ 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.
+ </zorba:description>
+
+ <zorba:function generateDECL="false">
+ <zorba:signature localname="map-pairs" prefix="fn" version="3.0">
+ <zorba:param>function()*</zorba:param>
+ <zorba:param>item()*</zorba:param>
+ <zorba:param>item()*</zorba:param>
+ <zorba:output>item()*</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+
+ <zorba:state generateInit="false" generateReset="false" generateDestructor="false">
+ <zorba:member type="PlanState*" name="thePlanState"/>
+ <zorba:member type="PlanIter_t" name="thePlan"/>
+ <zorba:member type="bool" name="theIsOpen"/>
+ <zorba:member type="uint32_t" name="theUDFStateOffset"/>
+ <zorba:member type="store::Item_t" name="theFnItem"/>
+ </zorba:state>
+
+ </zorba:iterator>
+
+ <!--
+ /*******************************************************************************
+ fn:fold-left
+ fn:fold-right
+ ********************************************************************************/
+ -->
+ <zorba:iterator name="FnFoldLeftIterator" generateOpenImpl="true" generateGetStateSize="true">
+ <zorba:description author="Zorba Team">
+ 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.
+ </zorba:description>
+
+ <zorba:member type="bool" name="theIsFoldRight"/>
+
+ <zorba:constructor>
+ <zorba:parameter type="bool" name="aIsFoldRight"/>
+ </zorba:constructor>
+
+ <zorba:function generateDECL="false" generateCodegen="false">
+ <zorba:signature localname="fold-left" prefix="fn" version="3.0">
+ <zorba:param>function()*</zorba:param>
+ <zorba:param>item()*</zorba:param>
+ <zorba:param>item()*</zorba:param>
+ <zorba:output>item()*</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+
+ <zorba:function generateDECL="false" generateCodegen="false">
+ <zorba:signature localname="fold-right" prefix="fn" version="3.0">
+ <zorba:param>function()*</zorba:param>
+ <zorba:param>item()*</zorba:param>
+ <zorba:param>item()*</zorba:param>
+ <zorba:output>item()*</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+
+ <zorba:state generateInit="false" generateReset="false" generateDestructor="false">
+ <zorba:member type="PlanState*" name="thePlanState"/>
+ <zorba:member type="PlanIter_t" name="thePlan"/>
+ <zorba:member type="bool" name="theIsOpen"/>
+ <zorba:member type="uint32_t" name="theUDFStateOffset"/>
+ <zorba:member type="store::Item_t" name="theFnItem"/>
+ </zorba:state>
+
+ </zorba:iterator>
+
+</zorba:iterators>
=== modified file 'src/runtime/visitors/pregenerated/printer_visitor.cpp'
--- src/runtime/visitors/pregenerated/printer_visitor.cpp 2013-03-15 08:22:41 +0000
+++ src/runtime/visitors/pregenerated/printer_visitor.cpp 2013-03-27 00:48:21 +0000
@@ -49,7 +49,7 @@
#include "runtime/fetch/fetch.h"
#include "runtime/fnput/fnput.h"
#include "runtime/full_text/ft_module.h"
-#include "runtime/function_item/function_item_iter.h"
+#include "runtime/hof/fn_hof_functions.h"
#include "runtime/indexing/ic_ddl.h"
#include "runtime/indexing/index_func.h"
#include "runtime/introspection/sctx.h"
Follow ups