zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #05396
[Merge] lp:~zorba-coders/zorba/concat_operator into lp:zorba
William Candillon has proposed merging lp:~zorba-coders/zorba/concat_operator into lp:zorba.
Requested reviews:
Markos Zaharioudakis (markos-za)
Matthias Brantner (matthias-brantner)
Related bugs:
Bug #937120 in Zorba: "Improve error message for || "
https://bugs.launchpad.net/zorba/+bug/937120
Bug #942011 in Zorba: "translator should flatten a tree of StringConcatExprs"
https://bugs.launchpad.net/zorba/+bug/942011
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/concat_operator/+merge/94869
Optimize iterator generation for the concat operator.
--
https://code.launchpad.net/~zorba-coders/zorba/concat_operator/+merge/94869
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp 2012-02-19 19:43:28 +0000
+++ src/compiler/translator/translator.cpp 2012-02-27 22:07:44 +0000
@@ -9401,7 +9401,26 @@
expr_t right = pop_nodestack();
expr_t left = pop_nodestack();
concat_args.push_back(left);
- concat_args.push_back(right);
+
+ //If the right leaf is the concat expr,
+ //we add directly its leafs to the new concat expr.
+ fo_expr* lFoExpr = dynamic_cast<fo_expr*>(right.getp());
+ bool rightLeafIsConcatExpr = false;
+ if(lFoExpr != NULL) {
+ if(lFoExpr->get_func() == GET_BUILTIN_FUNCTION(FN_CONCAT_N)) {
+ rightLeafIsConcatExpr = true;
+ csize i = 0;
+ for(i = 0; i < lFoExpr->num_args(); ++i)
+ {
+ concat_args.push_back(lFoExpr->get_arg(i));
+ }
+ }
+ }
+
+ if(!rightLeafIsConcatExpr){
+ concat_args.push_back(right);
+ }
+
rchandle<expr> concat = new fo_expr(theRootSctx, loc, GET_BUILTIN_FUNCTION(FN_CONCAT_N), concat_args);
push_nodestack(concat);
}
Follow ups