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

Proposed by Markos Zaharioudakis
Status: Merged
Approved by: Markos Zaharioudakis
Approved revision: 11098
Merged at revision: 11434
Proposed branch: lp:~zorba-coders/zorba/markos-scratch
Merge into: lp:zorba
Diff against target: 272 lines (+72/-28)
8 files modified
src/compiler/translator/translator.cpp (+52/-23)
src/runtime/hof/dynamic_fncall_iterator.cpp (+1/-4)
src/runtime/json/jsoniq_functions_impl.cpp (+12/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/member_04.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/value_03.xml.res (+1/-0)
test/rbkt/Queries/zorba/jsoniq/member_03.spec (+1/-1)
test/rbkt/Queries/zorba/jsoniq/member_04.xq (+1/-0)
test/rbkt/Queries/zorba/jsoniq/value_03.xq (+3/-0)
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+162529@code.launchpad.net

Commit message

Fix for bug #1167993

Description of the change

Fix for bug #1167993

To post a comment you must log in.
11098. By Markos Zaharioudakis

Fixed bug #1167993

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-05-05T05-03-58.062Z 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 'src/compiler/translator/translator.cpp'
2--- src/compiler/translator/translator.cpp 2013-05-04 20:20:05 +0000
3+++ src/compiler/translator/translator.cpp 2013-05-05 04:52:29 +0000
4@@ -4565,7 +4565,6 @@
5 RAISE_ERROR(err::XQST0048, loc, ERROR_PARAMS(ve->get_name()->getStringValue()));
6 }
7
8-
9 if (v.is_extern() && initExpr != NULL)
10 {
11 RAISE_ERROR(err::XPST0003, loc, ERROR_PARAMS(ZED(XPST0003_ExternalVar)));
12@@ -11925,6 +11924,22 @@
13
14 break;
15 }
16+ case FunctionConsts::FN_JSONIQ_VALUE_2:
17+ {
18+ arguments[1] = CREATE(cast)(theRootSctx, theUDF, loc,
19+ arguments[1],
20+ theRTM.STRING_TYPE_ONE,
21+ false);
22+ break;
23+ }
24+ case FunctionConsts::FN_JSONIQ_MEMBER_2:
25+ {
26+ arguments[1] = CREATE(cast)(theRootSctx, theUDF, loc,
27+ arguments[1],
28+ theRTM.INTEGER_TYPE_ONE,
29+ false);
30+ break;
31+ }
32 case FunctionConsts::FN_CONCAT_N:
33 {
34 if (numArgs < 2)
35@@ -12193,33 +12208,47 @@
36 }
37
38 function* func;
39-
40- if (TypeOps::is_subtype(tm, *srcType, *theRTM.JSON_ARRAY_TYPE_STAR))
41- {
42- func = (numArgs == 1 ?
43- BUILTIN_FUNC(FN_JSONIQ_MEMBER_2) :
44- BUILTIN_FUNC(FN_JSONIQ_MEMBERS_1));
45- }
46- else if (TypeOps::is_subtype(tm, *srcType, *theRTM.JSON_OBJECT_TYPE_STAR))
47- {
48- func = (numArgs == 1 ?
49- BUILTIN_FUNC(FN_JSONIQ_VALUE_2) :
50- BUILTIN_FUNC(FN_JSONIQ_KEYS_1));
51+ expr* accessorExpr;
52+
53+ if (numArgs == 1)
54+ {
55+ if (TypeOps::is_subtype(tm, *srcType, *theRTM.JSON_ARRAY_TYPE_STAR))
56+ {
57+ func = BUILTIN_FUNC(FN_JSONIQ_MEMBER_2);
58+ }
59+ else if (TypeOps::is_subtype(tm, *srcType, *theRTM.JSON_OBJECT_TYPE_STAR))
60+ {
61+ func = BUILTIN_FUNC(FN_JSONIQ_VALUE_2);
62+ }
63+ else
64+ {
65+ func = BUILTIN_FUNC(OP_ZORBA_JSON_ITEM_ACCESSOR_2);
66+ }
67+
68+ arguments.insert(arguments.begin(), flworVarExpr);
69+
70+ accessorExpr = generate_fn_body(func, arguments, loc);
71 }
72 else
73 {
74- func = (numArgs == 1 ?
75- BUILTIN_FUNC(OP_ZORBA_JSON_ITEM_ACCESSOR_2) :
76- BUILTIN_FUNC(OP_ZORBA_JSON_ITEM_ACCESSOR_1));
77+ if (TypeOps::is_subtype(tm, *srcType, *theRTM.JSON_ARRAY_TYPE_STAR))
78+ {
79+ func = BUILTIN_FUNC(FN_JSONIQ_MEMBERS_1);
80+ }
81+ else if (TypeOps::is_subtype(tm, *srcType, *theRTM.JSON_OBJECT_TYPE_STAR))
82+ {
83+ func = BUILTIN_FUNC(FN_JSONIQ_KEYS_1);
84+ }
85+ else
86+ {
87+ func = BUILTIN_FUNC(OP_ZORBA_JSON_ITEM_ACCESSOR_1);
88+ }
89+
90+ accessorExpr = CREATE(fo)(theRootSctx, theUDF, loc, func, flworVarExpr);
91+
92+ normalize_fo(static_cast<fo_expr*>(accessorExpr));
93 }
94
95- fo_expr* accessorExpr =
96- (numArgs == 1 ?
97- CREATE(fo)(theRootSctx, theUDF, loc, func, flworVarExpr, arguments[0]) :
98- CREATE(fo)(theRootSctx, theUDF, loc, func, flworVarExpr));
99-
100- normalize_fo(accessorExpr);
101-
102 flworExpr->set_return_expr(accessorExpr);
103 }
104 else
105
106=== modified file 'src/runtime/hof/dynamic_fncall_iterator.cpp'
107--- src/runtime/hof/dynamic_fncall_iterator.cpp 2013-04-16 20:06:08 +0000
108+++ src/runtime/hof/dynamic_fncall_iterator.cpp 2013-05-05 04:52:29 +0000
109@@ -176,13 +176,11 @@
110 store::Item_t item;
111 store::Item_t targetItem;
112 FunctionItem* fnItem;
113-#ifdef ZORBA_WITH_JSON
114 store::Item_t selectorItem1;
115 store::Item_t selectorItem2;
116 store::Item_t selectorItem3;
117 bool isObjectNav;
118 bool selectorError;
119-#endif
120
121 TypeManager* tm = theSctx->get_typemanager();
122
123@@ -268,7 +266,7 @@
124 } // if (theIsPartialApply)
125
126 } // if (targetItem->isFunction())
127-#ifdef ZORBA_WITH_JSON
128+
129 else if (targetItem->isJSONObject() || targetItem->isJSONArray())
130 {
131 if (theChildren.size() > 2)
132@@ -366,7 +364,6 @@
133 state->theIterator->close();
134 }
135 }
136-#endif
137 else
138 {
139 xqtref_t type = tm->create_value_type(targetItem);
140
141=== modified file 'src/runtime/json/jsoniq_functions_impl.cpp'
142--- src/runtime/json/jsoniq_functions_impl.cpp 2013-04-05 22:56:02 +0000
143+++ src/runtime/json/jsoniq_functions_impl.cpp 2013-05-05 04:52:29 +0000
144@@ -249,6 +249,7 @@
145 return true;
146 }
147
148+
149 bool
150 JSONDecodeFromRoundtripIterator::decodeXDM(
151 const store::Item_t& anObj,
152@@ -318,6 +319,7 @@
153 }
154 }
155
156+
157 bool
158 JSONDecodeFromRoundtripIterator::decodeObject(
159 const store::Item_t& anObj,
160@@ -356,6 +358,7 @@
161 return false;
162 }
163
164+
165 bool
166 JSONDecodeFromRoundtripIterator::decodeArray(
167 const store::Item_t& anArray,
168@@ -384,6 +387,7 @@
169 return false;
170 }
171
172+
173 bool
174 JSONDecodeFromRoundtripIterator::decodeItem(
175 const store::Item_t& anItem,
176@@ -405,6 +409,7 @@
177 }
178 }
179
180+
181 bool
182 JSONDecodeFromRoundtripIterator::nextImpl(
183 store::Item_t& aResult,
184@@ -492,6 +497,7 @@
185 return false;
186 }
187
188+
189 bool
190 JSONEncodeForRoundtripIterator::encodeArray(
191 const store::Item_t& anArray,
192@@ -608,6 +614,7 @@
193 return true;
194 }
195
196+
197 bool
198 JSONEncodeForRoundtripIterator::encodeNode(
199 const store::Item_t& aNode,
200@@ -657,6 +664,7 @@
201 return true;
202 }
203
204+
205 bool
206 JSONEncodeForRoundtripIterator::encodeItem(
207 const store::Item_t& anItem,
208@@ -681,6 +689,7 @@
209 }
210 }
211
212+
213 bool
214 JSONEncodeForRoundtripIterator::nextImpl(
215 store::Item_t& aResult,
216@@ -772,6 +781,7 @@
217 loader_ = nullptr;
218 }
219
220+
221 JSONParseIteratorState::~JSONParseIteratorState()
222 {
223 if (theInput == NULL)
224@@ -779,6 +789,7 @@
225 delete loader_;
226 }
227
228+
229 bool JSONParseIterator::processBooleanOption( store::Item_t const &options,
230 char const *option_name,
231 bool *option_value ) const
232@@ -809,6 +820,7 @@
233 return false;
234 }
235
236+
237 bool
238 JSONParseIterator::nextImpl(
239 store::Item_t& result,
240
241=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/member_04.xml.res'
242--- test/rbkt/ExpQueryResults/zorba/jsoniq/member_04.xml.res 1970-01-01 00:00:00 +0000
243+++ test/rbkt/ExpQueryResults/zorba/jsoniq/member_04.xml.res 2013-05-05 04:52:29 +0000
244@@ -0,0 +1,1 @@
245+1
246
247=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/value_03.xml.res'
248--- test/rbkt/ExpQueryResults/zorba/jsoniq/value_03.xml.res 1970-01-01 00:00:00 +0000
249+++ test/rbkt/ExpQueryResults/zorba/jsoniq/value_03.xml.res 2013-05-05 04:52:29 +0000
250@@ -0,0 +1,1 @@
251+2
252
253=== modified file 'test/rbkt/Queries/zorba/jsoniq/member_03.spec'
254--- test/rbkt/Queries/zorba/jsoniq/member_03.spec 2012-02-05 17:39:57 +0000
255+++ test/rbkt/Queries/zorba/jsoniq/member_03.spec 2013-05-05 04:52:29 +0000
256@@ -1,1 +1,1 @@
257-Error: http://www.w3.org/2005/xqt-errors:XPTY0004
258+Error: http://www.w3.org/2005/xqt-errors:FORG0001
259
260=== added file 'test/rbkt/Queries/zorba/jsoniq/member_04.xq'
261--- test/rbkt/Queries/zorba/jsoniq/member_04.xq 1970-01-01 00:00:00 +0000
262+++ test/rbkt/Queries/zorba/jsoniq/member_04.xq 2013-05-05 04:52:29 +0000
263@@ -0,0 +1,1 @@
264+[ 1 ]("1")
265
266=== added file 'test/rbkt/Queries/zorba/jsoniq/value_03.xq'
267--- test/rbkt/Queries/zorba/jsoniq/value_03.xq 1970-01-01 00:00:00 +0000
268+++ test/rbkt/Queries/zorba/jsoniq/value_03.xq 2013-05-05 04:52:29 +0000
269@@ -0,0 +1,3 @@
270+
271+
272+{"1":2}(1)

Subscribers

People subscribed via source and target branches