xalan-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mor...@apache.org
Subject cvs commit: xml-xalan/java/src/org/apache/xalan/xsltc/runtime AbstractTranslet.java
Date Tue, 27 Nov 2001 15:20:56 GMT
morten      01/11/27 07:20:56

  Modified:    java/src/org/apache/xalan/xsltc/compiler FilterExpr.java
                        Predicate.java VariableRefBase.java
               java/src/org/apache/xalan/xsltc/dom
                        CurrentNodeListIterator.java DOMImpl.java
                        FilteredStepIterator.java KeyIndex.java
                        MatchingIterator.java MultiDOM.java
                        NthIterator.java StepIterator.java
                        UnionIterator.java
               java/src/org/apache/xalan/xsltc/runtime
                        AbstractTranslet.java
  Log:
  A fix for trees of step iterators stored inside variables.
  Also some fixes for recently introduced regressions.
  PR:		n/a
  Obtained from:	n/a
  Submitted by:	morten@xml.apache.org
  Reviewed by:	morten@xml.apache.iorg
  
  Revision  Changes    Path
  1.5       +8 -1      xml-xalan/java/src/org/apache/xalan/xsltc/compiler/FilterExpr.java
  
  Index: FilterExpr.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/FilterExpr.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- FilterExpr.java	2001/08/27 09:07:19	1.4
  +++ FilterExpr.java	2001/11/27 15:20:55	1.5
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: FilterExpr.java,v 1.4 2001/08/27 09:07:19 morten Exp $
  + * @(#)$Id: FilterExpr.java,v 1.5 2001/11/27 15:20:55 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -79,6 +79,13 @@
   	_primary = primary;
   	_predicates = predicates;
   	primary.setParent(this);
  +    }
  +
  +    protected Expression getExpr() {
  +	if (_primary instanceof CastExpr)
  +	    return ((CastExpr)_primary).getExpr();
  +	else
  +	    return _primary;
       }
   
       public void setParser(Parser parser) {
  
  
  
  1.18      +15 -7     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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Predicate.java	2001/11/26 12:50:12	1.17
  +++ Predicate.java	2001/11/27 15:20:55	1.18
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Predicate.java,v 1.17 2001/11/26 12:50:12 morten Exp $
  + * @(#)$Id: Predicate.java,v 1.18 2001/11/27 15:20:55 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -198,12 +198,20 @@
   		if (_exp.typeCheck(stable) != Type.Boolean) {
   		    _exp = new CastExpr(_exp, Type.Boolean);
   		}
  -		if ((parent instanceof Pattern) ||
  -		    (parent instanceof VariableBase))
  -		    _nthPositionFilter = true;
  -		else
  -		    _nthPositionFilter = false;
  -		_nthPositionFilter = true;
  +
  +		if (parent instanceof Pattern) {
  + 		    _nthPositionFilter = true;
  +		}
  +		else if (parent instanceof FilterExpr) {
  +		    FilterExpr filter = (FilterExpr)parent;
  +
  +		    if (filter.getExpr() instanceof KeyCall)
  +			_canOptimize = false;
  +		    else if (_exp.hasPositionCall())
  +			_canOptimize = false;
  +		    if (_canOptimize)
  +			_nthPositionFilter = true;
  +		}
   		return _type = Type.Boolean;
   	    }
   	    // Use NthPositionIterator to handle [position()] or [a]
  
  
  
  1.6       +5 -2      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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- VariableRefBase.java	2001/10/29 11:47:25	1.5
  +++ VariableRefBase.java	2001/11/27 15:20:55	1.6
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: VariableRefBase.java,v 1.5 2001/10/29 11:47:25 morten Exp $
  + * @(#)$Id: VariableRefBase.java,v 1.6 2001/11/27 15:20:55 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -101,8 +101,11 @@
        */
       public VariableBase findParentVariable() {
   	SyntaxTreeNode node = this;
  -	while ((node != null) && (!(node instanceof VariableBase)))
  +	while ((node != null) && (!(node instanceof VariableBase))) {
  +	    if (node instanceof Predicate)
  +		((Predicate)node).dontOptimize();
   	    node = node.getParent();
  +	}
   	return (VariableBase)node;
       }
   
  
  
  
  1.4       +2 -2      xml-xalan/java/src/org/apache/xalan/xsltc/dom/CurrentNodeListIterator.java
  
  Index: CurrentNodeListIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/CurrentNodeListIterator.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- CurrentNodeListIterator.java	2001/11/05 18:47:51	1.3
  +++ CurrentNodeListIterator.java	2001/11/27 15:20:55	1.4
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: CurrentNodeListIterator.java,v 1.3 2001/11/05 18:47:51 morten Exp $
  + * @(#)$Id: CurrentNodeListIterator.java,v 1.4 2001/11/27 15:20:55 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -112,8 +112,8 @@
   	try {
   	    final CurrentNodeListIterator clone =
   		(CurrentNodeListIterator)super.clone();
  -	    clone._isRestartable = false;
   	    clone._nodes = (IntegerArray)_nodes.clone();
  +	    clone._isRestartable = false;
   	    return clone.reset();
   	}
   	catch (CloneNotSupportedException e) {
  
  
  
  1.63      +28 -4     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.62
  retrieving revision 1.63
  diff -u -r1.62 -r1.63
  --- DOMImpl.java	2001/11/27 08:40:28	1.62
  +++ DOMImpl.java	2001/11/27 15:20:55	1.63
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: DOMImpl.java,v 1.62 2001/11/27 08:40:28 morten Exp $
  + * @(#)$Id: DOMImpl.java,v 1.63 2001/11/27 15:20:55 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -720,7 +720,7 @@
        * for efficiency (both speed and size of translet).
        */
       private final class TypedChildrenIterator extends NodeIteratorBase {
  -	private final int _nodeType;
  +	private int _nodeType;
   	// node to consider next
   	private int _currentChild;
            
  @@ -738,6 +738,21 @@
   	    return this;
   	}
   
  +	public NodeIterator cloneIterator() {
  +	    try {
  +		final TypedChildrenIterator clone =
  +		    (TypedChildrenIterator)super.clone();
  +		clone._nodeType = _nodeType;
  +		clone._isRestartable = false;
  +		return clone.reset();
  +	    }
  +	    catch (CloneNotSupportedException e) {
  +		BasisLibrary.runTimeError(BasisLibrary.ITERATOR_CLONE_ERR,
  +					  e.toString());
  +		return null;
  +	    }
  +	}
  +
   	public NodeIterator reset() {
   	    if (hasChildren(_startNode))
   		_currentChild = _offsetOrChild[_startNode];
  @@ -977,6 +992,15 @@
   	    }
   	    return this;
   	}
  +
  +	public NodeIterator reset() {
  +	    int node = _startNode;
  +	    for (node = _lengthOrAttr[node];
  +		 node != NULL && _type[node] != _nodeType;
  +		 node = _nextSibling[node]);
  +	    _attribute = node;
  +	    return resetPosition();
  +	}
                     
   	public int next() {
   	    final int node = _attribute;
  @@ -1175,9 +1199,9 @@
            
   	public NodeIterator cloneIterator() {
   	    try {
  -		_isRestartable = false;
   		final PrecedingIterator clone = 
   		    (PrecedingIterator)super.clone();
  +		clone._isRestartable = false;
   		return clone.reset();
   	    }
   	    catch (CloneNotSupportedException e) {
  @@ -1335,9 +1359,9 @@
   	}
            
   	public NodeIterator cloneIterator() {
  -	    _isRestartable = false;         // must set to false for any clone
   	    try {
   		final AncestorIterator clone = (AncestorIterator)super.clone();
  +		clone._isRestartable = false; // must set to false for any clone
   		clone._startNode = _startNode;
   		return clone.reset();
   	    }
  
  
  
  1.4       +2 -2      xml-xalan/java/src/org/apache/xalan/xsltc/dom/FilteredStepIterator.java
  
  Index: FilteredStepIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/FilteredStepIterator.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FilteredStepIterator.java	2001/11/27 08:40:28	1.3
  +++ FilteredStepIterator.java	2001/11/27 15:20:55	1.4
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: FilteredStepIterator.java,v 1.3 2001/11/27 08:40:28 morten Exp $
  + * @(#)$Id: FilteredStepIterator.java,v 1.4 2001/11/27 15:20:55 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -79,13 +79,13 @@
       }
   
       public NodeIterator cloneIterator() {
  -	setNotRestartable();
   	try {
   	    final FilteredStepIterator clone =
   		(FilteredStepIterator)super.clone();
   	    clone._source = _source.cloneIterator();
   	    clone._iterator = _iterator.cloneIterator();
   	    clone._filter = _filter;
  +	    clone.setNotRestartable();
   	    return clone.reset();
   	}
   	catch (CloneNotSupportedException e) {
  
  
  
  1.6       +2 -1      xml-xalan/java/src/org/apache/xalan/xsltc/dom/KeyIndex.java
  
  Index: KeyIndex.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/KeyIndex.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- KeyIndex.java	2001/09/19 15:53:42	1.5
  +++ KeyIndex.java	2001/11/27 15:20:55	1.6
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: KeyIndex.java,v 1.5 2001/09/19 15:53:42 morten Exp $
  + * @(#)$Id: KeyIndex.java,v 1.6 2001/11/27 15:20:55 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -70,6 +70,7 @@
   import org.apache.xalan.xsltc.runtime.Hashtable;
   
   public class KeyIndex implements NodeIterator {
  +
       private Hashtable _index = new Hashtable();
       private BitArray  _nodes = null;
       private int       _pos = 0;
  
  
  
  1.5       +2 -2      xml-xalan/java/src/org/apache/xalan/xsltc/dom/MatchingIterator.java
  
  Index: MatchingIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/MatchingIterator.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MatchingIterator.java	2001/10/30 15:49:32	1.4
  +++ MatchingIterator.java	2001/11/27 15:20:55	1.5
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: MatchingIterator.java,v 1.4 2001/10/30 15:49:32 morten Exp $
  + * @(#)$Id: MatchingIterator.java,v 1.5 2001/11/27 15:20:55 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -79,8 +79,8 @@
       public NodeIterator cloneIterator() {
   	try {
   	    final MatchingIterator clone = (MatchingIterator)super.clone();
  -	    clone._isRestartable = false;
   	    clone._source = _source.cloneIterator();
  +	    clone._isRestartable = false;
   	    return clone;
   	}
   	catch (CloneNotSupportedException e) {
  
  
  
  1.15      +2 -2      xml-xalan/java/src/org/apache/xalan/xsltc/dom/MultiDOM.java
  
  Index: MultiDOM.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/MultiDOM.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- MultiDOM.java	2001/11/26 14:03:09	1.14
  +++ MultiDOM.java	2001/11/27 15:20:55	1.15
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: MultiDOM.java,v 1.14 2001/11/26 14:03:09 morten Exp $
  + * @(#)$Id: MultiDOM.java,v 1.15 2001/11/27 15:20:55 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -190,10 +190,10 @@
   	public NodeIterator cloneIterator() {
   	    try {
   		NodeValueIterator clone = (NodeValueIterator)super.clone();
  -		clone._isRestartable = false;
   		clone._source = _source.cloneIterator();
   		clone._value = _value;
   		clone._op = _op;
  +		_isRestartable = false;
   		return clone.reset();
   	    }
   	    catch (CloneNotSupportedException e) {
  
  
  
  1.8       +9 -7      xml-xalan/java/src/org/apache/xalan/xsltc/dom/NthIterator.java
  
  Index: NthIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/NthIterator.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- NthIterator.java	2001/10/05 09:47:56	1.7
  +++ NthIterator.java	2001/11/27 15:20:55	1.8
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: NthIterator.java,v 1.7 2001/10/05 09:47:56 morten Exp $
  + * @(#)$Id: NthIterator.java,v 1.8 2001/11/27 15:20:55 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -65,10 +65,11 @@
   
   import org.apache.xalan.xsltc.DOM;
   import org.apache.xalan.xsltc.NodeIterator;
  +import org.apache.xalan.xsltc.runtime.BasisLibrary;
   
   public final class NthIterator extends NodeIteratorBase {
       // ...[N]
  -    private final NodeIterator _source;
  +    private NodeIterator _source;
       private final int _position;
       private boolean _ready;
   
  @@ -123,11 +124,12 @@
       public void gotoMark() {
   	_source.gotoMark();
       }
  -    
  +
       public NodeIterator cloneIterator() {
  -	//!! not clear when cloning is performed
  -	// and what's the desired state of the new clone
  -	return new NthIterator(_source.cloneIterator(), _position);
  +	NodeIterator clone = _source.cloneIterator();
  +	((NodeIteratorBase)clone)._isRestartable = true;
  +	NthIterator other = new NthIterator(clone, _position);
  +	other._isRestartable = false;
  +	return other.reset();
       }
  -
   }
  
  
  
  1.9       +7 -11     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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- StepIterator.java	2001/11/27 08:40:28	1.8
  +++ StepIterator.java	2001/11/27 15:20:55	1.9
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: StepIterator.java,v 1.8 2001/11/27 08:40:28 morten Exp $
  + * @(#)$Id: StepIterator.java,v 1.9 2001/11/27 15:20:55 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -79,27 +79,23 @@
       }
   
       protected void setNotRestartable() {
  +	_isRestartable = false;
   	if (_source instanceof StepIterator) {
  -	    _isRestartable = true;
  -	    if (_iterator instanceof NodeIteratorBase)
  -		((NodeIteratorBase)_iterator)._isRestartable = true;
   	    ((StepIterator)_source).setNotRestartable();
   	}
  -	else {
  -	    _isRestartable = false;
  -	    if (_source instanceof NodeIteratorBase)
  -		((NodeIteratorBase)_source)._isRestartable = false;
  -	    if (_iterator instanceof NodeIteratorBase)
  -		((NodeIteratorBase)_iterator)._isRestartable = true;
  +	else if (_source instanceof NodeIteratorBase) {
  +	    ((NodeIteratorBase)_source)._isRestartable = false;
   	}
  +	if (_iterator instanceof NodeIteratorBase)
  +	    ((NodeIteratorBase)_iterator)._isRestartable = true;
       }
   
       public NodeIterator cloneIterator() {
  -	setNotRestartable();
   	try {
   	    final StepIterator clone = (StepIterator)super.clone();
   	    clone._source = _source.cloneIterator();
   	    clone._iterator = _iterator.cloneIterator();
  +	    clone.setNotRestartable();
   	    return clone.reset();
   	}
   	catch (CloneNotSupportedException e) {
  
  
  
  1.9       +2 -2      xml-xalan/java/src/org/apache/xalan/xsltc/dom/UnionIterator.java
  
  Index: UnionIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/UnionIterator.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- UnionIterator.java	2001/11/27 08:40:28	1.8
  +++ UnionIterator.java	2001/11/27 15:20:55	1.9
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: UnionIterator.java,v 1.8 2001/11/27 08:40:28 morten Exp $
  + * @(#)$Id: UnionIterator.java,v 1.9 2001/11/27 15:20:55 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -120,12 +120,12 @@
       }
   
       public NodeIterator cloneIterator() {
  -	_isRestartable = false;
   	final LookAheadIterator[] heapCopy = 
   	    new LookAheadIterator[_heap.length];
   	try {
   	    final UnionIterator clone = (UnionIterator)super.clone();
   	    System.arraycopy(_heap, 0, heapCopy, 0, _heap.length);
  +	    clone._isRestartable = false;
   	    clone._heap = heapCopy;
   	    return clone.reset();
   	} 
  
  
  
  1.30      +4 -6      xml-xalan/java/src/org/apache/xalan/xsltc/runtime/AbstractTranslet.java
  
  Index: AbstractTranslet.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/AbstractTranslet.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- AbstractTranslet.java	2001/11/16 17:31:16	1.29
  +++ AbstractTranslet.java	2001/11/27 15:20:56	1.30
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: AbstractTranslet.java,v 1.29 2001/11/16 17:31:16 tmiller Exp $
  + * @(#)$Id: AbstractTranslet.java,v 1.30 2001/11/27 15:20:56 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -320,11 +320,9 @@
   	    // The name cannot be null - use empty string instead
   	    if (name == null) name = EMPTYSTRING;
   
  -	    final DecimalFormat df = (DecimalFormat)_formatSymbols.get(name);
  -	    if (df != null)
  -		return df;
  -	    else
  -		return((DecimalFormat)_formatSymbols.get(EMPTYSTRING));
  +	    DecimalFormat df = (DecimalFormat)_formatSymbols.get(name);
  +	    if (df == null) df = (DecimalFormat)_formatSymbols.get(EMPTYSTRING);
  +	    return df;
   	}
   	return(null);
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org


Mime
View raw message