This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Minimal Bytecode Generation Program


Andreas Schlapbach wrote:

>I'm interested in the bytecode-generation features of KAWA, I might use it
>for a backend for a compiler.
>
>I've been reading the javadoced source and the archives, but I didn't find
>a minimal programm to get started. Is there any such resource?
>
>All I would be interested in is how to generate bytecode for [...]
>and how to pass it on to the JVM using gnu.bytecode.*
>
Some people do use just gnu.bytecode for a compiler backend and that has 
the advantage
that gnu.bytecode is relatively simple, understandable, and the 
interface is fairly stable.
However, it is very low-level.  If you want to use Kawa to write a 
compiler, I
recommend using the higher-level gnu.expr functionality.  That
gives you various optimization and features builtin.  The best way to 
figure out
how to do this is look at the implementation of the XQuery language.

An example of XQuery hello world in action.  First try putting:
"Hello, world!"
in a file named hello.xql, and then running:
java kawa.repl --main --xquery -C hello.xql
and
java hello

Then study the XQuery souce code in gnu/xquery/lang/*.java.  Except for 
the parser,
there isn't all that much to it. You can use this code as a model, 
though note that you need
to register your language in the table in gnu/expr/Interpreter.java.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]