morten      01/11/01 02:53:25

  Modified:    java/src/org/apache/xalan/xsltc/compiler Parser.java
  Log:
  Fix for re-definitions of variables inside templates (in different scopes).
  PR:           bugzilla 3406
  Obtained from:        n/a
  Submitted by: [EMAIL PROTECTED]
  Reviewed by:  [EMAIL PROTECTED]
  
  Revision  Changes    Path
  1.32      +37 -4     
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.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- Parser.java       2001/10/31 08:31:56     1.31
  +++ Parser.java       2001/11/01 10:53:25     1.32
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Parser.java,v 1.31 2001/10/31 08:31:56 morten Exp $
  + * @(#)$Id: Parser.java,v 1.32 2001/11/01 10:53:25 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -167,19 +167,52 @@
       }
   
       public void addVariable(Variable var) {
  -     _variableScope.put(var.getName(), var);
  +     addVariableOrParam(var);
       }
   
       public void addParameter(Param param) {
  -     _variableScope.put(param.getName(), param);
  +     addVariableOrParam(param);
       }
   
  +    private void addVariableOrParam(VariableBase var) {
  +     Object existing = _variableScope.get(var.getName());
  +     if (existing != null) {
  +         if (existing instanceof Stack) {
  +             Stack stack = (Stack)existing;
  +             stack.push(var);
  +         }
  +         else if (existing instanceof VariableBase) {
  +             Stack stack = new Stack();
  +             stack.push(existing);
  +             stack.push(var);
  +             _variableScope.put(var.getName(), stack);
  +         }
  +     }
  +     else {
  +         _variableScope.put(var.getName(), var);
  +     }
  +    }
  +
       public void removeVariable(QName name) {
  +     Object existing = _variableScope.get(name);
  +     if (existing instanceof Stack) {
  +         Stack stack = (Stack)existing;
  +         if (!stack.isEmpty()) stack.pop();
  +         if (!stack.isEmpty()) return;
  +     }
        _variableScope.remove(name);
       }
   
       public VariableBase lookupVariable(QName name) {
  -     return((VariableBase)_variableScope.get(name));
  +     Object existing = _variableScope.get(name);
  +     if (existing instanceof VariableBase) {
  +         return((VariableBase)existing);
  +     }
  +     else if (existing instanceof Stack) {
  +         Stack stack = (Stack)existing;
  +         return((VariableBase)stack.peek());
  +     }
  +     return(null);
       }
   
       public void setXSLTC(XSLTC xsltc) {
  
  
  

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

Reply via email to