Merge lp:~nbrinza/zorba/bugs2 into lp:zorba

Proposed by Nicolae Brinza
Status: Merged
Approved by: Nicolae Brinza
Approved revision: 10996
Merged at revision: 10996
Proposed branch: lp:~nbrinza/zorba/bugs2
Merge into: lp:zorba
Diff against target: 239 lines (+32/-28)
4 files modified
ChangeLog (+1/-0)
src/compiler/translator/translator.cpp (+26/-28)
test/rbkt/ExpQueryResults/zorba/casting/qname-dynamic-string.xml.res (+2/-0)
test/rbkt/Queries/zorba/casting/qname-dynamic-string.xq (+3/-0)
To merge this branch: bzr merge lp:~nbrinza/zorba/bugs2
Reviewer Review Type Date Requested Status
Nicolae Brinza Approve
Chris Hillery Approve
Review via email: mp+120711@code.launchpad.net

This proposal supersedes a proposal from 2012-08-21.

Commit message

Dynamically computed strings can now be cast to xs:QName. Fixes bug #898792

Description of the change

Dynamically computed strings can now be cast to xs:QName. Fixes bug #898792

To post a comment you must log in.
Revision history for this message
Chris Hillery (ceejatec) wrote : Posted in a previous version of this proposal

Please don't leave commented-out code in there; just delete it (it's still in Bazaar and can be recovered if necessary).

Why is this merge proposal associated with bug 931501? Mistake I guess, since that bug is Fix Released?

Revision history for this message
Nicolae Brinza (nbrinza) wrote : Posted in a previous version of this proposal

I left the old code in there as an explanation -- if anything gets messed up, it would be possible to see how the code was change in this sensitive spot without having to go dig through the history. Anyway, I've changed it to a comment that explains the modification.

The merge is associated with the bug 931501 because it's an older branch created by me for bugfixing that I'm now reusing.

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Chris Hillery (ceejatec) wrote :

Ok, thanks for the explanation.

