Re: multiple assignment

bonzini@gnu.org
6 Mar 2000 01:07:07 -0500

          From comp.compilers

Related articles
multiple assignment mklarson@gte.net (Michael Larson) (2000-02-28)
Re: multiple assignment Jens_Kilian@agilent.com (Jens Kilian) (2000-03-06)
Re: multiple assignment rkrayhawk@aol.com (2000-03-06)
Re: multiple assignment bonzini@gnu.org (2000-03-06)
| List of all articles for this month |

From: bonzini@gnu.org
Newsgroups: comp.compilers
Date: 6 Mar 2000 01:07:07 -0500
Organization: Deja.com - Before you buy.
References: 00-02-160
Keywords: parse, code

mklarson@gte.net wrote:


> I have a testbed compiler for a simple C dialect (Renderman Shading
> Language). One of the problems I am having with evaluating the parse
> tree is with multiple assignement. It should be clean but it really is
> a hack for a recusive evaluator.
>
> a = b = c + 1
>
> [requires]
>
> pop b
> push b


You should implement a 'store' bytecode. Simple single assignments
would be compiled as 'store b' + 'pop top' (pop top is generated
by the semicolon) and then peephole-optimized to 'pop b'. If your
hack works for horrible C hacks as


          foo(a = b);


you can modify it to be a kind of 'in-place' peephole optimization.
So it would lose its hack status and become an elegant solution...


Paolo Bonzini


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.