Re: code transformations?

Charles Fiterman <>
23 Sep 1996 21:21:41 -0400

          From comp.compilers

Related articles
code transformations? (1996-09-22)
Re: code transformations? (1996-09-23)
Re: code transformations? (Charles Fiterman) (1996-09-23)
Re: code transformations? (1996-09-25)
Re: code transformations? (Darius Blasband) (1996-09-26)
Re: code transformations? (1996-09-26)
Re: code transformations? (1996-09-26)
Re: code transformations? (1996-09-29)
Re: code transformations? (Norman Culver) (1996-09-29)
[4 later articles]
| List of all articles for this month |

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

Tom Lord <> 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.