[Jastadd] Fwd: RE: JastAdd bug report: rewrite to List

From: Emma Söderberg <emma.soderberg_at_cs.lth.se>
Date: Mon, 27 Feb 2012 22:47:37 +0100

Hi Jesper,

Thanks for your reply. I'm forwarding it to the jastadd list. I'll get
back to you with comments about this issue.

Cheers,
Emma

-------- Original Message --------
Subject: RE: [Jastadd] JastAdd bug report: rewrite to List
Date: Mon, 27 Feb 2012 02:43:33 -0800
From: Jesper Mattsson <jesper.mattsson_at_modelon.com>
To: Emma Söderberg <emma.soderberg_at_cs.lth.se>



Hi Emma

Sorry for the delay.

Right now I am using it to eliminate if-equations with constant test
expressions. In this case we insert the equations in the reachable
branch into the list that contained the if-equation. Currently it is a
rewrite that in the case of only one reachable branch results in an
FElseEquation, that is normally only used as the last branch of an
if-elseif-else. Then we need a rewrite that inserts the contents of that
loose else clause in the surrounding list of equations:

rewrite FElseEquation in FEquationBlock.getFAbstractEquation() {

     when (true) to List getFAbstractEquations();

}

Johan told me about that syntax, and that it's used in several places in
our compiler. As far as I can see, it's meant to insert the list
resulting from the rewrite into the list where the node being rewritten is.

The resulting generated code (in rewriteTo()) is:

*if*(getParent().getParent() *instanceof*FEquationBlock &&

       ((FEquationBlock)getParent().getParent()).getFAbstractEquationListNoTransform() == getParent() && getNumFAbstractEquation() > 0) {

     state().duringTransformCanonical++;

       List list = (List)getParent();

*int*i = list.getIndexOfChild(*this*);

       List newList = rewriteFEquationBlock_getFAbstractEquation();

*for*(*int*j = 1; j < newList.getNumChildNoTransform(); j++)

         list.insertChild(newList.getChildNoTransform(j), ++i);

         state().duringTransformCanonical--;

*return*newList.getChildNoTransform(0);

}

Jesper

*Jesper MATTSSON, MSc*

Software Developer & IT Administrator

Phone direct: +46 73 324 5909

Email: jesper.mattsson_at_modelon.com <mailto:jesper.mattsson_at_modelon.com>


Description: Description: Description: Modelon_2011_Gradient_RGB_400

------------------------------------------------------------------------

Modelon AB
Ideon Science Park
SE-223 70 Lund, Sweden

        

Phone: +46 46 286 2200
Fax: +46 46 286 2201

        


Web: http://www.modelon.com <http://www.modelon.com/>

*From:*jastadd-bounces_at_cs.lth.se [mailto:jastadd-bounces_at_cs.lth.se] *On
Behalf Of *Emma Söderberg
*Sent:* den 22 februari 2012 11:07
*To:* jastadd_at_cs.lth.se
*Subject:* Re: [Jastadd] JastAdd bug report: rewrite to List

Hi Jesper,

Are you trying to add a list in a list? When is this useful? Do you have
a small example?

Regards,
Emma

On 02/20/2012 06:17 PM, Jesper Mattsson wrote:

Hi

Consider a rewrite that returns a List to be inlined in the List that
the node being rewritten was in.

If it returns an empty list, then a null pointer exception is thrown
from the line:

*return*newList.getChildNoTransform(0);

in rewriteTo().

Jesper

*Jesper MATTSSON, MSc*

Software Developer & IT Administrator

Phone direct: +46 73 324 5909

Email: jesper.mattsson_at_modelon.com <mailto:jesper.mattsson_at_modelon.com>


Description: Description: Description: Modelon_2011_Gradient_RGB_400

------------------------------------------------------------------------

Modelon AB
Ideon Science Park
SE-223 70 Lund, Sweden

        

Phone: +46 46 286 2200
Fax: +46 46 286 2201

        


Web: http://www.modelon.com <http://www.modelon.com/>




_______________________________________________

JastAdd mailing list

JastAdd_at_cs.lth.se <mailto:JastAdd_at_cs.lth.se>

https://mail1.cs.lth.se/cgi-bin/mailman/listinfo/jastadd
Received on Mon Feb 27 2012 - 22:47:58 CET

This archive was generated by hypermail 2.3.0 : Wed Apr 16 2014 - 17:19:06 CEST