Markos Zaharioudakis has proposed merging lp:~zorba-coders/zorba/markos-scratch 
into lp:zorba.

Commit message:
fixed implementation of xqdoc functions

Requested reviews:
  Markos Zaharioudakis (markos-za)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/126549

fixed implementation of xqdoc functions
-- 
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/126549
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog	2012-09-26 17:09:11 +0000
+++ ChangeLog	2012-09-26 21:04:24 +0000
@@ -45,6 +45,7 @@
     variables)
   * Fixed bug #899366 (enforce the type declaration of a window variable)
   * Now using native UUID libraries.
+  * Fixed bug in implementation of xqdoc functions
   * Fixed bug #1034942 (improper variable inlining inside general flwor expr)
   * Fixed bug #1024892 (index declaration references udf declared after the index)
   * Fixed bug #1038410 (Memory leaks in parser, trace iterator, and general index)

=== modified file 'src/compiler/expression/var_expr.cpp'
--- src/compiler/expression/var_expr.cpp	2012-09-19 18:18:02 +0000
+++ src/compiler/expression/var_expr.cpp	2012-09-26 21:04:24 +0000
@@ -126,6 +126,7 @@
   if (theVarInfo)
   {
     assert(theVarKind == prolog_var);
+    assert(theVarInfo->getName() != NULL);
     theVarInfo->clearVar();
   }
 }

=== modified file 'src/runtime/xqdoc/xqdoc_impl.cpp'
--- src/runtime/xqdoc/xqdoc_impl.cpp	2012-09-17 00:36:37 +0000
+++ src/runtime/xqdoc/xqdoc_impl.cpp	2012-09-26 21:04:24 +0000
@@ -27,6 +27,7 @@
 #include "system/globalenv.h"
 #include "zorbatypes/URI.h"
 #include "diagnostics/dict.h"
+#include "diagnostics/util_macros.h"
 
 #include "context/static_context.h"
 #include "context/uri_resolver.h"
@@ -57,13 +58,6 @@
   std::istream* lFile;
   zstring lErrorMessage;
 
-  // setup a new CompilerCB and a new XQueryCompiler 
-  CompilerCB lCompilerCB(*planState.theCompilerCB);
-  lCompilerCB.theRootSctx = GENV.getRootStaticContext().create_child_context();
-  (planState.theCompilerCB->theSctxMap)[1] = lCompilerCB.theRootSctx; 
-
-  XQueryCompiler lCompiler(&lCompilerCB);
-
   PlanIteratorState* state;
   DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
 
@@ -76,18 +70,17 @@
   // resolve the uri in the surrounding static context and use
   // the URI resolver to retrieve the module
   lSctx = theSctx;
+
   lItem->getStringValue2(strval);
   lURI = lSctx->resolve_relative_uri(strval);
   lResource = lSctx->resolve_uri(lURI, internal::EntityData::MODULE, lErrorMessage);
+
   lStream = static_cast<internal::StreamResource*>(lResource.get());
   if ( ! lStream )
   {
-    throw XQUERY_EXCEPTION(
-      err::XQST0046,
-      ERROR_PARAMS( lURI, ZED( ModuleNotFound ) ),
-      ERROR_LOC( loc )
-    );
+    RAISE_ERROR(err::XQST0046, loc, ERROR_PARAMS(lURI, ZED(ModuleNotFound)));
   }
+
   lFile = lStream->getStream();
 
   // now, do the real work
@@ -95,6 +88,11 @@
   {
     try 
     {
+      // setup a new CompilerCB and a new XQueryCompiler 
+      CompilerCB lCompilerCB(*planState.theCompilerCB);
+
+      XQueryCompiler lCompiler(&lCompilerCB);
+
       // retrieve the xqdoc elements 
       lCompiler.xqdoc(*lFile,
                       lFileName,
@@ -111,11 +109,7 @@
   }
   else
   {
-    throw XQUERY_EXCEPTION(
-      err::XQST0046,
-      ERROR_PARAMS( lURI, ZED( ModuleNotFound ) ),
-      ERROR_LOC( loc )
-    );
+    RAISE_ERROR(err::XQST0046, loc, ERROR_PARAMS(lURI, ZED(ModuleNotFound)));
   }
 
   STACK_END(state);
@@ -131,15 +125,6 @@
   store::Item_t lItem;
   zstring lFileName;
 
-  // setup a new CompilerCB and a new XQueryCompiler 
-  CompilerCB lCompilerCB(*planState.theCompilerCB);
-  lCompilerCB.theRootSctx = GENV.getRootStaticContext().create_child_context();
-  (planState.theCompilerCB->theSctxMap)[1] = lCompilerCB.theRootSctx; 
-
-  // the XQueryCompiler's constructor destroys the existing type manager 
-  // in the static context. Hence, we create a new one
-  XQueryCompiler lCompiler(&lCompilerCB);
-
   PlanIteratorState* state;
   DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
 
@@ -150,6 +135,13 @@
   {
     std::istringstream is(lItem->getStringValue().c_str());
 
+    // setup a new CompilerCB and a new XQueryCompiler 
+    CompilerCB lCompilerCB(*planState.theCompilerCB);
+
+    // the XQueryCompiler's constructor destroys the existing type manager 
+    // in the static context. Hence, we create a new one
+    XQueryCompiler lCompiler(&lCompilerCB);
+
     // retrieve the xqdoc elements
     lCompiler.xqdoc(is,
                     lFileName,

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to