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/87335

fixed a bug in the cloning of a var_expr
-- 
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/87335
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/compiler/expression/var_expr.cpp'
--- src/compiler/expression/var_expr.cpp	2011-11-24 16:10:24 +0000
+++ src/compiler/expression/var_expr.cpp	2012-01-03 11:43:10 +0000
@@ -101,6 +101,28 @@
 /*******************************************************************************
 
 ********************************************************************************/
+var_expr::var_expr(const var_expr& source)
+  :
+  expr(source),
+  theUniqueId(0),
+  theKind(source.theKind),
+  theName(source.theName),
+  theDeclaredType(source.theDeclaredType),
+  theFlworClause(NULL),
+  theCopyClause(NULL),
+  theParamPos(source.theParamPos),
+  theUDF(source.theUDF),
+  theIsExternal(source.theIsExternal),
+  theIsPrivate(source.theIsPrivate),
+  theIsMutable(source.theIsMutable),
+  theHasInitializer(source.theHasInitializer)
+{
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
 void var_expr::serialize(::zorba::serialization::Archiver& ar)
 {
   serialize_baseclass(ar, (expr*)this);

=== modified file 'src/compiler/expression/var_expr.h'
--- src/compiler/expression/var_expr.h	2011-11-24 16:10:24 +0000
+++ src/compiler/expression/var_expr.h	2012-01-03 11:43:10 +0000
@@ -193,6 +193,8 @@
       var_kind k,
       store::Item* name);
 
+  var_expr(const var_expr& source);
+
   ulong get_unique_id() const { return theUniqueId; }
 
   void set_unique_id(ulong v) { assert(theUniqueId == 0); theUniqueId = v; }

=== modified file 'src/context/namespace_context.cpp'
--- src/context/namespace_context.cpp	2011-07-02 12:55:44 +0000
+++ src/context/namespace_context.cpp	2012-01-03 11:43:10 +0000
@@ -31,11 +31,13 @@
 /*******************************************************************************
 
 ********************************************************************************/
-namespace_context::namespace_context(const static_context *sctx, store::NsBindings& bindings)
+namespace_context::namespace_context(
+    const static_context* sctx,
+    store::NsBindings& bindings)
   :
   m_sctx(const_cast<static_context*>(sctx))
 {
-  for (unsigned long i = 0; i < bindings.size(); ++i)
+  for (csize i = 0; i < bindings.size(); ++i)
   {
     bind_ns(bindings[i].first, bindings[i].second);
   }    

=== modified file 'src/context/namespace_context.h'
--- src/context/namespace_context.h	2011-07-02 12:55:44 +0000
+++ src/context/namespace_context.h	2012-01-03 11:43:10 +0000
@@ -49,7 +49,11 @@
   void serialize(::zorba::serialization::Archiver& ar);
 
 public:
-  namespace_context(const static_context* sctx) : m_sctx(const_cast<static_context*>(sctx)) { }
+  namespace_context(const static_context* sctx) 
+    :
+    m_sctx(const_cast<static_context*>(sctx))
+  {
+  }
 
   namespace_context(const static_context* sctx, store::NsBindings& bindings);
 

=== modified file 'src/runtime/booleans/BooleanImpl.cpp'
--- src/runtime/booleans/BooleanImpl.cpp	2011-12-21 14:40:33 +0000
+++ src/runtime/booleans/BooleanImpl.cpp	2012-01-03 11:43:10 +0000
@@ -451,8 +451,7 @@
       if (consumeNext(item0, theChild0.getp(), planState) ||
           consumeNext(item1, theChild1.getp(), planState))
       {
-        RAISE_ERROR(err::XPTY0004, loc,
-        ERROR_PARAMS(ZED(NoSeqInValueComp)));
+        RAISE_ERROR(err::XPTY0004, loc, ERROR_PARAMS(ZED(NoSeqInValueComp)));
       }
     }
   }

=== modified file 'src/runtime/core/sequencetypes.cpp'
--- src/runtime/core/sequencetypes.cpp	2011-07-29 06:13:28 +0000
+++ src/runtime/core/sequencetypes.cpp	2012-01-03 11:43:10 +0000
@@ -16,6 +16,7 @@
 #include "stdafx.h"
 
 #include "diagnostics/xquery_diagnostics.h"
+#include "diagnostics/util_macros.h"
 
 #include "system/globalenv.h"
 
@@ -176,18 +177,15 @@
   PlanIteratorState* state;
   DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
 
