Fix for bug 1511. Predicates on the format ((a or b) and c) are not
handled correctly. I added a small piece of code to direct the true-list
of the OR expression to the beginning of the AND test.
PR: Bugzilla 1511
Obtained from: n/a
Submitted by: morten@xml.apache.org
Reviewed by: morten@xml.apache.org
diff --git a/src/org/apache/xalan/xsltc/compiler/LogicalExpr.java b/src/org/apache/xalan/xsltc/compiler/LogicalExpr.java
index b882cb9..cc7c6e7 100644
--- a/src/org/apache/xalan/xsltc/compiler/LogicalExpr.java
+++ b/src/org/apache/xalan/xsltc/compiler/LogicalExpr.java
@@ -58,6 +58,7 @@
*
* @author Jacek Ambroziak
* @author Santiago Pericas-Geertsen
+ * @author Morten Jorgensen
*
*/
@@ -128,17 +129,30 @@
public void translateDesynthesized(ClassGenerator classGen,
MethodGenerator methodGen) {
final InstructionList il = methodGen.getInstructionList();
+ final SyntaxTreeNode parent = getParent();
if (_op == AND) {
_left.translateDesynthesized(classGen, methodGen);
if ((_left instanceof FunctionCall) &&
(!(_left instanceof ContainsCall)))
_falseList.add(il.append(new IFEQ(null)));
+ InstructionHandle middle = il.append(NOP);
_right.translateDesynthesized(classGen, methodGen);
if ((_right instanceof FunctionCall) &&
(!(_right instanceof ContainsCall)))
_falseList.add(il.append(new IFEQ(null)));
- _trueList.append(_right._trueList.append(_left._trueList));
_falseList.append(_right._falseList.append(_left._falseList));
+
+ // Special case for ((a OR b) and c)
+ if (_left instanceof LogicalExpr) {
+ LogicalExpr left = (LogicalExpr)_left;
+ if (left.getOp() == OR) {
+ left.backPatchTrueList(middle);
+ _trueList.append(_right._trueList);
+ return;
+ }
+ }
+
+ _trueList.append(_right._trueList.append(_left._trueList));
}
else { // _op == OR
_left.translateDesynthesized(classGen, methodGen);