zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #04898
[Merge] lp:~zorba-coders/zorba/markos-scratch into lp:zorba
Markos Zaharioudakis has proposed merging lp:~zorba-coders/zorba/markos-scratch into lp:zorba.
Requested reviews:
Markos Zaharioudakis (markos-za)
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/93175
Fixed bug #867022
--
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/93175
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp 2012-02-10 10:48:40 +0000
+++ src/compiler/translator/translator.cpp 2012-02-15 10:32:20 +0000
@@ -3848,7 +3848,7 @@
{
TRACE_VISIT_OUT();
- bool recognised = false;
+ //bool recognised = false;
store::Item_t lExpandedQName;
expand_function_qname(lExpandedQName, v.get_qname().getp(), loc);
@@ -3869,7 +3869,7 @@
+ ":" + lExpandedQName->getLocalName())));
}
- recognised = true;
+ //recognised = true;
}
std::vector<rchandle<const_expr> > lLiterals;
=== modified file 'src/diagnostics/diagnostic_en.xml'
--- src/diagnostics/diagnostic_en.xml 2011-12-21 14:40:33 +0000
+++ src/diagnostics/diagnostic_en.xml 2012-02-15 10:32:20 +0000
@@ -51,6 +51,11 @@
by the matching rules in 2.5.4 SequenceType Matching.
</comment>
<value>$1</value>
+
+ <entry key="FormatNumber_2">
+ <value>"the first parameter to the format-number() function is of type $2, which is not allowed</value>
+ </entry>
+
</diagnostic>
<diagnostic code="XPST0005">
=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
--- src/diagnostics/pregenerated/dict_en.cpp 2011-12-21 14:40:33 +0000
+++ src/diagnostics/pregenerated/dict_en.cpp 2012-02-15 10:32:20 +0000
@@ -657,6 +657,7 @@
{ "~VariabledUndeclared", "undeclared variable" },
{ "~WindowClause11", "\"window\" clause only available in XQuery 1.1 or later" },
{ "~XMLSchema", "XML schema" },
+ { "~XPTY0004_FormatNumber_2", "\"the first parameter to the format-number() function is of type $2, which is not allowed" },
{ "~XQST0106_CONFLICTING", "conflicting" },
{ "~XQST0106_THE_SAME", "the same" },
{ "~XQueryVersionAtLeast10_2", "\"$2\": XQuery version must be at least 1.0" },
=== modified file 'src/runtime/core/constructors.cpp'
--- src/runtime/core/constructors.cpp 2012-01-11 17:30:25 +0000
+++ src/runtime/core/constructors.cpp 2012-02-15 10:32:20 +0000
@@ -147,8 +147,7 @@
if (child->getNodeKind() == store::StoreConsts::attributeNode)
{
- RAISE_ERROR(err::XPTY0004, loc,
- ERROR_PARAMS(ZED(NoAttrNodesInDocument)));
+ RAISE_ERROR(err::XPTY0004, loc, ERROR_PARAMS(ZED(NoAttrNodesInDocument)));
}
if (child->getParent() != result.getp())
@@ -846,8 +845,10 @@
try
{
if (!consumeNext(lItem, theChild0, planState))
- // TODO: needs type in error message
- throw XQUERY_EXCEPTION(err::XPTY0004, ERROR_LOC(loc));
+ {
+ // translator places a cast to xs:NCName op
+ ZORBA_ASSERT(false);
+ }
}
catch (ZorbaException const& e)
{
@@ -858,10 +859,11 @@
}
if (consumeNext(temp, theChild0, planState))
- // TODO: needs type in error message
- throw XQUERY_EXCEPTION(err::XPTY0004, ERROR_LOC(loc));
+ {
+ // translator places a cast to xs:NCName op
+ ZORBA_ASSERT(false);
+ }
- // TODO: check if lItem is string, raise XPTY0004 if not
lItem->getStringValue2(target);
if (target.empty())
@@ -1320,19 +1322,13 @@
if (!consumeNext(result, theChild.getp(), planState))
{
- throw XQUERY_EXCEPTION(
- err::XPTY0004,
- ERROR_PARAMS( ZED( EmptySeqNoCastToQName ) ),
- ERROR_LOC( loc )
- );
+ RAISE_ERROR(err::XPTY0004, loc, ERROR_PARAMS(ZED(EmptySeqNoCastToQName)));
}
valid = true;
if (consumeNext(temp, theChild, planState))
{
- throw XQUERY_EXCEPTION(
- err::XPTY0004, ERROR_PARAMS( ZED( SeqNoCastToQName ) ), ERROR_LOC( loc )
- );
+ RAISE_ERROR(err::XPTY0004, loc, ERROR_PARAMS(ZED(SeqNoCastToQName)));
}
try
@@ -1355,19 +1351,13 @@
// this needs to be checked and thrown here as the optimizer
// might try to fold a const expression and would return a different error code
if (theIsAttrName)
- throw XQUERY_EXCEPTION(
- err::XQDY0044, ERROR_PARAMS(name), ERROR_LOC(loc)
- );
+ RAISE_ERROR(err::XQDY0044, loc, ERROR_PARAMS(name));
else
- throw XQUERY_EXCEPTION(
- err::XQDY0096, ERROR_PARAMS(name), ERROR_LOC(loc)
- );
+ RAISE_ERROR(err::XQDY0096, loc, ERROR_PARAMS(name));
}
else
// the returned error codes are wrong for name casting => they must be changed
- throw XQUERY_EXCEPTION(
- err::XQDY0074, ERROR_PARAMS( "item" ), ERROR_LOC( loc )
- );
+ RAISE_ERROR(err::XQDY0074, loc, ERROR_PARAMS("item"));
}
else
{
=== modified file 'src/runtime/core/flwor_iterator.cpp'
--- src/runtime/core/flwor_iterator.cpp 2012-01-11 17:30:25 +0000
+++ src/runtime/core/flwor_iterator.cpp 2012-02-15 10:32:20 +0000
@@ -1339,7 +1339,7 @@
std::vector<store::Item*>& sortTuple = sortTable[numTuples].theKeyValues;
sortTuple.resize(numSpecs);
- for (ulong i = 0; i < numSpecs; ++i)
+ for (csize i = 0; i < numSpecs; ++i)
{
store::Item_t sortKeyItem;
if (consumeNext(sortKeyItem, orderSpecs[i].theDomainIter, planState))
@@ -1349,9 +1349,8 @@
store::Item_t temp;
if (consumeNext(temp, orderSpecs[i].theDomainIter, planState))
{
- throw XQUERY_EXCEPTION(
- err::XPTY0004, ERROR_PARAMS(ZED(SingletonExpected_2o))
- );
+ RAISE_ERROR(err::XPTY0004, theMaterializeClause->theLocation,
+ ERROR_PARAMS(ZED(SingletonExpected_2o)));
}
}
else
@@ -1382,19 +1381,19 @@
FlworState::SortTable& sortTable = iterState->theSortTable;
FlworState::ResultTable& resultTable = iterState->theResultTable;
- ulong numTuples = (ulong)sortTable.size();
+ csize numTuples = sortTable.size();
sortTable.resize(numTuples + 1);
resultTable.resize(numTuples + 1);
// Create the sort tuple
std::vector<OrderSpec>& orderSpecs = theOrderByClause->theOrderSpecs;
- ulong numSpecs = (ulong)orderSpecs.size();
+ csize numSpecs = orderSpecs.size();
std::vector<store::Item*>& sortKey = sortTable[numTuples].theKeyValues;
sortKey.resize(numSpecs);
- for (ulong i = 0; i < numSpecs; ++i)
+ for (csize i = 0; i < numSpecs; ++i)
{
store::Item_t sortKeyItem;
if (consumeNext(sortKeyItem, orderSpecs[i].theDomainIter, planState))
@@ -1404,9 +1403,8 @@
store::Item_t temp;
if (consumeNext(temp, orderSpecs[i].theDomainIter, planState))
{
- throw XQUERY_EXCEPTION(
- err::XPTY0004, ERROR_PARAMS(ZED(SingletonExpected_2o))
- );
+ RAISE_ERROR(err::XPTY0004, theOrderByClause->theLocation,
+ ERROR_PARAMS(ZED(SingletonExpected_2o)));
}
}
else
@@ -1473,7 +1471,7 @@
store::Item_t temp;
if (typedValueIter->next(temp))
{
- RAISE_ERROR(err::XPTY0004, loc,
+ RAISE_ERROR(err::XPTY0004, theGroupByClause->theLocation,
ERROR_PARAMS(ZED(SingletonExpected_2o),
ZED(AtomizationHasMoreThanOneValue)));
}
@@ -1484,7 +1482,8 @@
store::Item_t temp;
if (consumeNext(temp, specIter->theInput, planState))
{
- RAISE_ERROR(err::XPTY0004, loc, ERROR_PARAMS(ZED(SingletonExpected_2o)));
+ RAISE_ERROR(err::XPTY0004, theGroupByClause->theLocation,
+ ERROR_PARAMS(ZED(SingletonExpected_2o)));
}
}
=== modified file 'src/runtime/core/gflwor/orderby_iterator.cpp'
--- src/runtime/core/gflwor/orderby_iterator.cpp 2011-06-14 17:26:33 +0000
+++ src/runtime/core/gflwor/orderby_iterator.cpp 2012-02-15 10:32:20 +0000
@@ -17,6 +17,7 @@
#include "zorbautils/fatal.h"
#include "diagnostics/assert.h"
+#include "diagnostics/util_macros.h"
#include "diagnostics/xquery_diagnostics.h"
#include "zorbautils/checked_vector.h"
@@ -377,18 +378,18 @@
OrderByState::SortTable& sortTable = iterState->theSortTable;
OrderByState::DataTable& dataTable = iterState->theDataTable;
- ulong numTuples = (ulong)sortTable.size();
+ csize numTuples = sortTable.size();
sortTable.resize(numTuples + 1);
dataTable.resize(numTuples + 1);
// Create the sort tuple
- ulong numSpecs = (ulong)theOrderSpecs.size();
+ csize numSpecs = theOrderSpecs.size();
std::vector<store::Item*>& sortKey = sortTable[numTuples].theKeyValues;
sortKey.resize(numSpecs);
- for (ulong i = 0; i < numSpecs; ++i)
+ for (csize i = 0; i < numSpecs; ++i)
{
store::Item_t sortKeyItem;
if (consumeNext(sortKeyItem, theOrderSpecs[i].theDomainIter, planState))
@@ -398,9 +399,8 @@
store::Item_t temp;
if (consumeNext(temp, theOrderSpecs[i].theDomainIter, planState))
{
- throw XQUERY_EXCEPTION(
- err::XPTY0004, ERROR_PARAMS( ZED( SingletonExpected_2o ) )
- );
+ RAISE_ERROR(err::XPTY0004, loc,
+ ERROR_PARAMS(ZED(SingletonExpected_2o)));
}
}
else
@@ -415,14 +415,14 @@
// create the data tuple
- ulong numForVars = (ulong)theInputForVars.size();
- ulong numLetVars = (ulong)theInputLetVars.size();
+ csize numForVars = theInputForVars.size();
+ csize numLetVars = theInputLetVars.size();
StreamTuple& streamTuple = dataTable[numTuples];
streamTuple.theItems.resize(numForVars);
streamTuple.theSequences.resize(numLetVars);
- for (ulong i = 0; i < numForVars; ++i)
+ for (csize i = 0; i < numForVars; ++i)
{
store::Item_t forItem;
consumeNext(forItem, theInputForVars[i], planState);
@@ -432,7 +432,7 @@
theInputForVars[i]->reset(planState);
}
- for (ulong i = 0; i < numLetVars; ++i)
+ for (csize i = 0; i < numLetVars; ++i)
{
store::TempSeq_t letTempSeq;
createTempSeq(letTempSeq, theInputLetVars[i], planState, false);
=== modified file 'src/runtime/errors_and_diagnostics/errors_and_diagnostics_impl.cpp'
--- src/runtime/errors_and_diagnostics/errors_and_diagnostics_impl.cpp 2011-06-14 17:26:33 +0000
+++ src/runtime/errors_and_diagnostics/errors_and_diagnostics_impl.cpp 2012-02-15 10:32:20 +0000
@@ -79,6 +79,7 @@
STACK_END(state);
}
+
/*******************************************************************************
3.2.1 fn:trace
********************************************************************************/
@@ -88,12 +89,10 @@
TraceIteratorState *state;
DEFAULT_STACK_INIT(TraceIteratorState, state, planState);
- if (!consumeNext(state->theTagItem, theChildren[1], planState)) {
- throw XQUERY_EXCEPTION(
- err::FORG0006,
- ERROR_PARAMS(
- ZED( BadArgTypeForFn_2o34o ), ZED( EmptySequence ), "fn:trace"
- ),
+ if (!consumeNext(state->theTagItem, theChildren[1], planState))
+ {
+ throw XQUERY_EXCEPTION(err::FORG0006,
+ ERROR_PARAMS(ZED(BadArgTypeForFn_2o34o), ZED(EmptySequence), "fn:trace"),
ERROR_LOC( loc )
);
}
@@ -112,7 +111,7 @@
}
- STACK_END (state);
+ STACK_END(state);
}
} // namespace zorba
=== modified file 'src/runtime/errors_and_diagnostics/other_diagnostics_impl.cpp'
--- src/runtime/errors_and_diagnostics/other_diagnostics_impl.cpp 2011-06-14 17:26:33 +0000
+++ src/runtime/errors_and_diagnostics/other_diagnostics_impl.cpp 2012-02-15 10:32:20 +0000
@@ -35,16 +35,21 @@
/*******************************************************************************
Diagnostics iterators: a dummy iterator for dynamic exception stack traces
********************************************************************************/
-bool FunctionTraceIterator::nextImpl(store::Item_t &result, PlanState &aPlanState) const
+bool FunctionTraceIterator::nextImpl(store::Item_t& result, PlanState& aPlanState) const
{
- try {
+ try
+ {
PlanIteratorState* lState = 0;
DEFAULT_STACK_INIT(PlanIteratorState, lState, aPlanState);
- while (consumeNext(result, theChildren[0], aPlanState)) {
- STACK_PUSH(true, lState);
- }
- STACK_END(lState);
- } catch (ZorbaException& err) {
+
+ while (consumeNext(result, theChildren[0], aPlanState))
+ {
+ STACK_PUSH(true, lState);
+ }
+ STACK_END(lState);
+ }
+ catch (ZorbaException& err)
+ {
recordStackTrace(
theFunctionLocation,
theFunctionCallLocation,
@@ -58,6 +63,7 @@
return false;
}
+
void FunctionTraceIterator::setFunctionName(const store::Item_t& aFunctionName)
{
theFunctionName = aFunctionName;
=== modified file 'src/runtime/function_item/dynamic_fncall_iterator.cpp'
--- src/runtime/function_item/dynamic_fncall_iterator.cpp 2011-06-14 17:26:33 +0000
+++ src/runtime/function_item/dynamic_fncall_iterator.cpp 2012-02-15 10:32:20 +0000
@@ -15,6 +15,7 @@
*/
#include "stdafx.h"
+#include "diagnostics/util_macros.h"
#include "runtime/function_item/dynamic_fncall_iterator.h"
#include "runtime/function_item/function_item.h"
@@ -27,6 +28,10 @@
#include "store/api/item_factory.h"
+#include "types/root_typemanager.h"
+
+#include "system/globalenv.h"
+
namespace zorba
{
@@ -156,12 +161,27 @@
// first child must return exactly one item which is a function item
// otherwise XPTY0004 is raised
- if (!consumeNext(funcItem, theChildren[0], planState) ||
- !funcItem->isFunction() ||
- consumeNext(item, theChildren[0], planState))
- {
- // TODO: needs type in error message
- throw XQUERY_EXCEPTION(err::XPTY0004, ERROR_LOC(loc));
+ if (!consumeNext(funcItem, theChildren[0], planState))
+ {
+ RAISE_ERROR(err::XPTY0004, loc,
+ ERROR_PARAMS(ZED(EmptySeqNoPromoteTo),
+ GENV_TYPESYSTEM.ANY_FUNCTION_TYPE_ONE->toSchemaString()));
+ }
+
+ if (consumeNext(item, theChildren[0], planState))
+ {
+ RAISE_ERROR(err::XPTY0004, loc, ERROR_PARAMS(ZED(NoSeqTypePromotion)));
+ }
+
+ if (!funcItem->isFunction())
+ {
+ const TypeManager* tm = theSctx->get_typemanager();
+ xqtref_t type = tm->create_value_type(funcItem);
+
+ RAISE_ERROR(err::XPTY0004, loc,
+ ERROR_PARAMS(ZED(NoTypePromotion_23),
+ type->toSchemaString(),
+ GENV_TYPESYSTEM.ANY_FUNCTION_TYPE_ONE->toSchemaString()));
}
fnItem = static_cast<FunctionItem*>(funcItem.getp());
=== modified file 'src/runtime/numerics/numerics_impl.cpp'
--- src/runtime/numerics/numerics_impl.cpp 2011-07-10 14:55:46 +0000
+++ src/runtime/numerics/numerics_impl.cpp 2012-02-15 10:32:20 +0000
@@ -20,6 +20,7 @@
#include "common/shared_types.h"
#include "diagnostics/assert.h"
+#include "diagnostics/util_macros.h"
#include "diagnostics/xquery_diagnostics.h"
#include "zorbatypes/zorbatypes_decl.h"
@@ -121,24 +122,19 @@
}
else
{
- throw XQUERY_EXCEPTION(
- err::XPTY0004,
- ERROR_PARAMS( ZED( BadTypeFor_23 ), type, "fn:abs" ),
- ERROR_LOC( loc )
- );
+ RAISE_ERROR(err::XPTY0004, loc,
+ ERROR_PARAMS(ZED(BadTypeFor_23), type, "fn:abs" ));
}
if ( consumeNext(item, theChildren[0].getp(), planState ))
{
- throw XQUERY_EXCEPTION(
- err::XPTY0004,
- ERROR_PARAMS( ZED( NoSeqForFnOp_2 ), "fn:abs" ),
- ERROR_LOC( loc )
- );
+ RAISE_ERROR(err::XPTY0004, loc,
+ ERROR_PARAMS(ZED(NoSeqForFnOp_2), "fn:abs"));
}
- STACK_PUSH ( true, state );
+
+ STACK_PUSH(true, state);
}
- STACK_END (state);
+ STACK_END(state);
}
//6.4.2 fn:ceiling
@@ -186,24 +182,18 @@
else
{
- throw XQUERY_EXCEPTION(
- err::XPTY0004,
- ERROR_PARAMS( ZED( BadTypeFor_23 ), type, "fn:ceiling" ),
- ERROR_LOC( loc )
- );
+ RAISE_ERROR(err::XPTY0004, loc,
+ ERROR_PARAMS(ZED(BadTypeFor_23), type, "fn:ceiling" ));
}
if ( consumeNext(item, theChildren[0].getp(), planState ))
{
- throw XQUERY_EXCEPTION(
- err::XPTY0004,
- ERROR_PARAMS( ZED( NoSeqForFnOp_2 ), "fn:ceiling" ),
- ERROR_LOC( loc )
- );
+ RAISE_ERROR(err::XPTY0004, loc,
+ ERROR_PARAMS(ZED(NoSeqForFnOp_2), "fn:ceiling"));
}
- STACK_PUSH ( true, state );
+ STACK_PUSH(true, state);
}
- STACK_END (state);
+ STACK_END(state);
}
//6.4.3 fn:floor
@@ -251,20 +241,14 @@
else
{
- throw XQUERY_EXCEPTION(
- err::XPTY0004,
- ERROR_PARAMS( ZED( BadTypeFor_23 ), type, "fn:floor" ),
- ERROR_LOC( loc )
- );
+ RAISE_ERROR(err::XPTY0004, loc,
+ ERROR_PARAMS(ZED(BadTypeFor_23), type, "fn:floor"));
}
if ( consumeNext(item, theChildren[0].getp(), planState ) )
{
- throw XQUERY_EXCEPTION(
- err::XPTY0004,
- ERROR_PARAMS( ZED( NoSeqForFnOp_2 ), "fn:floor" ),
- ERROR_LOC( loc )
- );
+ RAISE_ERROR(err::XPTY0004, loc,
+ ERROR_PARAMS(ZED(NoSeqForFnOp_2), "fn:floor" ));
}
STACK_PUSH (true, state );
}
@@ -329,20 +313,14 @@
else
{
- throw XQUERY_EXCEPTION(
- err::XPTY0004,
- ERROR_PARAMS( ZED( BadTypeFor_23 ), type, "fn:round" ),
- ERROR_LOC( loc )
- );
+ RAISE_ERROR(err::XPTY0004, loc,
+ ERROR_PARAMS(ZED(BadTypeFor_23), type, "fn:round"));
}
if ( consumeNext(item, theChildren[0].getp(), planState ))
{
- throw XQUERY_EXCEPTION(
- err::XPTY0004,
- ERROR_PARAMS( ZED( NoSeqForFnOp_2 ), "fn:round" ),
- ERROR_LOC( loc )
- );
+ RAISE_ERROR(err::XPTY0004, loc,
+ ERROR_PARAMS(ZED(NoSeqForFnOp_2), "fn:round" ));
}
STACK_PUSH (true, state );
}
@@ -404,20 +382,14 @@
else
{
- throw XQUERY_EXCEPTION(
- err::XPTY0004,
- ERROR_PARAMS( ZED( BadTypeFor_23 ), type, "fn:round-half-to-even" ),
- ERROR_LOC( loc )
- );
+ RAISE_ERROR(err::XPTY0004, loc,
+ ERROR_PARAMS(ZED(BadTypeFor_23), type, "fn:round-half-to-even"));
}
if ( consumeNext(item, theChildren [0].getp(), planState ))
{
- throw XQUERY_EXCEPTION(
- err::XPTY0004,
- ERROR_PARAMS( ZED( NoSeqForFnOp_2 ), "fn:round-half-to-even" ),
- ERROR_LOC( loc )
- );
+ RAISE_ERROR(err::XPTY0004, loc,
+ ERROR_PARAMS(ZED(NoSeqForFnOp_2), "fn:round-half-to-even"));
}
STACK_PUSH ( true, state );
}
@@ -807,7 +779,6 @@
store::Item_t zero;
store::Item_t doubleItem;
- bool positive = true;
FormatNumberInfo::SubPictureInfo& sub_picture = info.pos_subpicture;
GENV_ITEMFACTORY->createDouble(zero, xs_double::zero());
@@ -816,7 +787,6 @@
if (doubleItem->compare(zero) == -1)
{
- positive = false;
sub_picture = info.neg_subpicture;
}
@@ -910,7 +880,8 @@
info.loc = loc;
if (!isAllowedType(result->getType()))
{
- throw XQUERY_EXCEPTION(err::XPTY0004, ERROR_PARAMS("the first paramter to the format-number() function is of type \"" + result->getType()->getStringValue() + "\", which is not allowed"), ERROR_LOC(info.loc));
+ RAISE_ERROR(err::XPTY0004, info.loc,
+ ERROR_PARAMS(ZED(FormatNumber_2), result->getType()->getStringValue()));
}
consumeNext(pictureItem, theChildren[1].getp(), planState);
@@ -923,7 +894,8 @@
{
do // use a do/while to avoid a horde of nested if/then/elses
{
- // The formatName is a string, which must be interpreted as a QName -> must resolve the namespace, if any
+ // The formatName is a string, which must be interpreted as a QName ->
+ // must resolve the namespace, if any
consumeNext(formatName, theChildren[2].getp(), planState);
zstring tmpFormatName = formatName->getStringValue();
formatName = NULL;
=== modified file 'src/runtime/sequences/sequences_impl.cpp'
--- src/runtime/sequences/sequences_impl.cpp 2012-02-13 10:23:06 +0000
+++ src/runtime/sequences/sequences_impl.cpp 2012-02-15 10:32:20 +0000
@@ -1530,9 +1530,10 @@
STACK_PUSH(true, state);
}
- STACK_END (state);
+ STACK_END(state);
}
+
/*******************************************************************************
15.4.5 fn:sum - Float
********************************************************************************/
Follow ups