review: Approve
Revision history for this message
Nicolae Brinza (nbrinza) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bugs2-2012-08-22T06-48-32.988Z 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 2012-08-16 18:31:02 +0000
3+++ ChangeLog 2012-08-22 06:46:21 +0000
4@@ -3,6 +3,7 @@
5 version 2.7
6
7 Bug Fixes/Other Changes:
8+ * Fixed bug #898792 (Dynamically computed strings can now be cast to xs:QName)
9 * Fixed bugs #899364 and 899363 (throw XQST0103 in case of non-distinct window
10 variables)
11 * Fixed bug #899366 (enforce the type declaration of a window variable)
12
13=== modified file 'src/compiler/translator/translator.cpp'
14--- src/compiler/translator/translator.cpp 2012-08-16 18:31:02 +0000
15+++ src/compiler/translator/translator.cpp 2012-08-22 06:46:21 +0000
16@@ -1420,7 +1420,7 @@
17 {
18 argExpr = wrap_in_atomization(argExpr);
19 argExpr = wrap_in_type_promotion(argExpr,
20- paramType,
21+ paramType,
22 PromoteIterator::FUNC_PARAM,
23 func->getName());
24 }
25@@ -1988,7 +1988,7 @@
26 stmts.push_back(new treat_expr(theRootSctx,
27 loc,
28 getExpr,
29- varType,
30+ varType,
31 TreatIterator::TYPE_MATCH));
32 }
33 }
34@@ -3719,7 +3719,7 @@
35 {
36 body = wrap_in_type_match(body,
37 returnType,
38- loc,
39+ loc,
40 TreatIterator::FUNC_RETURN,
41 udf->getName());
42 }
43@@ -3928,7 +3928,7 @@
44 // Make sure that there is no other prolog var with the same name in any of
45 // modules translated so far.
46 bind_var(ve, theModulesInfo->globalSctx.get());
47-
48+
49 // If this is a library module, register the var in the exported sctx as well.
50 if (export_sctx != NULL)
51 bind_var(ve, export_sctx);
52@@ -5686,7 +5686,7 @@
53 #ifdef ZORBA_WITH_DEBUGGER
54 if (initExpr != NULL && theCCB->theDebuggerCommons != NULL)
55 {
56- QueryLoc lExpandedLocation =
57+ QueryLoc lExpandedLocation =
58 expandQueryLoc(v.get_var_name()->get_location(), initExpr->get_loc());
59
60 wrap_in_debugger_expr(initExpr, lExpandedLocation, false, true);
61@@ -6173,7 +6173,7 @@
62 // it's important to insert the debugger before the scope is pushed.
63 // Otherwise, the variable in question would already be in scope for
64 // the debugger but no value would be bound
65- QueryLoc lExpandedLocation =
66+ QueryLoc lExpandedLocation =
67 expandQueryLoc(v.get_var_name()->get_location(), domainExpr->get_loc());
68
69 wrap_in_debugger_expr(domainExpr, lExpandedLocation);
70@@ -6602,7 +6602,7 @@
71 for (csize i = 0; i < lList->size(); ++i)
72 {
73 GroupSpec* spec = (*lList)[i];
74-
75+
76 const QName* varname = spec->get_var_name();
77
78 const var_expr* ve = NULL;
79@@ -6684,7 +6684,7 @@
80
81 if (groupSpec.get_collation_spec() != NULL &&
82 prevSpec.get_collation_spec() != NULL &&
83- groupSpec.get_collation_spec()->get_uri() ==
84+ groupSpec.get_collation_spec()->get_uri() ==
85 prevSpec.get_collation_spec()->get_uri())
86 break;
87 }
88@@ -6801,7 +6801,7 @@
89
90 if (v.get_var_type() != NULL)
91 type = pop_tstack();
92-
93+
94 create_let_clause(loc, v.get_var_name(), domainExpr, type);
95 }
96 }
97@@ -8277,11 +8277,9 @@
98 // when casting to type T, where T is QName or subtype of, and the input
99 // is not a const expr, then the input MUST be of type T or subtype of.
100 if (isCast)
101- return new treat_expr(theRootSctx,
102- loc,
103- node,
104- qnameType,
105- TreatIterator::TYPE_MATCH);
106+ // This was previously a treat_expr() with TYPE_MATCH. It was changed to cast_expr()
107+ // in order to allow dynamically computed strings to be cast to xs:QName.
108+ return new cast_expr(theRootSctx, loc, wrap_in_atomization(node), qnameType);
109 else
110 return new instanceof_expr(theRootSctx, loc, node, qnameType);
111 }
112@@ -12991,7 +12989,7 @@
113 for (int i = 0; i < (int)lParamTypes->size(); ++i)
114 {
115 const SequenceType* lParamType = (*lParamTypes)[i].getp();
116- if (lParamType == 0)
117+ if (lParamType == 0)
118 {
119 lParamXQTypes.push_back(GENV_TYPESYSTEM.ITEM_TYPE_STAR);
120 }
121@@ -13024,7 +13022,7 @@
122
123
124 /*******************************************************************************
125- JSONObjectInsertExpr ::=
126+ JSONObjectInsertExpr ::=
127 "insert" "json" "{" PairConstructor ("," PairConstructor)* "}"
128 ********************************************************************************/
129 void* begin_visit(const JSONObjectInsertExpr& v)
130@@ -13062,11 +13060,11 @@
131 {
132 expr_t nameExpr = pop_nodestack();
133 expr_t valueExpr = pop_nodestack();
134-
135+
136 nameExpr = wrap_in_type_promotion(nameExpr,
137 theRTM.STRING_TYPE_ONE,
138 PromoteIterator::JSONIQ_OBJECT_SELECTOR); // JNUP0007
139-
140+
141 valueExpr = wrap_in_type_match(valueExpr,
142 rtm.ITEM_TYPE_ONE,
143 loc,
144@@ -13078,7 +13076,7 @@
145 }
146
147 expr_t updExpr = new fo_expr(theRootSctx,
148- loc,
149+ loc,
150 GET_BUILTIN_FUNCTION(OP_OBJECT_INSERT_N),
151 args);
152
153@@ -13088,7 +13086,7 @@
154
155
156 /*******************************************************************************
157- JSONArrayInsertExpr ::=
158+ JSONArrayInsertExpr ::=
159 "insert" "json" "[" ExprSingle "]" "into" ExprSingle "at" "position" ExprSingle
160 ********************************************************************************/
161 void* begin_visit(const JSONArrayInsertExpr& v)
162@@ -13130,7 +13128,7 @@
163 args[2] = sourceExpr;
164
165 fo_expr_t updExpr = new fo_expr(theRootSctx,
166- loc,
167+ loc,
168 GET_BUILTIN_FUNCTION(OP_ZORBA_JSON_ARRAY_INSERT_3),
169 args);
170 normalize_fo(updExpr.getp());
171@@ -13168,7 +13166,7 @@
172 NULL);
173
174 fo_expr_t updExpr = new fo_expr(theRootSctx,
175- loc,
176+ loc,
177 GET_BUILTIN_FUNCTION(OP_ZORBA_JSON_ARRAY_APPEND_2),
178 targetExpr,
179 contentExpr);
180@@ -13210,12 +13208,12 @@
181 #ifdef ZORBA_WITH_JSON
182 expr_t selExpr = pop_nodestack();
183 expr_t targetExpr = pop_nodestack();
184-
185+
186 selExpr = wrap_in_type_promotion(selExpr,
187 theRTM.ANY_ATOMIC_TYPE_ONE,
188 PromoteIterator::JSONIQ_SELECTOR, // JNUP0007
189 NULL);
190-
191+
192 targetExpr = wrap_in_type_match(targetExpr,
193 theRTM.JSON_ITEM_TYPE_ONE,
194 loc,
195@@ -13223,7 +13221,7 @@
196 NULL);
197
198 fo_expr_t updExpr = new fo_expr(theRootSctx,
199- loc,
200+ loc,
201 GET_BUILTIN_FUNCTION(OP_ZORBA_JSON_DELETE_2),
202 targetExpr,
203 selExpr);
204@@ -13272,9 +13270,9 @@
205 loc,
206 TreatIterator::JSONIQ_OBJECT_UPDATE_VALUE, // JNUP0017
207 NULL);
208-
209+
210 fo_expr_t updExpr = new fo_expr(theRootSctx,
211- loc,
212+ loc,
213 GET_BUILTIN_FUNCTION(OP_ZORBA_JSON_REPLACE_VALUE_3),
214 args);
215 push_nodestack(updExpr.getp());
216@@ -13321,7 +13319,7 @@
217 PromoteIterator::JSONIQ_OBJECT_SELECTOR); // JNUP0007
218
219 fo_expr_t updExpr = new fo_expr(theRootSctx,
220- loc,
221+ loc,
222 GET_BUILTIN_FUNCTION(OP_ZORBA_JSON_RENAME_3),
223 args);
224 push_nodestack(updExpr.getp());
225
226=== added file 'test/rbkt/ExpQueryResults/zorba/casting/qname-dynamic-string.xml.res'
227--- test/rbkt/ExpQueryResults/zorba/casting/qname-dynamic-string.xml.res 1970-01-01 00:00:00 +0000
228+++ test/rbkt/ExpQueryResults/zorba/casting/qname-dynamic-string.xml.res 2012-08-22 06:46:21 +0000
229@@ -0,0 +1,2 @@
230+<?xml version="1.0" encoding="UTF-8"?>
231+local:test
232
233=== added file 'test/rbkt/Queries/zorba/casting/qname-dynamic-string.xq'
234--- test/rbkt/Queries/zorba/casting/qname-dynamic-string.xq 1970-01-01 00:00:00 +0000
235+++ test/rbkt/Queries/zorba/casting/qname-dynamic-string.xq 2012-08-22 06:46:21 +0000
236@@ -0,0 +1,3 @@
237+(: Cast a dynamically computed string to QName :)
238+
239+xs:QName(concat("local:", "test"))

Subscribers

People subscribed via source and target branches