-  ZORBA_ASSERT(theQuantifier == TypeConstants::QUANT_ONE ||
-               theQuantifier == TypeConstants::QUANT_QUESTION);
+  assert(theQuantifier == TypeConstants::QUANT_ONE ||
+         theQuantifier == TypeConstants::QUANT_QUESTION);
 
   if (!consumeNext(lItem, theChild.getp(), planState))
   {
     if (theQuantifier == TypeConstants::QUANT_ONE)
     {
-      throw XQUERY_EXCEPTION(
-        err::XPTY0004,
-        ERROR_PARAMS( ZED( EmptySeqNoCastToTypeWithQuantOne ) ),
-        ERROR_LOC( loc )
-      );
+      RAISE_ERROR(err::XPTY0004, loc,
+      ERROR_PARAMS(ZED(EmptySeqNoCastToTypeWithQuantOne)));
     }
   }
   else
@@ -207,11 +205,8 @@
 
     if (consumeNext(lItem, theChild.getp(), planState))
     {
-      throw XQUERY_EXCEPTION(
-        err::XPTY0004,
-        ERROR_PARAMS( ZED( NoSeqCastToTypeWithQuantOneOrQuestion ) ),
-        ERROR_LOC( loc )
-      );
+      RAISE_ERROR(err::XPTY0004, loc,
+      ERROR_PARAMS(ZED(NoSeqCastToTypeWithQuantOneOrQuestion)));
     }
 
     STACK_PUSH(valid, state);
@@ -338,21 +333,20 @@
     if (theQuantifier == TypeConstants::QUANT_PLUS ||
         theQuantifier == TypeConstants::QUANT_ONE)
     {
-      zstring const type = thePromoteType->toSchemaString() + (theQuantifier == TypeConstants::QUANT_PLUS? "+" : "");
+      zstring const type = thePromoteType->toSchemaString() + 
+                           (theQuantifier == TypeConstants::QUANT_PLUS? "+" : "");
 
       if (theFnQName.getp())
       {
-        throw XQUERY_EXCEPTION(err::XPTY0004,
-                               ERROR_PARAMS(ZED(EmptySeqNotAsFunctionResult_23),
-                                            theFnQName->getStringValue(),
-                                            type),
-                               ERROR_LOC(loc));
+        RAISE_ERROR(err::XPTY0004, loc,
+        ERROR_PARAMS(ZED(EmptySeqNotAsFunctionResult_23),
+                     theFnQName->getStringValue(),
+                     type));
       }
       else
       {
-        throw XQUERY_EXCEPTION(err::XPTY0004,
-                               ERROR_PARAMS(ZED(EmptySeqNoPromoteTo), type),
-                               ERROR_LOC(loc));
+        RAISE_ERROR(err::XPTY0004, loc,
+        ERROR_PARAMS(ZED(EmptySeqNoPromoteTo), type));
       }
     }
   }
@@ -367,17 +361,14 @@
                                        (theQuantifier == TypeConstants::QUANT_QUESTION ?
                                         "?" : ""));
 
-        throw XQUERY_EXCEPTION(err::XPTY0004,
-                               ERROR_PARAMS(ZED(NoSeqTypePromotion_23),
-                                            tmp,
-                                            theFnQName->getStringValue()),
-                               ERROR_LOC(loc));
+        RAISE_ERROR(err::XPTY0004, loc,
+        ERROR_PARAMS(ZED(NoSeqTypePromotion_23),
+                     tmp,
+                     theFnQName->getStringValue()));
       }
       else
       {
-        throw XQUERY_EXCEPTION(err::XPTY0004,
-                               ERROR_PARAMS(ZED(NoSeqTypePromotion)),
-                               ERROR_LOC(loc));
+        RAISE_ERROR(err::XPTY0004, loc, ERROR_PARAMS(ZED(NoSeqTypePromotion)));
       }
     }
 
