zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #03741
[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/89017
Fixed bug 917923 (bug in copying outer var values into the eval dynamic context)
--
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/89017
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog 2012-01-11 17:30:25 +0000
+++ ChangeLog 2012-01-18 12:21:28 +0000
@@ -7,6 +7,7 @@
%ann:must-copy-input-nodes to be used by the no-copy optimization.
* Caching of results for recursive functions with atomic parameter and return types.
* Added %ann:cache and %ann:no-cache to enable or disable caching of results of functions with atomic parameter and return types.
+ * Fixed bug 917923 (bug in copying outer var values into the eval dynamic context)
* Fixed bug 909126 (bug in cloning of var_expr)
* Fixed bug in destruction of exit_catcher_expr
* Types-related optimization for the comparison operators
=== modified file 'src/context/dynamic_context.cpp'
--- src/context/dynamic_context.cpp 2011-12-21 14:40:33 +0000
+++ src/context/dynamic_context.cpp 2012-01-18 12:21:28 +0000
@@ -400,11 +400,8 @@
if (varid >= theVarValues.size() ||
theVarValues[varid].theState == VarValue::undeclared)
{
- throw XQUERY_EXCEPTION(
- err::XPDY0002,
- ERROR_PARAMS( varname->getStringValue(), ZED( VariabledUndeclared ) ),
- ERROR_LOC( loc )
- );
+ RAISE_ERROR(err::XPDY0002, loc,
+ ERROR_PARAMS(varname->getStringValue(), ZED(VariabledUndeclared)));
}
VarValue& var = theVarValues[varid];
@@ -449,22 +446,16 @@
if (varid >= theVarValues.size() ||
theVarValues[varid].theState == VarValue::undeclared)
{
- zstring lVarName = static_context::var_name(varname.getp());
- throw XQUERY_EXCEPTION(
- err::XPDY0002,
- ERROR_PARAMS( lVarName, ZED( VariabledUndeclared ) ),
- ERROR_LOC( loc )
- );
+ zstring varName = static_context::var_name(varname.getp());
+ RAISE_ERROR(err::XPDY0002, loc,
+ ERROR_PARAMS(varName, ZED(VariabledUndeclared)));
}
if (theVarValues[varid].theState == VarValue::declared)
{
- zstring lVarName = static_context::var_name(varname.getp());
- throw XQUERY_EXCEPTION(
- err::XPDY0002,
- ERROR_PARAMS( lVarName, ZED( VariabledHasNoValue ) ),
- ERROR_LOC( loc )
- );
+ zstring varName = static_context::var_name(varname.getp());
+ RAISE_ERROR(err::XPDY0002, loc,
+ ERROR_PARAMS(varName, ZED(VariabledHasNoValue)));
}
const VarValue& var = theVarValues[varid];
=== modified file 'src/context/dynamic_context.h'
--- src/context/dynamic_context.h 2011-11-09 05:42:08 +0000
+++ src/context/dynamic_context.h 2012-01-18 12:21:28 +0000
@@ -51,22 +51,7 @@
{
friend class DebugIterator;
-protected:
-
- struct dctx_value_t
- {
- typedef enum
- {
- no_val,
- ext_func_param, // params that can be used by ext. functions
- ext_func_param_typed
- } val_type_t;
-
- val_type_t type;
- void* func_param;
- };
-
-
+public:
struct VarValue
{
typedef enum
@@ -81,7 +66,7 @@
{
store::Item* item;
store::TempSeq* temp_seq;
- } theValue;
+ } theValue;
ValueState theState;
@@ -92,7 +77,28 @@
VarValue(const VarValue& other);
- ~VarValue();
+ ~VarValue();
+
+ bool isSet() const { return (theState == item || theState == temp_seq); }
+
+ bool hasItemValue() const { return (theState == item); }
+
+ bool hasSeqValue() const { return (theState == temp_seq); }
+ };
+
+protected:
+
+ struct dctx_value_t
+ {
+ typedef enum
+ {
+ no_val,
+ ext_func_param, // params that can be used by ext. functions
+ ext_func_param_typed
+ } val_type_t;
+
+ val_type_t type;
+ void* func_param;
};
typedef HashMapZString<dctx_value_t> ValueMap;
@@ -140,6 +146,8 @@
long get_implicit_timezone() const;
+ const std::vector<VarValue>& get_variables() const { return theVarValues; }
+
void add_variable(ulong varid, store::Item_t& value);
void add_variable(ulong varid, store::Iterator_t& value);
=== modified file 'src/runtime/eval/eval.cpp'
--- src/runtime/eval/eval.cpp 2012-01-11 17:30:25 +0000
+++ src/runtime/eval/eval.cpp 2012-01-18 12:21:28 +0000
@@ -222,38 +222,33 @@
dynamic_context* outerDctx = evalDctx->getParent();
- std::vector<var_expr_t> globalVars;
- outerSctx->get_parent()->getVariables(globalVars, theForDebugger, true);
-
- FOR_EACH(std::vector<var_expr_t>, ite, globalVars)
+ const std::vector<dynamic_context::VarValue>& outerVars = outerDctx->get_variables();
+ csize numOuterVars = outerVars.size();
+
+ for (csize i = 0; i < numOuterVars; ++i)
{
- var_expr* globalVar = (*ite).getp();
-
- ulong globalVarId = globalVar->get_unique_id();
-
- if (globalVarId > maxOuterVarId)
- maxOuterVarId = globalVarId;
+ const dynamic_context::VarValue& outerVar = outerVars[i];
+
+ if (!outerVar.isSet())
+ continue;
+
+ ulong outerVarId = static_cast<ulong>(i);
+
+ if (outerVarId > maxOuterVarId)
+ maxOuterVarId = outerVarId;
store::Item_t itemValue;
store::TempSeq_t seqValue;
- if (!outerDctx->is_set_variable(globalVarId))
- continue;
-
- outerDctx->get_variable(globalVarId,
- globalVar->get_name(),
- loc,
- itemValue,
- seqValue);
-
- if (itemValue != NULL)
+ if (outerVar.hasItemValue())
{
- evalDctx->add_variable(globalVarId, itemValue);
+ store::Item_t value = outerVar.theValue.item;
+ evalDctx->add_variable(outerVarId, value);
}
else
{
- store::Iterator_t iteValue = seqValue->getIterator();
- evalDctx->add_variable(globalVarId, iteValue);
+ store::Iterator_t iteValue = outerVar.theValue.temp_seq->getIterator();
+ evalDctx->add_variable(outerVarId, iteValue);
}
}
=== added file 'test/rbkt/ExpQueryResults/zorba/eval/invoke1.xml.res'
--- test/rbkt/ExpQueryResults/zorba/eval/invoke1.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/eval/invoke1.xml.res 2012-01-18 12:21:28 +0000
@@ -0,0 +1,1 @@
+20
=== added file 'test/rbkt/Queries/zorba/eval/invoke1.xq'
--- test/rbkt/Queries/zorba/eval/invoke1.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/eval/invoke1.xq 2012-01-18 12:21:28 +0000
@@ -0,0 +1,5 @@
+import module namespace invoke = 'http://www.zorba-xquery.com/modules/reflection';
+
+import module namespace foo1 = "http://foo1.com/" at "invoke1_1.xqlib";
+
+invoke:invoke-s ( fn:QName ( 'http://foo1.com/', 'bar' ) )
=== added file 'test/rbkt/Queries/zorba/eval/invoke1_1.xqlib'
--- test/rbkt/Queries/zorba/eval/invoke1_1.xqlib 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/eval/invoke1_1.xqlib 2012-01-18 12:21:28 +0000
@@ -0,0 +1,10 @@
+module namespace foo1 = "http://foo1.com/";
+
+import module namespace foo2 = "http://foo2.com/" at "invoke1_2.xqlib";
+
+declare variable $foo1:var := 2;
+
+declare function foo1:bar()
+{
+ $foo2:var
+};
=== added file 'test/rbkt/Queries/zorba/eval/invoke1_2.xqlib'
--- test/rbkt/Queries/zorba/eval/invoke1_2.xqlib 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/eval/invoke1_2.xqlib 2012-01-18 12:21:28 +0000
@@ -0,0 +1,3 @@
+module namespace foo2 = "http://foo2.com/";
+
+declare variable $foo2:var := 20;
Follow ups