Code Generation
摘要
This chapter describes how to generate code for the MicroJava Virtual Machine. The MicroJava VM is a simplified version of the Java VM. It is a stack machine with its own bytecode instruction set, which is executed by an interpreter. After discussing the instructions and the memory areas of the MicroJava VM we look at how to generate code for loading data, computing expressions, transforming control flow statements into jumps, and finally for calling methods including parameter passing. During code generation, we also need to check the semantic correctness of MicroJava programs, which is expressed by context conditions. All translation steps are described concisely by attributed grammars.