From intermediate code to Java bytecode (dragon bo

2019-09-03 08:34发布

I'm enrolled in a compilers course, using the "dragon book" as textbook. It gives instructions on how to convert the intermediate code generated by its compiler to an object language, assembly.

My question is: where can I find instructions to convert an intermediate code in the 3-address format to java bytecode, for the same grammar used in the book?

Textbook site: http://dragonbook.stanford.edu/index.html#courses

2条回答
倾城 Initia
2楼-- · 2019-09-03 08:52

I have implemented a translator that takes the three-address intermediate code, generated by the Dragon Book implementation of the front end of a compiler, and converts it to a Java bytecodes with a syntax similar to Jasmin. Then it uses Krakatau to assemble it into a classfile executable through the JVM.

You can check my implementation at https://github.com/joaofbsm/smallL/tree/master/code/translator.

查看更多
孤傲高冷的网名
3楼-- · 2019-09-03 09:06

If you want to know how to create a binary Java classfile yourself, there's no better resource than the official JVM specification.

If you want to write a classfile in a human readable textual format, there are various assemblers available: Krakatau, Jasmin, and Lilac among others. Note that Jasmin is old and largely unmaintained, though the Sable Research Group maintains a fork of it for use with their own tools.

查看更多
登录 后发表回答