dotgnu-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [DotGNU] treecc help required


From: Gomi Kapoor
Subject: Re: [DotGNU] treecc help required
Date: Fri, 31 Dec 2004 15:06:45 +0000 (GMT)

Hi guys,
Thanks for all the replies. I am just getting the hang
of using treecc.

Regards,
Gomi
 --- Gopal V <address@hidden> wrote: 
> Hi,
> 
> >  One major issue which I faced coming with this
> >  simple  implementation is casting between 
> >  Instruction* and other derived nodes. 
> >  I found that casting  between them to be very
> >  tedious.
> 
> The casting is the only way to do it. Even if
> you did it in *any* statically typed language in 
> the world, you would have to put the casts.
> 
> Imagine you do it in C# or Java with the following
> 
> %node Binary Instruction = 
> {
>       Opcode op;
>       Instruction x;
>       Instruction y;
> }
> 
> %node ArithOp Binary
> 
> Now the optimize code would look like 
> 
> Optimize(ArithOp)
> {
>    if ((inst.x is Constant) && (inst.y is Constant))
>    {
>      switch(inst.op) 
>      {
>        case ADD:
>        return new Constant((inst.x as
> Constant).value 
>                        + (inst.y as
> Constant).value));
>      }
>    }
>    return inst;
> }
> 
> There is no way you can get out of this without
> using
> some kind or other of casts (except if you do this
> in Python.. LOL).
> 
> I'm sure it doesn't look that different to you :)
> 
> >  I feel that I am  doing a basic mistake in using 
> >  treecc. Would you  mind commenting on the way I
> >  have (mis)used in the attached  simple 
> >  implementation.
> 
> Seems to be pretty much the way it should be done.
> The english speakers might have read that as if you
> made the mistake of choosing treecc, rather than
> just
> using it badly.
> 
> The advantage of using treecc is that you get 
> yykindname and yyisa in C , to allow dynamic 
> "safe" casts and all that :)
> 
> Gopal
> 
> 
>       
>               
> __________________________________ 
> Do you Yahoo!? 
> Yahoo! Mail - You care about security. So do we. 
> http://promotions.yahoo.com/new_mail
> _______________________________________________
> Developers mailing list
> address@hidden
> http://dotgnu.org/mailman/listinfo/developers
>  

________________________________________________________________________
Yahoo! India Matrimony: Find your life partner online
Go to: http://yahoo.shaadi.com/india-matrimony


reply via email to

[Prev in Thread] Current Thread [Next in Thread]