From intermediate code to Java bytecode (dragon book)

a 夏天 提交于 2019-12-12 04:18:17

问题


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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/34122323/from-intermediate-code-to-java-bytecode-dragon-book

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!