You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mo...@apache.org on 2001/05/17 13:05:43 UTC

cvs commit: xml-xalan/java/src/org/apache/xalan/xsltc/compiler Variable.java

morten      01/05/17 04:05:43

  Modified:    java/src/org/apache/xalan/xsltc/compiler Variable.java
  Log:
  Added code that resolved import precedence for multiple declarations of the
  same global variable/parameter. This fix would not have had any effect
  without the previous, recent fix for bug 1487 (in Stylesheet.java).
  PR:		bugzilla 1408 (related and dependent on fix for 1487)
  Obtained from:	n/a
  Submitted by:	morten@xml.apache.org
  Reviewed by:	morten@xml.apache.org
  
  Revision  Changes    Path
  1.3       +22 -4     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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Variable.java	2001/05/02 10:25:15	1.2
  +++ Variable.java	2001/05/17 11:05:38	1.3
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Variable.java,v 1.2 2001/05/02 10:25:15 morten Exp $
  + * @(#)$Id: Variable.java,v 1.3 2001/05/17 11:05:38 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -196,7 +196,7 @@
   	    ErrorMsg error = new ErrorMsg(ErrorMsg.VARREDEF_ERR, _name, this);
   	    parser.addError(error);
   	}
  -	
  +
   	final String select = element.getAttribute("select");
   	if (select.length() > 0) {
   	    _select = parser.parseExpression(this, element, "select");
  @@ -206,11 +206,29 @@
   	parseChildren(element, parser);
   
   	// Add a ref to this var to its enclosing construct
  -	final SyntaxTreeNode parent = getParent();
  +	SyntaxTreeNode parent = getParent();
   	if (parent instanceof Stylesheet) {
  +	    // Mark this as a global variable
   	    _isLocal = false;
  +	    // Check if a global variable with this name already exists...
  +	    Variable var = parser.getSymbolTable().lookupVariable(_name);
  +	    // ...and if it does we need to check import precedence
  +	    if (var != null) {
  +		final int us = this.getImportPrecedence();
  +		final int them = var.getImportPrecedence();
  +		// It is an error if the two have the same import precedence
  +		if (us == them) {
  +		    ErrorMsg error =
  +			new ErrorMsg(ErrorMsg.VARREDEF_ERR, _name, this);
  +		    parser.addError(error);
  +		}
  +		// Ignore this if previous definition has higher precedence
  +		else if (them > us) {
  +		    return;
  +		}
  +		// Add this variable if we have higher precedence
  +	    }
   	    ((Stylesheet)parent).addVariable(this);
  -	    //!! check for redef
   	    parser.getSymbolTable().addVariable(this);
   	}
   	else {
  
  
  

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