morten      01/11/29 03:33:10

  Modified:    java/src/org/apache/xalan/xsltc/compiler CastExpr.java
                        EqualityExpr.java Expression.java LastCall.java
                        Predicate.java VariableRefBase.java
               java/src/org/apache/xalan/xsltc/dom DOMImpl.java
                        StepIterator.java
  Log:
  A fix for resetting the source iterator of a node-value iterator.
  PR:           bugzilla 5152
  Obtained from:        n/a
  Submitted by: [EMAIL PROTECTED]
  Reviewed by:  [EMAIL PROTECTED]
  
  Revision  Changes    Path
  1.9       +5 -1      xml-xalan/java/src/org/apache/xalan/xsltc/compiler/CastExpr.java
  
  Index: CastExpr.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/CastExpr.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- CastExpr.java     2001/11/09 15:14:21     1.8
  +++ CastExpr.java     2001/11/29 11:33:09     1.9
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: CastExpr.java,v 1.8 2001/11/09 15:14:21 tmiller Exp $
  + * @(#)$Id: CastExpr.java,v 1.9 2001/11/29 11:33:09 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -177,6 +177,10 @@
        */
       public boolean hasPositionCall() {
        return(_left.hasPositionCall());
  +    }
  +
  +    public boolean hasLastCall() {
  +     return(_left.hasLastCall());
       }
   
       public String toString() {
  
  
  
  1.7       +7 -1      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/EqualityExpr.java
  
  Index: EqualityExpr.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/EqualityExpr.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- EqualityExpr.java 2001/11/06 13:42:04     1.6
  +++ EqualityExpr.java 2001/11/29 11:33:09     1.7
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: EqualityExpr.java,v 1.6 2001/11/06 13:42:04 morten Exp $
  + * @(#)$Id: EqualityExpr.java,v 1.7 2001/11/29 11:33:09 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -114,6 +114,12 @@
       public boolean hasPositionCall() {
        if (_left.hasPositionCall()) return true;
        if (_right.hasPositionCall()) return true;
  +     return false;
  +    }
  +
  +    public boolean hasLastCall() {
  +     if (_left.hasLastCall()) return true;
  +     if (_right.hasLastCall()) return true;
        return false;
       }
   
  
  
  
  1.9       +5 -1      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Expression.java
  
  Index: Expression.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Expression.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Expression.java   2001/11/06 13:42:04     1.8
  +++ Expression.java   2001/11/29 11:33:09     1.9
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Expression.java,v 1.8 2001/11/06 13:42:04 morten Exp $
  + * @(#)$Id: Expression.java,v 1.9 2001/11/29 11:33:09 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -104,6 +104,10 @@
   
       public boolean hasPositionCall() {
        return true;
  +    }
  +
  +    public boolean hasLastCall() {
  +     return false;
       }
                
       /**
  
  
  
  1.6       +5 -1      xml-xalan/java/src/org/apache/xalan/xsltc/compiler/LastCall.java
  
  Index: LastCall.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/LastCall.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- LastCall.java     2001/11/06 13:42:04     1.5
  +++ LastCall.java     2001/11/29 11:33:09     1.6
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: LastCall.java,v 1.5 2001/11/06 13:42:04 morten Exp $
  + * @(#)$Id: LastCall.java,v 1.6 2001/11/29 11:33:09 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -83,6 +83,10 @@
       }
   
       public boolean hasPositionCall() {
  +     return true;
  +    }
  +
  +    public boolean hasLastCall() {
        return true;
       }
   
  
  
  
  1.19      +2 -2      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Predicate.java
  
  Index: Predicate.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Predicate.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- Predicate.java    2001/11/27 15:20:55     1.18
  +++ Predicate.java    2001/11/29 11:33:09     1.19
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Predicate.java,v 1.18 2001/11/27 15:20:55 morten Exp $
  + * @(#)$Id: Predicate.java,v 1.19 2001/11/29 11:33:09 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -207,7 +207,7 @@
   
                    if (filter.getExpr() instanceof KeyCall)
                        _canOptimize = false;
  -                 else if (_exp.hasPositionCall())
  +                 else if (_exp.hasPositionCall() && _exp.hasLastCall())
                        _canOptimize = false;
                    if (_canOptimize)
                        _nthPositionFilter = true;
  
  
  
  1.7       +2 -5      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/VariableRefBase.java
  
  Index: VariableRefBase.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/VariableRefBase.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- VariableRefBase.java      2001/11/27 15:20:55     1.6
  +++ VariableRefBase.java      2001/11/29 11:33:09     1.7
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: VariableRefBase.java,v 1.6 2001/11/27 15:20:55 morten Exp $
  + * @(#)$Id: VariableRefBase.java,v 1.7 2001/11/29 11:33:09 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -101,11 +101,8 @@
        */
       public VariableBase findParentVariable() {
        SyntaxTreeNode node = this;
  -     while ((node != null) && (!(node instanceof VariableBase))) {
  -         if (node instanceof Predicate)
  -             ((Predicate)node).dontOptimize();
  +     while ((node != null) && (!(node instanceof VariableBase)))
            node = node.getParent();
  -     }
        return (VariableBase)node;
       }
   
  
  
  
  1.64      +9 -2      xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMImpl.java
  
  Index: DOMImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMImpl.java,v
  retrieving revision 1.63
  retrieving revision 1.64
  diff -u -r1.63 -r1.64
  --- DOMImpl.java      2001/11/27 15:20:55     1.63
  +++ DOMImpl.java      2001/11/29 11:33:09     1.64
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: DOMImpl.java,v 1.63 2001/11/27 15:20:55 morten Exp $
  + * @(#)$Id: DOMImpl.java,v 1.64 2001/11/29 11:33:09 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -1741,8 +1741,15 @@
        public NodeIterator cloneIterator() {
            try {
                NodeValueIterator clone = (NodeValueIterator)super.clone();
  -             clone._isRestartable = false;
                clone._source = _source.cloneIterator();
  +             if (_source instanceof StepIterator) {
  +                 StepIterator source = (StepIterator)clone._source;
  +                 source.setRestartable();
  +             }
  +             else if (_source instanceof NodeIteratorBase) {
  +                 NodeIteratorBase source = (NodeIteratorBase)clone._source;
  +                 source._isRestartable = true;
  +             }
                clone._value = _value;
                clone._op = _op;
                return clone.reset();
  
  
  
  1.10      +16 -1     xml-xalan/java/src/org/apache/xalan/xsltc/dom/StepIterator.java
  
  Index: StepIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/StepIterator.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- StepIterator.java 2001/11/27 15:20:55     1.9
  +++ StepIterator.java 2001/11/29 11:33:09     1.10
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: StepIterator.java,v 1.9 2001/11/27 15:20:55 morten Exp $
  + * @(#)$Id: StepIterator.java,v 1.10 2001/11/29 11:33:09 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -72,12 +72,25 @@
   
       protected NodeIterator _source;
       protected NodeIterator _iterator;
  +    private int _pos = -1;
   
       public StepIterator(NodeIterator source, NodeIterator iterator) {
        _source = source;
        _iterator = iterator;
       }
   
  +    protected void setRestartable() {
  +     _isRestartable = true;
  +     if (_source instanceof StepIterator) {
  +         ((StepIterator)_source).setRestartable();
  +     }
  +     else if (_source instanceof NodeIteratorBase) {
  +         ((NodeIteratorBase)_source)._isRestartable = true;
  +     }
  +     if (_iterator instanceof NodeIteratorBase)
  +         ((NodeIteratorBase)_iterator)._isRestartable = true;
  +    }
  +
       protected void setNotRestartable() {
        _isRestartable = false;
        if (_source instanceof StepIterator) {
  @@ -150,10 +163,12 @@
       public void setMark() {
        _source.setMark();
        _iterator.setMark();
  +     _pos = _position;
       }
   
       public void gotoMark() {
        _source.gotoMark();
        _iterator.gotoMark();
  +     _position = _pos;
       }
   }
  
  
  

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

Reply via email to