@@ -413,28 +404,20 @@
     {
       if (! GenericCast::promote(result, lItem, thePromoteType, tm, loc))
       {
-        if ( theFnQName.getp() )
+        if (theFnQName.getp())
         {
-          throw XQUERY_EXCEPTION(
-            err::XPTY0004,
-            ERROR_PARAMS(
-              ZED( NoTypePromotion_234 ),
-              tm->create_value_type(lItem)->toSchemaString(),
-              thePromoteType->toSchemaString(),
-              theFnQName->getStringValue()
-            ),
-            ERROR_LOC(loc));
+          RAISE_ERROR(err::XPTY0004, loc,
+          ERROR_PARAMS(ZED( NoTypePromotion_234 ),
+                       tm->create_value_type(lItem)->toSchemaString(),
+                       thePromoteType->toSchemaString(),
+                       theFnQName->getStringValue()));
         }
         else
         {
-          throw XQUERY_EXCEPTION(
-            err::XPTY0004,
-            ERROR_PARAMS(
-              ZED( NoTypePromotion_23 ),
-              tm->create_value_type(lItem)->toSchemaString(),
-              thePromoteType->toSchemaString()
-            ),
-            ERROR_LOC(loc));
+          RAISE_ERROR(err::XPTY0004, loc,
+          ERROR_PARAMS(ZED( NoTypePromotion_23 ),
+                       tm->create_value_type(lItem)->toSchemaString(),
+                       thePromoteType->toSchemaString()));
         }
       }
       else

=== modified file 'src/store/naive/atomic_items.cpp'
--- src/store/naive/atomic_items.cpp	2011-12-21 14:40:33 +0000
+++ src/store/naive/atomic_items.cpp	2012-01-03 11:43:10 +0000
@@ -461,11 +461,13 @@
 
 bool UntypedAtomicItem::castToDouble(store::Item_t& result) const
 {
-  try {
+  try 
+  {
     xs_double const doubleValue(theValue.c_str());
     return GET_FACTORY().createDouble(result, doubleValue);
   }
-  catch ( std::exception const& ) {
+  catch ( std::exception const& ) 
+  {
     result = NULL;
     return false;
   }

=== modified file 'src/types/casting.cpp'
--- src/types/casting.cpp	2011-10-22 15:44:45 +0000
+++ src/types/casting.cpp	2012-01-03 11:43:10 +0000
@@ -1689,7 +1689,7 @@
   ErrorInfo lErrorInfo = {&*sourceType, aTargetType, loc};
 
   if (!TypeOps::is_atomic(tm, *aTargetType))
-    throw XQUERY_EXCEPTION( err::XPST0051, ERROR_PARAMS( aTargetType ) );
+    RAISE_ERROR(err::XPST0051, loc, ERROR_PARAMS(aTargetType));
 
 #ifndef ZORBA_NO_XMLSCHEMA
   if (aTargetType->type_kind() == XQType::USER_DEFINED_KIND)
@@ -1728,7 +1728,7 @@
     CastFunc lCastFunc = theCastMatrix[theMapping[sourceTypeCode]]
                                       [theMapping[targetTypeCode]];
     if (lCastFunc == 0)
-      throw TYPE_EXCEPTION( err::XPTY0004, lErrorInfo );
+      throw TYPE_EXCEPTION(err::XPTY0004, lErrorInfo);
 
     valid = (*lCastFunc)(result,
                          lItem,
@@ -1816,8 +1816,7 @@
   if (targetTypeCode == TypeConstants::XS_NOTATION ||
       targetTypeCode == TypeConstants::XS_ANY_ATOMIC)
   {
-    RAISE_ERROR(err::XPST0080, loc,
-    ERROR_PARAMS(*errorInfo.theTargetType));
+    RAISE_ERROR(err::XPST0080, loc, ERROR_PARAMS(*errorInfo.theTargetType));
   }
 
   if (sourceTypeCode == TypeConstants::XS_ANY_ATOMIC)
@@ -1893,8 +1892,7 @@
     throw TYPE_EXCEPTION(err::FORG0001, lErrorInfo);
   }
 
-  const UserDefinedXQType* udt =
-    static_cast<const UserDefinedXQType*>(aTargetType);
+  const UserDefinedXQType* udt = static_cast<const UserDefinedXQType*>(aTargetType);
 
   switch ( udt->getTypeCategory() )
   {
@@ -1909,8 +1907,7 @@
                                                   baseItem,
                                                   NULL,
                                                   loc);
-
-    if ( hasResult )
+    if (hasResult)
     {
       store::Item_t typeName = udt->get_qname();
       GENV_ITEMFACTORY->createUserTypedAtomicItem(result, baseItem, typeName);

=== modified file 'test/unit/context_item.cpp'
--- test/unit/context_item.cpp	2011-12-21 12:10:32 +0000
+++ test/unit/context_item.cpp	2012-01-03 11:43:10 +0000
@@ -38,13 +38,17 @@
     std::ostringstream resultStream;
 
     {
-      zorba::TypeIdentifier_t type =
-      zorba::TypeIdentifier::createNamedType("http://www.w3.org/2001/XMLSchema";,
-                                             "integer");
-
-      zorba::Item ctxValue = zorba->getItemFactory()->createString("foo");
-
       zorba::StaticContext_t sctx = zorba->createStaticContext();
+
+      zorba::TypeIdentifier_t type = sctx->getContextItemStaticType();
+      zorba::IdentTypes::kind_t kind = type->getKind();
+      if (kind != zorba::IdentTypes::ITEM_TYPE)
+      {
+        return 10;
+      }
+
+      type = zorba::TypeIdentifier::createNamedType("http://www.w3.org/2001/XMLSchema";,
+                                                    "integer");
       sctx->setContextItemStaticType(type);
 
       zorba::XQuery_t query = zorba->compileQuery(queryStream, sctx);
@@ -52,6 +56,8 @@
       Zorba_SerializerOptions serOptions;
       serOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES;
 
+      zorba::Item ctxValue = zorba->getItemFactory()->createString("foo");
+
       zorba::DynamicContext* dctx = query->getDynamicContext();
       dctx->setContextItem(ctxValue);
 

-- 
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