20
20
#include "runtime/accessors/accessors.h"
22
22
#include "compiler/expression/expr_base.h"
23
#include "compiler/expression/fo_expr.h"
24
25
#include "functions/func_accessors_impl.h"
25
26
#include "functions/func_accessors.h"
31
32
#include "zorbamisc/ns_consts.h"
37
38
/*******************************************************************************
39
40
********************************************************************************/
40
41
BoolAnnotationValue fn_data::ignoresSortedNodes(expr* fo, ulong input) const
52
xqtref_t fn_data::getReturnType(
53
const TypeManager* tm,
54
const std::vector<xqtref_t>& arg_types) const
53
xqtref_t fn_data::getReturnType(const fo_expr* caller) const
55
const QueryLoc& loc = caller->get_loc();
57
TypeManager* tm = caller->get_type_manager();
56
58
RootTypeManager& RTM = GENV_TYPESYSTEM;
58
if (TypeOps::is_subtype(tm, *arg_types[0], *RTM.ANY_ATOMIC_TYPE_STAR, QueryLoc::null))
59
return arg_types[0]; // includes () case
61
const XQType& argType = *arg_types[0];
62
TypeConstants::quantifier_t q = TypeOps::quantifier(argType);
64
if (argType.type_kind() == XQType::NODE_TYPE_KIND)
60
xqtref_t argType = caller->get_arg(0)->get_return_type();
62
if (TypeOps::is_subtype(tm, *argType, *RTM.ANY_ATOMIC_TYPE_STAR, loc))
63
return argType; // includes () case
65
TypeConstants::quantifier_t q = TypeOps::quantifier(*argType);
67
if (argType->type_kind() == XQType::NODE_TYPE_KIND)
66
const NodeXQType& nType = static_cast<const NodeXQType&>(argType);
69
const NodeXQType& nType = static_cast<const NodeXQType&>(*argType);
68
71
store::StoreConsts::NodeKind nodeKind = nType.get_node_kind();
93
96
return tm->create_builtin_atomic_type(TypeConstants::XS_UNTYPED_ATOMIC, q);
95
else if (TypeOps::is_subtype(tm, *cType, *RTM.ANY_ATOMIC_TYPE_STAR, QueryLoc::null))
98
else if (TypeOps::is_subtype(tm, *cType, *RTM.ANY_ATOMIC_TYPE_STAR, loc))
97
100
return tm->create_type(*cType, q);
102
return tm->create_builtin_atomic_type(TypeConstants::XS_ANY_ATOMIC,
103
TypeConstants::QUANT_STAR);
105
return RTM.ANY_ATOMIC_TYPE_STAR;
106
109
/*******************************************************************************
110
fn_data_3_0 is converted to fn_data during translation
108
111
********************************************************************************/
109
BoolAnnotationValue fn_data_3_0::ignoresSortedNodes(expr* fo, ulong input) const
111
return fo->getIgnoresSortedNodes();
115
BoolAnnotationValue fn_data_3_0::ignoresDuplicateNodes(expr* fo, ulong input) const
117
return fo->getIgnoresDuplicateNodes();
121
xqtref_t fn_data_3_0::getReturnType(
122
const TypeManager* tm,
123
const std::vector<xqtref_t>& arg_types) const
125
return tm->create_builtin_atomic_type(TypeConstants::XS_ANY_ATOMIC,
126
TypeConstants::QUANT_STAR);
112
class fn_data_3_0 : public function
115
fn_data_3_0(const signature& sig, FunctionConsts::FunctionKind kind)
119
theXQueryVersion = StaticContextConsts::xquery_version_3_0;
126
PlanIter_t fn_data_3_0::codegen(
128
static_context* sctx,
130
std::vector<PlanIter_t>& argv,
131
AnnotationHolder& ann) const
130
137
/*******************************************************************************
132
139
********************************************************************************/
133
140
PlanIter_t fn_name_func::codegen(
134
141
CompilerCB* /*cb*/,
161
168
/*******************************************************************************
163
170
********************************************************************************/
164
171
void populate_context_accessors_impl(static_context* sctx)
166
173
DECL(sctx, fn_name_func,
167
174
(createQName(static_context::W3C_FN_NS.c_str(), "", "name"),
168
GENV_TYPESYSTEM.STRING_TYPE_ONE));
175
GENV_TYPESYSTEM.STRING_TYPE_ONE));
170
177
DECL(sctx, fn_name_func,
171
178
(createQName(static_context::W3C_FN_NS.c_str(), "", "name"),
172
179
GENV_TYPESYSTEM.ANY_NODE_TYPE_QUESTION,
173
180
GENV_TYPESYSTEM.STRING_TYPE_ONE));
182
DECL_WITH_KIND(sctx, fn_data_3_0,
183
(createQName("http://www.w3.org/2005/xpath-functions","","data"),
184
GENV_TYPESYSTEM.ANY_ATOMIC_TYPE_STAR),
185
FunctionConsts::FN_DATA_0);