Since CastExpr(...) pokes around to determine if a particular cast is valid
(and throws an exception if one isn't), perhaps a better patch would be:

diff -u -r1.3 NameBase.java
--- NameBase.java       2001/06/17 12:23:30     1.3
+++ NameBase.java       2001/06/29 22:06:19
@@ -107,8 +107,10 @@
            throw new TypeCheckError(this);
        }
 
-       if ((_type != Type.NodeSet) && (_type != Type.Node))
-           throw new TypeCheckError(this);
+        if ((_type != Type.NodeSet) && (_type != Type.Node)) {
+            _param = new CastExpr(_param, Type.NodeSet);
+            _type = Type.NodeSet;
+        }
 
        return Type.String;
     }

But is a conversion to a NodeSet better than a Node?

> -----Original Message-----
> From: Ovidiu Predescu [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 28, 2001 7:54 PM
> To: John Howard
> Cc: '[EMAIL PROTECTED]'
> Subject: Re: PATCH for 2343 - typecheck error invoking name(...) with
> templat e parameter arg 
> 
> 
> Somebody else, more knowledgeable with XSLTC than me, should comment
> on your patch.
> 
> However after looking at your patch, I don't understand why would we
> do a cast to NodeSet for ReferenceType nodes, but not for the other
> types?
> 
> And another thing, really a style issue, why not writing the code
> like:
> 
>         if(_type == Type.Reference) {
>            _param = new CastExpr(_param, Type.NodeSet);
>            _type = Type.NodeSet;
>         }
>         else if ((_type != Type.NodeSet) && (_type != Type.Node))
>             throw new TypeCheckError(this);
> 
> 
> Regards,
> -- 
> Ovidiu Predescu <[EMAIL PROTECTED]>
> http://orion.nsr.hp.com/ (inside HP's firewall only)
> http://sourceforge.net/users/ovidiu/ (my SourceForge page)
> http://www.geocities.com/SiliconValley/Monitor/7464/ (GNU, 
> Emacs, other stuff)
> 
> 
> On Thu, 28 Jun 2001 17:57:09 -0700, John Howard 
> <[EMAIL PROTECTED]> wrote:
> 
> > On Thursday, June 28, 2001 5:34 PM, Ovidiu Predescu
> > [mailto:[EMAIL PROTECTED]] wrote:
> > > 
> > > [snip]
> > > 
> > > Generating unidiff patches gives a little bit more of 
> context to your
> > > changes and is less strict with regard to changes in the 
> original file
> > > since you're generated your patch.
> > > 
> > 
> > Thanks for the feedback, is this more helpful?
> > 
> > cvs -q diff NameBase.java (in directory
> > C:\local\xml-xalan\java\src\org\apache\xalan\xsltc\compiler\)
> > Index: NameBase.java
> > ===================================================================
> > RCS file:
> > 
> /home/cvspublic/xml-xalan/java/src/org/apache/xalan/xsltc/comp
> iler/NameBase.
> > java,v
> > retrieving revision 1.3
> > diff -u -r1.3 NameBase.java
> > --- NameBase.java   2001/06/17 12:23:30     1.3
> > +++ NameBase.java   2001/06/29 00:48:12
> > @@ -107,6 +107,11 @@
> >         throw new TypeCheckError(this);
> >     }
> >  
> > +   if(_type == Type.Reference) {
> > +            _param = new CastExpr(_param, Type.NodeSet);
> > +            _type = Type.NodeSet;
> > +        }
> > +
> >     if ((_type != Type.NodeSet) && (_type != Type.Node))
> >         throw new TypeCheckError(this);
> > 
> 

Reply via email to