morten      01/07/10 10:46:30

  Modified:    java/src/org/apache/xalan/xsltc/compiler
                        AncestorPattern.java AttributeSet.java
                        CallTemplate.java CastExpr.java EqualityExpr.java
                        Expression.java FunctionCall.java If.java
                        Import.java Include.java Mode.java NameBase.java
                        Param.java ParameterRef.java Parser.java
                        StepPattern.java SyntaxTreeNode.java Template.java
                        TestSeq.java Variable.java VariableRef.java
                        XSLTC.java XslAttribute.java
               java/src/org/apache/xalan/xsltc/compiler/util ErrorMsg.java
                        ReferenceType.java
               java/src/org/apache/xalan/xsltc/dom MultiDOM.java
                        StepIterator.java
               java/src/org/apache/xalan/xsltc/runtime BasisLibrary.java
  Log:
  A wide range of fixes provided by Erwin Bolwidt.
   o) fix for long IF and GOTO instructions inside translets.
      'wide' GOTOs are now used (GOTO_W) instead of plain GOTO
      to allow longer jump offsets
   o) fix for illegal field/method names in the translet.
      Methods and fields no longer contain the '.' or '-' characters
   o) source filenames (and if possible also line numbers) are now
      provided with error and warning messages
   o) external functions that are not supported by XSLTC do not cause
      compile errors. They will still cause a warning message at
      compile-time if they are not wrapped in proper <xsl:if> or
      <xsl:when> elements that test on the availability of the function,
      and will cause a runtime error if the function is attempted called.
   o) added type cast from reference-type to node-type
   o) some other smaller fixes to prevent null-pointer exceptions
  Other changes:
   o) code cleanup and some added comments
  PR:           n/a
  Obtained from:        n/a
  Submitted by: Erwin Bolwidt <[EMAIL PROTECTED]>
  Reviewed by:  Morten Jorgensen <[EMAIL PROTECTED]>
  
  Revision  Changes    Path
  1.2       +7 -2      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AncestorPattern.java
  
  Index: AncestorPattern.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AncestorPattern.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AncestorPattern.java      2001/04/17 18:51:18     1.1
  +++ AncestorPattern.java      2001/07/10 17:45:02     1.2
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: AncestorPattern.java,v 1.1 2001/04/17 18:51:18 sboag Exp $
  + * @(#)$Id: AncestorPattern.java,v 1.2 2001/07/10 17:45:02 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -58,6 +58,7 @@
    *
    * @author Jacek Ambroziak
    * @author Santiago Pericas-Geertsen
  + * @author Erwin Bolwidt <[EMAIL PROTECTED]>
    *
    */
   
  @@ -105,6 +106,7 @@
       }
        
       public Type typeCheck(SymbolTable stable) throws TypeCheckError {
  +     if (_left != null) _left.typeCheck(stable);
        return _right.typeCheck(stable);
       }
   
  @@ -149,12 +151,15 @@
   
   
            final SyntaxTreeNode p = getParent();
  -         if (p instanceof Instruction || p instanceof TopLevelElement) {
  +         if ((p == null) || 
  +             (p instanceof Instruction) ||
  +             (p instanceof TopLevelElement)) {
                // do nothing
            }
            else {
                il.append(loadLocal);
            }
  +
            final BranchHandle exit = il.append(new GOTO(null));
            eloop = il.append(methodGen.loadDOM());
            il.append(loadLocal);
  
  
  
  1.6       +2 -2      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AttributeSet.java
  
  Index: AttributeSet.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AttributeSet.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AttributeSet.java 2001/06/12 14:09:53     1.5
  +++ AttributeSet.java 2001/07/10 17:45:04     1.6
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: AttributeSet.java,v 1.5 2001/06/12 14:09:53 morten Exp $
  + * @(#)$Id: AttributeSet.java,v 1.6 2001/07/10 17:45:04 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -85,7 +85,7 @@
        "Attribute sets can only have <xsl:attribute> child elements.";
   
       // This prefix is used for the method name of attribute set methods
  -    private static final String AttributeSetPrefix = "%as";
  +    private static final String AttributeSetPrefix = "$as$";
       
       // Element contents
       private QName            _name;
  
  
  
  1.4       +9 -3      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/CallTemplate.java
  
  Index: CallTemplate.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/CallTemplate.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- CallTemplate.java 2001/06/06 10:44:43     1.3
  +++ CallTemplate.java 2001/07/10 17:45:05     1.4
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: CallTemplate.java,v 1.3 2001/06/06 10:44:43 morten Exp $
  + * @(#)$Id: CallTemplate.java,v 1.4 2001/07/10 17:45:05 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -58,6 +58,7 @@
    *
    * @author Jacek Ambroziak
    * @author Santiago Pericas-Geertsen
  + * @author Erwin Bolwidt <[EMAIL PROTECTED]>
    *
    */
   
  @@ -128,15 +129,20 @@
            // translate with-params
            translateContents(classGen, methodGen);
        }
  -     
  +
        final String className = stylesheet.getClassName();
  +     // Generate a valid Java method name
  +     String methodName = _name.toString();
  +     methodName = methodName.replace('.', '$');
  +     methodName = methodName.replace('-', '$');
  +
        il.append(classGen.loadTranslet());
        il.append(methodGen.loadDOM());
        il.append(methodGen.loadIterator());
        il.append(methodGen.loadHandler());
        il.append(methodGen.loadCurrentNode());
        il.append(new INVOKEVIRTUAL(cpg.addMethodref(className,
  -                                                  _name.toString(),
  +                                                  methodName,
                                                     "("
                                                     + DOM_CLASS_SIG
                                                     + NODE_ITERATOR_SIG
  
  
  
  1.4       +4 -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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- CastExpr.java     2001/06/17 12:23:27     1.3
  +++ CastExpr.java     2001/07/10 17:45:06     1.4
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: CastExpr.java,v 1.3 2001/06/17 12:23:27 curcuru Exp $
  + * @(#)$Id: CastExpr.java,v 1.4 2001/07/10 17:45:06 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -58,6 +58,8 @@
    *
    * @author Jacek Ambroziak
    * @author Santiago Pericas-Geertsen
  + * @author Morten Jorgensen
  + * @author Erwin Bolwidt <[EMAIL PROTECTED]>
    *
    */
   
  @@ -126,6 +128,7 @@
        InternalTypeMap.put(Type.Reference, Type.Int);
        InternalTypeMap.put(Type.Reference, Type.Real);
        InternalTypeMap.put(Type.Reference, Type.String);
  +     InternalTypeMap.put(Type.Reference, Type.Node);
        InternalTypeMap.put(Type.Reference, Type.NodeSet);
   
        InternalTypeMap.put(Type.Void, Type.String);
  
  
  
  1.4       +3 -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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- EqualityExpr.java 2001/06/17 12:23:28     1.3
  +++ EqualityExpr.java 2001/07/10 17:45:08     1.4
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: EqualityExpr.java,v 1.3 2001/06/17 12:23:28 curcuru Exp $
  + * @(#)$Id: EqualityExpr.java,v 1.4 2001/07/10 17:45:08 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -58,6 +58,8 @@
    *
    * @author Jacek Ambroziak
    * @author Santiago Pericas-Geertsen
  + * @author Morten Jorgensen
  + * @author Erwin Bolwidt <[EMAIL PROTECTED]>
    *
    */
   
  
  
  
  1.5       +4 -2      
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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Expression.java   2001/06/17 12:23:28     1.4
  +++ Expression.java   2001/07/10 17:45:10     1.5
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Expression.java,v 1.4 2001/06/17 12:23:28 curcuru Exp $
  + * @(#)$Id: Expression.java,v 1.5 2001/07/10 17:45:10 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -58,6 +58,8 @@
    *
    * @author Jacek Ambroziak
    * @author Santiago Pericas-Geertsen
  + * @author Morten Jorgensen
  + * @author Erwin Bolwidt <[EMAIL PROTECTED]>
    *
    */
   
  @@ -182,7 +184,7 @@
        final ConstantPoolGen cpg = classGen.getConstantPool();
        final InstructionList il = methodGen.getInstructionList();
        _trueList.backPatch(il.append(ICONST_1));
  -     final BranchHandle truec = il.append(new GOTO(null));
  +     final BranchHandle truec = il.append(new GOTO_W(null));
        _falseList.backPatch(il.append(ICONST_0));
        truec.setTarget(il.append(NOP));
       }
  
  
  
  1.7       +30 -8     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/FunctionCall.java
  
  Index: FunctionCall.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/FunctionCall.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- FunctionCall.java 2001/06/19 10:44:09     1.6
  +++ FunctionCall.java 2001/07/10 17:45:13     1.7
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: FunctionCall.java,v 1.6 2001/06/19 10:44:09 morten Exp $
  + * @(#)$Id: FunctionCall.java,v 1.7 2001/07/10 17:45:13 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -58,6 +58,8 @@
    *
    * @author Jacek Ambroziak
    * @author Santiago Pericas-Geertsen
  + * @author Morten Jorgensen
  + * @author Erwin Bolwidt <[EMAIL PROTECTED]>
    *
    */
   
  @@ -82,14 +84,13 @@
       private Method     _chosenMethod;
       private MethodType _chosenMethodType;
   
  -    /**
  -     * Legal conversions between internal and Java types.
  -     */
  +    // Encapsulates all unsupported external function calls
  +    private boolean    unresolvedExternal;
  +
  +    // Legal conversions between internal and Java types.
       private static final MultiHashtable InternalToJava = new 
MultiHashtable();
   
  -    /**
  -     * Legal conversions between Java and internal types.
  -     */
  +    // Legal conversions between Java and internal types.
       private static final Hashtable JavaToInternal = new Hashtable();
        
       /**
  @@ -199,7 +200,19 @@
                _className = namespace.substring(len + 1);
            }                   
            else {
  -             throw new TypeCheckError(ErrorMsg.FUNRESOL_ERR, _fname);
  +             /*
  +              * Warn user if external function could not be resolved.
  +              * Warning will _NOT_ be issued is the call is properly
  +              * wrapped in an <xsl:if> or <xsl:when> element. For details
  +              * see If.parserContents() and When.parserContents()
  +              */
  +             final Parser parser = getParser();
  +             if (parser != null) {
  +                 reportWarning(this ,parser, ErrorMsg.FUNRESOL_ERR,
  +                               _fname.toString());
  +             }
  +             unresolvedExternal = true;
  +             return _type = Type.Void;
            }
            return typeCheckExternal(stable);
        }
  @@ -376,6 +389,15 @@
            // Invoke the method in the basis library
            index = cpg.addMethodref(BASIS_LIBRARY_CLASS, name,
                                     _chosenMethodType.toSignature(args));
  +         il.append(new INVOKESTATIC(index));
  +     }
  +     // Add call to BasisLibrary.unresolved_externalF() to generate
  +     // run-time error message for unsupported external functions
  +     else if (unresolvedExternal) {
  +         index = cpg.addMethodref(BASIS_LIBRARY_CLASS,
  +                                  "unresolved_externalF",
  +                                  "(Ljava/lang/String;)V");
  +         il.append(new PUSH(cpg, _fname.toString()));
            il.append(new INVOKESTATIC(index));
        }
        // Invoke function calls that are handled in separate classes
  
  
  
  1.6       +6 -1      
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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- If.java   2001/06/19 10:44:10     1.5
  +++ If.java   2001/07/10 17:45:15     1.6
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: If.java,v 1.5 2001/06/19 10:44:10 morten Exp $
  + * @(#)$Id: If.java,v 1.6 2001/07/10 17:45:15 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -106,6 +106,11 @@
        // test will always return 'false'.
        if (_test instanceof ElementAvailableCall) {
            ElementAvailableCall call = (ElementAvailableCall)_test;
  +         _ignore = !call.getResult();
  +         return;
  +     }
  +     if (_test instanceof FunctionAvailableCall) {
  +         FunctionAvailableCall call = (FunctionAvailableCall)_test;
            _ignore = !call.getResult();
            return;
        }
  
  
  
  1.4       +10 -6     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Import.java
  
  Index: Import.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Import.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Import.java       2001/06/06 10:45:02     1.3
  +++ Import.java       2001/07/10 17:45:17     1.4
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Import.java,v 1.3 2001/06/06 10:45:02 morten Exp $
  + * @(#)$Id: Import.java,v 1.4 2001/07/10 17:45:17 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -58,6 +58,7 @@
    *
    * @author Jacek Ambroziak
    * @author Morten Jorgensen
  + * @author Erwin Bolwidt <[EMAIL PROTECTED]>
    *
    */
   
  @@ -85,8 +86,8 @@
       }
   
       public void parseContents(final Parser parser) {
  +     final Stylesheet context = parser.getCurrentStylesheet();
        try {
  -         final Stylesheet context = parser.getCurrentStylesheet();
            final String href = getAttribute("href");
            final URL toImport = new URL(context.getURL(), href);
            if (context.checkForLoop(toImport))
  @@ -111,14 +112,17 @@
            final Enumeration elements = _imported.elements();
            final Stylesheet topStylesheet = parser.getTopLevelStylesheet();
            while (elements.hasMoreElements()) {
  -             final TopLevelElement topLevelElement =
  -                 (TopLevelElement)elements.nextElement();
  -             topStylesheet.addElement(topLevelElement);
  +             final Object element = elements.nextElement();
  +             if (element instanceof TopLevelElement) {
  +                 topStylesheet.addElement((TopLevelElement)element);
  +             }
            }
  -         parser.setCurrentStylesheet(context);
        }
        catch (Exception e) {
            e.printStackTrace();
  +     }
  +     finally {
  +         parser.setCurrentStylesheet(context);
        }
       }
       
  
  
  
  1.4       +10 -6     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Include.java
  
  Index: Include.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Include.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Include.java      2001/06/06 10:45:03     1.3
  +++ Include.java      2001/07/10 17:45:18     1.4
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Include.java,v 1.3 2001/06/06 10:45:03 morten Exp $
  + * @(#)$Id: Include.java,v 1.4 2001/07/10 17:45:18 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -58,6 +58,7 @@
    *
    * @author Jacek Ambroziak
    * @author Morten Jorgensen
  + * @author Erwin Bolwidt <[EMAIL PROTECTED]>
    *
    */
   
  @@ -85,8 +86,8 @@
       }
   
       public void parseContents(final Parser parser) {
  +     final Stylesheet context = parser.getCurrentStylesheet();
        try {
  -         final Stylesheet context = parser.getCurrentStylesheet();
            final String href = getAttribute("href");
            final URL toInclude = new URL(context.getURL(), href);
            if (context.checkForLoop(toInclude))
  @@ -111,14 +112,17 @@
            final Enumeration elements = _included.elements();
            final Stylesheet topStylesheet = parser.getTopLevelStylesheet();
            while (elements.hasMoreElements()) {
  -             final TopLevelElement topLevelElement =
  -                 (TopLevelElement)elements.nextElement();
  -             topStylesheet.addElement(topLevelElement);
  +             final Object element = elements.nextElement();
  +             if (element instanceof TopLevelElement) {
  +                 topStylesheet.addElement((TopLevelElement)element);
  +             }
            }
  -         parser.setCurrentStylesheet(context);
        }
        catch (Exception e) {
            e.printStackTrace();
  +     }
  +     finally {
  +         parser.setCurrentStylesheet(context);
        }
       }
       
  
  
  
  1.3       +18 -8     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Mode.java
  
  Index: Mode.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Mode.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Mode.java 2001/06/12 10:12:36     1.2
  +++ Mode.java 2001/07/10 17:45:19     1.3
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Mode.java,v 1.2 2001/06/12 10:12:36 morten Exp $
  + * @(#)$Id: Mode.java,v 1.3 2001/07/10 17:45:19 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -59,6 +59,7 @@
    * @author Jacek Ambroziak
    * @author Santiago Pericas-Geertsen
    * @author Morten Jorgensen
  + * @author Erwin Bolwidt <[EMAIL PROTECTED]>
    *
    */
   
  @@ -254,6 +255,11 @@
        final ConstantPoolGen cpg = classGen.getConstantPool();
        final InstructionList il = new InstructionList();
        final String DOM_CLASS_SIG = classGen.getDOMClassSig();
  +
  +     String methodName = template.getName().toString();
  +     methodName = methodName.replace('.', '$');
  +     methodName = methodName.replace('-', '$');
  +
        final NamedMethodGenerator methodGen =
            new NamedMethodGenerator(ACC_PUBLIC,
                                     de.fub.bytecode.generic.Type.VOID,
  @@ -269,8 +275,7 @@
                                         TRANSLET_OUTPUT_PNAME,
                                         NODE_PNAME
                                     },
  -                                  //!!! more name sophistication needed
  -                                  template.getName().toString(),
  +                                  methodName,
                                     getClassName(),
                                     il, cpg);
        
  @@ -299,7 +304,7 @@
            if (template.hasContents()) {
                // !!! TODO templates both named and matched
                InstructionList til = template.compile(classGen, methodGen);
  -             til.append(new GOTO(next));
  +             til.append(new GOTO_W(next));
                _templateInstructionLists.put(template, til);
                _templateInstructionHandles.put(template, til.getStart());
            }
  @@ -372,7 +377,7 @@
        il.append(new INVOKEVIRTUAL(getChildren));
        il.append(methodGen.loadHandler());
        il.append(new INVOKEVIRTUAL(applyTemplates));
  -     il.append(new GOTO(next));
  +     il.append(new GOTO_W(next));
        return il;
       }
   
  @@ -393,7 +398,7 @@
        il.append(new INVOKEVIRTUAL(cpg.addMethodref(DOM_CLASS,
                                                     CHARACTERS,
                                                     CHARACTERS_SIG)));
  -     il.append(new GOTO(next));
  +     il.append(new GOTO_W(next));
        return il;
       }
   
  @@ -530,7 +535,12 @@
        ilLoop.append(methodGen.nextNode());
        ilLoop.append(DUP);
        ilLoop.append(new ISTORE(_currentIndex));
  -     ilLoop.append(new IFNE(body.getStart()));
  +     // The body of this code can get very large - large than can be handled
  +     // by a single IFNE(body.getStart()) instruction - need workaround:
  +        final BranchHandle ifeq = ilLoop.append(new IFEQ(null));
  +     ilLoop.append(new GOTO_W(body.getStart()));
  +     ifeq.setTarget(ilLoop.append(NOP));
  +
        final InstructionHandle ihLoop = ilLoop.getStart();
   
        // (*) Compile default handling of elements (traverse children)
  @@ -700,7 +710,7 @@
        body.append(ilText);
   
        // putting together constituent instruction lists
  -     mainIL.append(new GOTO(ihLoop));
  +     mainIL.append(new GOTO_W(ihLoop));
        mainIL.append(body);
        // fall through to ilLoop
        mainIL.append(ilLoop);
  
  
  
  1.4       +17 -2     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/NameBase.java
  
  Index: NameBase.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/NameBase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- NameBase.java     2001/06/17 12:23:30     1.3
  +++ NameBase.java     2001/07/10 17:45:20     1.4
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: NameBase.java,v 1.3 2001/06/17 12:23:30 curcuru Exp $
  + * @(#)$Id: NameBase.java,v 1.4 2001/07/10 17:45:20 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -57,6 +57,7 @@
    * <http://www.apache.org/>.
    *
    * @author Morten Jorgensen
  + * @author Erwin Bolwidt <[EMAIL PROTECTED]>
    *
    */
   
  @@ -107,8 +108,12 @@
            throw new TypeCheckError(this);
        }
   
  -     if ((_type != Type.NodeSet) && (_type != Type.Node))
  +     // The argument has to be a node, a node-set or a node reference
  +     if ((_type != Type.NodeSet) &&
  +         (_type != Type.Node) &&
  +         (_type != Type.Reference)) {
            throw new TypeCheckError(this);
  +     }
   
        return Type.String;
       }
  @@ -136,6 +141,16 @@
        // Function was called with node parameter
        else if (_type == Type.Node) {
            _param.translate(classGen, methodGen);
  +     }
  +     else if (_type == Type.Reference) {
  +         _param.translate(classGen, methodGen);
  +         il.append(new INVOKESTATIC(cpg.addMethodref
  +                                    (BASIS_LIBRARY_CLASS,
  +                                     "referenceToNodeSet",
  +                                     "(Ljava/lang/Object;)" +
  +                                     "Lorg/apache/xalan/xsltc/" +
  +                                     "NodeIterator;")));
  +         il.append(methodGen.nextNode());
        }
        // Function was called with node-set parameter
        else {
  
  
  
  1.8       +9 -2      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Param.java
  
  Index: Param.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Param.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Param.java        2001/07/09 10:17:40     1.7
  +++ Param.java        2001/07/10 17:45:21     1.8
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Param.java,v 1.7 2001/07/09 10:17:40 morten Exp $
  + * @(#)$Id: Param.java,v 1.8 2001/07/10 17:45:21 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -59,6 +59,7 @@
    * @author Jacek Ambroziak
    * @author Santiago Pericas-Geertsen
    * @author Morten Jorgensen
  + * @author Erwin Bolwidt <[EMAIL PROTECTED]>
    *
    */
   
  @@ -220,12 +221,18 @@
   
   
       public void translate(ClassGenerator classGen, MethodGenerator 
methodGen) {
  +
        final ConstantPoolGen cpg = classGen.getConstantPool();
        final InstructionList il = methodGen.getInstructionList();
  -     final String name = _name.getLocalPart(); // TODO: namespace ?
   
        if (_compiled) return;
        _compiled = true;
  +
  +     // Make name acceptable for use as field name in class
  +     // TODO: convert to escape sequence like $dot$ and $dash$
  +     String name = _name.getLocalPart(); // TODO: namespace ?
  +     name = name.replace('.', '_');
  +     name = name.replace('-', '_');
   
        if (isLocal()) {
   
  
  
  
  1.2       +5 -1      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ParameterRef.java
  
  Index: ParameterRef.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ParameterRef.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ParameterRef.java 2001/04/17 18:51:41     1.1
  +++ ParameterRef.java 2001/07/10 17:45:23     1.2
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: ParameterRef.java,v 1.1 2001/04/17 18:51:41 sboag Exp $
  + * @(#)$Id: ParameterRef.java,v 1.2 2001/07/10 17:45:23 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -58,6 +58,8 @@
    *
    * @author Jacek Ambroziak
    * @author Santiago Pericas-Geertsen
  + * @author Morten Jorgensen
  + * @author Erwin Bolwidt <[EMAIL PROTECTED]>
    *
    */
   
  @@ -89,6 +91,8 @@
                
        final Type parType = _param.getType();
        String parName = _param.getName().getLocalPart();
  +     parName = parName.replace('.', '_');
  +     parName = parName.replace('-', '_');
   
        if (_param.isLocal()) {
            if (classGen.isExternal()) {
  
  
  
  1.15      +3 -3      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Parser.java
  
  Index: Parser.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Parser.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Parser.java       2001/06/29 12:04:35     1.14
  +++ Parser.java       2001/07/10 17:45:24     1.15
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Parser.java,v 1.14 2001/06/29 12:04:35 morten Exp $
  + * @(#)$Id: Parser.java,v 1.15 2001/07/10 17:45:24 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -60,6 +60,7 @@
    * @author Santiago Pericas-Geertsen
    * @author G. Todd Miller
    * @author Morten Jorgensen
  + * @author Erwin Bolwidt <[EMAIL PROTECTED]>
    *
    */
   
  @@ -952,9 +953,8 @@
       }
   
       /**
  -     * Suggested common error handler - not in use yet!!!
  +     * Common error/warning message handler
        */
  -// JUMP
       public void reportError(final int category, final ErrorMsg error) {
        try {
            switch (category) {
  
  
  
  1.3       +9 -2      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/StepPattern.java
  
  Index: StepPattern.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/StepPattern.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StepPattern.java  2001/07/09 10:17:41     1.2
  +++ StepPattern.java  2001/07/10 17:45:25     1.3
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: StepPattern.java,v 1.2 2001/07/09 10:17:41 morten Exp $
  + * @(#)$Id: StepPattern.java,v 1.3 2001/07/10 17:45:25 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -58,6 +58,7 @@
    *
    * @author Jacek Ambroziak
    * @author Santiago Pericas-Geertsen
  + * @author Erwin Bolwidt <[EMAIL PROTECTED]>
    *
    */
   
  @@ -72,6 +73,7 @@
   import org.apache.xalan.xsltc.compiler.util.*;
   
   final class StepPattern extends RelativePathPattern {
  +
       private static final int NO_CONTEXT = 0;
       private static final int SIMPLE_CONTEXT = 1;
       private static final int GENERAL_CONTEXT = 2;
  @@ -210,7 +212,12 @@
        il.append(new INVOKEVIRTUAL(cpg.addMethodref(DOM_CLASS,
                                                     "getType", "(I)I")));
        il.append(new PUSH(cpg, _nodeType));
  -     _falseList.add(il.append(new IF_ICMPNE(null)));
  +     
  +     // Need to allow for long jumps here - don't know if 100% correct
  +     //_falseList.add(il.append(new IF_ICMPNE(null)));
  +     final BranchHandle icmp = il.append(new IF_ICMPEQ(null));
  +     _falseList.add(il.append(new GOTO_W(null)));
  +     icmp.setTarget(il.append(NOP));
       }
   
       private void translateNoContext(ClassGenerator classGen, 
  
  
  
  1.8       +10 -8     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/SyntaxTreeNode.java
  
  Index: SyntaxTreeNode.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/SyntaxTreeNode.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- SyntaxTreeNode.java       2001/07/09 10:17:42     1.7
  +++ SyntaxTreeNode.java       2001/07/10 17:45:26     1.8
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: SyntaxTreeNode.java,v 1.7 2001/07/09 10:17:42 morten Exp $
  + * @(#)$Id: SyntaxTreeNode.java,v 1.8 2001/07/10 17:45:26 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -60,6 +60,7 @@
    * @author Santiago Pericas-Geertsen
    * @author G. Todd Miller
    * @author Morten Jorensen
  + * @author Erwin Bolwidt <[EMAIL PROTECTED]>
    *
    */
   
  @@ -68,6 +69,7 @@
   import java.util.Vector;
   import java.util.Enumeration;
   import java.util.Hashtable;
  +import java.net.URL;
   
   import javax.xml.parsers.*;
   
  @@ -219,7 +221,7 @@
        return _parent;
       }
   
  -    protected Stylesheet getStylesheet() {
  +    public Stylesheet getStylesheet() {
        SyntaxTreeNode parent = this;
        while (parent != null) {
            if (parent instanceof Stylesheet)
  @@ -510,15 +512,15 @@
        return _line;
       }
   
  -    protected static void reportError(SyntaxTreeNode element, Parser parser,
  -                                   int errorCode, String msg) {
  -     final ErrorMsg error = new ErrorMsg(errorCode, 0 /*lineNumber*/, msg);
  +    protected void reportError(SyntaxTreeNode element, Parser parser,
  +                            int errorCode, String message) {
  +     final ErrorMsg error = new ErrorMsg(errorCode, message, this);
           parser.reportError(Constants.ERROR, error);
       }
   
  -    protected static void reportWarning(SyntaxTreeNode element, Parser 
parser,
  -                                     int errorCode, String msg) {
  -     final ErrorMsg error = new ErrorMsg(errorCode, 0 /*lineNumber*/, msg);
  +    protected  void reportWarning(SyntaxTreeNode element, Parser parser,
  +                               int errorCode, String message) {
  +     final ErrorMsg error = new ErrorMsg(errorCode, message, this);
           parser.reportError(Constants.WARNING, error);
       }
   
  
  
  
  1.9       +9 -3      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Template.java
  
  Index: Template.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Template.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Template.java     2001/06/19 10:44:12     1.8
  +++ Template.java     2001/07/10 17:45:28     1.9
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Template.java,v 1.8 2001/06/19 10:44:12 morten Exp $
  + * @(#)$Id: Template.java,v 1.9 2001/07/10 17:45:28 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -59,6 +59,7 @@
    * @author Jacek Ambroziak
    * @author Santiago Pericas-Geertsen
    * @author Morten Jorgensen
  + * @author Erwin Bolwidt <[EMAIL PROTECTED]>
    *
    */
   
  @@ -209,7 +210,7 @@
   
       private Stylesheet _stylesheet = null;
   
  -    protected Stylesheet getStylesheet() {
  +    public Stylesheet getStylesheet() {
        return _stylesheet;
       }
   
  @@ -313,13 +314,18 @@
        final String DOM_CLASS_SIG = classGen.getDOMClassSig();
   
        if (_compiled && isNamed()){
  +
  +         String methodName = _name.toString();
  +         methodName = methodName.replace('.', '$');
  +         methodName = methodName.replace('-', '$');
  +
            il.append(classGen.loadTranslet());
            il.append(methodGen.loadDOM());
            il.append(methodGen.loadIterator());
            il.append(methodGen.loadHandler()); 
            il.append(methodGen.loadCurrentNode()); 
            il.append(new INVOKEVIRTUAL(cpg.addMethodref(className,
  -                                                      _name.toString(),
  +                                                      methodName,
                                                         "("
                                                         + DOM_CLASS_SIG
                                                         + NODE_ITERATOR_SIG
  
  
  
  1.2       +6 -3      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/TestSeq.java
  
  Index: TestSeq.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/TestSeq.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestSeq.java      2001/04/17 18:51:49     1.1
  +++ TestSeq.java      2001/07/10 17:45:30     1.2
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: TestSeq.java,v 1.1 2001/04/17 18:51:49 sboag Exp $
  + * @(#)$Id: TestSeq.java,v 1.2 2001/07/10 17:45:30 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -58,6 +58,7 @@
    *
    * @author Jacek Ambroziak
    * @author Santiago Pericas-Geertsen
  + * @author Erwin Bolwidt <[EMAIL PROTECTED]>
    *
    */
   
  @@ -172,8 +173,10 @@
                // apply the actual pattern
                il.append(pattern.compile(classGen, methodGen));
                // on success (fallthrough) goto template code
  -             final InstructionHandle success =
  -                 il.append(new 
GOTO(getTemplateHandle(pattern.getTemplate())));
  +             final Template template = pattern.getTemplate();
  +             final InstructionHandle gtmpl = getTemplateHandle(template);
  +             final InstructionHandle success = il.append(new GOTO_W(gtmpl));
  +
                pattern.backPatchTrueList(success);
                pattern.backPatchFalseList(fail);
                // the failure of the preceding test will lead to this test
  
  
  
  1.9       +8 -3      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Variable.java
  
  Index: Variable.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Variable.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Variable.java     2001/07/09 10:17:43     1.8
  +++ Variable.java     2001/07/10 17:45:31     1.9
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Variable.java,v 1.8 2001/07/09 10:17:43 morten Exp $
  + * @(#)$Id: Variable.java,v 1.9 2001/07/10 17:45:31 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -59,6 +59,7 @@
    * @author Jacek Ambroziak
    * @author Santiago Pericas-Geertsen
    * @author Morten Jorgensen
  + * @author Erwin Bolwidt <[EMAIL PROTECTED]>
    *
    */
   
  @@ -307,7 +308,9 @@
        if (isLocal() && !_refs.isEmpty()) {
            // Create a variable slot if none is allocated
            if (_local == null) {
  -             final String name = _name.getLocalPart();
  +             String name = _name.getLocalPart();
  +             name = name.replace('.', '_');
  +             name = name.replace('-', '_');
                _local = methodGen.addLocalVariable2(name,
                                                     _type.toJCType(),
                                                     il.getEnd());
  @@ -351,7 +354,9 @@
       public void translate(ClassGenerator classGen, MethodGenerator 
methodGen) {
        final ConstantPoolGen cpg = classGen.getConstantPool();
        final InstructionList il = methodGen.getInstructionList();
  -     final String name = _name.getLocalPart();
  +     String name = _name.getLocalPart();
  +     name = name.replace('.', '_');
  +        name = name.replace('-', '_');
   
        // Make sure that a variable instance is only compiled once
        if (_compiled) return;
  
  
  
  1.3       +5 -2      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/VariableRef.java
  
  Index: VariableRef.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/VariableRef.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- VariableRef.java  2001/06/28 15:36:21     1.2
  +++ VariableRef.java  2001/07/10 17:45:33     1.3
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: VariableRef.java,v 1.2 2001/06/28 15:36:21 morten Exp $
  + * @(#)$Id: VariableRef.java,v 1.3 2001/07/10 17:45:33 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -59,6 +59,7 @@
    * @author Jacek Ambroziak
    * @author Santiago Pericas-Geertsen
    * @author Morten Jorgensen
  + * @author Erwin Bolwidt <[EMAIL PROTECTED]>
    *
    */
   
  @@ -117,7 +118,9 @@
        final InstructionList il = methodGen.getInstructionList();
                
        final Type varType = _variable.getType();
  -     final String varName = _variable.getName().getLocalPart();
  +     String varName = _variable.getName().getLocalPart();
  +     varName = varName.replace('.', '_');
  +        varName = varName.replace('-', '_');
   
        if (varType.implementedAsMethod()) {
            // Fall-through for variables that are implemented as methods
  
  
  
  1.11      +51 -115   
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/XSLTC.java
  
  Index: XSLTC.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/XSLTC.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- XSLTC.java        2001/06/27 19:03:07     1.10
  +++ XSLTC.java        2001/07/10 17:45:34     1.11
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: XSLTC.java,v 1.10 2001/06/27 19:03:07 tmiller Exp $
  + * @(#)$Id: XSLTC.java,v 1.11 2001/07/10 17:45:34 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -170,24 +170,62 @@
        _multiDocument = flag;
       }
   
  -    // GTM: TBD this is a prototype to handle input stream input..
  -    public boolean compile(InputStream input, String transletName) {
  -     return compile(input, transletName, null);
  +    /**
  +     *
  +     */
  +    public boolean compile(URL url) { 
  +     return compile(url, null);
       }
  -    // GTM: TBD this is a prototype, copied and modified fr compile(URL..)
  -    public boolean compile(InputStream input, String transletName,
  -     ErrorListener elistener) 
  -    {
  -     if (elistener != null) {
  -         _parser.setErrorListener(elistener);
  +
  +    /**
  +     *
  +     */
  +    public boolean compile(URL url, ErrorListener listener) {
  +     try {
  +         final String name = Util.baseName(url.getFile());
  +         final InputStream input = url.openStream();
  +         return compile(input, name, url, listener);
  +     }
  +     catch (MalformedURLException e) {
  +         _parser.reportError(Constants.FATAL, new ErrorMsg(e.getMessage()));
  +         _parser.printErrors();
  +         return false;
        }
  +     catch (IOException e) {
  +         _parser.reportError(Constants.FATAL, new ErrorMsg(e.getMessage()));
  +         _parser.printErrors();
  +         return false;
  +     }
  +    }
  +
  +    /**
  +     *
  +     */
  +    public boolean compile(InputStream input, String transletName) {
  +     return compile(input, transletName, null, null);
  +    }
  +
  +    /**
  +     *
  +     */
  +    public boolean compile(InputStream input,
  +                        String transletName,
  +                        URL url,
  +                        ErrorListener listener) {
  +
  +     // Set the parser's error listener if defined
  +     if (listener != null) _parser.setErrorListener(listener);
  +
        try {
  +         // Reset globals in case we're called by compile(Vector v);
            reset();
  -         final String name = transletName;
  +
  +         // Set the translet's class name
            setClassName(transletName);
   
            // Get the root node of the abstract syntax tree
            final SyntaxTreeNode element = _parser.parse(input);
  +
            // Process any error and/or warning messages
            _parser.printWarnings();
            if (_parser.errorsFound()) {
  @@ -195,9 +233,10 @@
                return false;
            }
   
  +         // Compile the translet - this is where the work is done!
            if ((!_parser.errorsFound()) && (element != null)) {
                _stylesheet = _parser.makeStylesheet(element);
  -             //_stylesheet.setURL(url);
  +             _stylesheet.setURL(url);
                // This is the top level stylesheet - it has no parent
                _stylesheet.setParentStylesheet(null);
                _parser.setCurrentStylesheet(_stylesheet);
  @@ -223,79 +262,7 @@
            return false;  
        }
       }
  -    
  -    
  -    /**
  -     * Compiles the stylesheet into Java bytecode. Returns 'true' if the
  -     * compilation was successful - 'false' otherwise.
  -     */
  -    public boolean compile(URL stylesheet) { 
  -     return compile(stylesheet, null);   
  -    }
  -    
  -    /**
  -     * Compile stylesheet into Java bytecode. Returns 'true' if compilation
  -     * is successful. - 'false' otherwise. ErrorListener arg (may be null)
  -     * added to support TrAX API.
  -     */
  -    public boolean compile(URL url, ErrorListener elistener) {
  -     if (elistener != null) {
  -         _parser.setErrorListener(elistener);
  -     }
  -     try {
  -         reset();
  -         final String name = url.getFile();
  -         if (_className == null) {
  -             final String baseName = Util.baseName(name);
  -             setClassName(Util.toJavaName(Util.noExtName(baseName)));
  -         }
  -         
  -         // Get the root node of the abstract syntax tree
  -         final SyntaxTreeNode element = _parser.parse(url);
  -
  -         // Process any error and/or warning messages found so far...
  -         if ((_parser.errorsFound()) || (element == null)) {
  -             _parser.printWarnings();
  -             _parser.printErrors();
  -             return false;
  -         }
  -
  -         // Create the abstract syntax tree and parse each node in it
  -         _stylesheet = _parser.makeStylesheet(element);
  -         _stylesheet.setURL(url);
  -         _stylesheet.setParentStylesheet(null);
  -         _parser.setCurrentStylesheet(_stylesheet);
  -         _parser.createAST(_stylesheet);
  -
  -         // Process any error and/or warning messages found so far...
  -         if ((_parser.errorsFound()) || (_stylesheet == null)) {
  -             _parser.printWarnings();
  -             _parser.printErrors();
  -             return false;
  -         }
   
  -         // Compile the translet
  -         _stylesheet.setMultiDocument(_multiDocument);
  -         _stylesheet.translate();
  -
  -         // Process any error and/or warning messages found so far...
  -         if ((_parser.errorsFound()) || (_stylesheet == null)) {
  -             _parser.printWarnings();
  -             _parser.printErrors();
  -             return false;
  -         }
  -
  -         _parser.printWarnings();
  -         return true;
  -     }
  -     catch (CompilerException e) {
  -         e.printStackTrace();
  -         _parser.reportError(Constants.FATAL, new ErrorMsg(e.getMessage()));
  -         _parser.printErrors();
  -         return false;  
  -     }
  -    }
  -    
       private boolean compile(Vector stylesheets) {
        final int nStylesheets = stylesheets.size();
        /*
  @@ -439,37 +406,6 @@
        return code.intValue();
       }
       
  -    /**
  -     * Aborts the execution of the compiler if something found in the source 
  -     * file can't be compiled. It also prints which feature is not 
implemented 
  -     * if specified.
  -     */
  -    /*
  -    public void notYetImplemented(String feature) {
  -     System.err.println("'"+feature+"' is not supported by XSLTC.");
  -     if (debug()) {
  -         _parser.errorsFound(); // print stack
  -     }
  -     doSystemExit(1); throw new RuntimeException("System.exit(1) here!");
  -    }
  -    */
  -
  -    /**
  -     * Aborts the execution of the compiler if something found in the source 
  -     * file can't be compiled. It also prints which feature is not 
implemented 
  -     * if specified.
  -     */
  -    /*
  -    public void extensionNotSupported(String feature) {
  -     System.err.println("Extension element '"+feature+
  -                        "' is not supported by XSLTC.");
  -     if (debug()) {
  -         _parser.errorsFound(); // print stack
  -     }
  -     doSystemExit(1); throw new RuntimeException("System.exit(1) here!");
  -    }
  -    */
  -
       public int nextVariableSerial() {
        return _variableSerial++;
       }
  
  
  
  1.8       +7 -1      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/XslAttribute.java
  
  Index: XslAttribute.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/XslAttribute.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- XslAttribute.java 2001/06/11 12:53:05     1.7
  +++ XslAttribute.java 2001/07/10 17:45:35     1.8
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: XslAttribute.java,v 1.7 2001/06/11 12:53:05 morten Exp $
  + * @(#)$Id: XslAttribute.java,v 1.8 2001/07/10 17:45:35 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -59,6 +59,7 @@
    * @author Jacek Ambroziak
    * @author Santiago Pericas-Geertsen
    * @author Morten Jorgensen
  + * @author Erwin Bolwidt <[EMAIL PROTECTED]>
    *
    */
   
  @@ -121,9 +122,14 @@
        for (int i = 0; i < parent.elementCount(); i++) {
            SyntaxTreeNode item = (SyntaxTreeNode)siblings.elementAt(i);
            if (item == this) break;
  +         // These three objects result in one or more attribute output
            if (item instanceof XslAttribute) continue;
            if (item instanceof UseAttributeSets) continue;
            if (item instanceof LiteralAttribute) continue;
  +         // These objects _can_ result in one or more attribute
  +         // The output handler will generate an error if not (at runtime)
  +         if (item instanceof If) continue;
  +         if (item instanceof Choose) continue;
            _ignore = true;
            reportWarning(this, parser, ErrorMsg.ATTROUTS_ERR, name);
            return;
  
  
  
  1.2       +25 -5     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ErrorMsg.java
  
  Index: ErrorMsg.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ErrorMsg.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ErrorMsg.java     2001/04/17 18:52:14     1.1
  +++ ErrorMsg.java     2001/07/10 17:46:08     1.2
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: ErrorMsg.java,v 1.1 2001/04/17 18:52:14 sboag Exp $
  + * @(#)$Id: ErrorMsg.java,v 1.2 2001/07/10 17:46:08 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -59,6 +59,7 @@
    * @author Jacek Ambroziak
    * @author Santiago Pericas-Geertsen
    * @author G. Todd Miller
  + * @author Erwin Bolwidt <[EMAIL PROTECTED]>
    *
    */
   
  @@ -66,12 +67,14 @@
   
   import org.apache.xalan.xsltc.compiler.SyntaxTreeNode;
   
  +import java.net.URL;
   import java.text.MessageFormat;
   
   public final class ErrorMsg {
       private int _code;
       private int _line;
       private String _message = null;
  +    private String _url = null;
       Object[] _params = null;
        
       public static final int STLREDEF_ERR = 0;
  @@ -158,11 +161,13 @@
   
       public ErrorMsg(int code, SyntaxTreeNode node) {
        _code = code;
  +     _url  = getFileName(node);
        _line = node.getLineNumber();
       }
   
       public ErrorMsg(int code, Object param1, SyntaxTreeNode node) {
        _code = code;
  +     _url  = getFileName(node);
        _line = node.getLineNumber();
        _params = new Object[1];
        _params[0] = param1;
  @@ -171,18 +176,33 @@
       public ErrorMsg(int code, Object param1, Object param2,
                    SyntaxTreeNode node) {
        _code = code;
  +     _url  = getFileName(node);
        _line = node.getLineNumber();
        _params = new Object[2];
        _params[0] = param1;
        _params[1] = param2;
       }
   
  -    String formatLine() {
  -     String result = "";
  +    private String getFileName(SyntaxTreeNode node) {
  +     final URL url = node.getStylesheet().getURL();
  +     if (url != null)
  +         return url.toString();
  +     else
  +         return null;
  +    }
  +
  +    private String formatLine() {
  +     StringBuffer result = new StringBuffer();
  +     if (_url != null) {
  +         result.append(_url);
  +         result.append(": ");
  +     }
        if (_line > 0) {
  -         result = "Line " + Integer.toString(_line) + ", ";
  +         result.append("Line ");
  +         result.append(Integer.toString(_line));
  +         result.append(": ");
        }
  -     return result;
  +     return result.toString();
       }
        
       /**
  
  
  
  1.4       +17 -2     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ReferenceType.java
  
  Index: ReferenceType.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ReferenceType.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ReferenceType.java        2001/06/17 12:23:34     1.3
  +++ ReferenceType.java        2001/07/10 17:46:10     1.4
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: ReferenceType.java,v 1.3 2001/06/17 12:23:34 curcuru Exp $
  + * @(#)$Id: ReferenceType.java,v 1.4 2001/07/10 17:46:10 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -58,6 +58,7 @@
    *
    * @author Jacek Ambroziak
    * @author Santiago Pericas-Geertsen
  + * @author Erwin Bolwidt <[EMAIL PROTECTED]>
    *
    */
   
  @@ -108,6 +109,9 @@
        else if (type == Type.NodeSet) {
            translateTo(classGen, methodGen, (NodeSetType) type);
        }
  +     else if (type == Type.Node) {
  +         translateTo(classGen, methodGen, (NodeType) type);
  +     }
        else {
            classGen.getParser().internalError();               // undefined
        }
  @@ -194,11 +198,22 @@
       }
   
       /**
  +     * Casts a reference into a Node.
  +     *
  +     * @see org.apache.xalan.xsltc.compiler.util.Type#translateTo
  +     */
  +    public void translateTo(ClassGenerator classGen, MethodGenerator 
methodGen,
  +                         NodeType type) {
  +     translateTo(classGen, methodGen, Type.NodeSet);
  +     Type.NodeSet.translateTo(classGen, methodGen, type);
  +    }
  +
  +    /**
        * Expects a reference on the stack and translates it to a 
non-synthesized
        * boolean. It does not push a 0 or a 1 but instead returns branchhandle 
        * list to be appended to the false list.
        *
  -     * @see  
org.apache.xalan.xsltc.compiler.util.Type#translateToDesynthesized
  +     * @see 
org.apache.xalan.xsltc.compiler.util.Type#translateToDesynthesized
        */
       public FlowList translateToDesynthesized(ClassGenerator classGen, 
                                             MethodGenerator methodGen, 
  
  
  
  1.3       +4 -3      
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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MultiDOM.java     2001/05/22 17:26:43     1.2
  +++ MultiDOM.java     2001/07/10 17:46:18     1.3
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: MultiDOM.java,v 1.2 2001/05/22 17:26:43 morten Exp $
  + * @(#)$Id: MultiDOM.java,v 1.3 2001/07/10 17:46:18 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -58,6 +58,7 @@
    *
    * @author Jacek Ambroziak
    * @author Morten Jorgensen
  + * @author Erwin Bolwidt <[EMAIL PROTECTED]>
    *
    */
   
  @@ -121,7 +122,7 @@
        }
   
        public NodeIterator reset() {
  -         _source.reset();
  +         if (_source != null) _source.reset();
            return this;
        }
       
  @@ -306,7 +307,7 @@
       }
   
       public void setFilter(StripWhitespaceFilter filter) {
  -     for (int dom=0; dom<_adapters.length; dom++) {
  +     for (int dom=0; dom<_free; dom++) {
            _adapters[dom].setFilter(filter);
        }
       }
  
  
  
  1.2       +5 -2      
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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StepIterator.java 2001/04/17 18:52:36     1.1
  +++ StepIterator.java 2001/07/10 17:46:20     1.2
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: StepIterator.java,v 1.1 2001/04/17 18:52:36 sboag Exp $
  + * @(#)$Id: StepIterator.java,v 1.2 2001/07/10 17:46:20 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -58,6 +58,7 @@
    *
    * @author Jacek Ambroziak
    * @author Santiago Pericas-Geertsen
  + * @author Erwin Bolwidt <[EMAIL PROTECTED]>
    *
    */
   
  @@ -82,7 +83,9 @@
            clone._source = _source.cloneIterator();
            clone._iterator = _iterator.cloneIterator();
            // Special case -> _iterator must be restartable
  -         ((NodeIteratorBase)(clone._iterator))._isRestartable = true;
  +         if (clone._iterator instanceof NodeIteratorBase) {
  +             ((NodeIteratorBase)(clone._iterator))._isRestartable = true;
  +         }
            return clone.reset();
        }
        catch (CloneNotSupportedException e) {
  
  
  
  1.8       +15 -1     
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/BasisLibrary.java
  
  Index: BasisLibrary.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/BasisLibrary.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- BasisLibrary.java 2001/07/09 10:17:52     1.7
  +++ BasisLibrary.java 2001/07/10 17:46:26     1.8
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: BasisLibrary.java,v 1.7 2001/07/09 10:17:52 morten Exp $
  + * @(#)$Id: BasisLibrary.java,v 1.8 2001/07/10 17:46:26 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -59,6 +59,7 @@
    * @author Jacek Ambroziak
    * @author Santiago Pericas-Geertsen
    * @author Morten Jorgensen
  + * @author Erwin Bolwidt <[EMAIL PROTECTED]>
    *
    */
   
  @@ -362,6 +363,19 @@
        idx = value.lastIndexOf('@');
        if (idx >= 0) value = value.substring(idx + 1);
        return(value);
  +    }
  +
  +    /**
  +     * External functions that cannot be resolved are replaced with a call
  +     * to this method. This method will generate a runtime errors. A good
  +     * stylesheet checks whether the function exists using conditional
  +     * constructs, and never really tries to call it if it doesn't exist.
  +     * But simple stylesheets may result in a call to this method.
  +     * The compiler should generate a warning if it encounters a call to
  +     * an unresolved external function.
  +     */
  +    public static void unresolved_externalF(String name) {
  +     runTimeError("External function '"+name+"' not supported by XSLTC.");
       }
   
       /**
  
  
  

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

Reply via email to