Matt Fowles wrote:
> All~
> 
> I am trying to find a reasonable path towards direct bytecode
> generation.  My current setup has a hand rolled java dom that I then
> serialize to java code which I compile using javac.  I have found that
> I can replace my java dom with the jdt.core one and still do the
> serialize/compile trick.  But, I would really like to be able to skip
> the serialize step and go directly some AST to a .class file.

This is, in my opinion, is one of the values of the DLR 
toolchain...given an AST, properly transformed into a DLR AST, you get a 
compiler and such on the other side.

I have also very much wanted a way to take an AST and shove it directly 
into the standard Java compiler chain to produce output, rather than the 
(really really gross, in my opinion) age-old hack of writing to a file. 
My first suggestion would be your second proposed approach: to look at 
javac, which is now GPL along with the rest of OpenJDK. But I've looked 
into that code myself, and it's pretty crazy...so I'm not sure how easy 
it would be to construct the AST yourself and feed it in. A good day 
project would be to see if it's feasible, since the process for doing so 
would be incredibly useful to others.

> This approach is fairly nice in that it allows me to inspect the
> generated code easily and find bugs that way.  Thus I would like to
> maintain the ability to generate the java code, even if I only use it
> for debugging.

There's another benefit to the javac approach too...it's a damn good 
compiler. So feeding it an AST saves you the trouble of writing a good 
compiler yourself, and you don't have to serialize anything. Plus it 
opens up all sorts of other possibilities like producing custom Java 
ASTs by transforming other languages, allowing them to leverage javac 
directly too.

FWIW, even if you did find a way to make the Eclipse compiler be used in 
used in this way, I don't believe it's recommended as a production 
compiler (but I could be wrong on this, I haven't used it in a long time).

- Charlie

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "JVM 
Languages" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/jvm-languages?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to