Merge lp:~zorba-coders/zorba/markos-scratch into lp:zorba

Proposed by Markos Zaharioudakis
Status: Merged
Approved by: Markos Zaharioudakis
Approved revision: 11157
Merged at revision: 11528
Proposed branch: lp:~zorba-coders/zorba/markos-scratch
Merge into: lp:zorba
Diff against target: 274 lines (+73/-62)
7 files modified
ChangeLog (+2/-0)
src/compiler/translator/translator.cpp (+16/-26)
src/diagnostics/diagnostic_en.xml (+3/-0)
src/diagnostics/pregenerated/dict_en.cpp (+1/-0)
src/diagnostics/pregenerated/dict_zed_keys.h (+1/-0)
src/runtime/core/constructors.cpp (+38/-27)
src/types/casting.cpp (+12/-9)
To merge this branch: bzr merge lp:~zorba-coders/zorba/markos-scratch
Reviewer Review Type Date Requested Status
Markos Zaharioudakis Approve
Review via email: mp+170429@code.launchpad.net

Commit message

fixed bug in casting to xs:NCName + fixed bug in computed PI constructor

Description of the change

fixed bug in casting to xs:NCName + fixed bug in computed PI constructor

To post a comment you must log in.
Revision history for this message
Markos Zaharioudakis (markos-za) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job markos-scratch-2013-06-19T19-41-57.53Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2013-06-18 09:10:28 +0000
3+++ ChangeLog 2013-06-19 19:28:28 +0000
4@@ -30,6 +30,8 @@
5 * Fixed bug #1180220 (Consolidate redundant path/file public APIs)
6 * Fixed bug #1103115 (Timezone units as hours are wrong)
7 * Fixed bug #1188280 (casting xs:id to xs:ncname)
8+ * Fixed bug in casting to xs:NCName
9+ * Fixed bug in error conditions for computed PI constructor
10 * Fixed implementation of fn:deep-equal according to latest W3C spec.
11 * Must apply document ordering on the domain expression of a FOR clause, if
12 the FOR clause is followed by a sequential clause.
13
14=== modified file 'src/compiler/translator/translator.cpp'
15--- src/compiler/translator/translator.cpp 2013-06-19 09:54:46 +0000
16+++ src/compiler/translator/translator.cpp 2013-06-19 19:28:28 +0000
17@@ -1744,9 +1744,7 @@
18 {
19 e = wrap_in_atomization(e);
20
21- return CREATE(promote)(theRootSctx,
22- theUDF,
23- e->get_loc(),
24+ return CREATE(promote)(theRootSctx, theUDF, e->get_loc(),
25 e,
26 type,
27 errorKind,
28@@ -1774,14 +1772,12 @@
29 }
30 else
31 {
32- return theExprManager->create_treat_expr(theRootSctx,
33- theUDF,
34- e->get_loc(),
35- e,
36- type,
37- errorKind,
38- true,
39- qname);
40+ return CREATE(treat)(theRootSctx, theUDF, e->get_loc(),
41+ e,
42+ type,
43+ errorKind,
44+ true,
45+ qname);
46 }
47 }
48
49@@ -1791,11 +1787,9 @@
50 ********************************************************************************/
51 fo_expr* wrap_in_enclosed_expr(expr* contentExpr, const QueryLoc& loc)
52 {
53- return theExprManager->create_fo_expr(theRootSctx,
54- theUDF,
55- loc,
56- BUILTIN_FUNC(OP_ENCLOSED_1),
57- contentExpr);
58+ return CREATE(fo)(theRootSctx, theUDF, loc,
59+ BUILTIN_FUNC(OP_ENCLOSED_1),
60+ contentExpr);
61 }
62
63
64@@ -1804,12 +1798,9 @@
65 ********************************************************************************/
66 expr* wrap_in_bev(expr * e)
67 {
68- fo_expr* fo = theExprManager->create_fo_expr(theRootSctx,
69- theUDF,
70- e->get_loc(),
71- BUILTIN_FUNC(FN_BOOLEAN_1),
72- e);
73- return fo;
74+ return CREATE(fo)(theRootSctx, theUDF, e->get_loc(),
75+ BUILTIN_FUNC(FN_BOOLEAN_1),
76+ e);
77 }
78
79
80@@ -14269,10 +14260,9 @@
81 {
82 target = pop_nodestack();
83
84- expr* castExpr =
85- create_cast_expr(loc, target, theRTM.NCNAME_TYPE_ONE, false, true);
86-
87- target = wrap_in_enclosed_expr(castExpr, loc);
88+ target = wrap_in_type_promotion(target,
89+ theRTM.ANY_ATOMIC_TYPE_ONE,
90+ PROMOTE_TYPE_PROMOTION);
91 }
92
93 expr* e;
94
95=== modified file 'src/diagnostics/diagnostic_en.xml'
96--- src/diagnostics/diagnostic_en.xml 2013-06-18 14:29:16 +0000
97+++ src/diagnostics/diagnostic_en.xml 2013-06-19 19:28:28 +0000
98@@ -304,6 +304,9 @@
99 <value>atomization of grouping variable produces more than one item</value>
100 </entry>
101
102+ <entry key="PiTarget_3">
103+ <value>$3: type of processing instruction target is not xs:NCName, or xs:string, or xs:untypedAtomic</value>
104+ </entry>
105 </diagnostic>
106
107 <diagnostic code="XPTY0018">
108
109=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
110--- src/diagnostics/pregenerated/dict_en.cpp 2013-06-18 14:29:16 +0000
111+++ src/diagnostics/pregenerated/dict_en.cpp 2013-06-19 19:28:28 +0000
112@@ -922,6 +922,7 @@
113 { "~XPTY0004_NoReturnTypePromote_234", "$2 can not be promoted to return type $3 of function $4()" },
114 { "~XPTY0004_NoTreatAs_23", "$2 can not be treated as type $3" },
115 { "~XPTY0004_NoTypePromote_23", "$2 can not be promoted to type $3" },
116+ { "~XPTY0004_PiTarget_3", "$3: type of processing instruction target is not xs:NCName, or xs:string, or xs:untypedAtomic" },
117 { "~XPTY0117_NodeCast", "Cannot cast node to xs:QName" },
118 { "~XPTY0117_NotationParam_23", "$2 can not be promoted to parameter type xs:NOTATION of function $3()" },
119 { "~XQDY0027_InvalidValue", "\"$2\": invalid value for type${: 3}${: 4}" },
120
121=== modified file 'src/diagnostics/pregenerated/dict_zed_keys.h'
122--- src/diagnostics/pregenerated/dict_zed_keys.h 2013-06-18 14:29:16 +0000
123+++ src/diagnostics/pregenerated/dict_zed_keys.h 2013-06-19 19:28:28 +0000
124@@ -48,6 +48,7 @@
125 #define ZED_XPTY0004_NoTreatAs_23 "~XPTY0004_NoTreatAs_23"
126 #define ZED_XPTY0004_JSONIQ_SELECTOR "~XPTY0004_JSONIQ_SELECTOR"
127 #define ZED_XPTY0004_MultiValuedGroupingKey "~XPTY0004_MultiValuedGroupingKey"
128+#define ZED_XPTY0004_PiTarget_3 "~XPTY0004_PiTarget_3"
129 #define ZED_XPTY0117_NodeCast "~XPTY0117_NodeCast"
130 #define ZED_XPTY0117_NotationParam_23 "~XPTY0117_NotationParam_23"
131 #define ZED_XQST0046_BadHexDigit_3 "~XQST0046_BadHexDigit_3"
132
133=== modified file 'src/runtime/core/constructors.cpp'
134--- src/runtime/core/constructors.cpp 2013-06-05 00:37:35 +0000
135+++ src/runtime/core/constructors.cpp 2013-06-19 19:28:28 +0000
136@@ -856,8 +856,10 @@
137
138 bool PiIterator::nextImpl(store::Item_t& result, PlanState& planState) const
139 {
140- store::Item_t lItem;
141+ store::Item_t targetItem;
142+ store::SchemaTypeCode targetType;
143 store::Item_t temp;
144+ store::Item_t contentItem;
145 zstring content;
146 zstring target;
147 zstring baseUri;
148@@ -870,29 +872,38 @@
149 DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
150
151 // Compute the target of the pi node.
152- try
153- {
154- if (!consumeNext(lItem, theChild0, planState))
155- {
156- // translator places a cast to xs:NCName op
157- ZORBA_ASSERT(false);
158- }
159- }
160- catch (ZorbaException const& e)
161- {
162- if (e.diagnostic() == err::FORG0001)
163- throw XQUERY_EXCEPTION(err::XQDY0041, ERROR_LOC(loc));
164- else
165- throw;
166- }
167-
168- if (consumeNext(temp, theChild0, planState))
169- {
170- // translator places a cast to xs:NCName op
171- ZORBA_ASSERT(false);
172- }
173-
174- lItem->getStringValue2(target);
175+ // translator places a promote to xs:anyAtomicType op
176+ ZORBA_ASSERT(consumeNext(targetItem, theChild0, planState));
177+
178+ targetType = targetItem->getTypeCode();
179+
180+ if (targetType != store::XS_NCNAME &&
181+ targetType != store::XS_STRING &&
182+ targetType != store::XS_UNTYPED_ATOMIC)
183+ {
184+ TypeManager* tm = theSctx->get_typemanager();
185+ xqtref_t type = tm->create_value_type(targetItem);
186+ RAISE_ERROR(err::XPTY0004, loc,
187+ ERROR_PARAMS(ZED(XPTY0004_PiTarget_3), type->toSchemaString()));
188+ }
189+
190+ if (targetType != store::XS_NCNAME)
191+ {
192+ try
193+ {
194+ GenericCast::
195+ castToBuiltinAtomic(targetItem, targetItem, store::XS_NCNAME, NULL, loc);
196+ }
197+ catch (ZorbaException& e)
198+ {
199+ if (e.diagnostic() == err::FORG0001)
200+ throw XQUERY_EXCEPTION(err::XQDY0041, ERROR_LOC(loc));
201+ else
202+ throw;
203+ }
204+ }
205+
206+ targetItem->getStringValue2(target);
207
208 if (target.empty())
209 {
210@@ -909,14 +920,14 @@
211
212 // Compute the content of the pi node
213 for (lFirst = true;
214- consumeNext(lItem, theChild1.getp(), planState);
215+ consumeNext(contentItem, theChild1.getp(), planState);
216 lFirst = false)
217 {
218 if (! lFirst)
219 content += " ";
220
221 zstring strvalue;
222- lItem->getStringValue2(strvalue);
223+ contentItem->getStringValue2(strvalue);
224
225 if (strvalue.find("?>", 0, 2) != zstring::npos)
226 throw XQUERY_EXCEPTION(err::XQDY0026, ERROR_LOC(loc));
227@@ -934,7 +945,7 @@
228 GENV_ITEMFACTORY->createPiNode(result, parent, target, content, baseUri);
229 STACK_PUSH(true, state);
230
231- STACK_END (state);
232+ STACK_END(state);
233 }
234
235
236
237=== modified file 'src/types/casting.cpp'
238--- src/types/casting.cpp 2013-06-18 09:10:28 +0000
239+++ src/types/casting.cpp 2013-06-19 19:28:28 +0000
240@@ -2431,6 +2431,18 @@
241
242 for (csize i = 0; i < memberTypes.size(); ++i)
243 {
244+ if (TypeOps::is_subtype(tm, item.getp(), *memberTypes[i], loc))
245+ {
246+ store::Item_t tmp = item;
247+ resultList.clear();
248+
249+ ZORBA_ASSERT(castToSimple(tmp, memberTypes[i], nsCtx, resultList, tm, loc));
250+ return true;
251+ }
252+ }
253+
254+ for (csize i = 0; i < memberTypes.size(); ++i)
255+ {
256 try
257 {
258 store::Item_t tmp = item;
259@@ -2658,15 +2670,6 @@
260 throwXPTY0004Exception(errInfo);
261 }
262
263- if (targetTypeCode == store::XS_NCNAME &&
264- !TypeOps::is_subtype(sourceTypeCode, store::XS_NCNAME) &&
265- sourceTypeCode != store::XS_STRING &&
266- sourceTypeCode != store::XS_NCNAME &&
267- sourceTypeCode != store::XS_UNTYPED_ATOMIC)
268- {
269- throwXPTY0004Exception(errInfo);
270- }
271-
272 CastFunc castFunc = theCastMatrix[theMapping[sourceTypeCode]]
273 [theMapping[targetTypeCode]];
274 if (castFunc == 0)

Subscribers

People subscribed via source and target branches