2
* Copyright 2006-2008 The FLWOR Foundation.
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
18
#include "common/shared_types.h"
19
#include "types/typeops.h"
21
#include "functions/function.h"
22
#include "functions/function_impl.h"
23
#include "functions/func_fn_hof_functions.h"
25
#include "runtime/hof/fn_hof_functions.h"
27
#include "system/globalenv.h"
33
/*******************************************************************************
35
********************************************************************************/
36
class fn_map_3_0 : public function
39
fn_map_3_0(const signature& sig, FunctionConsts::FunctionKind kind)
43
theXQueryVersion = StaticContextConsts::xquery_version_3_0;
46
bool accessesDynCtx() const { return true; }
48
PlanIter_t codegen(CompilerCB* cb,
51
std::vector<PlanIter_t>& argv,
59
/*******************************************************************************
61
********************************************************************************/
62
class fn_filter : public function
65
fn_filter(const signature& sig, FunctionConsts::FunctionKind kind)
69
theXQueryVersion = StaticContextConsts::xquery_version_3_0;
72
bool accessesDynCtx() const { return true; }
74
PlanIter_t codegen(CompilerCB* ccb,
77
std::vector<PlanIter_t>& argv,
85
/*******************************************************************************
87
********************************************************************************/
88
PlanIter_t fn_fold_left_3_0::codegen(
92
std::vector<PlanIter_t>& argv,
95
return new FnFoldLeftIterator(sctx, loc, argv, false);
99
/*******************************************************************************
101
********************************************************************************/
102
PlanIter_t fn_fold_right_3_0::codegen(
104
static_context* sctx,
106
std::vector<PlanIter_t>& argv,
109
return new FnFoldLeftIterator(sctx, loc, argv, true);
113
/*******************************************************************************
115
********************************************************************************/
116
PlanIter_t fn_function_lookup_3_0::codegen(
118
static_context* sctx,
120
std::vector<PlanIter_t>& argv,
123
return new FunctionLookupIterator(sctx, loc, argv, ccb);
127
/*******************************************************************************
129
********************************************************************************/
130
void populate_context_hof_impl(static_context* sctx)
133
std::vector<xqtref_t> args;
134
args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE);
136
xqtref_t hofParamType = GENV_TYPESYSTEM.create_function_type(
138
GENV_TYPESYSTEM.ITEM_TYPE_STAR,
139
TypeConstants::QUANT_ONE);
143
(createQName(static_context::W3C_FN_NS, "", "map"),
145
GENV_TYPESYSTEM.ITEM_TYPE_STAR,
146
GENV_TYPESYSTEM.ITEM_TYPE_STAR),
147
FunctionConsts::FN_MAP_2);
151
std::vector<xqtref_t> args;
152
args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE);
154
xqtref_t hofParamType = GENV_TYPESYSTEM.create_function_type(
156
GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE,
157
TypeConstants::QUANT_ONE);
161
(createQName(static_context::W3C_FN_NS, "", "filter"),
163
GENV_TYPESYSTEM.ITEM_TYPE_STAR,
164
GENV_TYPESYSTEM.ITEM_TYPE_STAR),
165
FunctionConsts::FN_FILTER_2);
169
std::vector<xqtref_t> args;
170
args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE);
171
args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE);
173
xqtref_t hofParamType = GENV_TYPESYSTEM.create_function_type(
175
GENV_TYPESYSTEM.ITEM_TYPE_STAR,
176
TypeConstants::QUANT_ONE);
180
(createQName(static_context::W3C_FN_NS, "", "map-pairs"),
182
GENV_TYPESYSTEM.ITEM_TYPE_STAR,
183
GENV_TYPESYSTEM.ITEM_TYPE_STAR,
184
GENV_TYPESYSTEM.ITEM_TYPE_STAR),
185
FunctionConsts::FN_MAP_PAIRS_3);
189
std::vector<xqtref_t> args;
190
xqtref_t hofParamType;
192
args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_STAR);
193
args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE);
194
hofParamType = GENV_TYPESYSTEM.create_function_type(
196
GENV_TYPESYSTEM.ITEM_TYPE_STAR,
197
TypeConstants::QUANT_ONE);
201
(createQName(static_context::W3C_FN_NS, "", "fold-left"),
203
GENV_TYPESYSTEM.ITEM_TYPE_STAR,
204
GENV_TYPESYSTEM.ITEM_TYPE_STAR,
205
GENV_TYPESYSTEM.ITEM_TYPE_STAR),
206
FunctionConsts::FN_FOLD_LEFT_3);
209
args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE);
210
args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_STAR);
211
hofParamType = GENV_TYPESYSTEM.create_function_type(
213
GENV_TYPESYSTEM.ITEM_TYPE_STAR,
214
TypeConstants::QUANT_ONE);
218
(createQName(static_context::W3C_FN_NS, "", "fold-right"),
220
GENV_TYPESYSTEM.ITEM_TYPE_STAR,
221
GENV_TYPESYSTEM.ITEM_TYPE_STAR,
222
GENV_TYPESYSTEM.ITEM_TYPE_STAR),
223
FunctionConsts::FN_FOLD_RIGHT_3);
230
/* vim:set et sw=2 ts=2: */