Merge lp:~zorba-coders/zorba/hof-next into lp:zorba
- hof-next
- Merge into trunk
Proposed by
Markos Zaharioudakis
Status: | Merged |
---|---|
Approved by: | Markos Zaharioudakis |
Approved revision: | 11325 |
Merged at revision: | 11324 |
Proposed branch: | lp:~zorba-coders/zorba/hof-next |
Merge into: | lp:zorba |
Diff against target: |
427 lines (+46/-96) 12 files modified
src/compiler/codegen/plan_visitor.cpp (+5/-18) src/compiler/expression/expr_clone.cpp (+0/-1) src/compiler/expression/expr_manager.cpp (+1/-2) src/compiler/expression/expr_manager.h (+0/-1) src/compiler/expression/expr_type.cpp (+4/-1) src/compiler/expression/function_item_expr.cpp (+11/-12) src/compiler/expression/function_item_expr.h (+1/-2) src/compiler/translator/translator.cpp (+6/-47) src/runtime/core/fncall_iterator.cpp (+10/-5) src/runtime/core/fncall_iterator.h (+6/-6) src/runtime/hof/function_item.h (+1/-1) src/zorbaserialization/serialize_zorba_types.cpp (+1/-0) |
To merge this branch: | bzr merge lp:~zorba-coders/zorba/hof-next |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Markos Zaharioudakis | Approve | ||
Review via email: mp+155684@code.launchpad.net |
Commit message
some more hof cleanup
Description of the change
some more hof cleanup
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 hof-next-
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/codegen/plan_visitor.cpp' |
2 | --- src/compiler/codegen/plan_visitor.cpp 2013-03-27 07:55:14 +0000 |
3 | +++ src/compiler/codegen/plan_visitor.cpp 2013-03-27 09:33:25 +0000 |
4 | @@ -472,9 +472,6 @@ |
5 | fnInfo->theCCB = theCCB; |
6 | fnInfo->theMustDeleteCCB = false; |
7 | fnInfo->theLoc = qloc; |
8 | - fnInfo->theFunction = v.get_function(); |
9 | - fnInfo->theQName = v.get_qname(); |
10 | - fnInfo->theArity = v.get_arity(); |
11 | |
12 | if (v.is_inline()) |
13 | { |
14 | @@ -484,7 +481,8 @@ |
15 | fnInfo->theScopedVarsIterators.push_back(pop_itstack()); |
16 | } |
17 | |
18 | - std::reverse(fnInfo->theScopedVarsIterators.begin(), fnInfo->theScopedVarsIterators.end()); |
19 | + std::reverse(fnInfo->theScopedVarsIterators.begin(), |
20 | + fnInfo->theScopedVarsIterators.end()); |
21 | } |
22 | |
23 | |
24 | @@ -494,30 +492,22 @@ |
25 | csize numOuterVars = fnInfo->theScopedVarsNames.size(); |
26 | for (csize i = 0; i < numOuterVars; ++i) |
27 | { |
28 | - var_expr* ve = theCCB->theEM->create_var_expr(fnInfo->theClosureSctx, |
29 | - NULL, |
30 | - qloc, |
31 | - var_expr::hof_var, |
32 | - fnInfo->theScopedVarsNames[i].getp()); |
33 | - |
34 | if (!fnInfo->theIsGlobalVar[i]) |
35 | { |
36 | ++curChild; |
37 | |
38 | - if (fnInfo->theSubstVarsValues[i] != NULL |
39 | - && |
40 | + if (fnInfo->theSubstVarsValues[i] != NULL && |
41 | fnInfo->theSubstVarsValues[i]->get_unique_id() == 0) |
42 | { |
43 | fnInfo->theSubstVarsValues[i]->set_var_info(NULL); |
44 | fnInfo->theSubstVarsValues[i]->set_unique_id(theNextDynamicVarId++); |
45 | } |
46 | |
47 | - ve->set_unique_id(fnInfo->theSubstVarsValues[i]->get_unique_id()); |
48 | fnInfo->theVarId[i] = fnInfo->theSubstVarsValues[i]->get_unique_id(); |
49 | } |
50 | else |
51 | { |
52 | - static_context* outerSctx = fnInfo->theClosureSctx->get_parent(); |
53 | + static_context* outerSctx = fnInfo->theClosureSctx; |
54 | |
55 | VarInfo* outerGlobalVar = outerSctx->lookup_var(fnInfo->theScopedVarsNames[i]); |
56 | |
57 | @@ -536,15 +526,12 @@ |
58 | } |
59 | } |
60 | |
61 | - if (fnInfo->theSubstVarsValues[i] != NULL |
62 | - && |
63 | + if (fnInfo->theSubstVarsValues[i] != NULL && |
64 | fnInfo->theSubstVarsValues[i]->get_unique_id() == 0) |
65 | { |
66 | fnInfo->theSubstVarsValues[i]->set_unique_id(outerGlobalVarId); |
67 | } |
68 | |
69 | - ve->set_unique_id(outerGlobalVarId); |
70 | - |
71 | fnInfo->theVarId[i] = outerGlobalVarId; |
72 | } |
73 | } // for |
74 | |
75 | === modified file 'src/compiler/expression/expr_clone.cpp' |
76 | --- src/compiler/expression/expr_clone.cpp 2013-03-26 21:26:20 +0000 |
77 | +++ src/compiler/expression/expr_clone.cpp 2013-03-27 09:33:25 +0000 |
78 | @@ -387,7 +387,6 @@ |
79 | udf, |
80 | get_loc(), |
81 | e->theFunctionItemInfo->theFunction, |
82 | - e->theFunctionItemInfo->theFunction->getName(), |
83 | e->theFunctionItemInfo->theArity, |
84 | e->is_inline(), |
85 | e->needs_context_item(), |
86 | |
87 | === modified file 'src/compiler/expression/expr_manager.cpp' |
88 | --- src/compiler/expression/expr_manager.cpp 2013-03-23 15:20:54 +0000 |
89 | +++ src/compiler/expression/expr_manager.cpp 2013-03-27 09:33:25 +0000 |
90 | @@ -813,14 +813,13 @@ |
91 | user_function* udf, |
92 | const QueryLoc& loc, |
93 | function* f, |
94 | - store::Item* qname, |
95 | uint32_t arity, |
96 | bool isInline, |
97 | bool needsContextItem, |
98 | bool isCoercion) |
99 | { |
100 | CREATE_AND_RETURN_EXPR(function_item_expr, sctx, udf, loc, |
101 | - f, qname, arity, isInline, needsContextItem, isCoercion); |
102 | + f, arity, isInline, needsContextItem, isCoercion); |
103 | } |
104 | |
105 | |
106 | |
107 | === modified file 'src/compiler/expression/expr_manager.h' |
108 | --- src/compiler/expression/expr_manager.h 2013-03-23 15:20:54 +0000 |
109 | +++ src/compiler/expression/expr_manager.h 2013-03-27 09:33:25 +0000 |
110 | @@ -493,7 +493,6 @@ |
111 | user_function* udf, |
112 | const QueryLoc& loc, |
113 | function* f, |
114 | - store::Item* qname, |
115 | uint32_t arity, |
116 | bool isInline, |
117 | bool needsContextItem, |
118 | |
119 | === modified file 'src/compiler/expression/expr_type.cpp' |
120 | --- src/compiler/expression/expr_type.cpp 2013-03-16 08:48:16 +0000 |
121 | +++ src/compiler/expression/expr_type.cpp 2013-03-27 09:33:25 +0000 |
122 | @@ -653,12 +653,15 @@ |
123 | case function_item_expr_kind: |
124 | { |
125 | theType = rtm.ANY_FUNCTION_TYPE_ONE; |
126 | + |
127 | function_item_expr* fiExpr = static_cast<function_item_expr*>(this); |
128 | + |
129 | if (fiExpr->get_function() != NULL) |
130 | { |
131 | const xqtref_t& retType = fiExpr->get_function()->getSignature().returnType(); |
132 | std::vector<xqtref_t> paramTypes; |
133 | - for (csize i=0; i<fiExpr->get_function()->getSignature().paramCount(); i++ ) |
134 | + |
135 | + for (csize i = 0; i < fiExpr->get_function()->getSignature().paramCount(); ++i) |
136 | paramTypes.push_back(fiExpr->get_function()->getSignature()[i]); |
137 | |
138 | theType = new FunctionXQType(&rtm, paramTypes, retType, TypeConstants::QUANT_ONE); |
139 | |
140 | === modified file 'src/compiler/expression/function_item_expr.cpp' |
141 | --- src/compiler/expression/function_item_expr.cpp 2013-03-26 21:26:20 +0000 |
142 | +++ src/compiler/expression/function_item_expr.cpp 2013-03-27 09:33:25 +0000 |
143 | @@ -90,8 +90,7 @@ |
144 | user_function* udf, |
145 | const QueryLoc& loc, |
146 | function* f, |
147 | - store::Item* qname, |
148 | - uint32_t arity, |
149 | + csize arity, |
150 | bool isInline, |
151 | bool needsContextItem, |
152 | bool isCoercion) |
153 | @@ -100,7 +99,7 @@ |
154 | theFunctionItemInfo(new FunctionItemInfo(sctx, |
155 | loc, |
156 | f, |
157 | - qname, |
158 | + f->getName(), |
159 | arity, |
160 | isInline, |
161 | needsContextItem, |
162 | @@ -130,7 +129,7 @@ |
163 | needsContextItem, |
164 | isCoercion)) |
165 | { |
166 | - theScriptingKind = SIMPLE_EXPR; |
167 | + compute_scripting_kind(); |
168 | } |
169 | |
170 | |
171 | @@ -139,6 +138,13 @@ |
172 | } |
173 | |
174 | |
175 | +void function_item_expr::compute_scripting_kind() |
176 | +{ |
177 | + // ???? TODO |
178 | + theScriptingKind = SIMPLE_EXPR; |
179 | +} |
180 | + |
181 | + |
182 | void function_item_expr::add_variable( |
183 | expr* var, |
184 | var_expr* substVar, |
185 | @@ -158,13 +164,6 @@ |
186 | } |
187 | |
188 | |
189 | -void function_item_expr::compute_scripting_kind() |
190 | -{ |
191 | - // ???? TODO |
192 | - theScriptingKind = SIMPLE_EXPR; |
193 | -} |
194 | - |
195 | - |
196 | store::Item_t function_item_expr::create_inline_fname(const QueryLoc& loc) |
197 | { |
198 | store::Item_t name; |
199 | @@ -177,7 +176,7 @@ |
200 | } |
201 | |
202 | |
203 | -DEF_EXPR_ACCEPT (function_item_expr); |
204 | +DEF_EXPR_ACCEPT(function_item_expr); |
205 | |
206 | |
207 | }//end of namespace |
208 | |
209 | === modified file 'src/compiler/expression/function_item_expr.h' |
210 | --- src/compiler/expression/function_item_expr.h 2013-03-26 23:32:03 +0000 |
211 | +++ src/compiler/expression/function_item_expr.h 2013-03-27 09:33:25 +0000 |
212 | @@ -138,8 +138,7 @@ |
213 | user_function* udf, |
214 | const QueryLoc& loc, |
215 | function* f, |
216 | - store::Item* aQName, |
217 | - uint32_t aArity, |
218 | + csize arity, |
219 | bool isInline, |
220 | bool needsContextItem, |
221 | bool isCoercion); |
222 | |
223 | === modified file 'src/compiler/translator/translator.cpp' |
224 | --- src/compiler/translator/translator.cpp 2013-03-27 05:06:29 +0000 |
225 | +++ src/compiler/translator/translator.cpp 2013-03-27 09:33:25 +0000 |
226 | @@ -1568,8 +1568,6 @@ |
227 | |
228 | // bind the function item variable in the inner flwor |
229 | flwor_expr* inner_flwor = CREATE(flwor)(theRootSctx, theUDF, loc, false); |
230 | - var_expr* inner_arg_var = create_var(loc, fnItem_var->get_name(), var_expr::let_var); |
231 | - inner_arg_var->set_param_pos(inner_flwor->num_clauses()); |
232 | |
233 | // Handle parameters. For each parameter, a let binding is added to the inner flwor. |
234 | std::vector<expr*> arguments; // Arguments to the dynamic function call |
235 | @@ -11934,7 +11932,6 @@ |
236 | |
237 | expr* fiExpr = CREATE(function_item)(theRootSctx, theUDF, loc, |
238 | f, |
239 | - f->getName(), |
240 | arity, |
241 | false, // not inline |
242 | needs_context_item, |
243 | @@ -11964,39 +11961,6 @@ |
244 | |
245 | push_nodestack(fiExpr); |
246 | |
247 | - // Translate the return tyoe |
248 | - xqtref_t returnType = theRTM.ITEM_TYPE_STAR; |
249 | - if (v.getReturnType() != 0) |
250 | - { |
251 | - v.getReturnType()->accept(*this); |
252 | - returnType = pop_tstack(); |
253 | - } |
254 | - |
255 | - // Translate the type declarations for the function params |
256 | - rchandle<ParamList> params = v.getParamList(); |
257 | - std::vector<xqtref_t> paramTypes; |
258 | - |
259 | - if (params != 0) |
260 | - { |
261 | - std::vector<rchandle<Param> >::const_iterator lIt = params->begin(); |
262 | - for(; lIt != params->end(); ++lIt) |
263 | - { |
264 | - const Param* param = lIt->getp(); |
265 | - const SequenceType* paramType = param->get_typedecl(); |
266 | - if (paramType == 0) |
267 | - { |
268 | - paramTypes.push_back(theRTM.ITEM_TYPE_STAR); |
269 | - } |
270 | - else |
271 | - { |
272 | - paramType->accept(*this); |
273 | - paramTypes.push_back(pop_tstack()); |
274 | - } |
275 | - } |
276 | - } |
277 | - |
278 | - flwor_expr* flwor = NULL; |
279 | - |
280 | // Handle function parameters. Translation of the params, if any, results to |
281 | // a flwor expr with one let binding for each function parameter: |
282 | // |
283 | @@ -12005,6 +11969,8 @@ |
284 | // let $xN as TN := _xN |
285 | // |
286 | // where each _xi is an arg var. |
287 | + rchandle<ParamList> params = v.getParamList(); |
288 | + flwor_expr* flwor = NULL; |
289 | if (params) |
290 | { |
291 | params->accept(*this); |
292 | @@ -12015,8 +11981,7 @@ |
293 | flwor = CREATE(flwor)(theRootSctx, theUDF, loc, false); |
294 | } |
295 | |
296 | - // Handle inscope variables. For each inscope var, a let binding is added to |
297 | - // the flwor. |
298 | + // Handle inscope variables. |
299 | std::vector<VarInfo*>::iterator ite = scopedVars.begin(); |
300 | |
301 | for(; ite != scopedVars.end(); ++ite) |
302 | @@ -12045,16 +12010,14 @@ |
303 | else |
304 | throw; |
305 | } |
306 | + |
307 | + fiExpr->add_variable(varExpr, subst_var, varExpr->get_name(), 0); |
308 | } |
309 | else |
310 | { |
311 | subst_var = varExpr; |
312 | + fiExpr->add_variable(NULL, subst_var, varExpr->get_name(), 1); |
313 | } |
314 | - |
315 | - if (kind == var_expr::prolog_var) |
316 | - fiExpr->add_variable(NULL, subst_var, varExpr->get_name(), 1 /*var is global if it's a prolog var*/); |
317 | - else |
318 | - fiExpr->add_variable(varExpr, subst_var, varExpr->get_name(), 0); |
319 | } |
320 | |
321 | if (flwor->num_clauses() > 0) |
322 | @@ -12203,10 +12166,6 @@ |
323 | if (theCCB->theConfig.translate_cb != NULL && theCCB->theConfig.optimize_cb == NULL) |
324 | theCCB->theConfig.translate_cb(udf->getBody(), |
325 | udf->getName()->getStringValue().c_str()); |
326 | - |
327 | - if (theCCB->theConfig.optimize_cb != NULL) |
328 | - theCCB->theConfig.optimize_cb(udf->getBody(), |
329 | - udf->getName()->getStringValue().c_str()); |
330 | } |
331 | |
332 | /******************************************************************************* |
333 | |
334 | === modified file 'src/runtime/core/fncall_iterator.cpp' |
335 | --- src/runtime/core/fncall_iterator.cpp 2013-03-17 13:55:28 +0000 |
336 | +++ src/runtime/core/fncall_iterator.cpp 2013-03-27 09:33:25 +0000 |
337 | @@ -122,25 +122,30 @@ |
338 | /******************************************************************************* |
339 | Called by the openImpl method of UDFunctionCallIterator. |
340 | ********************************************************************************/ |
341 | -void UDFunctionCallIteratorState::open(PlanState& planState, user_function* udf, bool theIsDynamic, store::ItemHandle<FunctionItem>& theFunctionItem) |
342 | +void UDFunctionCallIteratorState::open( |
343 | + PlanState& planState, |
344 | + user_function* udf, |
345 | + bool theIsDynamic, |
346 | + store::ItemHandle<FunctionItem>& theFunctionItem) |
347 | { |
348 | thePlan = udf->getPlan(thePlanStateSize).getp(); |
349 | |
350 | thePlanStateSize = thePlan->getStateSizeOfSubtree(); |
351 | |
352 | - // Must allocate new dctx, as child of the "current" dctx, because the udf |
353 | - // may be a recursive udf with local block vars, all of which have the same |
354 | - // dynamic-context id, but they are distinct vars. |
355 | + // Must allocate new dctx because the udf may be a recursive udf with local |
356 | + // block vars, all of which have the same dynamic-context id, but they are |
357 | + // distinct vars. |
358 | |
359 | if (theIsDynamic) |
360 | { |
361 | if (theFunctionItem->getDctx() == NULL) |
362 | theFunctionItem->setDctx(new dynamic_context(planState.theGlobalDynCtx)); |
363 | + |
364 | theLocalDCtx = new dynamic_context(theFunctionItem->getDctx()); |
365 | } |
366 | else |
367 | { |
368 | - theLocalDCtx = new dynamic_context(planState.theGlobalDynCtx); |
369 | + theLocalDCtx = new dynamic_context(planState.theGlobalDynCtx); |
370 | } |
371 | |
372 | thePlanState = new PlanState(theIsDynamic ? theFunctionItem->getDctx() : planState.theGlobalDynCtx, |
373 | |
374 | === modified file 'src/runtime/core/fncall_iterator.h' |
375 | --- src/runtime/core/fncall_iterator.h 2013-03-26 23:32:03 +0000 |
376 | +++ src/runtime/core/fncall_iterator.h 2013-03-27 09:33:25 +0000 |
377 | @@ -134,8 +134,8 @@ |
378 | typedef std::vector<LetVarIter_t> ArgVarRefs; |
379 | |
380 | protected: |
381 | - user_function * theUDF; |
382 | - bool theIsDynamic; |
383 | + user_function * theUDF; |
384 | + bool theIsDynamic; |
385 | store::ItemHandle<FunctionItem> theFunctionItem; |
386 | |
387 | public: |
388 | @@ -149,10 +149,10 @@ |
389 | |
390 | public: |
391 | UDFunctionCallIterator( |
392 | - static_context* sctx, |
393 | - const QueryLoc& loc, |
394 | - std::vector<PlanIter_t>& args, |
395 | - const user_function* aUDF); |
396 | + static_context* sctx, |
397 | + const QueryLoc& loc, |
398 | + std::vector<PlanIter_t>& args, |
399 | + const user_function* aUDF); |
400 | |
401 | bool isUpdating() const; |
402 | |
403 | |
404 | === modified file 'src/runtime/hof/function_item.h' |
405 | --- src/runtime/hof/function_item.h 2013-03-27 07:55:14 +0000 |
406 | +++ src/runtime/hof/function_item.h 2013-03-27 09:33:25 +0000 |
407 | @@ -170,7 +170,7 @@ |
408 | class FunctionItem : public store::Item, public zorba::serialization::SerializeBaseClass |
409 | { |
410 | protected: |
411 | - FunctionItemInfo_t theFunctionItemInfo; |
412 | + FunctionItemInfo_t theFunctionItemInfo; |
413 | |
414 | unsigned int theArity; // The arity of the function |
415 | // item will decrease when a |
416 | |
417 | === modified file 'src/zorbaserialization/serialize_zorba_types.cpp' |
418 | --- src/zorbaserialization/serialize_zorba_types.cpp 2013-03-26 23:32:03 +0000 |
419 | +++ src/zorbaserialization/serialize_zorba_types.cpp 2013-03-27 09:33:25 +0000 |
420 | @@ -45,6 +45,7 @@ |
421 | #include "zorbatypes/decimal.h" |
422 | |
423 | #include "functions/function.h" |
424 | + |
425 | #include "runtime/hof/function_item.h" |
426 | |
427 | #include "context/static_context.h" |
Validation queue starting for merge proposal. zorbatest. lambda. nu:8080/ remotequeue/ hof-next- 2013-03- 27T09-35- 56.894Z/ log.html
Log at: http://