morten      01/08/01 04:52:59

  Modified:    java/src/org/apache/xalan/xsltc/compiler Constants.java
                        If.java Key.java Predicate.java Step.java When.java
               java/src/org/apache/xalan/xsltc/compiler/util
                        CompareGenerator.java
               java/src/org/apache/xalan/xsltc/dom NodeCounter.java
               java/src/org/apache/xalan/xsltc/runtime
                        DefaultSAXOutputHandler.java
  Log:
  A few changes to make our output look more like Saxon's (to simplyfy
  test diffs).
  PR:           n/a
  Obtained from:        n/a
  Submitted by: [EMAIL PROTECTED]
  Reviewed by:  [EMAIL PROTECTED]
  
  Revision  Changes    Path
  1.9       +6 -1      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Constants.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Constants.java    2001/07/09 10:17:40     1.8
  +++ Constants.java    2001/08/01 11:52:58     1.9
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Constants.java,v 1.8 2001/07/09 10:17:40 morten Exp $
  + * @(#)$Id: Constants.java,v 1.9 2001/08/01 11:52:58 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -448,6 +448,11 @@
        = "getVariable";
       public static final String GET_VARIABLE_SIG
        = "(I)" + OBJECT_SIG;
  +
  +    public static final String GET_NODE_VALUE_ITERATOR
  +     = "getNodeValueIterator";
  +    public static final String GET_NODE_VALUE_ITERATOR_SIG
  +     = "("+NODE_ITERATOR_SIG+STRING_SIG+"Z)"+NODE_ITERATOR_SIG;
   
       public static final int POSITION_INDEX = 2;
       public static final int LAST_INDEX     = 3;
  
  
  
  1.7       +1 -2      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/If.java
  
  Index: If.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/If.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- If.java   2001/07/10 17:45:15     1.6
  +++ If.java   2001/08/01 11:52:58     1.7
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: If.java,v 1.6 2001/07/10 17:45:15 morten Exp $
  + * @(#)$Id: If.java,v 1.7 2001/08/01 11:52:58 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -139,7 +139,6 @@
        * The contents will be ignored if we know the test will always fail.
        */
       public void translate(ClassGenerator classGen, MethodGenerator 
methodGen) {
  -
        final InstructionList il = methodGen.getInstructionList();
        _test.translateDesynthesized(classGen, methodGen);
        // remember end of condition
  
  
  
  1.6       +1 -2      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Key.java
  
  Index: Key.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Key.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Key.java  2001/06/17 12:23:29     1.5
  +++ Key.java  2001/08/01 11:52:58     1.6
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Key.java,v 1.5 2001/06/17 12:23:29 curcuru Exp $
  + * @(#)$Id: Key.java,v 1.6 2001/08/01 11:52:58 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -222,7 +222,6 @@
                                         "getAxisIterator",
                                         "(I)"+NODE_ITERATOR_SIG);
   
  -     // Save current node and current iterator on the stack
        il.append(methodGen.loadCurrentNode());
        il.append(methodGen.loadIterator());
   
  
  
  
  1.9       +7 -6      
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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Predicate.java    2001/07/31 10:04:51     1.8
  +++ Predicate.java    2001/08/01 11:52:58     1.9
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Predicate.java,v 1.8 2001/07/31 10:04:51 morten Exp $
  + * @(#)$Id: Predicate.java,v 1.9 2001/08/01 11:52:58 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -306,7 +306,7 @@
       }
   
       private Expression _value = null;
  -    private Expression _step = null;
  +    private Step _step = null;
   
       /**
        * Utility method for optimisation. See isNodeValueTest()
  @@ -352,7 +352,7 @@
       /**
        * Utility method for optimisation. See isNodeValueTest()
        */
  -    public Expression getStep() {
  +    public Step getStep() {
        if (_step != null) return _step;
        if (_exp == null) return null;
   
  @@ -362,11 +362,12 @@
            Expression right = exp.getRight();
   
            if (left instanceof CastExpr) left = ((CastExpr)left).getExpr();
  -         if (left instanceof Step) _step = left;
  +         if (left instanceof Step) _step = (Step)left;
            
            if (right instanceof CastExpr) right = ((CastExpr)right).getExpr();
  -         if (right instanceof Step) _step = right;
  +         if (right instanceof Step) _step = (Step)right;
        }
  +     //if ((_step != null) && (_step.isAbbreviatedDot())) _step = null;
        return _step;
       }
   
  @@ -383,7 +384,7 @@
        if (_nthPositionFilter || _nthDescendant) {
            _exp.translate(classGen, methodGen);
        }
  -     else if (isNodeValueTest()) {
  +     else if (isNodeValueTest() && (getParent() instanceof Step)) {
            _value.translate(classGen, methodGen);
            il.append(new PUSH(cpg, ((EqualityExpr)_exp).getOp()));
        }
  
  
  
  1.7       +26 -15    
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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Step.java 2001/07/31 10:04:51     1.6
  +++ Step.java 2001/08/01 11:52:58     1.7
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Step.java,v 1.6 2001/07/31 10:04:51 morten Exp $
  + * @(#)$Id: Step.java,v 1.7 2001/08/01 11:52:58 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -356,25 +356,36 @@
            final Predicate predicate = (Predicate)_predicates.lastElement();
            _predicates.remove(predicate);
   
  -         // Handle '//[EMAIL PROTECTED] = $var]' expression
  +         // Special case for predicates that can use the NodeValueIterator
  +         // instead of an auxiliary class. Certain path/predicates pairs
  +         // are translated into a base path, on top of which we place a
  +         // node value iterator that tests for the desired value:
  +         //   [EMAIL PROTECTED] = 'str']  ->  foo/@attr + test(value='str')
  +         //   foo[bar = 'str']    ->  foo/bar + test(value='str')
  +         //   foo/bar[. = 'str']  ->  foo/bar + test(value='str')
            if (predicate.isNodeValueTest()) {
  -             Step step = (Step)(predicate.getStep());
  -             ParentLocationPath path = new ParentLocationPath(this, step);
  +             Step step = predicate.getStep();
   
  -             try {
  -                 path.typeCheck(getParser().getSymbolTable());
  -             }
  -             catch (TypeCheckError e) { }
  -
                il.append(methodGen.loadDOM());
  -             path.translate(classGen, methodGen);
  +             // If the predicate's Step is simply '.' we translate this Step
  +             // and place the node test on top of the resulting iterator
  +             if (step.isAbbreviatedDot()) {
  +                 translate(classGen, methodGen);
  +             }
  +             // Otherwise we create a parent location path with this Step and
  +             // the predicates Step, and place the node test on top of that
  +             else {
  +                 ParentLocationPath path = new ParentLocationPath(this,step);
  +                 try {
  +                     path.typeCheck(getParser().getSymbolTable());
  +                 }
  +                 catch (TypeCheckError e) { }
  +                 path.translate(classGen, methodGen);
  +             }
                predicate.translate(classGen, methodGen);
  -
  -             final String signature =
  -                 "("+NODE_ITERATOR_SIG+STRING_SIG+"Z)"+NODE_ITERATOR_SIG;
                final int iter = cpg.addMethodref(DOM_CLASS,
  -                                               "getNodeValueIterator",
  -                                               signature);
  +                                               GET_NODE_VALUE_ITERATOR,
  +                                               GET_NODE_VALUE_ITERATOR_SIG);
                il.append(new INVOKEVIRTUAL(iter));
            }
            // Handle '//*[n]' expression
  
  
  
  1.7       +2 -1      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/When.java
  
  Index: When.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/When.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- When.java 2001/06/29 12:04:35     1.6
  +++ When.java 2001/08/01 11:52:58     1.7
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: When.java,v 1.6 2001/06/29 12:04:35 morten Exp $
  + * @(#)$Id: When.java,v 1.7 2001/08/01 11:52:58 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -126,6 +126,7 @@
        if (!_ignore) {
            typeCheckContents(stable);
        }
  +
        return Type.Void;
       }
   
  
  
  
  1.2       +2 -1      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/CompareGenerator.java
  
  Index: CompareGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/CompareGenerator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CompareGenerator.java     2001/04/17 18:52:14     1.1
  +++ CompareGenerator.java     2001/08/01 11:52:59     1.2
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: CompareGenerator.java,v 1.1 2001/04/17 18:52:14 sboag Exp $
  + * @(#)$Id: CompareGenerator.java,v 1.2 2001/08/01 11:52:59 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -68,6 +68,7 @@
   import org.apache.xalan.xsltc.compiler.Template;
   
   public final class CompareGenerator extends MethodGenerator {
  +
       private static int DOM_INDEX      = 1;
       private static int CURRENT_INDEX  = 2;
       private static int LEVEL_INDEX    = 3;
  
  
  
  1.3       +5 -12     
xml-xalan/java/src/org/apache/xalan/xsltc/dom/NodeCounter.java
  
  Index: NodeCounter.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/NodeCounter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- NodeCounter.java  2001/07/31 18:55:58     1.2
  +++ NodeCounter.java  2001/08/01 11:52:59     1.3
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: NodeCounter.java,v 1.2 2001/07/31 18:55:58 morten Exp $
  + * @(#)$Id: NodeCounter.java,v 1.3 2001/08/01 11:52:59 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -209,9 +209,7 @@
        for (int j = 0, i = 0; i < length;) {
               char c = _format.charAt(i);
               for (j = i; Character.isLetterOrDigit(c);) {
  -                if (++i == length) {
  -                 break;
  -             }
  +                if (++i == length) break;
                c = _format.charAt(i);
               }
               if (i > j) {
  @@ -222,15 +220,11 @@
                   formatToks.addElement(_format.substring(j, i));
               }
   
  -            if (i == length) {
  -             break;
  -         }
  +            if (i == length) break;
   
               c = _format.charAt(i);
               for (j = i; !Character.isLetterOrDigit(c);) {
  -                if (++i == length) {
  -                 break;
  -             }
  +                if (++i == length) break;
                   c = _format.charAt(i);
                   isFirst = false;
               }
  @@ -257,8 +251,7 @@
                if (!isFirst) {
                    buffer.append((String) separToks.elementAt(t));
                }
  -             formatValue(value, (String) formatToks.elementAt(t++),
  -                         buffer);
  +             formatValue(value, (String) formatToks.elementAt(t++), buffer);
                if (t == formatToks.size()) {
                    t--;
                }
  
  
  
  1.11      +13 -12    
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/DefaultSAXOutputHandler.java
  
  Index: DefaultSAXOutputHandler.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/DefaultSAXOutputHandler.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DefaultSAXOutputHandler.java      2001/07/31 18:13:23     1.10
  +++ DefaultSAXOutputHandler.java      2001/08/01 11:52:59     1.11
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: DefaultSAXOutputHandler.java,v 1.10 2001/07/31 18:13:23 morten 
Exp $
  + * @(#)$Id: DefaultSAXOutputHandler.java,v 1.11 2001/08/01 11:52:59 morten 
Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -115,9 +115,10 @@
   
       private static final String EMPTYSTRING = "";
   
  -    private boolean   _indentNextEndTag = false;
  -    private boolean   _linefeedNextStartTag = false;
  -    private int       _indentLevel = 0;
  +    private boolean _lineFeedNextStartTag = false;
  +    private boolean _linefeedNextEndTag = false;
  +    private boolean _indentNextEndTag = false;
  +    private int     _indentLevel = 0;
   
       // This is used for aggregating namespace declarations
       private AttributeList _namespaceDeclarations = new AttributeList();
  @@ -181,7 +182,6 @@
        _outputType = TextOutput.UNKNOWN;
        _indent = false;
        _indentNextEndTag = false;
  -     _linefeedNextStartTag = false;
        _indentLevel = 0;
        _startTagOpen = false;
       }
  @@ -255,16 +255,17 @@
   
            // Handle indentation (not a requirement)
               if (_indent) {
  -                indent(_linefeedNextStartTag);
  -                _indentLevel++;
  +             indent(_lineFeedNextStartTag);
  +             _lineFeedNextStartTag = true;
                   _indentNextEndTag = false;
  +                _indentLevel++;
               }
  -            _linefeedNextStartTag = true;
   
            // Now, finally, output the start tag for the element.
            _writer.write('<');
            _writer.write(elementName);
            _startTagOpen = true;
  +         _indentNextEndTag = false;
   
            // Output namespace declarations first...
            int declCount = _namespaceDeclarations.getLength();
  @@ -304,15 +305,16 @@
                           String elementName)  throws SAXException {
        try {
   
  -           _linefeedNextStartTag = false;
  -
               if (_indent) _indentLevel--;
   
               if (_startTagOpen) {
                   closeStartTag(false);
               }
               else {
  -                if ((_indent) && (_indentNextEndTag)) indent(false);
  +                if ((_indent) && (_indentNextEndTag)) {
  +                 indent(_indentNextEndTag);
  +                 _indentNextEndTag = true;
  +             }
                   char[] endTag = (char[])_endTags.get(elementName);
                   if (endTag == null) {
                    // We dont' want to concatenate String objects!!!!
  @@ -359,7 +361,6 @@
                determineOutputType(null);
            
               if (len == 0) return;
  -            _linefeedNextStartTag = false;
   
               // Close any open start-tags.
               if (_startTagOpen) closeStartTag(true);
  
  
  

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

Reply via email to