santiagopg    2002/06/24 10:02:21

  Modified:    java/src/org/apache/xalan/xsltc/compiler Step.java
  Log:
  Fix for Bugzilla 8551.
  
  Revision  Changes    Path
  1.34      +31 -29    
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Step.java
  
  Index: Step.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Step.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- Step.java 14 May 2002 22:12:00 -0000      1.33
  +++ Step.java 24 Jun 2002 17:02:21 -0000      1.34
  @@ -74,23 +74,28 @@
   
   final class Step extends RelativeLocationPath {
   
  -    // This step's axis as defined in class Axis.
  +    /**
  +     * This step's axis as defined in class Axis.
  +     */
       private int _axis;
   
  -    // A vector of predicates (filters) defined on this step - may be null
  +    /**
  +     * A vector of predicates (filters) defined on this step - may be null
  +     */
       private Vector _predicates;
   
  -    // Some simple predicates can be handled by this class (and not by the
  -    // Predicate class) and will be removed from the above vector as they are
  -    // handled. We use this boolean to remember if we did have any 
predicates.
  +    /**
  +     * Some simple predicates can be handled by this class (and not by the
  +     * Predicate class) and will be removed from the above vector as they are
  +     * handled. We use this boolean to remember if we did have any 
predicates.
  +     */
       private boolean _hadPredicates = false;
   
  -    // Type of the node test.
  -    private int _nodeType;
  -
       /**
  -     * Constructor
  +     * Type of the node test.
        */
  +    private int _nodeType;
  +
       public Step(int axis, int nodeType, Vector predicates) {
        _axis = axis;
        _nodeType = nodeType;
  @@ -156,16 +161,12 @@
        * an element like <xsl:for-each> or <xsl:apply-templates>.
        */
       private boolean hasParentPattern() {
  -     SyntaxTreeNode parent = getParent();
  -     if ((parent instanceof ParentPattern) ||
  -         (parent instanceof ParentLocationPath) ||
  -         (parent instanceof UnionPathExpr) ||
  -         (parent instanceof FilterParentPath))
  -         return(true);
  -     else
  -         return(false);
  +     final SyntaxTreeNode parent = getParent();
  +     return (parent instanceof ParentPattern ||
  +             parent instanceof ParentLocationPath ||
  +             parent instanceof UnionPathExpr ||
  +             parent instanceof FilterParentPath);
       }
  -
       
       /**
        * Returns 'true' if this step has any predicates
  @@ -214,14 +215,7 @@
   
        // Special case for '.' 
        if (isAbbreviatedDot()) {
  -         if (hasParentPattern())
  -             _type = Type.NodeSet;
  -         else
  -             _type = Type.Node;
  -     }
  -     // Special case for '..'
  -     else if (isAbbreviatedDDot()) {
  -         _type = Type.NodeSet;
  +         _type =  (hasParentPattern()) ? Type.NodeSet : Type.Node;
        }
        else {
            _type = Type.NodeSet;
  @@ -256,7 +250,6 @@
            // the nodes for us.
            if (hasParentPattern()) return false;
            if (hasPredicates()) return false;
  -         if (_hadPredicates) return false;
            
            // Check if this step occured under an <xsl:apply-templates> element
            SyntaxTreeNode parent = this;
  @@ -385,7 +378,11 @@
                il.append(new PUSH(cpg, _axis));
                il.append(new PUSH(cpg, _nodeType));
                il.append(new INVOKEINTERFACE(ty, 3));
  -             orderIterator(classGen, methodGen);
  +
  +             // If needed, create a reverse iterator
  +             if (!_hadPredicates) {
  +                 orderIterator(classGen, methodGen);
  +             }
                break;
            }
        }
  @@ -490,6 +487,11 @@
                    il.append(new CHECKCAST(cpg.addClass(className)));
                }
                il.append(new INVOKESPECIAL(idx));
  +
  +             // If needed, create a reverse iterator after compiling preds
  +             if (_predicates.size() == 0) {
  +                 orderIterator(classGen, methodGen);
  +             }
            }
        }
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to