At 18:43 11 Nov 1999 +0100, Kontorotsui wrote:
> What I want to do is a tool that "flattens" the class hierachy to improve
> performance. In this way I'll be able to write properly structured code but the
> tool will cut away performance-wise useless classes and method before I compile.
> I know it is not always possible to do that and that the rules to change the
> program must always keep semanthic unchanged... I know this is not easy.
> But suppose I manage to write down a set of rules to do that, I'll need a parser
> to parse the Java code and provide the changed source code according to the
> rules.
>
> After I explained my goal, what would be the best parser to achieve it?
The trend today (as far as I can tell) seems to be to perform these
optimisations in the JVM itself, as opposed to a 'precompilation' step. If
you look at IBM's high performance java compiler or VM, for instance, it
does lots and lots of really cool analysis and inlining. If you were to
make the method 'final', I expect that decent JIT's would be able to
optimise away.
Having said that, if I wanted to do something like this, I would use
JavaCC, or, specifically, the "jjtree" tool in JavaCC. jjtree will
automatically parse the file into an OO structure ready for manipulation.
(ie, you might set it up to create a "class object", a "method object", and
a 'methodcall' object, among other things. You could then use this like
any other tree. This will probably automate something you would have done
anyway.
If you get it done/started, be sure to let us take a look at it!
Paul
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]