zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #02865
[Merge] lp:~zorba-coders/zorba/fn-type-inference into lp:zorba
Markos Zaharioudakis has proposed merging lp:~zorba-coders/zorba/fn-type-inference into lp:zorba.
Requested reviews:
Markos Zaharioudakis (markos-za)
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/fn-type-inference/+merge/86339
Changed functions to use getReturnType(const fo_expr*) const instead of the old one recieving a TypeManager* and std::vector<xqtref_t>.
--
https://code.launchpad.net/~zorba-coders/zorba/fn-type-inference/+merge/86339
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/compiler/expression/expr_type.cpp'
--- src/compiler/expression/expr_type.cpp 2011-12-01 11:02:25 +0000
+++ src/compiler/expression/expr_type.cpp 2011-12-20 05:51:25 +0000
@@ -1,12 +1,12 @@
/*
* 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.
@@ -77,7 +77,7 @@
if (deep)
{
ExprIterator iter(this);
- while (!iter.done())
+ while (!iter.done())
{
(*iter)->compute_return_type(deep, modified);
iter.next();
@@ -126,7 +126,7 @@
ulong numClauses = e->num_clauses();
- for (ulong i = 0; i < numClauses && quant != TypeConstants::QUANT_STAR; ++i)
+ for (ulong i = 0; i < numClauses && quant != TypeConstants::QUANT_STAR; ++i)
{
const flwor_clause* c = e->theClauses[i];
@@ -186,7 +186,7 @@
{
domainExpr = e->get_domain_expr();
ZORBA_ASSERT(domainExpr != NULL);
-
+
xqtref_t domainType = domainExpr->get_return_type();
if (e->theKind == var_expr::for_var)
@@ -256,10 +256,10 @@
{
xqtref_t stepType = sourceType;
- for (ulong i = 1; i < e->size(); ++i)
+ for (ulong i = 1; i < e->size(); ++i)
{
const axis_step_expr* axisStep = e->theSteps[i].cast<axis_step_expr>();
-
+
stepType = axis_step_type(theSctx,
axisStep,
static_cast<const NodeXQType*>(stepType.getp()));
@@ -300,7 +300,7 @@
*/
FunctionConsts::FunctionKind funcKind = func->getKind();
- switch (funcKind)
+ switch (funcKind)
{
case FunctionConsts::ZORBA_STORE_COLLECTIONS_STATIC_DML_COLLECTION_1:
{
@@ -346,13 +346,7 @@
if (newType == NULL)
{
- ulong numArgs = (ulong)e->theArgs.size();
- std::vector<xqtref_t> types(numArgs);
-
- for (ulong i = 0; i < numArgs; ++i)
- types[i] = e->theArgs[i]->get_return_type();
-
- newType = e->theFunction->getReturnType(tm, types);
+ newType = e->theFunction->getReturnType(e);
}
break;
@@ -365,7 +359,7 @@
xqtref_t argType = e->theInputExpr->get_return_type();
TypeConstants::quantifier_t argQuant = argType->get_quantifier();
TypeConstants::quantifier_t targetQuant = e->theTargetType->get_quantifier();
-
+
if (TypeOps::is_equal(tm, *argType, *rtm.EMPTY_TYPE, get_loc()) &&
(targetQuant == TypeConstants::QUANT_QUESTION ||
targetQuant == TypeConstants::QUANT_STAR))
@@ -393,7 +387,7 @@
TypeOps::intersect_quant(TypeOps::quantifier(*input_type),
TypeOps::quantifier(*e->theTargetType));
- if (TypeOps::is_subtype(tm, *input_ptype, *target_ptype, get_loc()))
+ if (TypeOps::is_subtype(tm, *input_ptype, *target_ptype, get_loc()))
{
newType = tm->create_type(*input_ptype, q);
}
@@ -430,24 +424,24 @@
// TODO: for nodes, the result would be none
if (TypeOps::is_equal(tm, *in_ptype, *rtm.UNTYPED_ATOMIC_TYPE_ONE))
return tm->create_type_x_quant(*target_ptype, q);
-
+
// decimal --> float
- if (TypeOps::is_subtype(tm, *target_ptype, *rtm.FLOAT_TYPE_ONE))
+ if (TypeOps::is_subtype(tm, *target_ptype, *rtm.FLOAT_TYPE_ONE))
{
if (TypeOps::is_subtype(tm, *in_ptype, *ts.DECIMAL_TYPE_ONE))
return tm->create_type_x_quant(*target_ptype, q);
}
-
+
// decimal/float --> double
- if (TypeOps::is_subtype(tm, *target_ptype, *rtm.DOUBLE_TYPE_ONE))
+ if (TypeOps::is_subtype(tm, *target_ptype, *rtm.DOUBLE_TYPE_ONE))
{
if (TypeOps::is_subtype(tm, *in_ptype, *rtm.DECIMAL_TYPE_ONE) ||
TypeOps::is_subtype(tm, *in_ptype, *rtm.FLOAT_TYPE_ONE))
return tm->create_type_x_quant(*target_ptype, q);
}
-
+
// uri --> string
- if (TypeOps::is_subtype(tm, *target_ptype, *rtm.STRING_TYPE_ONE))
+ if (TypeOps::is_subtype(tm, *target_ptype, *rtm.STRING_TYPE_ONE))
{
if (TypeOps::is_subtype(tm, *in_ptype, *rtm.ANY_URI_TYPE_ONE))
return tm->create_type_x_quant(*target_ptype, q);
@@ -488,7 +482,7 @@
{
xqtref_t typeName =
(theSctx->construction_mode() == StaticContextConsts::cons_preserve ?
- rtm.ANY_TYPE :
+ rtm.ANY_TYPE :
rtm.UNTYPED_TYPE);
newType = tm->create_node_type(store::StoreConsts::elementNode,
@@ -523,9 +517,9 @@
TypeConstants::quantifier_t q = TypeConstants::QUANT_ONE;
- switch (e->type)
+ switch (e->type)
{
- case text_expr::text_constructor:
+ case text_expr::text_constructor:
{
xqtref_t t = e->get_text()->get_return_type();
@@ -671,7 +665,7 @@
newType = e->theExpr->get_return_type();
std::vector<expr*> exitExprs;
-
+
body->get_exprs_of_kind(exit_expr_kind, exitExprs);
ulong numExitExprs = exitExprs.size();
@@ -748,7 +742,7 @@
assert(newType != NULL);
- if (modified != NULL &&
+ if (modified != NULL &&
(theType == NULL || !TypeOps::is_equal(tm, *newType, *theType, get_loc())))
{
*modified = true;
@@ -838,7 +832,7 @@
// Only element or doc nodes are reachable via the parent axis.
if (testNodeKind != store::StoreConsts::documentNode &&
- testNodeKind != store::StoreConsts::elementNode &&
+ testNodeKind != store::StoreConsts::elementNode &&
testNodeKind != store::StoreConsts::anyNode)
{
throw XQUERY_EXCEPTION(err::XPST0005, ERROR_LOC(loc));
@@ -866,7 +860,7 @@
// Only element or doc nodes are reachable via the ancestor axis.
if (testNodeKind != store::StoreConsts::documentNode &&
- testNodeKind != store::StoreConsts::elementNode &&
+ testNodeKind != store::StoreConsts::elementNode &&
testNodeKind != store::StoreConsts::anyNode)
{
throw XQUERY_EXCEPTION(err::XPST0005, ERROR_LOC(loc));
@@ -903,7 +897,7 @@
{
return RTM.ANY_NODE_TYPE_STAR;
}
- else
+ else
{
// We are looking for attribute, test, pi, or comment ancestor nodes. Only
// the "self" node may qualify, so we jump to the axis_kind_self case.
@@ -974,7 +968,7 @@
case axis_kind_descendant_or_self:
{
- // If we are looking for descendants or self of attribute, test, pi, or
+ // If we are looking for descendants or self of attribute, test, pi, or
// comment nodes, only the "self" node may qualify, so we jump to the
// axis_kind_self case.
if (inNodeKind == store::StoreConsts::attributeNode ||
@@ -986,7 +980,7 @@
}
// if we are looking for document or attribute descendants of a node, only
- // the "self" node may qualify, so we jump to the axis_kind_self case.
+ // the "self" node may qualify, so we jump to the axis_kind_self case.
if (testNodeKind == store::StoreConsts::documentNode ||
testNodeKind == store::StoreConsts::attributeNode)
{
@@ -1006,7 +1000,7 @@
case store::StoreConsts::piNode:
return RTM.PI_TYPE_STAR;
-
+
case store::StoreConsts::commentNode:
return RTM.COMMENT_TYPE_STAR;
@@ -1047,7 +1041,7 @@
case store::StoreConsts::piNode:
return RTM.PI_TYPE_STAR;
-
+
case store::StoreConsts::commentNode:
return RTM.COMMENT_TYPE_STAR;
@@ -1069,7 +1063,7 @@
// only attribute nodes are reachable via the attribute axis.
if (testKind != match_name_test &&
- testKind != match_anykind_test &&
+ testKind != match_anykind_test &&
testKind != match_attr_test &&
testKind != match_xs_attr_test)
{
@@ -1133,7 +1127,7 @@
case store::StoreConsts::piNode:
return RTM.PI_TYPE_STAR;
-
+
case store::StoreConsts::commentNode:
return RTM.COMMENT_TYPE_STAR;
@@ -1168,9 +1162,9 @@
{
RootTypeManager& RTM = GENV_TYPESYSTEM;
- if (untyped)
+ if (untyped)
{
- xqtref_t contentType;
+ xqtref_t contentType;
if (nodekind == store::StoreConsts::attributeNode)
contentType = RTM.UNTYPED_ATOMIC_TYPE_ONE;
else
@@ -1197,7 +1191,7 @@
}
else
{
- xqtref_t contentType;
+ xqtref_t contentType;
if (nodekind == store::StoreConsts::attributeNode)
contentType = RTM.ANY_SIMPLE_TYPE;
else
=== modified file 'src/functions/func_accessors_impl.cpp'
--- src/functions/func_accessors_impl.cpp 2011-07-01 05:22:12 +0000
+++ src/functions/func_accessors_impl.cpp 2011-12-20 05:51:25 +0000
@@ -20,6 +20,7 @@
#include "runtime/accessors/accessors.h"
#include "compiler/expression/expr_base.h"
+#include "compiler/expression/fo_expr.h"
#include "functions/func_accessors_impl.h"
#include "functions/func_accessors.h"
@@ -31,11 +32,11 @@
#include "zorbamisc/ns_consts.h"
-namespace zorba
+namespace zorba
{
/*******************************************************************************
-
+
********************************************************************************/
BoolAnnotationValue fn_data::ignoresSortedNodes(expr* fo, ulong input) const
{
@@ -49,16 +50,21 @@
}
-xqtref_t fn_data::getReturnType(
- const TypeManager* tm,
- const std::vector<xqtref_t>& arg_types) const
+xqtref_t fn_data::getReturnType(const fo_expr* caller) const
{
+ TypeManager* tm = caller->get_type_manager();
+
RootTypeManager& RTM = GENV_TYPESYSTEM;
- if (TypeOps::is_subtype(tm, *arg_types[0], *RTM.ANY_ATOMIC_TYPE_STAR, QueryLoc::null))
- return arg_types[0]; // includes () case
-
- const XQType& argType = *arg_types[0];
+ xqtref_t arg_type = caller->get_arg(0)->get_return_type();
+
+ if (TypeOps::is_subtype(tm,
+ *arg_type,
+ *RTM.ANY_ATOMIC_TYPE_STAR,
+ QueryLoc::null))
+ return arg_type; // includes () case
+
+ const XQType& argType = *arg_type;
TypeConstants::quantifier_t q = TypeOps::quantifier(argType);
if (argType.type_kind() == XQType::NODE_TYPE_KIND)
@@ -78,7 +84,7 @@
{
return tm->create_builtin_atomic_type(TypeConstants::XS_UNTYPED_ATOMIC, q);
}
-
+
xqtref_t cType = nType.get_content_type();
if (cType != NULL)
{
@@ -104,7 +110,7 @@
}
/*******************************************************************************
-
+
********************************************************************************/
BoolAnnotationValue fn_data_3_0::ignoresSortedNodes(expr* fo, ulong input) const
{
@@ -118,17 +124,17 @@
}
-xqtref_t fn_data_3_0::getReturnType(
- const TypeManager* tm,
- const std::vector<xqtref_t>& arg_types) const
+xqtref_t fn_data_3_0::getReturnType(const fo_expr* caller) const
{
+ TypeManager* tm = caller->get_type_manager();
+
return tm->create_builtin_atomic_type(TypeConstants::XS_ANY_ATOMIC,
TypeConstants::QUANT_STAR);
}
/*******************************************************************************
-
+
********************************************************************************/
PlanIter_t fn_name_func::codegen(
CompilerCB* /*cb*/,
@@ -145,7 +151,7 @@
/*******************************************************************************
-
+
********************************************************************************/
PlanIter_t fn_string::codegen(
CompilerCB* /*cb*/,
@@ -159,7 +165,7 @@
/*******************************************************************************
-
+
********************************************************************************/
void populate_context_accessors_impl(static_context* sctx)
{
=== modified file 'src/functions/func_errors_and_diagnostics_impl.cpp'
--- src/functions/func_errors_and_diagnostics_impl.cpp 2011-12-01 11:02:25 +0000
+++ src/functions/func_errors_and_diagnostics_impl.cpp 2011-12-20 05:51:25 +0000
@@ -19,6 +19,7 @@
#include "compiler/api/compilercb.h"
#include "compiler/expression/expr_base.h"
+#include "compiler/expression/fo_expr.h"
#include "zorbamisc/ns_consts.h"
#include "functions/func_errors_and_diagnostics.h"
@@ -33,15 +34,15 @@
********************************************************************************/
BoolAnnotationValue fn_trace::ignoresSortedNodes(
expr* fo,
- ulong input) const
+ ulong input) const
{
return fo->getIgnoresSortedNodes();
}
BoolAnnotationValue fn_trace::ignoresDuplicateNodes(
- expr* fo,
- ulong input) const
+ expr* fo,
+ ulong input) const
{
return fo->getIgnoresDuplicateNodes();
}
@@ -68,11 +69,9 @@
/*******************************************************************************
********************************************************************************/
-xqtref_t fn_trace::getReturnType(
- const TypeManager* tm,
- const std::vector<xqtref_t>& argTypes) const
+xqtref_t fn_trace::getReturnType(const fo_expr* caller) const
{
- return argTypes[0];
+ return caller->get_arg(0)->get_return_type();
}
} // namespace zorba
=== modified file 'src/functions/func_numerics_impl.cpp'
--- src/functions/func_numerics_impl.cpp 2011-06-14 17:26:33 +0000
+++ src/functions/func_numerics_impl.cpp 2011-12-20 05:51:25 +0000
@@ -18,6 +18,8 @@
#include "runtime/numerics/NumericsImpl.h"
#include "runtime/core/arithmetic_impl.h"
+#include "compiler/expression/fo_expr.h"
+
#include "functions/func_numerics.h"
#include "functions/func_numerics_impl.h"
@@ -25,7 +27,7 @@
#include "types/typeops.h"
-namespace zorba
+namespace zorba
{
#define SPECIALIZE_NUMERIC_ARITH_FUNCTION(kind, type) \
@@ -67,7 +69,7 @@
class bin_num_arith_func : public function
{
public:
- bin_num_arith_func(const signature& sig, FunctionConsts::FunctionKind kind)
+ bin_num_arith_func(const signature& sig, FunctionConsts::FunctionKind kind)
:
function(sig, kind)
{
@@ -75,13 +77,13 @@
bool isArithmeticFunction() const { return true; }
- xqtref_t getReturnType(
- const TypeManager* tm,
- const std::vector<xqtref_t>& arg_types) const
+ xqtref_t getReturnType(const fo_expr* caller)
{
+ TypeManager* tm = caller->get_type_manager();
+
return TypeOps::arithmetic_type(tm,
- *arg_types[0],
- *arg_types[1],
+ *(caller->get_arg(0)->get_return_type()),
+ *(caller->get_arg(1)->get_return_type()),
arithmeticKind() == ArithmeticConsts::DIVISION);
}
};
@@ -90,7 +92,7 @@
/*******************************************************************************
********************************************************************************/
-class specializable_bin_num_arith_func : public bin_num_arith_func
+class specializable_bin_num_arith_func : public bin_num_arith_func
{
public:
specializable_bin_num_arith_func(
@@ -109,7 +111,7 @@
function* specializable_bin_num_arith_func::specialize(
static_context* sctx,
- const std::vector<xqtref_t>& argTypes) const
+ const std::vector<xqtref_t>& argTypes) const
{
xqtref_t t0 = argTypes[0];
xqtref_t t1 = argTypes[1];
@@ -119,10 +121,10 @@
{
TypeConstants::atomic_type_code_t tc0 = TypeOps::get_atomic_type_code(*t0);
TypeConstants::atomic_type_code_t tc1 = TypeOps::get_atomic_type_code(*t1);
-
+
if (tc0 == tc1)
{
- switch(tc0)
+ switch(tc0)
{
case TypeConstants::XS_DOUBLE:
SPECIALIZE_NUMERIC_ARITH_FUNCTION(theKind, DOUBLE);
@@ -149,15 +151,15 @@
6.2.1 op:numeric-add
op:numeric-add($arg1 as numeric, $arg2 as numeric) as numeric
-
- Summary: Backs up the "+" operator and returns the arithmetic sum of
+
+ Summary: Backs up the "+" operator and returns the arithmetic sum of
its operands: ($arg1 + $arg2).
-
+
Note:
- For xs:float or xs:double values, if one of the operands is a zero or
- a finite number and the other is INF or -INF, INF or -INF is returned.
- If both operands are INF, INF is returned. If both operands are -INF,
- -INF is returned. If one of the operands is INF and the other is -INF,
+ For xs:float or xs:double values, if one of the operands is a zero or
+ a finite number and the other is INF or -INF, INF or -INF is returned.
+ If both operands are INF, INF is returned. If both operands are -INF,
+ -INF is returned. If one of the operands is INF and the other is -INF,
NaN is returned.
********************************************************************************/
class op_numeric_add : public specializable_bin_num_arith_func
@@ -169,7 +171,7 @@
{
};
- ArithmeticConsts::OperationKind arithmeticKind() const
+ ArithmeticConsts::OperationKind arithmeticKind() const
{
return ArithmeticConsts::ADDITION;
}
@@ -186,7 +188,7 @@
{
}
- ArithmeticConsts::OperationKind arithmeticKind() const
+ ArithmeticConsts::OperationKind arithmeticKind() const
{
return ArithmeticConsts::ADDITION;
}
@@ -195,27 +197,27 @@
};
-typedef
+typedef
op_numeric_add_specific<TypeConstants::XS_DOUBLE,
- FunctionConsts::OP_NUMERIC_ADD_DOUBLE_2>
+ FunctionConsts::OP_NUMERIC_ADD_DOUBLE_2>
op_numeric_add_double;
-typedef
+typedef
op_numeric_add_specific<TypeConstants::XS_FLOAT,
- FunctionConsts::OP_NUMERIC_ADD_FLOAT_2>
+ FunctionConsts::OP_NUMERIC_ADD_FLOAT_2>
op_numeric_add_float;
-typedef
+typedef
op_numeric_add_specific<TypeConstants::XS_DECIMAL,
- FunctionConsts::OP_NUMERIC_ADD_DECIMAL_2>
+ FunctionConsts::OP_NUMERIC_ADD_DECIMAL_2>
op_numeric_add_decimal;
-typedef
+typedef
op_numeric_add_specific<TypeConstants::XS_INTEGER,
- FunctionConsts::OP_NUMERIC_ADD_INTEGER_2>
+ FunctionConsts::OP_NUMERIC_ADD_INTEGER_2>
op_numeric_add_integer;
@@ -223,10 +225,10 @@
6.2.2 op:numeric-subtract
op:numeric-subtract($arg1 as numeric, $arg2 as numeric) as numeric
-
+
Summary: Backs up the "-" operator and returns the arithmetic difference of
its operands: ($arg1 - $arg2).
-
+
Note:
For xs:float or xs:double values, if one of the operands is a zero or a
finite number and the other is INF or -INF, an infinity of the appropriate
@@ -237,13 +239,13 @@
class op_numeric_subtract : public specializable_bin_num_arith_func
{
public:
- op_numeric_subtract(const signature& sig)
+ op_numeric_subtract(const signature& sig)
:
specializable_bin_num_arith_func(sig, FunctionConsts::OP_NUMERIC_SUBTRACT_2)
{
};
- ArithmeticConsts::OperationKind arithmeticKind() const
+ ArithmeticConsts::OperationKind arithmeticKind() const
{
return ArithmeticConsts::SUBTRACTION;
}
@@ -260,7 +262,7 @@
{
}
- ArithmeticConsts::OperationKind arithmeticKind() const
+ ArithmeticConsts::OperationKind arithmeticKind() const
{
return ArithmeticConsts::SUBTRACTION;
}
@@ -269,27 +271,27 @@
};
-typedef
+typedef
op_numeric_subtract_specific<TypeConstants::XS_DOUBLE,
- FunctionConsts::OP_NUMERIC_SUBTRACT_DOUBLE_2>
+ FunctionConsts::OP_NUMERIC_SUBTRACT_DOUBLE_2>
op_numeric_subtract_double;
-typedef
+typedef
op_numeric_subtract_specific<TypeConstants::XS_FLOAT,
- FunctionConsts::OP_NUMERIC_SUBTRACT_FLOAT_2>
+ FunctionConsts::OP_NUMERIC_SUBTRACT_FLOAT_2>
op_numeric_subtract_float;
-typedef
+typedef
op_numeric_subtract_specific<TypeConstants::XS_DECIMAL,
- FunctionConsts::OP_NUMERIC_SUBTRACT_DECIMAL_2>
+ FunctionConsts::OP_NUMERIC_SUBTRACT_DECIMAL_2>
op_numeric_subtract_decimal;
-typedef
+typedef
op_numeric_subtract_specific<TypeConstants::XS_INTEGER,
- FunctionConsts::OP_NUMERIC_SUBTRACT_INTEGER_2>
+ FunctionConsts::OP_NUMERIC_SUBTRACT_INTEGER_2>
op_numeric_subtract_integer;
@@ -297,10 +299,10 @@
6.2.3 op:numeric-multiply
op:numeric-multiply($arg1 as numeric, $arg2 as numeric) as numeric
-
+
Summary: Backs up the "*" operator and returns the arithmetic product of its
operands: ($arg1 * $arg2).
-
+
Note:
For xs:float or xs:double values, if one of the operands is a zero and the
other is an infinity, NaN is returned. If one of the operands is a non-zero
@@ -310,13 +312,13 @@
class op_numeric_multiply : public specializable_bin_num_arith_func
{
public:
- op_numeric_multiply(const signature& sig)
+ op_numeric_multiply(const signature& sig)
:
specializable_bin_num_arith_func(sig, FunctionConsts::OP_NUMERIC_MULTIPLY_2)
{
};
- ArithmeticConsts::OperationKind arithmeticKind() const
+ ArithmeticConsts::OperationKind arithmeticKind() const
{
return ArithmeticConsts::MULTIPLICATION;
}
@@ -333,7 +335,7 @@
{
};
- ArithmeticConsts::OperationKind arithmeticKind() const
+ ArithmeticConsts::OperationKind arithmeticKind() const
{
return ArithmeticConsts::MULTIPLICATION;
}
@@ -354,13 +356,13 @@
op_numeric_multiply_float;
-typedef
-op_numeric_multiply_specific<TypeConstants::XS_DECIMAL,
+typedef
+op_numeric_multiply_specific<TypeConstants::XS_DECIMAL,
FunctionConsts::OP_NUMERIC_MULTIPLY_DECIMAL_2>
op_numeric_multiply_decimal;
-typedef
+typedef
op_numeric_multiply_specific<TypeConstants::XS_INTEGER,
FunctionConsts::OP_NUMERIC_MULTIPLY_INTEGER_2>
op_numeric_multiply_integer;
@@ -373,16 +375,16 @@
Summary: Backs up the "div" operator and returns the arithmetic quotient of
its operands: ($arg1 div $arg2).
-
+
As a special case, if the types of both $arg1 and $arg2 are xs:integer, then
the return type is xs:decimal.
-
+
Notes:
For xs:decimal and xs:integer operands, if the divisor is (positive or
- negative) zero, an error is raised [err:FOAR0001]. For xs:float and
- xs:double operands, floating point division is performed as specified
+ negative) zero, an error is raised [err:FOAR0001]. For xs:float and
+ xs:double operands, floating point division is performed as specified
in [IEEE 754-1985].
-
+
For xs:float or xs:double values, a positive number divided by positive zero
returns INF. A negative number divided by positive zero returns -INF. Division
by negative zero returns -INF and INF, respectively. Positive or negative zero
@@ -392,13 +394,13 @@
class op_numeric_divide : public specializable_bin_num_arith_func
{
public:
- op_numeric_divide(const signature& sig)
+ op_numeric_divide(const signature& sig)
:
specializable_bin_num_arith_func(sig, FunctionConsts::OP_NUMERIC_DIVIDE_2)
{
}
- ArithmeticConsts::OperationKind arithmeticKind() const
+ ArithmeticConsts::OperationKind arithmeticKind() const
{
return ArithmeticConsts::DIVISION;
}
@@ -415,7 +417,7 @@
{
}
- ArithmeticConsts::OperationKind arithmeticKind() const
+ ArithmeticConsts::OperationKind arithmeticKind() const
{
return ArithmeticConsts::DIVISION;
}
@@ -436,15 +438,15 @@
op_numeric_divide_float;
-typedef
+typedef
op_numeric_divide_specific<TypeConstants::XS_DECIMAL,
- FunctionConsts::OP_NUMERIC_DIVIDE_DECIMAL_2>
+ FunctionConsts::OP_NUMERIC_DIVIDE_DECIMAL_2>
op_numeric_divide_decimal;
-typedef
+typedef
op_numeric_divide_specific<TypeConstants::XS_INTEGER,
- FunctionConsts::OP_NUMERIC_DIVIDE_INTEGER_2>
+ FunctionConsts::OP_NUMERIC_DIVIDE_INTEGER_2>
op_numeric_divide_integer;
@@ -453,37 +455,37 @@
6.2.5 op:numeric-integer-divide
op:numeric-integer-divide($arg1 as numeric, $arg2 as numeric) as xs:integer
-
+
Summary: This function backs up the "idiv" operator and performs an integer
division: that is, it divides the first argument by the second, and returns
the integer obtained by truncating the fractional part of the result. The
division is performed so that the sign of the fractional part is the same as
the sign of the dividend.
-
+
If the dividend, $arg1, is not evenly divided by the divisor, $arg2, then
the quotient is the xs:integer value obtained, ignoring (truncating) any
remainder that results from the division (that is, no rounding is performed).
Thus, the semantics " $a idiv $b " are equivalent to " ($a div $b) cast as
xs:integer" except for error situations.
-
- If the divisor is (positive or negative) zero, then an error is raised
+
+ If the divisor is (positive or negative) zero, then an error is raised
[err:FOAR0001]. If either operand is NaN or if $arg1 is INF or -INF then
an error is raised [err:FOAR0002].
-
+
Note:
- The semantics of this function are different from integer division as
+ The semantics of this function are different from integer division as
defined in programming languages such as Java and C++.
********************************************************************************/
class op_numeric_integer_divide : public bin_num_arith_func
{
public:
- op_numeric_integer_divide(const signature& sig)
+ op_numeric_integer_divide(const signature& sig)
:
bin_num_arith_func(sig, FunctionConsts::OP_NUMERIC_INTEGER_DIVIDE_2)
{
};
- ArithmeticConsts::OperationKind arithmeticKind() const
+ ArithmeticConsts::OperationKind arithmeticKind() const
{
return ArithmeticConsts::INTEGER_DIVISION;
}
@@ -497,46 +499,46 @@
6.2.6 op:numeric-mod
op:numeric-mod($arg1 as numeric, $arg2 as numeric) as numeric
-
- Summary: Backs up the "mod" operator. Informally, this function
- returns the remainder resulting from dividing $arg1, the dividend, by
- $arg2, the divisor. The operation a mod b for operands that are
- xs:integer or xs:decimal, or types derived from them, produces a
- result such that (a idiv b)*b+(a mod b) is equal to a and the
- magnitude of the result is always less than the magnitude of b. This
- identity holds even in the special case that the dividend is the
- negative integer of largest possible magnitude for its type and the
- divisor is -1 (the remainder is 0). It follows from this rule that the
+
+ Summary: Backs up the "mod" operator. Informally, this function
+ returns the remainder resulting from dividing $arg1, the dividend, by
+ $arg2, the divisor. The operation a mod b for operands that are
+ xs:integer or xs:decimal, or types derived from them, produces a
+ result such that (a idiv b)*b+(a mod b) is equal to a and the
+ magnitude of the result is always less than the magnitude of b. This
+ identity holds even in the special case that the dividend is the
+ negative integer of largest possible magnitude for its type and the
+ divisor is -1 (the remainder is 0). It follows from this rule that the
sign of the result is the sign of the dividend.
-
- For xs:integer and xs:decimal operands, if $arg2 is zero, then an
+
+ For xs:integer and xs:decimal operands, if $arg2 is zero, then an
error is raised [err:FOAR0001].
For xs:float and xs:double operands the following rules apply:
* If either operand is NaN, the result is NaN.
- * If the dividend is positive or negative infinity, or the divisor
+ * If the dividend is positive or negative infinity, or the divisor
is positive or negative zero (0), or both, the result is NaN.
- * If the dividend is finite and the divisor is an infinity, the
+ * If the dividend is finite and the divisor is an infinity, the
result equals the dividend.
- * If the dividend is positive or negative zero and the divisor is
+ * If the dividend is positive or negative zero and the divisor is
finite, the result is the same as the dividend.
- * In the remaining cases, where neither positive or negative
- infinity, nor positive or negative zero, nor NaN is involved, the
- result obeys (a idiv b)*b+(a mod b) = a. Division is truncating
- division, analogous to integer division, not [IEEE 754-1985] rounding
- division i.e. additional digits are truncated, not rounded to the
+ * In the remaining cases, where neither positive or negative
+ infinity, nor positive or negative zero, nor NaN is involved, the
+ result obeys (a idiv b)*b+(a mod b) = a. Division is truncating
+ division, analogous to integer division, not [IEEE 754-1985] rounding
+ division i.e. additional digits are truncated, not rounded to the
required precision.
********************************************************************************/
class op_numeric_mod : public bin_num_arith_func
{
public:
- op_numeric_mod(const signature& sig)
+ op_numeric_mod(const signature& sig)
:
- bin_num_arith_func(sig, FunctionConsts::OP_NUMERIC_MOD_2)
+ bin_num_arith_func(sig, FunctionConsts::OP_NUMERIC_MOD_2)
{
};
- ArithmeticConsts::OperationKind arithmeticKind() const
+ ArithmeticConsts::OperationKind arithmeticKind() const
{
return ArithmeticConsts::MODULO;
}
@@ -549,7 +551,7 @@
/*******************************************************************************
********************************************************************************/
-class single_numeric_func : public function
+class single_numeric_func : public function
{
public:
single_numeric_func(const signature& sig, FunctionConsts::FunctionKind kind)
@@ -558,11 +560,9 @@
{
}
- virtual xqtref_t getReturnType(
- const TypeManager* tm,
- const std::vector<xqtref_t>& arg_types) const
+ virtual xqtref_t getReturnType(const fo_expr* caller) const
{
- return arg_types[0];
+ return caller->get_arg(0)->get_return_type();
}
virtual bool specializable() const { return true; }
@@ -603,7 +603,7 @@
/*******************************************************************************
6.2.7 op:numeric-unary-plus
-
+
op:numeric-unary-plus($arg as numeric) as numeric
Summary: Backs up the unary "+" operator and returns its operand with the
@@ -661,14 +661,14 @@
/*******************************************************************************
6.2.8 op:numeric-unary-minus
-
+
op:numeric-unary-minus($arg as numeric) as numeric
Summary: Backs up the unary "-" operator and returns its operand with the
- sign reverse: (- $arg).
+ sign reverse: (- $arg).
- For xs:integer and xs:decimal arguments, 0 and 0.0 return 0 and 0.0,
- respectively. For xs:float and xs:double arguments, NaN returns NaN,
+ For xs:integer and xs:decimal arguments, 0 and 0.0 return 0 and 0.0,
+ respectively. For xs:float and xs:double arguments, NaN returns NaN,
0.0E0 returns -0.0E0 and vice versa. INF returns -INF. -INF returns INF.
********************************************************************************/
class op_numeric_unary_minus : public single_numeric_func
@@ -724,36 +724,35 @@
/*******************************************************************************
********************************************************************************/
-xqtref_t fn_floor::getReturnType(
- const TypeManager* tm,
- const std::vector<xqtref_t>& argTypes) const
+xqtref_t fn_floor::getReturnType(const fo_expr* caller) const
{
+ TypeManager* tm = caller->get_type_manager();
RootTypeManager& rtm = GENV_TYPESYSTEM;
- const XQType& argType = *argTypes[0];
+ const XQType& argType = *(caller->get_arg(0)->get_return_type());
TypeConstants::quantifier_t quant = argType.get_quantifier();
if (TypeOps::is_subtype(tm, argType, *rtm.DOUBLE_TYPE_QUESTION))
{
- return (quant == TypeConstants::QUANT_ONE ?
+ return (quant == TypeConstants::QUANT_ONE ?
rtm.DOUBLE_TYPE_ONE :
rtm.DOUBLE_TYPE_QUESTION);
}
else if (TypeOps::is_subtype(tm, argType, *rtm.FLOAT_TYPE_QUESTION))
{
- return (quant == TypeConstants::QUANT_ONE ?
+ return (quant == TypeConstants::QUANT_ONE ?
rtm.FLOAT_TYPE_ONE :
rtm.FLOAT_TYPE_QUESTION);
}
else if (TypeOps::is_subtype(tm, argType, *rtm.DECIMAL_TYPE_QUESTION))
{
- return (quant == TypeConstants::QUANT_ONE ?
+ return (quant == TypeConstants::QUANT_ONE ?
rtm.DECIMAL_TYPE_ONE :
rtm.DECIMAL_TYPE_QUESTION);
}
else if (TypeOps::is_subtype(tm, argType, *rtm.INTEGER_TYPE_QUESTION))
{
- return (quant == TypeConstants::QUANT_ONE ?
+ return (quant == TypeConstants::QUANT_ONE ?
rtm.INTEGER_TYPE_ONE :
rtm.INTEGER_TYPE_QUESTION);
}
@@ -786,7 +785,7 @@
DECL_ARITH(sctx, op, integer, INTEGER)
-void populateContext_Numerics(static_context* sctx)
+void populateContext_Numerics(static_context* sctx)
{
const char* xquery_op_ns = static_context::XQUERY_OP_NS.c_str();
const char* zorba_op_ns = static_context::ZORBA_OP_NS.c_str();
@@ -809,14 +808,14 @@
GENV_TYPESYSTEM.ANY_ATOMIC_TYPE_QUESTION));
/*
- XPath 2.0 Specification
+ XPath 2.0 Specification
http://www.w3.org/TR/xpath20/#id-arithmetic says that:
- If the atomized operand is an empty sequence, the result
- of the arithmetic expression is an empty sequence, and the
- implementation need not evaluate the other operand or
+ If the atomized operand is an empty sequence, the result
+ of the arithmetic expression is an empty sequence, and the
+ implementation need not evaluate the other operand or
apply the operator.
- Thus the arithmetic operators allow for empty sequences
+ Thus the arithmetic operators allow for empty sequences
as parameters and return results, contrary to the signature
of these functions as described in XQuery and XPath Functions
Specification.
=== modified file 'src/functions/func_sequences_impl.cpp'
--- src/functions/func_sequences_impl.cpp 2011-12-14 04:23:24 +0000
+++ src/functions/func_sequences_impl.cpp 2011-12-20 05:51:25 +0000
@@ -42,11 +42,11 @@
/*******************************************************************************
********************************************************************************/
-xqtref_t op_concatenate::getReturnType(
- const TypeManager* tm,
- const std::vector<xqtref_t>& arg_types) const
+xqtref_t op_concatenate::getReturnType(const fo_expr* caller) const
{
- ulong sz = (ulong)arg_types.size();
+ TypeManager* tm = caller->get_type_manager();
+
+ ulong sz = (ulong)caller->num_args();
if (sz == 0)
{
@@ -54,11 +54,11 @@
}
else
{
- xqtref_t t = arg_types[0];
+ xqtref_t t = caller->get_arg(0)->get_return_type();
TypeConstants::quantifier_t q = TypeConstants::QUANT_STAR;
for (ulong i = 1; i < sz; i++)
{
- t = TypeOps::union_type(*t, *arg_types[i], tm);
+ t = TypeOps::union_type(*t, *caller->get_arg(i)->get_return_type(), tm);
TypeConstants::quantifier_t pq = TypeOps::quantifier(*t);
if (pq == TypeConstants::QUANT_ONE || pq == TypeConstants::QUANT_PLUS)
q = TypeConstants::QUANT_PLUS;
@@ -116,11 +116,9 @@
/*******************************************************************************
********************************************************************************/
-xqtref_t fn_distinct_values::getReturnType(
- const TypeManager* tm,
- const std::vector<xqtref_t>& arg_types) const
+xqtref_t fn_distinct_values::getReturnType(const fo_expr* caller) const
{
- return arg_types[0];
+ return caller->get_arg(0)->get_return_type();
}
@@ -149,6 +147,16 @@
/*******************************************************************************
********************************************************************************/
+xqtref_t fn_insert_before::getReturnType(const fo_expr* caller) const
+{
+ TypeManager* tm = caller->get_type_manager();
+ xqtref_t list_type = caller->get_arg(0)->get_return_type();
+ xqtref_t insert_type = caller->get_arg(2)->get_return_type();
+
+ return TypeOps::union_type(*list_type, *insert_type, tm);
+}
+
+
BoolAnnotationValue fn_insert_before::ignoresSortedNodes(
expr* fo,
ulong input) const
@@ -174,11 +182,13 @@
/*******************************************************************************
********************************************************************************/
-xqtref_t fn_remove::getReturnType(
- const TypeManager* tm,
- const std::vector<xqtref_t>& arg_types) const
+xqtref_t fn_remove::getReturnType(const fo_expr* caller) const
{
- return tm->create_type_x_quant(*arg_types[0], TypeConstants::QUANT_QUESTION);
+ TypeManager* tm = caller->get_type_manager();
+
+ return tm->create_type_x_quant(
+ *caller->get_arg(0)->get_return_type(),
+ TypeConstants::QUANT_QUESTION);
}
@@ -204,11 +214,9 @@
/*******************************************************************************
********************************************************************************/
-xqtref_t fn_reverse::getReturnType(
- const TypeManager* tm,
- const std::vector<xqtref_t>& arg_types) const
+xqtref_t fn_reverse::getReturnType(const fo_expr* caller) const
{
- return arg_types[0];
+ return caller->get_arg(0)->get_return_type();
}
@@ -231,11 +239,22 @@
/*******************************************************************************
********************************************************************************/
-xqtref_t fn_subsequence::getReturnType(
- const TypeManager* tm,
- const std::vector<xqtref_t>& arg_types) const
+xqtref_t fn_subsequence::getReturnType(const fo_expr* caller) const
{
- return tm->create_type_x_quant(*arg_types[0], TypeConstants::QUANT_QUESTION);
+ TypeManager* tm = caller->get_type_manager();
+ xqtref_t list_type = caller->get_arg(0)->get_return_type();
+
+ //When there is a length argument and it's 1 then we know we will return
+ //a value type T? where the input sequence was type T* or T+
+ if(caller->num_args() > 2 &&
+ caller->get_arg(2)->get_expr_kind() == const_expr_kind)
+ {
+ store::Item* len_item =
+ dynamic_cast<const_expr*>(caller->get_arg(2))->get_val();
+ if(len_item->getDoubleValue().round().getNumber() == 1)
+ return tm->create_type(*list_type, TypeConstants::QUANT_QUESTION);
+ }
+ return tm->create_type_x_quant(*list_type, TypeConstants::QUANT_QUESTION);
}
@@ -302,11 +321,22 @@
/******************************************************************************
*******************************************************************************/
-xqtref_t op_zorba_subsequence_int::getReturnType(
- const TypeManager* tm,
- const std::vector<xqtref_t>& arg_types) const
+xqtref_t op_zorba_subsequence_int::getReturnType(const fo_expr* caller) const
{
- return tm->create_type_x_quant(*arg_types[0], TypeConstants::QUANT_QUESTION);
+ TypeManager* tm = caller->get_type_manager();
+ xqtref_t list_type = caller->get_arg(0)->get_return_type();
+
+ //When there is a length argument and it's 1 then we know we will return
+ //a value type T? where the input sequence was type T* or T+
+ if(caller->num_args() > 2 &&
+ caller->get_arg(2)->get_expr_kind() == const_expr_kind)
+ {
+ store::Item* len_item =
+ dynamic_cast<const_expr*>(caller->get_arg(2))->get_val();
+ if(len_item->getIntegerValue() == Integer(1))
+ return tm->create_type(*list_type, TypeConstants::QUANT_QUESTION);
+ }
+ return tm->create_type_x_quant(*list_type, TypeConstants::QUANT_QUESTION);
}
@@ -398,10 +428,13 @@
********************************************************************************/
xqtref_t op_zorba_sequence_point_access::getReturnType(
- const TypeManager* tm,
- const std::vector<xqtref_t>& arg_types) const
+ const fo_expr* caller) const
{
- return tm->create_type(*arg_types[0], TypeConstants::QUANT_QUESTION);
+ TypeManager* tm = caller->get_type_manager();
+
+ return tm->create_type(
+ *caller->get_arg(0)->get_return_type(),
+ TypeConstants::QUANT_QUESTION);
}
@@ -532,7 +565,7 @@
FnCollectionIterator& collection =
static_cast<FnCollectionIterator&>(*argv[0]);
- return new CountCollectionIterator(sctx,
+ return new CountCollectionIterator(sctx,
loc,
collection.getChildren(),
CountCollectionIterator::W3C);
@@ -573,11 +606,11 @@
/*******************************************************************************
********************************************************************************/
-xqtref_t fn_zero_or_one::getReturnType(
- const TypeManager* tm,
- const std::vector<xqtref_t>& arg_types) const
+xqtref_t fn_zero_or_one::getReturnType(const fo_expr* caller) const
{
- xqtref_t srcType = arg_types[0];
+ TypeManager* tm = caller->get_type_manager();
+
+ xqtref_t srcType = caller->get_arg(0)->get_return_type();
return tm->create_type(*TypeOps::prime_type(tm, *srcType),
TypeConstants::QUANT_QUESTION);
@@ -607,12 +640,13 @@
/*******************************************************************************
********************************************************************************/
-xqtref_t fn_one_or_more::getReturnType(
- const TypeManager* tm,
- const std::vector<xqtref_t>& arg_types) const
+xqtref_t fn_one_or_more::getReturnType(const fo_expr* caller) const
{
- return tm->create_type(*TypeOps::prime_type(tm, *arg_types[0]),
- TypeConstants::QUANT_PLUS);
+ TypeManager* tm = caller->get_type_manager();
+
+ return tm->create_type(
+ *TypeOps::prime_type(tm, *(caller->get_arg(0)->get_return_type())),
+ TypeConstants::QUANT_PLUS);
}
@@ -631,14 +665,16 @@
/*******************************************************************************
********************************************************************************/
-xqtref_t fn_exactly_one_noraise::getReturnType(
- const TypeManager* tm,
- const std::vector<xqtref_t>& arg_types) const
+xqtref_t fn_exactly_one_noraise::getReturnType(const fo_expr* caller) const
{
+ TypeManager* tm = caller->get_type_manager();
+
+ xqtref_t srcType = caller->get_arg(0)->get_return_type();
+
if (theRaiseError)
- return TypeOps::prime_type(tm, *arg_types[0]);
+ return TypeOps::prime_type(tm, *srcType);
else
- return function::getReturnType(tm, arg_types);
+ return function::getReturnType(caller);
}
=== modified file 'src/functions/func_sequences_impl.h'
--- src/functions/func_sequences_impl.h 2011-06-14 17:26:33 +0000
+++ src/functions/func_sequences_impl.h 2011-12-20 05:51:25 +0000
@@ -1,12 +1,12 @@
/*
* 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.
@@ -31,7 +31,7 @@
/*******************************************************************************
********************************************************************************/
-class fn_unordered : public function
+class fn_unordered : public function
{
public:
fn_unordered(const signature& sig)
@@ -40,16 +40,14 @@
{
}
- xqtref_t getReturnType(
- const TypeManager* tm,
- const std::vector<xqtref_t>& arg_types) const
+ xqtref_t getReturnType(const fo_expr* caller) const
{
- return arg_types[0];
+ return caller->get_arg(0)->get_return_type();
}
- bool isMap(ulong input) const
+ bool isMap(ulong input) const
{
- return true;
+ return true;
}
FunctionConsts::AnnotationValue producesSortedNodes() const
@@ -89,11 +87,9 @@
{
}
- xqtref_t getReturnType(
- const TypeManager* tm,
- const std::vector<xqtref_t>& arg_types) const;
+ xqtref_t getReturnType(const fo_expr* caller) const;
- BoolAnnotationValue ignoresSortedNodes(expr* fo, ulong input) const
+ BoolAnnotationValue ignoresSortedNodes(expr* fo, ulong input) const
{
return ANNOTATION_TRUE;
}
@@ -117,7 +113,7 @@
theKind = FunctionConsts::FN_EXACTLY_ONE_1;
}
- BoolAnnotationValue ignoresSortedNodes(expr* fo, ulong input) const
+ BoolAnnotationValue ignoresSortedNodes(expr* fo, ulong input) const
{
return ANNOTATION_TRUE;
}
@@ -136,12 +132,12 @@
{
}
- BoolAnnotationValue ignoresSortedNodes(expr* fo, ulong input) const
+ BoolAnnotationValue ignoresSortedNodes(expr* fo, ulong input) const
{
return ANNOTATION_TRUE;
}
- BoolAnnotationValue ignoresDuplicateNodes(expr* fo, ulong input) const
+ BoolAnnotationValue ignoresDuplicateNodes(expr* fo, ulong input) const
{
return ANNOTATION_TRUE;
}
@@ -169,7 +165,7 @@
class fn_intersect : public function
{
public:
- fn_intersect(const signature& sig)
+ fn_intersect(const signature& sig)
:
function(sig, FunctionConsts::OP_INTERSECT_2)
{
@@ -185,7 +181,7 @@
return producer == 0;
}
- BoolAnnotationValue ignoresSortedNodes(expr* fo, ulong input) const
+ BoolAnnotationValue ignoresSortedNodes(expr* fo, ulong input) const
{
if (input == 0)
return fo->getIgnoresSortedNodes();
@@ -193,7 +189,7 @@
return ANNOTATION_TRUE;
}
- BoolAnnotationValue ignoresDuplicateNodes(expr* fo, ulong input) const
+ BoolAnnotationValue ignoresDuplicateNodes(expr* fo, ulong input) const
{
if (input == 0)
return fo->getIgnoresDuplicateNodes();
@@ -208,10 +204,10 @@
/*******************************************************************************
********************************************************************************/
-class fn_except: public function
+class fn_except: public function
{
public:
- fn_except(const signature& sig)
+ fn_except(const signature& sig)
:
function(sig, FunctionConsts::OP_EXCEPT_2)
{
@@ -227,7 +223,7 @@
return producer == 0;
}
- BoolAnnotationValue ignoresSortedNodes(expr* fo, ulong input) const
+ BoolAnnotationValue ignoresSortedNodes(expr* fo, ulong input) const
{
if (input == 0)
return fo->getIgnoresSortedNodes();
@@ -235,7 +231,7 @@
return ANNOTATION_TRUE;
}
- BoolAnnotationValue ignoresDuplicateNodes(expr* fo, ulong input) const
+ BoolAnnotationValue ignoresDuplicateNodes(expr* fo, ulong input) const
{
if (input == 0)
return fo->getIgnoresDuplicateNodes();
@@ -262,12 +258,12 @@
FunctionConsts::FN_MAX_2);
}
- BoolAnnotationValue ignoresSortedNodes(expr* fo, ulong input) const
+ BoolAnnotationValue ignoresSortedNodes(expr* fo, ulong input) const
{
return ANNOTATION_TRUE;
}
- BoolAnnotationValue ignoresDuplicateNodes(expr* fo, ulong input) const
+ BoolAnnotationValue ignoresDuplicateNodes(expr* fo, ulong input) const
{
return ANNOTATION_TRUE;
}
@@ -282,7 +278,7 @@
class fn_min : public function
{
public:
- fn_min(const signature& sig)
+ fn_min(const signature& sig)
:
function(sig, FunctionConsts::FN_UNKNOWN)
{
@@ -291,12 +287,12 @@
FunctionConsts::FN_MIN_2);
}
- BoolAnnotationValue ignoresSortedNodes(expr* fo, ulong input) const
+ BoolAnnotationValue ignoresSortedNodes(expr* fo, ulong input) const
{
return ANNOTATION_TRUE;
}
- BoolAnnotationValue ignoresDuplicateNodes(expr* fo, ulong input) const
+ BoolAnnotationValue ignoresDuplicateNodes(expr* fo, ulong input) const
{
return ANNOTATION_TRUE;
}
@@ -308,7 +304,7 @@
/*******************************************************************************
Fuction is implemented by translator, who turns it into subsequence(arg, 1, 1)
********************************************************************************/
-class fn_head : public function
+class fn_head : public function
{
public:
fn_head(const signature& sig)
@@ -325,7 +321,7 @@
/*******************************************************************************
Fuction is implemented by translator, who turns it into subsequence(arg, 2)
********************************************************************************/
-class fn_tail : public function
+class fn_tail : public function
{
public:
fn_tail(const signature& sig)
=== modified file 'src/functions/function.cpp'
--- src/functions/function.cpp 2011-11-01 13:47:10 +0000
+++ src/functions/function.cpp 2011-12-20 05:51:25 +0000
@@ -16,6 +16,7 @@
#include "stdafx.h"
#include "compiler/expression/expr_base.h"
+#include "compiler/expression/fo_expr.h"
#include "system/globalenv.h"
@@ -77,9 +78,7 @@
/*******************************************************************************
********************************************************************************/
-xqtref_t function::getReturnType(
- const TypeManager* tm,
- const std::vector<xqtref_t>&) const
+xqtref_t function::getReturnType(const fo_expr*) const
{
return theSignature.returnType();
}
@@ -121,7 +120,7 @@
/*******************************************************************************
********************************************************************************/
-bool function::isSequential() const
+bool function::isSequential() const
{
return expr::is_sequential(getScriptingKind());
}
=== modified file 'src/functions/function.h'
--- src/functions/function.h 2011-07-29 06:13:28 +0000
+++ src/functions/function.h 2011-12-20 05:51:25 +0000
@@ -66,12 +66,12 @@
virtual ~function() {}
- StaticContextConsts::xquery_version_t getXQueryVersion() const
+ StaticContextConsts::xquery_version_t getXQueryVersion() const
{
- return theXQueryVersion;
+ return theXQueryVersion;
}
- void setXQueryVersion(StaticContextConsts::xquery_version_t version)
+ void setXQueryVersion(StaticContextConsts::xquery_version_t version)
{
theXQueryVersion = version;
}
@@ -161,8 +161,7 @@
virtual short getScriptingKind() const { return SIMPLE_EXPR; }
virtual xqtref_t getReturnType(
- const TypeManager* tm,
- const std::vector<xqtref_t>& argTypes) const;
+ const fo_expr* caller) const;
virtual bool accessesDynCtx() const { return false; }
=== modified file 'src/functions/pregenerated/func_accessors.h'
--- src/functions/pregenerated/func_accessors.h 2011-10-19 15:28:51 +0000
+++ src/functions/pregenerated/func_accessors.h 2011-12-20 05:51:25 +0000
@@ -98,9 +98,7 @@
theXQueryVersion = StaticContextConsts::xquery_version_3_0;
}
- xqtref_t getReturnType(
- const TypeManager* tm,
- const std::vector<xqtref_t>& arg_types) const;
+ xqtref_t getReturnType(const fo_expr* caller) const;
bool isMap(ulong producer) const { return producer == 0; }
@@ -120,9 +118,7 @@
}
- xqtref_t getReturnType(
- const TypeManager* tm,
- const std::vector<xqtref_t>& arg_types) const;
+ xqtref_t getReturnType(const fo_expr* caller) const;
bool isMap(ulong producer) const { return producer == 0; }
=== modified file 'src/functions/pregenerated/func_errors_and_diagnostics.h'
--- src/functions/pregenerated/func_errors_and_diagnostics.h 2011-12-01 11:02:25 +0000
+++ src/functions/pregenerated/func_errors_and_diagnostics.h 2011-12-20 05:51:25 +0000
@@ -74,9 +74,7 @@
bool accessesDynCtx() const { return true; }
- xqtref_t getReturnType(
- const TypeManager* tm,
- const std::vector<xqtref_t>& arg_types) const;
+ xqtref_t getReturnType(const fo_expr* caller) const;
CODEGEN_DECL();
};
=== modified file 'src/functions/pregenerated/func_numerics.h'
--- src/functions/pregenerated/func_numerics.h 2011-11-09 05:42:08 +0000
+++ src/functions/pregenerated/func_numerics.h 2011-12-20 05:51:25 +0000
@@ -73,9 +73,7 @@
}
- xqtref_t getReturnType(
- const TypeManager* tm,
- const std::vector<xqtref_t>& arg_types) const;
+ xqtref_t getReturnType(const fo_expr* caller) const;
CODEGEN_DECL();
};
=== modified file 'src/functions/pregenerated/func_sequences.h'
--- src/functions/pregenerated/func_sequences.h 2011-11-09 05:42:08 +0000
+++ src/functions/pregenerated/func_sequences.h 2011-12-20 05:51:25 +0000
@@ -47,9 +47,7 @@
}
- xqtref_t getReturnType(
- const TypeManager* tm,
- const std::vector<xqtref_t>& arg_types) const;
+ xqtref_t getReturnType(const fo_expr* caller) const;
BoolAnnotationValue ignoresSortedNodes(expr* fo, ulong producer) const;
@@ -115,9 +113,7 @@
}
- xqtref_t getReturnType(
- const TypeManager* tm,
- const std::vector<xqtref_t>& arg_types) const;
+ xqtref_t getReturnType(const fo_expr* caller) const;
BoolAnnotationValue ignoresSortedNodes(expr* fo, ulong producer) const;
@@ -136,6 +132,8 @@
}
+ xqtref_t getReturnType(const fo_expr* caller) const;
+
BoolAnnotationValue ignoresSortedNodes(expr* fo, ulong producer) const;
BoolAnnotationValue ignoresDuplicateNodes(expr* fo, ulong producer) const;
@@ -153,9 +151,7 @@
}
- xqtref_t getReturnType(
- const TypeManager* tm,
- const std::vector<xqtref_t>& arg_types) const;
+ xqtref_t getReturnType(const fo_expr* caller) const;
bool propagatesDistinctNodes(ulong producer) const { return producer == 0; }
@@ -178,9 +174,7 @@
}
- xqtref_t getReturnType(
- const TypeManager* tm,
- const std::vector<xqtref_t>& arg_types) const;
+ xqtref_t getReturnType(const fo_expr* caller) const;
bool propagatesDistinctNodes(ulong producer) const { return producer == 0; }
@@ -201,9 +195,7 @@
}
- xqtref_t getReturnType(
- const TypeManager* tm,
- const std::vector<xqtref_t>& arg_types) const;
+ xqtref_t getReturnType(const fo_expr* caller) const;
bool propagatesDistinctNodes(ulong producer) const { return producer == 0; }
@@ -224,9 +216,7 @@
}
- xqtref_t getReturnType(
- const TypeManager* tm,
- const std::vector<xqtref_t>& arg_types) const;
+ xqtref_t getReturnType(const fo_expr* caller) const;
bool propagatesDistinctNodes(ulong producer) const { return producer == 0; }
@@ -245,9 +235,7 @@
}
- xqtref_t getReturnType(
- const TypeManager* tm,
- const std::vector<xqtref_t>& arg_types) const;
+ xqtref_t getReturnType(const fo_expr* caller) const;
bool propagatesDistinctNodes(ulong producer) const { return producer == 0; }
@@ -266,9 +254,7 @@
}
- xqtref_t getReturnType(
- const TypeManager* tm,
- const std::vector<xqtref_t>& arg_types) const;
+ xqtref_t getReturnType(const fo_expr* caller) const;
BoolAnnotationValue ignoresSortedNodes(expr* fo, ulong producer) const;
@@ -285,9 +271,7 @@
}
- xqtref_t getReturnType(
- const TypeManager* tm,
- const std::vector<xqtref_t>& arg_types) const;
+ xqtref_t getReturnType(const fo_expr* caller) const;
bool isMap(ulong producer) const { return producer == 0; }
=== modified file 'src/runtime/spec/codegen-h.xq'
--- src/runtime/spec/codegen-h.xq 2011-08-17 20:22:07 +0000
+++ src/runtime/spec/codegen-h.xq 2011-12-20 05:51:25 +0000
@@ -203,11 +203,7 @@
if (name($meth) eq 'zorba:getReturnType')
then
string-join(($gen:newline, $gen:indent,
- 'xqtref_t getReturnType(',
- $gen:newline, $gen:indent, $gen:indent, $gen:indent, $gen:indent,
- 'const TypeManager* tm,',
- $gen:newline, $gen:indent, $gen:indent, $gen:indent, $gen:indent,
- 'const std::vector<xqtref_t>& arg_types) const;',
+ 'xqtref_t getReturnType(const fo_expr* caller) const;',
$gen:newline), '')
else if (name($meth) eq 'zorba:getScriptingKind')
=== modified file 'src/runtime/spec/sequences/sequences.xml'
--- src/runtime/spec/sequences/sequences.xml 2011-10-07 23:56:40 +0000
+++ src/runtime/spec/sequences/sequences.xml 2011-12-20 05:51:25 +0000
@@ -264,6 +264,7 @@
</zorba:signature>
<zorba:methods>
+ <zorba:getReturnType/>
<zorba:ignoresSortedNodes/>
<zorba:ignoresDuplicateNodes/>
</zorba:methods>
Follow ups