[CIL users] Representation for some operators

 [CIL users] Representation for some operators From: Pietro Braione - 2013-01-23 01:57:46 ```Hello to everyone. I am not able to find in the documentation the representation for some kind of statements, i.e., pre/postincrement (++ and --), and all the operator/assignment statements (with +=, -=, *=, etc). What is their representation? I need to detect and remove them (by transforming x++ in x = x + 1, etc). Regards Pietro ```

 [CIL users] Representation for some operators From: Pietro Braione - 2013-01-23 01:57:46 ```Hello to everyone. I am not able to find in the documentation the representation for some kind of statements, i.e., pre/postincrement (++ and --), and all the operator/assignment statements (with +=, -=, *=, etc). What is their representation? I need to detect and remove them (by transforming x++ in x = x + 1, etc). Regards Pietro ```
 Re: [CIL users] Representation for some operators From: Gabriel Kerneis - 2013-01-23 07:54:36 ```Hi Pietro, On Wed, Jan 23, 2013 at 02:38:53AM +0100, Pietro Braione wrote: > by transforming x++ in x = x + 1, etc. CIL already does that for you automatically. 17. One of the most significant transformations is that expressions that contain side-effects are separated into statements. int x, f(int); return (x ++ + f(x)); See the CIL output for this code fragment Internally, the x ++ statement is turned into an assignment which the pretty-printer prints like the original. CIL has only three forms of basic statements: assignments, function calls and inline assembly. --- http://kerneis.github.com/cil/doc/html/cil/cil004.html#sec-cabs2cil If you really want to have "x = x + 1" printed as "x ++", you can use the flag --printCilAsIs [1] or write your own pretty-printer [2]. [1] http://kerneis.github.com/cil/doc/html/cil/cil007.html#toc8 [2] http://kerneis.github.com/cil/doc/html/cil/attributes.html#toc6 Best, -- Gabriel ```
 Re: [CIL users] Representation for some operators From: Pietro Braione - 2013-01-23 10:41:12 Attachments: Message as HTML ```Hello Gabriel, and thanks for your answer. Il giorno 23/gen/2013, alle ore 08.54, Gabriel Kerneis ha scritto: > Hi Pietro, > > On Wed, Jan 23, 2013 at 02:38:53AM +0100, Pietro Braione wrote: >> by transforming x++ in x = x + 1, etc. > > CIL already does that for you automatically. > > 17. One of the most significant transformations is that expressions that > contain side-effects are separated into statements. > > int x, f(int); > return (x ++ + f(x)); > > See the CIL output for this code fragment The problem is, I do not need to transform only *expressions*, but also *statements* - e.g., the above example translates to (http://kerneis.github.com/cil/doc/html/cil/examples/ex16.txt): #line 2 tmp = x; #line 2 x ++; //NONONO! #line 2 tmp___0 = f(x); #line 2 return (tmp + tmp___0); that still has an x++ statement. I want that x++ to be transformed to x = x + 1. Is there a plain way to do that? Thank you Pietro ```
 Re: [CIL users] Representation for some operators From: Gabriel Kerneis - 2013-01-23 11:02:13 ```On Wed, Jan 23, 2013 at 11:41:02AM +0100, Pietro Braione wrote: > Il giorno 23/gen/2013, alle ore 08.54, Gabriel Kerneis ha scritto: > > On Wed, Jan 23, 2013 at 02:38:53AM +0100, Pietro Braione wrote: > >> by transforming x++ in x = x + 1, etc. > > > > CIL already does that for you automatically. > > > > 17. One of the most significant transformations is that expressions that > > contain side-effects are separated into statements. > > > > int x, f(int); > > return (x ++ + f(x)); > > > > See the CIL output for this code fragment > > The problem is, I do not need to transform only *expressions*, but also > *statements* - e.g., the above example […] still has an x++ statement. No, it doesn't. Please the re-read the part of the manual that you did *not* quote above (hint: it starts with "internally"). And try --printCilAsIs as suggested. Best, -- Gabriel ```
 Re: [CIL users] Representation for some operators From: Pietro Braione - 2013-01-23 11:39:18 ```Il giorno 23/gen/2013, alle ore 12.02, Gabriel Kerneis ha scritto: > And try --printCilAsIs as suggested. I misunderstood the meaning of the switch. It works! Thanks Pietro ```