morten      01/10/04 05:11:57

  Modified:    java/src/org/apache/xalan/xsltc/compiler Step.java
  Log:
  Fixed a regression after an update to the descendant and descendant-or-self
  axis.
  PR:           n/a
  Obtained from:        n/a
  Submitted by: [EMAIL PROTECTED]
  Reviewed by:  [EMAIL PROTECTED]
  
  Revision  Changes    Path
  1.17      +33 -28    
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.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- Step.java 2001/09/26 13:41:42     1.16
  +++ Step.java 2001/10/04 12:11:57     1.17
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Step.java,v 1.16 2001/09/26 13:41:42 morten Exp $
  + * @(#)$Id: Step.java,v 1.17 2001/10/04 12:11:57 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -58,6 +58,7 @@
    *
    * @author Jacek Ambroziak
    * @author Santiago Pericas-Geertsen
  + * @author Morten Jorgensen
    *
    */
   
  @@ -358,6 +359,8 @@
        final ConstantPoolGen cpg = classGen.getConstantPool();
        final InstructionList il = methodGen.getInstructionList();
   
  +     int idx = 0;
  +
        if (_predicates.size() == 0) {
            translate(classGen, methodGen);
        }
  @@ -394,10 +397,10 @@
                    il.append(new ICONST(DOM.RETURN_PARENT));
                }
                predicate.translate(classGen, methodGen);
  -             int iter = cpg.addInterfaceMethodref(DOM_INTF,
  -                                          GET_NODE_VALUE_ITERATOR,
  -                                          GET_NODE_VALUE_ITERATOR_SIG);
  -             il.append(new INVOKEINTERFACE(iter, 5));
  +             idx = cpg.addInterfaceMethodref(DOM_INTF,
  +                                             GET_NODE_VALUE_ITERATOR,
  +                                             GET_NODE_VALUE_ITERATOR_SIG);
  +             il.append(new INVOKEINTERFACE(idx, 5));
            }
            // Handle '//*[n]' expression
            else if (predicate.isNthDescendant()) {
  @@ -405,43 +408,45 @@
                //il.append(methodGen.loadContextNode());
                il.append(new ICONST(-1));
                predicate.translate(classGen, methodGen);
  -             int iter = cpg.addInterfaceMethodref(DOM_INTF,
  -                                                  "getNthDescendant",
  -                                                  "(II)"+NODE_ITERATOR_SIG);
  -             il.append(new INVOKEINTERFACE(iter, 3));
  +             idx = cpg.addInterfaceMethodref(DOM_INTF,
  +                                             "getNthDescendant",
  +                                             "(II)"+NODE_ITERATOR_SIG);
  +             il.append(new INVOKEINTERFACE(idx, 3));
            }
            // Handle 'elem[n]' expression
            else if (predicate.isNthPositionFilter()) {
  -             if ((_axis == 4) || (_axis == 5)) {
  +             // Special case for typed descendant / decendant-or-self axis
  +             if (((_axis == Axis.DESCENDANT) ||
  +                  (_axis == Axis.DESCENDANTORSELF)) &&
  +                 (_nodeType > DOM.ATTRIBUTE)) {
                    il.append(methodGen.loadDOM());
                    il.append(new PUSH(cpg, _nodeType));
                    predicate.translate(classGen, methodGen);
  -                 int iter = cpg.addInterfaceMethodref(DOM_INTF,
  -                                                      "getNthDescendant",
  -                                                      
"(II)"+NODE_ITERATOR_SIG);
  -                 il.append(new INVOKEINTERFACE(iter, 3));                
  +                 idx = cpg.addInterfaceMethodref(DOM_INTF,
  +                                                 "getNthDescendant",
  +                                                 "(II)"+NODE_ITERATOR_SIG);
  +                 il.append(new INVOKEINTERFACE(idx, 3));                 
                }
                else {
  -                 final int initNI =
  -                     cpg.addMethodref(NTH_ITERATOR_CLASS,
  -                                      "<init>",
  -                                      "(" + NODE_ITERATOR_SIG + "I)V");
  +                 idx = cpg.addMethodref(NTH_ITERATOR_CLASS,
  +                                        "<init>",
  +                                        "("+NODE_ITERATOR_SIG+"I)V");
                    il.append(new NEW(cpg.addClass(NTH_ITERATOR_CLASS)));
                    il.append(DUP);
                    translatePredicates(classGen, methodGen); // recursive call
                    predicate.translate(classGen, methodGen);
  -                 il.append(new INVOKESPECIAL(initNI));
  +                 il.append(new INVOKESPECIAL(idx));
                }
            }
            else {
  -             final int init = cpg.addMethodref(CURRENT_NODE_LIST_ITERATOR,
  -                                               "<init>",
  -                                               "("
  -                                               + NODE_ITERATOR_SIG
  -                                               + CURRENT_NODE_LIST_FILTER_SIG
  -                                               + NODE_SIG
  -                                               + TRANSLET_SIG
  -                                               + ")V");
  +             idx = cpg.addMethodref(CURRENT_NODE_LIST_ITERATOR,
  +                                    "<init>",
  +                                    "("
  +                                    + NODE_ITERATOR_SIG
  +                                    + CURRENT_NODE_LIST_FILTER_SIG
  +                                    + NODE_SIG
  +                                    + TRANSLET_SIG
  +                                    + ")V");
                // create new CurrentNodeListIterator
                il.append(new NEW(cpg.addClass(CURRENT_NODE_LIST_ITERATOR)));
                il.append(DUP);
  @@ -454,7 +459,7 @@
                    final String className = classGen.getClassName();
                    il.append(new CHECKCAST(cpg.addClass(className)));
                }
  -             il.append(new INVOKESPECIAL(init));
  +             il.append(new INVOKESPECIAL(idx));
            }
        }
       }
  
  
  

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

Reply via email to