Fwd: [jvm-l] View this page "Jvm Bytecode Libraries"

3 views
Skip to first unread message

Alex Eagle

unread,
Dec 22, 2009, 1:01:54 PM12/22/09
to noop...@googlegroups.com
Here's an interesting technique for producing java bytecodes:
transform the AST into the javac AST and run it through the javac
backend.

This guy Remi has done it for his language and points to source. We
should try this when the time is right - it's a shortcut along the
lines of our plan to emit java sources and use Javac, but without the
java sources part.

-Alex

---------- Forwarded message ----------
From: Rémi Forax <fo...@univ-mlv.fr>
Date: Thu, Dec 17, 2009 at 10:40 AM
Subject: Re: [jvm-l] View this page "Jvm Bytecode Libraries"
To: jvm-la...@googlegroups.com


Le 17/12/2009 17:42, Charles Oliver Nutter a écrit :
> On Thu, Dec 17, 2009 at 8:58 AM, Matt Fowles<matt....@gmail.com>  wrote:
>
>> I am interested in this technique, can you provide a pointer to some
>> starting point where I can see how you do this?  I thought javac didn't
>> expose these classes.
>>
> Yeah, I'd like to hear more as well. I would use it in at least Duby's
> JVM backend, and potentially for other things. I've hacked javac
> internals, but never tried to feed it valid trees and make it spit out
> bytecode.
>
> - Charlie
>

Yes, I can :)

Let me introduce Pseudo, a language that is a simpler C/Python.
It's aim is to be used in first years of computer science
to teach algorithmics.
The cool feature of this language is gradual typing.

Some samples are available here:
https://code.google.com/p/pseudo-language/source/browse/trunk/pseudo/#pseudo/samples

The grammar of the language is defined here:
https://code.google.com/p/pseudo-language/source/browse/trunk/pseudo/compiler/pseudo.ebnf

I use a parser generator that I've written with two friends,
to generate the AST from the grammar.

Here is an example of backend that takes an AST of Pseudo,
convert it to a javac AST and run javac backend on the resulting tree:
https://code.google.com/p/pseudo-language/source/browse/trunk/pseudo/compiler/src/com/googlecode/pseudo/compiler/gen/Gen.java

PS: Gen is more complex than it could be because it generates
invokedynamic call when it goes dynamic and tail call just for fun.

cheers,
Rémi

--

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

Christian Edward Gruber

unread,
Dec 22, 2009, 2:54:50 PM12/22/09
to noop...@googlegroups.com
Interesting. This might just be a half-way point we don't need,
because the Java exercise was to allow us to get the basics working,
as well as to see what noop would look like to Java so we can get
integration right. But ultimately we'll probably want to do things
supported in the JVM, but not in the javac compiler, so we'll need our
own back-end.

Having said that, this might still be a decent partial or temporary
approach, and may allow us to get something into the field sooner -
AND it is probably really good for learning about what we want.

Christian.

Reply all
Reply to author
Forward
0 new messages