morten      01/09/25 05:59:56

  Modified:    java/src/org/apache/xalan/xsltc/compiler Param.java
                        Stylesheet.java Variable.java VariableBase.java
  Log:
  Fix to resolving multiple defined global variables or parameters.
  PR:           bugzilla 3404
  Obtained from:        n/a
  Submitted by: [EMAIL PROTECTED]
  Reviewed by:  [EMAIL PROTECTED]
  
  Revision  Changes    Path
  1.14      +7 -12     
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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Param.java        2001/09/24 12:27:39     1.13
  +++ Param.java        2001/09/25 12:59:56     1.14
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Param.java,v 1.13 2001/09/24 12:27:39 morten Exp $
  + * @(#)$Id: Param.java,v 1.14 2001/09/25 12:59:56 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -149,22 +149,17 @@
                final int them = param.getImportPrecedence();
                // It is an error if the two have the same import precedence
                if (us == them) {
  -                 System.err.println("FOOOOOOOOOOOOOO!");
  -                 System.err.println("us = "+this);
  -                 System.err.println("us parent = "+
  -                                    ((Stylesheet)getParent()).getSystemId());
  -                 System.err.println("us prec. = "+us);
  -                 System.err.println("them = "+param);
  -                 System.err.println("them parent = "+
  -                                    
((Stylesheet)param.getParent()).getSystemId());
  -                 System.err.println("them prec = "+them);
                    reportError(this, parser, ErrorMsg.VARREDEF_ERR,
                                _name.toString());
                }
                // Ignore this if previous definition has higher precedence
                else if (them > us) {
  +                 _ignore = true;
                    return;
                }
  +             else {
  +                 param.disable();
  +             }
            }
            // Add this variable if we have higher precedence
            ((Stylesheet)parent).addParam(this);
  @@ -205,8 +200,8 @@
        final ConstantPoolGen cpg = classGen.getConstantPool();
        final InstructionList il = methodGen.getInstructionList();
   
  -     if (_compiled) return;
  -     _compiled = true;
  +     if (_ignore) return;
  +     _ignore = true;
   
        final String name = getVariable();
        final String signature = _type.toSignature();
  
  
  
  1.18      +2 -13     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Stylesheet.java
  
  Index: Stylesheet.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Stylesheet.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Stylesheet.java   2001/09/24 12:27:39     1.17
  +++ Stylesheet.java   2001/09/25 12:59:56     1.18
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Stylesheet.java,v 1.17 2001/09/24 12:27:39 morten Exp $
  + * @(#)$Id: Stylesheet.java,v 1.18 2001/09/25 12:59:56 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -141,23 +141,12 @@
        return _multiDocument;
       }
   
  -    /*
  -    public boolean isImported() {
  -     final SyntaxTreeNode parent = getParent();
  -     return ((parent != null) && (parent instanceof Import));
  -    }
  -
  -    public boolean isIncluded() {
  -     final SyntaxTreeNode parent = getParent();
  -     return ((parent != null) && (parent instanceof Include));
  -    }
  -    */
  -
       public void numberFormattingUsed() {
        _numberFormattingUsed = true;
       }
   
       public void setImportPrecedence(final int precedence) {
  +     //System.err.println("PREC="+precedence+" for "+getSystemId());
        // Set import precedence for this stylesheet
        _importPrecedence = precedence;
   
  
  
  
  1.17      +7 -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.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- Variable.java     2001/09/17 08:20:54     1.16
  +++ Variable.java     2001/09/25 12:59:56     1.17
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Variable.java,v 1.16 2001/09/17 08:20:54 morten Exp $
  + * @(#)$Id: Variable.java,v 1.17 2001/09/25 12:59:56 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -147,8 +147,12 @@
                }
                // Ignore this if previous definition has higher precedence
                else if (them > us) {
  +                 _ignore = true;
                    return;
                }
  +             else {
  +                 var.disable();
  +             }
                // Add this variable if we have higher precedence
            }
            ((Stylesheet)parent).addVariable(this);
  @@ -219,8 +223,8 @@
        final String name = getVariable();
   
        // Make sure that a variable instance is only compiled once
  -     if (_compiled) return;
  -     _compiled = true;
  +     if (_ignore) return;
  +     _ignore = true;
   
        if (isLocal()) {
            // Push args to call addVariable()
  
  
  
  1.6       +9 -2      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/VariableBase.java
  
  Index: VariableBase.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/VariableBase.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- VariableBase.java 2001/09/20 14:55:42     1.5
  +++ VariableBase.java 2001/09/25 12:59:56     1.6
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: VariableBase.java,v 1.5 2001/09/20 14:55:42 morten Exp $
  + * @(#)$Id: VariableBase.java,v 1.6 2001/09/25 12:59:56 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -90,7 +90,14 @@
       protected Vector      _refs = new Vector(2); 
   
       // Used to make sure parameter field is not added twice
  -    protected boolean    _compiled = false;
  +    protected boolean    _ignore = false;
  +
  +    /**
  +     * Disable this variable/parameter
  +     */
  +    public void disable() {
  +     _ignore = true;
  +    }
   
       /**
        * Add a reference to this variable. Called by VariableRef when an
  
  
  

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

Reply via email to