Re: code transformations?

Charles Fiterman <cef@geodesic.com>
23 Sep 1996 21:21:41 -0400

          From comp.compilers

Related articles
code transformations? lord@emf.net (1996-09-22)
Re: code transformations? null@diku.dk (1996-09-23)
Re: code transformations? cef@geodesic.com (Charles Fiterman) (1996-09-23)
Re: code transformations? ma@camcon.co.uk (1996-09-25)
Re: code transformations? darius@phidani.be (Darius Blasband) (1996-09-26)
Re: code transformations? meulenbr@prl.philips.nl (1996-09-26)
Re: code transformations? albaugh@agames.com (1996-09-26)
Re: code transformations? torbenm@diku.dk (1996-09-29)
Re: code transformations? ndc@icanect.net (Norman Culver) (1996-09-29)
[4 later articles]
| List of all articles for this month |

From: Charles Fiterman <cef@geodesic.com>
Newsgroups: comp.compilers
Date: 23 Sep 1996 21:21:41 -0400
Organization: Geodesic Systems
References: 96-09-094
Keywords: translator

Tom Lord <lord@emf.net> wrote:
>Some time ago, somebody suggested to me the idea of writing a certain
>kind of C preprocessor. The gist of it was that the preprocessor
>would actually parse the program, make some changes to the AST and
>then write source back to disk. This got me to thinking -- suitably
>sophisticated transformations could preserve the semantics of the
>program, while completely disguising the text of the source. This has
>obvious implications for anyone into intellectual property theft.
>
>So the question is, has anybody written such a program? Will anyone?
>Would releasing such a program on the net be like the SATAN of IP?
>[There are certainly C obfuscators, but the ones I know of perform primarily
>lexical smooshing. -John]


There are plenty of programs like that. The strongest are partial
evaluators and can be looked up under partial evaluation. I'm suprised
that C compilers don't make the transformation. But sqrt(4.0) should
generate 2.0 not a function call. This works better if you can tell
the system which functions may be regarded as pure functions. For
example sqrt(-1.0) will produce an error message. Now an error message
is a side effect and thus sqrt is not pure on examination. But that
error message is more useful at compile time than run time so the user
should say sqrt is pure.


The opposite example is delay(int milliseconds) compiler examination
of the function may show it is pure and can thus be run at compile
time, lifted out of loops, or even discarded since it returns
nothing. Any of these acts is clearly an error. The user must have a
way of saying delay is not pure no matter what it looks like.


--


Post a followup to this message

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