Merge lp:~zorba-coders/zorba/markos-scratch into lp:zorba
- markos-scratch
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Markos Zaharioudakis |
Approved revision: | 11042 |
Merged at revision: | 11293 |
Proposed branch: | lp:~zorba-coders/zorba/markos-scratch |
Merge into: | lp:zorba |
Diff against target: |
844 lines (+299/-146) 14 files modified
ChangeLog (+1/-0) bin/zorbacmd.cpp (+3/-0) src/api/staticcontextimpl.cpp (+1/-1) src/compiler/translator/translator.cpp (+105/-77) src/context/root_static_context.cpp (+2/-1) src/context/static_context.cpp (+71/-16) src/context/static_context.h (+17/-10) src/functions/func_sequences_impl.cpp (+44/-0) src/functions/pregenerated/func_sequences.cpp (+0/-9) src/runtime/sequences/pregenerated/sequences.cpp (+2/-0) src/runtime/sequences/pregenerated/sequences.h (+6/-2) src/runtime/sequences/sequences_impl.cpp (+36/-26) src/runtime/spec/sequences/sequences.xml (+9/-3) test/rbkt/testdriver.cpp (+2/-1) |
To merge this branch: | bzr merge lp:~zorba-coders/zorba/markos-scratch |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Markos Zaharioudakis | Approve | ||
Review via email: mp+153930@code.launchpad.net |
Commit message
1.In jsoniq mode, allow multiple default function namespaces and no need to use the xs prefix for naming builtin atomic types.
2. Optimization for indef-of function.
Description of the change
1.In jsoniq mode, allow multiple default function namespaces and no need to use the xs prefix for naming builtin atomic types.
2. Optimization for indef-of function.
Markos Zaharioudakis (markos-za) : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~zorba-coders/zorba/markos-scratch into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job markos-
The final status was:
6 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~zorba-coders/zorba/markos-scratch into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job markos-
The final status was:
5 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
- 11042. By Markos Zaharioudakis
-
a bug fix for index-of
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job markos-
All tests succeeded!
Preview Diff
1 | === modified file 'ChangeLog' | |||
2 | --- ChangeLog 2013-03-16 20:55:24 +0000 | |||
3 | +++ ChangeLog 2013-03-20 02:47:23 +0000 | |||
4 | @@ -15,6 +15,7 @@ | |||
5 | 15 | for streamable strings and base64Binary. | 15 | for streamable strings and base64Binary. |
6 | 16 | * Added millis-to-dateTime() function in datetime module. | 16 | * Added millis-to-dateTime() function in datetime module. |
7 | 17 | * fn:trace outputs "empty-sequence()" if the input is the empty-sequence. | 17 | * fn:trace outputs "empty-sequence()" if the input is the empty-sequence. |
8 | 18 | * Allow multiple default function namespaces. | ||
9 | 18 | * Added xqxq:variable-value function. | 19 | * Added xqxq:variable-value function. |
10 | 19 | * Added canonicalize function to modules/xml. | 20 | * Added canonicalize function to modules/xml. |
11 | 20 | * Added support for xs:dateTimeStamp type from XMLSchema 1.1, bug #924754. | 21 | * Added support for xs:dateTimeStamp type from XMLSchema 1.1, bug #924754. |
12 | 21 | 22 | ||
13 | === modified file 'bin/zorbacmd.cpp' | |||
14 | --- bin/zorbacmd.cpp 2013-02-07 17:24:36 +0000 | |||
15 | +++ bin/zorbacmd.cpp 2013-03-20 02:47:23 +0000 | |||
16 | @@ -673,6 +673,8 @@ | |||
17 | 673 | std::auto_ptr<std::fstream> planFile; | 673 | std::auto_ptr<std::fstream> planFile; |
18 | 674 | std::fstream* planFilep = NULL; | 674 | std::fstream* planFilep = NULL; |
19 | 675 | 675 | ||
20 | 676 | lHints.jsoniq_mode = (qfilepath.rfind(".jq") == qfilepath.size() - 3); | ||
21 | 677 | |||
22 | 676 | if (serializePlan) | 678 | if (serializePlan) |
23 | 677 | { | 679 | { |
24 | 678 | if (savePlan || loadPlan) | 680 | if (savePlan || loadPlan) |
25 | @@ -724,6 +726,7 @@ | |||
26 | 724 | } | 726 | } |
27 | 725 | 727 | ||
28 | 726 | Zorba_SerializerOptions lSerOptions = Zorba_SerializerOptions::SerializerOptionsFromStringParams(properties.getSerializerParameters()); | 728 | Zorba_SerializerOptions lSerOptions = Zorba_SerializerOptions::SerializerOptionsFromStringParams(properties.getSerializerParameters()); |
29 | 729 | |||
30 | 727 | createSerializerOptions(lSerOptions, properties); | 730 | createSerializerOptions(lSerOptions, properties); |
31 | 728 | 731 | ||
32 | 729 | zorba::XQuery_t query; | 732 | zorba::XQuery_t query; |
33 | 730 | 733 | ||
34 | === modified file 'src/api/staticcontextimpl.cpp' | |||
35 | --- src/api/staticcontextimpl.cpp 2013-02-07 17:24:36 +0000 | |||
36 | +++ src/api/staticcontextimpl.cpp 2013-03-20 02:47:23 +0000 | |||
37 | @@ -316,7 +316,7 @@ | |||
38 | 316 | 316 | ||
39 | 317 | ********************************************************************************/ | 317 | ********************************************************************************/ |
40 | 318 | String | 318 | String |
42 | 319 | StaticContextImpl::getDefaultFunctionNamespace( ) const | 319 | StaticContextImpl::getDefaultFunctionNamespace() const |
43 | 320 | { | 320 | { |
44 | 321 | try | 321 | try |
45 | 322 | { | 322 | { |
46 | 323 | 323 | ||
47 | === modified file 'src/compiler/translator/translator.cpp' | |||
48 | --- src/compiler/translator/translator.cpp 2013-03-08 00:09:46 +0000 | |||
49 | +++ src/compiler/translator/translator.cpp 2013-03-20 02:47:23 +0000 | |||
50 | @@ -1031,6 +1031,11 @@ | |||
51 | 1031 | Convert a lexical qname identifying a function to an expanded qname item. | 1031 | Convert a lexical qname identifying a function to an expanded qname item. |
52 | 1032 | If the lexical qname does not have a prefix, the default function namespace | 1032 | If the lexical qname does not have a prefix, the default function namespace |
53 | 1033 | (if any) will be used to build the expanded qname item. | 1033 | (if any) will be used to build the expanded qname item. |
54 | 1034 | |||
55 | 1035 | Raise error is the prefix is non-empty and there is no ns associated with it. | ||
56 | 1036 | |||
57 | 1037 | This method is used during the processing of function declarations (when the | ||
58 | 1038 | function object is not supposed to exist already). | ||
59 | 1034 | ********************************************************************************/ | 1039 | ********************************************************************************/ |
60 | 1035 | void expand_function_qname( | 1040 | void expand_function_qname( |
61 | 1036 | store::Item_t& qnameItem, | 1041 | store::Item_t& qnameItem, |
62 | @@ -1297,7 +1302,7 @@ | |||
63 | 1297 | ********************************************************************************/ | 1302 | ********************************************************************************/ |
64 | 1298 | void bind_fn( | 1303 | void bind_fn( |
65 | 1299 | function_t& f, | 1304 | function_t& f, |
67 | 1300 | ulong nargs, | 1305 | csize nargs, |
68 | 1301 | const QueryLoc& loc) | 1306 | const QueryLoc& loc) |
69 | 1302 | { | 1307 | { |
70 | 1303 | theSctx->bind_fn(f, nargs, loc); | 1308 | theSctx->bind_fn(f, nargs, loc); |
71 | @@ -1313,14 +1318,17 @@ | |||
72 | 1313 | 1318 | ||
73 | 1314 | /******************************************************************************* | 1319 | /******************************************************************************* |
74 | 1315 | Lookup in the sctx the function object for a function with a given prefix | 1320 | Lookup in the sctx the function object for a function with a given prefix |
76 | 1316 | local name and arity. Return NULL if such a function is not found | 1321 | local name and arity. Raise error if the prefix is non-empty and does not have |
77 | 1322 | an associated namespace. Return NULL if such a function is not found. | ||
78 | 1317 | ********************************************************************************/ | 1323 | ********************************************************************************/ |
80 | 1318 | function* lookup_fn(const QName* qname, ulong arity, const QueryLoc& loc) | 1324 | function* lookup_fn(const QName* qname, csize arity, const QueryLoc& loc) |
81 | 1319 | { | 1325 | { |
86 | 1320 | store::Item_t qnameItem; | 1326 | return theSctx->lookup_fn(qname->get_namespace(), |
87 | 1321 | expand_function_qname(qnameItem, qname, loc); | 1327 | qname->get_prefix(), |
88 | 1322 | 1328 | qname->get_localname(), | |
89 | 1323 | return theSctx->lookup_fn(qnameItem, arity); | 1329 | arity, |
90 | 1330 | theCCB->theConfig.jsoniq_mode, | ||
91 | 1331 | loc); | ||
92 | 1324 | } | 1332 | } |
93 | 1325 | 1333 | ||
94 | 1326 | 1334 | ||
95 | @@ -4140,10 +4148,10 @@ | |||
96 | 4140 | 4148 | ||
97 | 4141 | //bool recognised = false; | 4149 | //bool recognised = false; |
98 | 4142 | 4150 | ||
101 | 4143 | store::Item_t lExpandedQName; | 4151 | store::Item_t expandedQName; |
102 | 4144 | expand_function_qname(lExpandedQName, v.get_qname(), loc); | 4152 | expand_function_qname(expandedQName, v.get_qname(), loc); |
103 | 4145 | 4153 | ||
105 | 4146 | zstring annotNS = lExpandedQName->getNamespace(); | 4154 | zstring annotNS = expandedQName->getNamespace(); |
106 | 4147 | 4155 | ||
107 | 4148 | if (annotNS == static_context::W3C_XML_NS || | 4156 | if (annotNS == static_context::W3C_XML_NS || |
108 | 4149 | annotNS == XML_SCHEMA_NS || | 4157 | annotNS == XML_SCHEMA_NS || |
109 | @@ -4152,10 +4160,10 @@ | |||
110 | 4152 | annotNS == XQUERY_MATH_FN_NS || | 4160 | annotNS == XQUERY_MATH_FN_NS || |
111 | 4153 | annotNS == ZORBA_ANNOTATIONS_NS) | 4161 | annotNS == ZORBA_ANNOTATIONS_NS) |
112 | 4154 | { | 4162 | { |
114 | 4155 | if (AnnotationInternal::lookup(lExpandedQName) == AnnotationInternal::zann_end) | 4163 | if (AnnotationInternal::lookup(expandedQName) == AnnotationInternal::zann_end) |
115 | 4156 | { | 4164 | { |
116 | 4157 | RAISE_ERROR(err::XQST0045, loc, | 4165 | RAISE_ERROR(err::XQST0045, loc, |
118 | 4158 | ERROR_PARAMS(lExpandedQName->getLocalName(), ZED(ANNOTATION), annotNS)); | 4166 | ERROR_PARAMS(expandedQName->getLocalName(), ZED(ANNOTATION), annotNS)); |
119 | 4159 | } | 4167 | } |
120 | 4160 | 4168 | ||
121 | 4161 | //recognised = true; | 4169 | //recognised = true; |
122 | @@ -4177,7 +4185,7 @@ | |||
123 | 4177 | } | 4185 | } |
124 | 4178 | 4186 | ||
125 | 4179 | //if (recognised) | 4187 | //if (recognised) |
127 | 4180 | theAnnotations->push_back(lExpandedQName, lLiterals); | 4188 | theAnnotations->push_back(expandedQName, lLiterals); |
128 | 4181 | } | 4189 | } |
129 | 4182 | 4190 | ||
130 | 4183 | 4191 | ||
131 | @@ -8640,9 +8648,19 @@ | |||
132 | 8640 | 8648 | ||
133 | 8641 | rchandle<QName> qname = v.get_qname(); | 8649 | rchandle<QName> qname = v.get_qname(); |
134 | 8642 | store::Item_t qnameItem; | 8650 | store::Item_t qnameItem; |
136 | 8643 | expand_elem_qname(qnameItem, qname, loc); | 8651 | |
137 | 8652 | if (!qname->get_prefix().empty() || !theCCB->theConfig.jsoniq_mode) | ||
138 | 8653 | { | ||
139 | 8654 | expand_elem_qname(qnameItem, qname, loc); | ||
140 | 8655 | } | ||
141 | 8656 | else | ||
142 | 8657 | { | ||
143 | 8658 | GENV_ITEMFACTORY-> | ||
144 | 8659 | createQName(qnameItem, XML_SCHEMA_NS, "", qname->get_localname()); | ||
145 | 8660 | } | ||
146 | 8644 | 8661 | ||
147 | 8645 | xqtref_t t = CTX_TM->create_named_simple_type(qnameItem); | 8662 | xqtref_t t = CTX_TM->create_named_simple_type(qnameItem); |
148 | 8663 | |||
149 | 8646 | if (t == NULL) | 8664 | if (t == NULL) |
150 | 8647 | { | 8665 | { |
151 | 8648 | if (theSctx->xquery_version() < StaticContextConsts::xquery_version_3_0) | 8666 | if (theSctx->xquery_version() < StaticContextConsts::xquery_version_3_0) |
152 | @@ -10738,20 +10756,6 @@ | |||
153 | 10738 | 10756 | ||
154 | 10739 | TypeManager* tm = CTX_TM; | 10757 | TypeManager* tm = CTX_TM; |
155 | 10740 | 10758 | ||
156 | 10741 | // Expand the function qname | ||
157 | 10742 | rchandle<QName> qname = v.get_fname(); | ||
158 | 10743 | |||
159 | 10744 | store::Item_t qnameItem; | ||
160 | 10745 | expand_function_qname(qnameItem, qname, loc); | ||
161 | 10746 | |||
162 | 10747 | const zstring& fn_ns = qnameItem->getNamespace(); | ||
163 | 10748 | |||
164 | 10749 | if (static_context::is_reserved_module(fn_ns)) | ||
165 | 10750 | { | ||
166 | 10751 | RAISE_ERROR(zerr::ZXQP0016_RESERVED_MODULE_TARGET_NAMESPACE, loc, | ||
167 | 10752 | ERROR_PARAMS(fn_ns)); | ||
168 | 10753 | } | ||
169 | 10754 | |||
170 | 10755 | // Collect the arguments of this function in reverse order | 10759 | // Collect the arguments of this function in reverse order |
171 | 10756 | std::vector<expr*> arguments; | 10760 | std::vector<expr*> arguments; |
172 | 10757 | 10761 | ||
173 | @@ -10767,17 +10771,73 @@ | |||
174 | 10767 | 10771 | ||
175 | 10768 | csize numArgs = arguments.size(); | 10772 | csize numArgs = arguments.size(); |
176 | 10769 | 10773 | ||
177 | 10774 | // Lookup the function | ||
178 | 10775 | store::Item_t qnameItem; | ||
179 | 10776 | const QName* qname = v.get_fname(); | ||
180 | 10777 | |||
181 | 10770 | function* f = lookup_fn(qname, numArgs, loc); | 10778 | function* f = lookup_fn(qname, numArgs, loc); |
182 | 10771 | 10779 | ||
183 | 10780 | zstring fn_ns; | ||
184 | 10781 | |||
185 | 10782 | if (f != NULL) | ||
186 | 10783 | { | ||
187 | 10784 | qnameItem = f->getName(); | ||
188 | 10785 | fn_ns = qnameItem->getNamespace(); | ||
189 | 10786 | |||
190 | 10787 | if (static_context::is_reserved_module(fn_ns)) | ||
191 | 10788 | { | ||
192 | 10789 | RAISE_ERROR(zerr::ZXQP0016_RESERVED_MODULE_TARGET_NAMESPACE, loc, | ||
193 | 10790 | ERROR_PARAMS(fn_ns)); | ||
194 | 10791 | } | ||
195 | 10792 | } | ||
196 | 10793 | else | ||
197 | 10794 | { | ||
198 | 10795 | // Check if this is a call to a type constructor function | ||
199 | 10796 | expand_function_qname(qnameItem, qname, loc); | ||
200 | 10797 | |||
201 | 10798 | xqtref_t type = CTX_TM->create_named_type(qnameItem, | ||
202 | 10799 | TypeConstants::QUANT_QUESTION, | ||
203 | 10800 | loc); | ||
204 | 10801 | |||
205 | 10802 | if (type != NULL) | ||
206 | 10803 | { | ||
207 | 10804 | if (numArgs != 1 || | ||
208 | 10805 | TypeOps::is_equal(tm, *type, *GENV_TYPESYSTEM.NOTATION_TYPE_QUESTION, loc) || | ||
209 | 10806 | TypeOps::is_equal(tm, *type, *GENV_TYPESYSTEM.ANY_ATOMIC_TYPE_QUESTION, loc)) | ||
210 | 10807 | { | ||
211 | 10808 | RAISE_ERROR(err::XPST0017, loc, | ||
212 | 10809 | ERROR_PARAMS(qname->get_qname(), ZED(FunctionUndeclared_3), numArgs)); | ||
213 | 10810 | } | ||
214 | 10811 | |||
215 | 10812 | push_nodestack(create_cast_expr(loc, arguments[0], type, true, true)); | ||
216 | 10813 | |||
217 | 10814 | return; | ||
218 | 10815 | } | ||
219 | 10816 | |||
220 | 10817 | if (theHaveModuleImportCycle) | ||
221 | 10818 | { | ||
222 | 10819 | fn_ns = qnameItem->getNamespace(); | ||
223 | 10820 | |||
224 | 10821 | std::map<zstring, zstring>::const_iterator ite = theModulesStack.begin(); | ||
225 | 10822 | std::map<zstring, zstring>::const_iterator end = theModulesStack.end(); | ||
226 | 10823 | |||
227 | 10824 | --end; | ||
228 | 10825 | assert((*end).second == theModuleNamespace); | ||
229 | 10826 | |||
230 | 10827 | for (; ite != end; ++ite) | ||
231 | 10828 | { | ||
232 | 10829 | if ((*ite).second == fn_ns) | ||
233 | 10830 | RAISE_ERROR(err::XQST0093, loc, ERROR_PARAMS(theModuleNamespace)); | ||
234 | 10831 | } | ||
235 | 10832 | } | ||
236 | 10833 | |||
237 | 10834 | RAISE_ERROR(err::XPST0017, loc, | ||
238 | 10835 | ERROR_PARAMS(qname->get_qname(), ZED(FunctionUndeclared_3), numArgs)); | ||
239 | 10836 | } | ||
240 | 10837 | |||
241 | 10772 | if (fn_ns == static_context::W3C_FN_NS) | 10838 | if (fn_ns == static_context::W3C_FN_NS) |
242 | 10773 | { | 10839 | { |
243 | 10774 | // Some special processing is required for certain "fn" functions | 10840 | // Some special processing is required for certain "fn" functions |
244 | 10775 | if (f == NULL) | ||
245 | 10776 | { | ||
246 | 10777 | RAISE_ERROR(err::XPST0017, loc, | ||
247 | 10778 | ERROR_PARAMS(qname->get_qname(), ZED(FunctionUndeclared_3), numArgs)); | ||
248 | 10779 | } | ||
249 | 10780 | |||
250 | 10781 | switch (f->getKind()) | 10841 | switch (f->getKind()) |
251 | 10782 | { | 10842 | { |
252 | 10783 | case FunctionConsts::FN_HEAD_1: | 10843 | case FunctionConsts::FN_HEAD_1: |
253 | @@ -11062,48 +11122,7 @@ | |||
254 | 11062 | 11122 | ||
255 | 11063 | numArgs = arguments.size(); // recompute size | 11123 | numArgs = arguments.size(); // recompute size |
256 | 11064 | 11124 | ||
299 | 11065 | // Check if this is a call to a type constructor function | 11125 | { |
258 | 11066 | xqtref_t type = CTX_TM->create_named_type(qnameItem, | ||
259 | 11067 | TypeConstants::QUANT_QUESTION, | ||
260 | 11068 | loc); | ||
261 | 11069 | |||
262 | 11070 | if (type != NULL) | ||
263 | 11071 | { | ||
264 | 11072 | if (numArgs != 1 || | ||
265 | 11073 | TypeOps::is_equal(tm, *type, *GENV_TYPESYSTEM.NOTATION_TYPE_QUESTION, loc) || | ||
266 | 11074 | TypeOps::is_equal(tm, *type, *GENV_TYPESYSTEM.ANY_ATOMIC_TYPE_QUESTION, loc)) | ||
267 | 11075 | { | ||
268 | 11076 | RAISE_ERROR(err::XPST0017, loc, | ||
269 | 11077 | ERROR_PARAMS(qname->get_qname(), ZED(FunctionUndeclared_3), numArgs)); | ||
270 | 11078 | } | ||
271 | 11079 | |||
272 | 11080 | push_nodestack(create_cast_expr(loc, arguments[0], type, true, true)); | ||
273 | 11081 | } | ||
274 | 11082 | |||
275 | 11083 | // It is not a builtin constructor function | ||
276 | 11084 | else | ||
277 | 11085 | { | ||
278 | 11086 | if (f == NULL) | ||
279 | 11087 | { | ||
280 | 11088 | if (theHaveModuleImportCycle) | ||
281 | 11089 | { | ||
282 | 11090 | std::map<zstring, zstring>::const_iterator ite = theModulesStack.begin(); | ||
283 | 11091 | std::map<zstring, zstring>::const_iterator end = theModulesStack.end(); | ||
284 | 11092 | |||
285 | 11093 | --end; | ||
286 | 11094 | assert((*end).second == theModuleNamespace); | ||
287 | 11095 | |||
288 | 11096 | for (; ite != end; ++ite) | ||
289 | 11097 | { | ||
290 | 11098 | if ((*ite).second == fn_ns) | ||
291 | 11099 | RAISE_ERROR(err::XQST0093, loc, ERROR_PARAMS(theModuleNamespace)); | ||
292 | 11100 | } | ||
293 | 11101 | } | ||
294 | 11102 | |||
295 | 11103 | RAISE_ERROR(err::XPST0017, loc, | ||
296 | 11104 | ERROR_PARAMS(qname->get_qname(), ZED(FunctionUndeclared_3), numArgs)); | ||
297 | 11105 | } | ||
298 | 11106 | |||
300 | 11107 | // If this is a udf that is invoked from another udf, mark that other udf | 11126 | // If this is a udf that is invoked from another udf, mark that other udf |
301 | 11108 | // as a non-leaf function. | 11127 | // as a non-leaf function. |
302 | 11109 | if (f->isUdf()) | 11128 | if (f->isUdf()) |
303 | @@ -13084,7 +13103,16 @@ | |||
304 | 13084 | 13103 | ||
305 | 13085 | rchandle<QName> qname = v.get_qname(); | 13104 | rchandle<QName> qname = v.get_qname(); |
306 | 13086 | store::Item_t qnameItem; | 13105 | store::Item_t qnameItem; |
308 | 13087 | expand_elem_qname(qnameItem, qname, loc); | 13106 | |
309 | 13107 | if (!qname->get_prefix().empty() || !theCCB->theConfig.jsoniq_mode) | ||
310 | 13108 | { | ||
311 | 13109 | expand_elem_qname(qnameItem, qname, loc); | ||
312 | 13110 | } | ||
313 | 13111 | else | ||
314 | 13112 | { | ||
315 | 13113 | GENV_ITEMFACTORY-> | ||
316 | 13114 | createQName(qnameItem, XML_SCHEMA_NS, "", qname->get_localname()); | ||
317 | 13115 | } | ||
318 | 13088 | 13116 | ||
319 | 13089 | xqtref_t t = CTX_TM->create_named_simple_type(qnameItem); | 13117 | xqtref_t t = CTX_TM->create_named_simple_type(qnameItem); |
320 | 13090 | 13118 | ||
321 | 13091 | 13119 | ||
322 | === modified file 'src/context/root_static_context.cpp' | |||
323 | --- src/context/root_static_context.cpp 2013-02-07 17:24:36 +0000 | |||
324 | +++ src/context/root_static_context.cpp 2013-03-20 02:47:23 +0000 | |||
325 | @@ -157,7 +157,8 @@ | |||
326 | 157 | 157 | ||
327 | 158 | set_default_elem_type_ns(zstring(), true, loc); | 158 | set_default_elem_type_ns(zstring(), true, loc); |
328 | 159 | 159 | ||
330 | 160 | set_default_function_ns(W3C_FN_NS, true, loc); | 160 | set_default_function_ns(JSONIQ_FN_NS, false, loc); |
331 | 161 | set_default_function_ns(W3C_FN_NS, false, loc); | ||
332 | 161 | 162 | ||
333 | 162 | add_collation(ZORBA_DEF_COLLATION_NS, QueryLoc::null); | 163 | add_collation(ZORBA_DEF_COLLATION_NS, QueryLoc::null); |
334 | 163 | add_collation(W3C_CODEPT_COLLATION_NS, QueryLoc::null); | 164 | add_collation(W3C_CODEPT_COLLATION_NS, QueryLoc::null); |
335 | 164 | 165 | ||
336 | === modified file 'src/context/static_context.cpp' | |||
337 | --- src/context/static_context.cpp 2013-02-26 04:12:43 +0000 | |||
338 | +++ src/context/static_context.cpp 2013-03-20 02:47:23 +0000 | |||
339 | @@ -677,7 +677,6 @@ | |||
340 | 677 | theExternalModulesMap(NULL), | 677 | theExternalModulesMap(NULL), |
341 | 678 | theNamespaceBindings(NULL), | 678 | theNamespaceBindings(NULL), |
342 | 679 | theHaveDefaultElementNamespace(false), | 679 | theHaveDefaultElementNamespace(false), |
343 | 680 | theHaveDefaultFunctionNamespace(false), | ||
344 | 681 | theContextItemType(NULL), | 680 | theContextItemType(NULL), |
345 | 682 | theVariablesMap(NULL), | 681 | theVariablesMap(NULL), |
346 | 683 | theImportedPrivateVariablesMap(NULL), | 682 | theImportedPrivateVariablesMap(NULL), |
347 | @@ -724,7 +723,6 @@ | |||
348 | 724 | theExternalModulesMap(NULL), | 723 | theExternalModulesMap(NULL), |
349 | 725 | theNamespaceBindings(NULL), | 724 | theNamespaceBindings(NULL), |
350 | 726 | theHaveDefaultElementNamespace(false), | 725 | theHaveDefaultElementNamespace(false), |
351 | 727 | theHaveDefaultFunctionNamespace(false), | ||
352 | 728 | theContextItemType(NULL), | 726 | theContextItemType(NULL), |
353 | 729 | theVariablesMap(NULL), | 727 | theVariablesMap(NULL), |
354 | 730 | theImportedPrivateVariablesMap(NULL), | 728 | theImportedPrivateVariablesMap(NULL), |
355 | @@ -776,7 +774,6 @@ | |||
356 | 776 | theExternalModulesMap(NULL), | 774 | theExternalModulesMap(NULL), |
357 | 777 | theNamespaceBindings(NULL), | 775 | theNamespaceBindings(NULL), |
358 | 778 | theHaveDefaultElementNamespace(false), | 776 | theHaveDefaultElementNamespace(false), |
359 | 779 | theHaveDefaultFunctionNamespace(false), | ||
360 | 780 | theContextItemType(NULL), | 777 | theContextItemType(NULL), |
361 | 781 | theVariablesMap(NULL), | 778 | theVariablesMap(NULL), |
362 | 782 | theImportedPrivateVariablesMap(NULL), | 779 | theImportedPrivateVariablesMap(NULL), |
363 | @@ -1086,8 +1083,7 @@ | |||
364 | 1086 | ar & theNamespaceBindings; | 1083 | ar & theNamespaceBindings; |
365 | 1087 | ar & theDefaultElementNamespace; | 1084 | ar & theDefaultElementNamespace; |
366 | 1088 | ar & theHaveDefaultElementNamespace; | 1085 | ar & theHaveDefaultElementNamespace; |
369 | 1089 | ar & theDefaultFunctionNamespace; | 1086 | ar & theDefaultFunctionNamespaces; |
368 | 1090 | ar & theHaveDefaultFunctionNamespace; | ||
370 | 1091 | 1087 | ||
371 | 1092 | ar & theContextItemType; | 1088 | ar & theContextItemType; |
372 | 1093 | 1089 | ||
373 | @@ -2039,9 +2035,9 @@ | |||
374 | 2039 | ********************************************************************************/ | 2035 | ********************************************************************************/ |
375 | 2040 | const zstring& static_context::default_function_ns() const | 2036 | const zstring& static_context::default_function_ns() const |
376 | 2041 | { | 2037 | { |
378 | 2042 | if (theHaveDefaultFunctionNamespace || theParent == NULL) | 2038 | if (!theDefaultFunctionNamespaces.empty() || theParent == NULL) |
379 | 2043 | { | 2039 | { |
381 | 2044 | return theDefaultFunctionNamespace; | 2040 | return theDefaultFunctionNamespaces[0]; |
382 | 2045 | } | 2041 | } |
383 | 2046 | else | 2042 | else |
384 | 2047 | { | 2043 | { |
385 | @@ -2058,10 +2054,9 @@ | |||
386 | 2058 | bool raiseError, | 2054 | bool raiseError, |
387 | 2059 | const QueryLoc& loc) | 2055 | const QueryLoc& loc) |
388 | 2060 | { | 2056 | { |
390 | 2061 | if (!theHaveDefaultFunctionNamespace) | 2057 | if (theDefaultFunctionNamespaces.empty()) |
391 | 2062 | { | 2058 | { |
394 | 2063 | theDefaultFunctionNamespace = ns; | 2059 | theDefaultFunctionNamespaces.push_back(ns); |
393 | 2064 | theHaveDefaultFunctionNamespace = true; | ||
395 | 2065 | } | 2060 | } |
396 | 2066 | else if (raiseError) | 2061 | else if (raiseError) |
397 | 2067 | { | 2062 | { |
398 | @@ -2069,7 +2064,7 @@ | |||
399 | 2069 | } | 2064 | } |
400 | 2070 | else | 2065 | else |
401 | 2071 | { | 2066 | { |
403 | 2072 | theDefaultFunctionNamespace = ns; | 2067 | theDefaultFunctionNamespaces.insert(theDefaultFunctionNamespaces.begin(), ns); |
404 | 2073 | } | 2068 | } |
405 | 2074 | } | 2069 | } |
406 | 2075 | 2070 | ||
407 | @@ -2429,7 +2424,7 @@ | |||
408 | 2429 | ********************************************************************************/ | 2424 | ********************************************************************************/ |
409 | 2430 | void static_context::bind_fn( | 2425 | void static_context::bind_fn( |
410 | 2431 | function_t& f, | 2426 | function_t& f, |
412 | 2432 | ulong arity, | 2427 | csize arity, |
413 | 2433 | const QueryLoc& loc) | 2428 | const QueryLoc& loc) |
414 | 2434 | { | 2429 | { |
415 | 2435 | store::Item* qname = f->getName(); | 2430 | store::Item* qname = f->getName(); |
416 | @@ -2441,7 +2436,7 @@ | |||
417 | 2441 | 2436 | ||
418 | 2442 | if (theFunctionMap == NULL) | 2437 | if (theFunctionMap == NULL) |
419 | 2443 | { | 2438 | { |
421 | 2444 | ulong size = (is_global_root_sctx() ? 500 : 32); | 2439 | csize size = (is_global_root_sctx() ? 500 : 32); |
422 | 2445 | theFunctionMap = new FunctionMap(HashMapItemPointerCmp(0, NULL), size, false); | 2440 | theFunctionMap = new FunctionMap(HashMapItemPointerCmp(0, NULL), size, false); |
423 | 2446 | } | 2441 | } |
424 | 2447 | 2442 | ||
425 | @@ -2503,7 +2498,7 @@ | |||
426 | 2503 | ********************************************************************************/ | 2498 | ********************************************************************************/ |
427 | 2504 | void static_context::unbind_fn( | 2499 | void static_context::unbind_fn( |
428 | 2505 | const store::Item* qname, | 2500 | const store::Item* qname, |
430 | 2506 | ulong arity) | 2501 | csize arity) |
431 | 2507 | { | 2502 | { |
432 | 2508 | ZORBA_ASSERT(!is_global_root_sctx()); | 2503 | ZORBA_ASSERT(!is_global_root_sctx()); |
433 | 2509 | 2504 | ||
434 | @@ -2563,6 +2558,66 @@ | |||
435 | 2563 | } | 2558 | } |
436 | 2564 | 2559 | ||
437 | 2565 | 2560 | ||
438 | 2561 | /******************************************************************************* | ||
439 | 2562 | Search in the sctx, starting from "this" and moving upwards, for the function | ||
440 | 2563 | object for a function with a given prefix local name and arity. Raise error if | ||
441 | 2564 | the prefix is non-empty and does not have an associated namespace. Return NULL | ||
442 | 2565 | if such a function is not found. | ||
443 | 2566 | ********************************************************************************/ | ||
444 | 2567 | function* static_context::lookup_fn( | ||
445 | 2568 | const zstring& ns, | ||
446 | 2569 | const zstring& pre, | ||
447 | 2570 | const zstring& local, | ||
448 | 2571 | csize arity, | ||
449 | 2572 | bool allowMultipleDefaultNamespaces, | ||
450 | 2573 | const QueryLoc& loc) | ||
451 | 2574 | { | ||
452 | 2575 | store::Item_t qnameItem; | ||
453 | 2576 | std::vector<zstring>::const_iterator ite; | ||
454 | 2577 | std::vector<zstring>::const_iterator end; | ||
455 | 2578 | function* f = NULL; | ||
456 | 2579 | |||
457 | 2580 | if (!ns.empty()) | ||
458 | 2581 | { | ||
459 | 2582 | ITEM_FACTORY->createQName(qnameItem, ns, "", local); | ||
460 | 2583 | |||
461 | 2584 | f = lookup_fn(qnameItem, arity, true); | ||
462 | 2585 | } | ||
463 | 2586 | else if (!pre.empty()) | ||
464 | 2587 | { | ||
465 | 2588 | expand_qname(qnameItem, "", pre, local, loc); | ||
466 | 2589 | |||
467 | 2590 | f = lookup_fn(qnameItem, arity, true); | ||
468 | 2591 | } | ||
469 | 2592 | else if (allowMultipleDefaultNamespaces) | ||
470 | 2593 | { | ||
471 | 2594 | static_context* sctx = this; | ||
472 | 2595 | |||
473 | 2596 | while (f == NULL && sctx != NULL) | ||
474 | 2597 | { | ||
475 | 2598 | ite = sctx->theDefaultFunctionNamespaces.begin(); | ||
476 | 2599 | end = sctx->theDefaultFunctionNamespaces.end(); | ||
477 | 2600 | |||
478 | 2601 | for (; f == NULL && ite != end; ++ite) | ||
479 | 2602 | { | ||
480 | 2603 | ITEM_FACTORY->createQName(qnameItem, *ite, "", local); | ||
481 | 2604 | f = lookup_fn(qnameItem, arity, true); | ||
482 | 2605 | } | ||
483 | 2606 | |||
484 | 2607 | sctx = sctx->theParent; | ||
485 | 2608 | } | ||
486 | 2609 | } | ||
487 | 2610 | else | ||
488 | 2611 | { | ||
489 | 2612 | expand_qname(qnameItem, default_function_ns(), pre, local, loc); | ||
490 | 2613 | |||
491 | 2614 | f = lookup_fn(qnameItem, arity, true); | ||
492 | 2615 | } | ||
493 | 2616 | |||
494 | 2617 | return f; | ||
495 | 2618 | } | ||
496 | 2619 | |||
497 | 2620 | |||
498 | 2566 | /***************************************************************************//** | 2621 | /***************************************************************************//** |
499 | 2567 | Search the static-context tree, starting from "this" and moving upwards, | 2622 | Search the static-context tree, starting from "this" and moving upwards, |
500 | 2568 | looking for the 1st sctx obj that contains a binding for a function with | 2623 | looking for the 1st sctx obj that contains a binding for a function with |
501 | @@ -2572,7 +2627,7 @@ | |||
502 | 2572 | ********************************************************************************/ | 2627 | ********************************************************************************/ |
503 | 2573 | function* static_context::lookup_fn( | 2628 | function* static_context::lookup_fn( |
504 | 2574 | const store::Item* qname, | 2629 | const store::Item* qname, |
506 | 2575 | ulong arity, | 2630 | csize arity, |
507 | 2576 | bool skipDisabled) | 2631 | bool skipDisabled) |
508 | 2577 | { | 2632 | { |
509 | 2578 | FunctionInfo fi; | 2633 | FunctionInfo fi; |
510 | @@ -2627,7 +2682,7 @@ | |||
511 | 2627 | ********************************************************************************/ | 2682 | ********************************************************************************/ |
512 | 2628 | function* static_context::lookup_local_fn( | 2683 | function* static_context::lookup_local_fn( |
513 | 2629 | const store::Item* qname, | 2684 | const store::Item* qname, |
515 | 2630 | ulong arity, | 2685 | csize arity, |
516 | 2631 | bool skipDisabled) | 2686 | bool skipDisabled) |
517 | 2632 | { | 2687 | { |
518 | 2633 | FunctionInfo fi; | 2688 | FunctionInfo fi; |
519 | 2634 | 2689 | ||
520 | === modified file 'src/context/static_context.h' | |||
521 | --- src/context/static_context.h 2013-02-26 04:12:43 +0000 | |||
522 | +++ src/context/static_context.h 2013-03-20 02:47:23 +0000 | |||
523 | @@ -352,9 +352,9 @@ | |||
524 | 352 | ---------------------------- | 352 | ---------------------------- |
525 | 353 | The namespace URI to be used for element and type qnames whose prefix is empty. | 353 | The namespace URI to be used for element and type qnames whose prefix is empty. |
526 | 354 | 354 | ||
530 | 355 | theDefaultFunctionNamespace : | 355 | theDefaultFunctionNamespaces : |
531 | 356 | ----------------------------- | 356 | ------------------------------ |
532 | 357 | The namespace URI to be used for function qnames whose prefix is empty. | 357 | The namespace URIs to be used for function qnames whose prefix is empty. |
533 | 358 | 358 | ||
534 | 359 | theContextItemType : | 359 | theContextItemType : |
535 | 360 | -------------------- | 360 | -------------------- |
536 | @@ -598,8 +598,7 @@ | |||
537 | 598 | zstring theDefaultElementNamespace; | 598 | zstring theDefaultElementNamespace; |
538 | 599 | bool theHaveDefaultElementNamespace; | 599 | bool theHaveDefaultElementNamespace; |
539 | 600 | 600 | ||
542 | 601 | zstring theDefaultFunctionNamespace; | 601 | std::vector<zstring> theDefaultFunctionNamespaces; |
541 | 602 | bool theHaveDefaultFunctionNamespace; | ||
543 | 603 | 602 | ||
544 | 604 | xqtref_t theContextItemType; | 603 | xqtref_t theContextItemType; |
545 | 605 | 604 | ||
546 | @@ -893,18 +892,26 @@ | |||
547 | 893 | // | 892 | // |
548 | 894 | // Functions | 893 | // Functions |
549 | 895 | // | 894 | // |
553 | 896 | void bind_fn(function_t& f, ulong arity, const QueryLoc& loc); | 895 | void bind_fn(function_t& f, csize arity, const QueryLoc& loc); |
554 | 897 | 896 | ||
555 | 898 | void unbind_fn(const store::Item* qname, ulong arity); | 897 | void unbind_fn(const store::Item* qname, csize arity); |
556 | 898 | |||
557 | 899 | function* lookup_fn( | ||
558 | 900 | const zstring& ns, | ||
559 | 901 | const zstring& pre, | ||
560 | 902 | const zstring& local, | ||
561 | 903 | csize arity, | ||
562 | 904 | bool allowMultipleDefaultNamespaces, | ||
563 | 905 | const QueryLoc& loc); | ||
564 | 899 | 906 | ||
565 | 900 | function* lookup_fn( | 907 | function* lookup_fn( |
566 | 901 | const store::Item* qname, | 908 | const store::Item* qname, |
568 | 902 | ulong arity, | 909 | csize arity, |
569 | 903 | bool skipDisabled = true); | 910 | bool skipDisabled = true); |
570 | 904 | 911 | ||
571 | 905 | function* lookup_local_fn( | 912 | function* lookup_local_fn( |
572 | 906 | const store::Item* qname, | 913 | const store::Item* qname, |
574 | 907 | ulong arity, | 914 | csize arity, |
575 | 908 | bool skipDisabled = true); | 915 | bool skipDisabled = true); |
576 | 909 | 916 | ||
577 | 910 | void get_functions(std::vector<function*>& functions) const; | 917 | void get_functions(std::vector<function*>& functions) const; |
578 | 911 | 918 | ||
579 | === modified file 'src/functions/func_sequences_impl.cpp' | |||
580 | --- src/functions/func_sequences_impl.cpp 2013-02-07 17:24:36 +0000 | |||
581 | +++ src/functions/func_sequences_impl.cpp 2013-03-20 02:47:23 +0000 | |||
582 | @@ -492,6 +492,50 @@ | |||
583 | 492 | /******************************************************************************* | 492 | /******************************************************************************* |
584 | 493 | 493 | ||
585 | 494 | ********************************************************************************/ | 494 | ********************************************************************************/ |
586 | 495 | PlanIter_t fn_index_of::codegen( | ||
587 | 496 | CompilerCB*, | ||
588 | 497 | static_context* sctx, | ||
589 | 498 | const QueryLoc& loc, | ||
590 | 499 | std::vector<PlanIter_t>& argv, | ||
591 | 500 | expr& caller) const | ||
592 | 501 | { | ||
593 | 502 | TypeManager* tm = caller.get_type_manager(); | ||
594 | 503 | RootTypeManager& rtm = GENV_TYPESYSTEM; | ||
595 | 504 | |||
596 | 505 | fo_expr* fo = static_cast<fo_expr*>(&caller); | ||
597 | 506 | expr* seqArg = fo->get_arg(0); | ||
598 | 507 | expr* keyArg = fo->get_arg(1); | ||
599 | 508 | xqtref_t seqType = seqArg->get_return_type(); | ||
600 | 509 | xqtref_t pseqType = TypeOps::prime_type(tm, *seqType); | ||
601 | 510 | xqtref_t keyType = keyArg->get_return_type(); | ||
602 | 511 | |||
603 | 512 | if (TypeOps::is_equal(tm, *keyType, *rtm.ANY_ATOMIC_TYPE_ONE) || | ||
604 | 513 | TypeOps::is_equal(tm, *pseqType, *rtm.ANY_ATOMIC_TYPE_ONE)) | ||
605 | 514 | { | ||
606 | 515 | return new FnIndexOfIterator(sctx, loc, argv, 0); | ||
607 | 516 | } | ||
608 | 517 | |||
609 | 518 | if (TypeOps::is_subtype(tm, *keyType, *seqType) || | ||
610 | 519 | (TypeOps::is_subtype(tm, *keyType, *rtm.UNTYPED_ATOMIC_TYPE_ONE) && | ||
611 | 520 | TypeOps::is_subtype(tm, *seqType, *rtm.STRING_TYPE_STAR)) || | ||
612 | 521 | (TypeOps::is_subtype(tm, *keyType, *rtm.STRING_TYPE_ONE) && | ||
613 | 522 | TypeOps::is_subtype(tm, *seqType, *rtm.UNTYPED_ATOMIC_TYPE_STAR))) | ||
614 | 523 | { | ||
615 | 524 | return new FnIndexOfIterator(sctx, loc, argv, 1); | ||
616 | 525 | } | ||
617 | 526 | |||
618 | 527 | if (TypeOps::is_subtype(tm, *pseqType, *keyType)) | ||
619 | 528 | { | ||
620 | 529 | return new FnIndexOfIterator(sctx, loc, argv, 2); | ||
621 | 530 | } | ||
622 | 531 | |||
623 | 532 | return new FnIndexOfIterator(sctx, loc, argv, 0); | ||
624 | 533 | } | ||
625 | 534 | |||
626 | 535 | |||
627 | 536 | /******************************************************************************* | ||
628 | 537 | |||
629 | 538 | ********************************************************************************/ | ||
630 | 495 | xqtref_t fn_subsequence::getReturnType(const fo_expr* caller) const | 539 | xqtref_t fn_subsequence::getReturnType(const fo_expr* caller) const |
631 | 496 | { | 540 | { |
632 | 497 | TypeManager* tm = caller->get_type_manager(); | 541 | TypeManager* tm = caller->get_type_manager(); |
633 | 498 | 542 | ||
634 | === modified file 'src/functions/pregenerated/func_sequences.cpp' | |||
635 | --- src/functions/pregenerated/func_sequences.cpp 2013-03-05 23:11:50 +0000 | |||
636 | +++ src/functions/pregenerated/func_sequences.cpp 2013-03-20 02:47:23 +0000 | |||
637 | @@ -44,15 +44,6 @@ | |||
638 | 44 | return new FnConcatIterator(sctx, loc, argv); | 44 | return new FnConcatIterator(sctx, loc, argv); |
639 | 45 | } | 45 | } |
640 | 46 | 46 | ||
641 | 47 | PlanIter_t fn_index_of::codegen( | ||
642 | 48 | CompilerCB*, | ||
643 | 49 | static_context* sctx, | ||
644 | 50 | const QueryLoc& loc, | ||
645 | 51 | std::vector<PlanIter_t>& argv, | ||
646 | 52 | expr& ann) const | ||
647 | 53 | { | ||
648 | 54 | return new FnIndexOfIterator(sctx, loc, argv); | ||
649 | 55 | } | ||
650 | 56 | 47 | ||
651 | 57 | PlanIter_t fn_empty::codegen( | 48 | PlanIter_t fn_empty::codegen( |
652 | 58 | CompilerCB*, | 49 | CompilerCB*, |
653 | 59 | 50 | ||
654 | === modified file 'src/runtime/sequences/pregenerated/sequences.cpp' | |||
655 | --- src/runtime/sequences/pregenerated/sequences.cpp 2013-03-05 23:11:50 +0000 | |||
656 | +++ src/runtime/sequences/pregenerated/sequences.cpp 2013-03-20 02:47:23 +0000 | |||
657 | @@ -72,6 +72,8 @@ | |||
658 | 72 | { | 72 | { |
659 | 73 | serialize_baseclass(ar, | 73 | serialize_baseclass(ar, |
660 | 74 | (NaryBaseIterator<FnIndexOfIterator, FnIndexOfIteratorState>*)this); | 74 | (NaryBaseIterator<FnIndexOfIterator, FnIndexOfIteratorState>*)this); |
661 | 75 | |||
662 | 76 | ar & theFastComp; | ||
663 | 75 | } | 77 | } |
664 | 76 | 78 | ||
665 | 77 | 79 | ||
666 | 78 | 80 | ||
667 | === modified file 'src/runtime/sequences/pregenerated/sequences.h' | |||
668 | --- src/runtime/sequences/pregenerated/sequences.h 2013-03-05 23:11:50 +0000 | |||
669 | +++ src/runtime/sequences/pregenerated/sequences.h 2013-03-20 02:47:23 +0000 | |||
670 | @@ -124,6 +124,8 @@ | |||
671 | 124 | 124 | ||
672 | 125 | class FnIndexOfIterator : public NaryBaseIterator<FnIndexOfIterator, FnIndexOfIteratorState> | 125 | class FnIndexOfIterator : public NaryBaseIterator<FnIndexOfIterator, FnIndexOfIteratorState> |
673 | 126 | { | 126 | { |
674 | 127 | protected: | ||
675 | 128 | int theFastComp; // | ||
676 | 127 | public: | 129 | public: |
677 | 128 | SERIALIZABLE_CLASS(FnIndexOfIterator); | 130 | SERIALIZABLE_CLASS(FnIndexOfIterator); |
678 | 129 | 131 | ||
679 | @@ -135,9 +137,11 @@ | |||
680 | 135 | FnIndexOfIterator( | 137 | FnIndexOfIterator( |
681 | 136 | static_context* sctx, | 138 | static_context* sctx, |
682 | 137 | const QueryLoc& loc, | 139 | const QueryLoc& loc, |
684 | 138 | std::vector<PlanIter_t>& children) | 140 | std::vector<PlanIter_t>& children, |
685 | 141 | int fastComp) | ||
686 | 139 | : | 142 | : |
688 | 140 | NaryBaseIterator<FnIndexOfIterator, FnIndexOfIteratorState>(sctx, loc, children) | 143 | NaryBaseIterator<FnIndexOfIterator, FnIndexOfIteratorState>(sctx, loc, children), |
689 | 144 | theFastComp(fastComp) | ||
690 | 141 | {} | 145 | {} |
691 | 142 | 146 | ||
692 | 143 | virtual ~FnIndexOfIterator(); | 147 | virtual ~FnIndexOfIterator(); |
693 | 144 | 148 | ||
694 | === modified file 'src/runtime/sequences/sequences_impl.cpp' | |||
695 | --- src/runtime/sequences/sequences_impl.cpp 2013-03-05 12:34:19 +0000 | |||
696 | +++ src/runtime/sequences/sequences_impl.cpp 2013-03-20 02:47:23 +0000 | |||
697 | @@ -76,18 +76,16 @@ | |||
698 | 76 | store::Item_t temp; | 76 | store::Item_t temp; |
699 | 77 | 77 | ||
700 | 78 | if (!PlanIterator::consumeNext(lCollationItem, iter, planState)) | 78 | if (!PlanIterator::consumeNext(lCollationItem, iter, planState)) |
706 | 79 | throw XQUERY_EXCEPTION( | 79 | { |
707 | 80 | err::XPTY0004, | 80 | RAISE_ERROR(err::XPTY0004, loc, |
708 | 81 | ERROR_PARAMS( ZED( NoEmptySeqAsCollationParam ) ), | 81 | ERROR_PARAMS(ZED(NoEmptySeqAsCollationParam))); |
709 | 82 | ERROR_LOC( loc ) | 82 | } |
705 | 83 | ); | ||
710 | 84 | 83 | ||
711 | 85 | if (PlanIterator::consumeNext(temp, iter, planState)) | 84 | if (PlanIterator::consumeNext(temp, iter, planState)) |
717 | 86 | throw XQUERY_EXCEPTION( | 85 | { |
718 | 87 | err::XPTY0004, | 86 | RAISE_ERROR(err::XPTY0004, loc, |
719 | 88 | ERROR_PARAMS( ZED( NoSeqAsCollationParam ) ), | 87 | ERROR_PARAMS(ZED(NoSeqAsCollationParam))); |
720 | 89 | ERROR_LOC( loc ) | 88 | } |
716 | 90 | ); | ||
721 | 91 | 89 | ||
722 | 92 | return sctx->get_collator(lCollationItem->getStringValue().str(), loc); | 90 | return sctx->get_collator(lCollationItem->getStringValue().str(), loc); |
723 | 93 | } | 91 | } |
724 | @@ -147,11 +145,9 @@ | |||
725 | 147 | bool | 145 | bool |
726 | 148 | FnIndexOfIterator::nextImpl(store::Item_t& result, PlanState& planState) const | 146 | FnIndexOfIterator::nextImpl(store::Item_t& result, PlanState& planState) const |
727 | 149 | { | 147 | { |
731 | 150 | store::Item_t lSequenceItem; | 148 | store::Item_t seqItem; |
729 | 151 | store::Item_t lCollationItem; | ||
730 | 152 | xqtref_t lCollationItemType; | ||
732 | 153 | store::Item_t searchItem; | 149 | store::Item_t searchItem; |
734 | 154 | TypeManager* typemgr = theSctx->get_typemanager(); | 150 | TypeManager* tm = theSctx->get_typemanager(); |
735 | 155 | long timezone = 0; | 151 | long timezone = 0; |
736 | 156 | bool found; | 152 | bool found; |
737 | 157 | 153 | ||
738 | @@ -163,26 +159,39 @@ | |||
739 | 163 | RAISE_ERROR(err::FORG0006, loc, ERROR_PARAMS(ZED(EmptySeqNoSearchItem))); | 159 | RAISE_ERROR(err::FORG0006, loc, ERROR_PARAMS(ZED(EmptySeqNoSearchItem))); |
740 | 164 | } | 160 | } |
741 | 165 | 161 | ||
745 | 166 | if ( theChildren.size() == 3 ) | 162 | if (theChildren.size() == 3) |
746 | 167 | state->theCollator = getCollator(theSctx, loc, | 163 | { |
747 | 168 | planState, theChildren[2].getp()); | 164 | state->theCollator = |
748 | 165 | getCollator(theSctx, loc, planState, theChildren[2].getp()); | ||
749 | 166 | } | ||
750 | 169 | 167 | ||
752 | 170 | while ( consumeNext(lSequenceItem, theChildren[0].getp(), planState)) | 168 | while (consumeNext(seqItem, theChildren[0].getp(), planState)) |
753 | 171 | { | 169 | { |
754 | 172 | // inc the position in the sequence; do it at the beginning of the loop | 170 | // inc the position in the sequence; do it at the beginning of the loop |
755 | 173 | // because index-of starts with one | 171 | // because index-of starts with one |
756 | 174 | ++state->theCurrentPos; | 172 | ++state->theCurrentPos; |
757 | 175 | 173 | ||
758 | 176 | searchItem = state->theSearchItem; | ||
759 | 177 | |||
760 | 178 | try | 174 | try |
761 | 179 | { | 175 | { |
768 | 180 | found = CompareIterator::valueEqual(loc, | 176 | if (theFastComp == 1) |
769 | 181 | lSequenceItem, | 177 | { |
770 | 182 | searchItem, | 178 | found = seqItem->equals(state->theSearchItem, timezone, state->theCollator); |
771 | 183 | typemgr, | 179 | } |
772 | 184 | timezone, | 180 | else if (theFastComp == 2) |
773 | 185 | state->theCollator); | 181 | { |
774 | 182 | found = state->theSearchItem->equals(seqItem, timezone, state->theCollator); | ||
775 | 183 | } | ||
776 | 184 | else | ||
777 | 185 | { | ||
778 | 186 | searchItem = state->theSearchItem; | ||
779 | 187 | |||
780 | 188 | found = CompareIterator::valueEqual(loc, | ||
781 | 189 | seqItem, | ||
782 | 190 | searchItem, | ||
783 | 191 | tm, | ||
784 | 192 | timezone, | ||
785 | 193 | state->theCollator); | ||
786 | 194 | } | ||
787 | 186 | } | 195 | } |
788 | 187 | catch (ZorbaException const& e) | 196 | catch (ZorbaException const& e) |
789 | 188 | { | 197 | { |
790 | @@ -203,6 +212,7 @@ | |||
791 | 203 | STACK_END(state); | 212 | STACK_END(state); |
792 | 204 | } | 213 | } |
793 | 205 | 214 | ||
794 | 215 | |||
795 | 206 | /******************************************************************************* | 216 | /******************************************************************************* |
796 | 207 | 15.1.4 fn:empty | 217 | 15.1.4 fn:empty |
797 | 208 | ********************************************************************************/ | 218 | ********************************************************************************/ |
798 | 209 | 219 | ||
799 | === modified file 'src/runtime/spec/sequences/sequences.xml' | |||
800 | --- src/runtime/spec/sequences/sequences.xml 2013-02-07 17:24:36 +0000 | |||
801 | +++ src/runtime/spec/sequences/sequences.xml 2013-03-20 02:47:23 +0000 | |||
802 | @@ -102,7 +102,7 @@ | |||
803 | 102 | The result sequence is in ascending numeric order. | 102 | The result sequence is in ascending numeric order. |
804 | 103 | </zorba:description> | 103 | </zorba:description> |
805 | 104 | 104 | ||
807 | 105 | <zorba:function > | 105 | <zorba:function generateCodegen="false"> |
808 | 106 | 106 | ||
809 | 107 | <zorba:signature localname="index-of" prefix="fn"> | 107 | <zorba:signature localname="index-of" prefix="fn"> |
810 | 108 | <zorba:param>xs:anyAtomicType*</zorba:param> | 108 | <zorba:param>xs:anyAtomicType*</zorba:param> |
811 | @@ -124,12 +124,18 @@ | |||
812 | 124 | brief="the current position in the sequence"/> | 124 | brief="the current position in the sequence"/> |
813 | 125 | 125 | ||
814 | 126 | <zorba:member type="store::Item_t" name="theSearchItem" defaultValue="NULL" | 126 | <zorba:member type="store::Item_t" name="theSearchItem" defaultValue="NULL" |
816 | 127 | brief="the item to search for"/> | 127 | brief="the item to search for"/> |
817 | 128 | 128 | ||
818 | 129 | <zorba:member type="XQPCollator*" name="theCollator" defaultValue="0" | 129 | <zorba:member type="XQPCollator*" name="theCollator" defaultValue="0" |
820 | 130 | brief="the collator"/> | 130 | brief="the collator"/> |
821 | 131 | </zorba:state> | 131 | </zorba:state> |
822 | 132 | 132 | ||
823 | 133 | <zorba:constructor> | ||
824 | 134 | <zorba:parameter type="int" name="fastComp"/> | ||
825 | 135 | </zorba:constructor> | ||
826 | 136 | |||
827 | 137 | <zorba:member type="int" name="theFastComp"/> | ||
828 | 138 | |||
829 | 133 | </zorba:iterator> | 139 | </zorba:iterator> |
830 | 134 | 140 | ||
831 | 135 | <!-- | 141 | <!-- |
832 | 136 | 142 | ||
833 | === modified file 'test/rbkt/testdriver.cpp' | |||
834 | --- test/rbkt/testdriver.cpp 2013-03-16 00:58:28 +0000 | |||
835 | +++ test/rbkt/testdriver.cpp 2013-03-20 02:47:23 +0000 | |||
836 | @@ -325,7 +325,8 @@ | |||
837 | 325 | lQuery = engine->createQuery(&errHandler); | 325 | lQuery = engine->createQuery(&errHandler); |
838 | 326 | lQuery->setFileName(lQueryFile.get_path()); | 326 | lQuery->setFileName(lQueryFile.get_path()); |
839 | 327 | 327 | ||
841 | 328 | bool lJSONiqMode = lQueryFile.get_path().rfind(".jq") == lQueryFile.get_path().size() - 3; | 328 | bool lJSONiqMode = |
842 | 329 | (lQueryFile.get_path().rfind(".jq") == lQueryFile.get_path().size() - 3); | ||
843 | 329 | 330 | ||
844 | 330 | lQuery->compile(lQueryString.c_str(), lContext, getCompilerHints(lJSONiqMode)); | 331 | lQuery->compile(lQueryString.c_str(), lContext, getCompilerHints(lJSONiqMode)); |
845 | 331 | 332 |
Attempt to merge into lp:zorba failed due to conflicts:
text conflict in ChangeLog