Compiler Construction bio photo

Compiler Construction

Twitter Github

Edit on GitHub

Milestone 3: Code Generation

Overview

In this milestone, you extend the MiniJava editor from the previous milestone to a MiniJava compiler, which is able to generate Java class files from MiniJava programs.

Jasmin Editor

Jasmin is an assembler for the Java Virtual Machine. It takes ASCII descriptions of Java classes, written in a simple assembler-like syntax using the Java Virtual Machine instruction set. It converts them into binary Java class files, suitable for loading by a Java runtime system. Basically, Jasmin is a nice syntax for Java bytecode, with a compiler to actual Java bytecode in class files. A Spoofax implementation of Jasmin is available on GitHub.

Usage

We provide you with a Jasmin editor which was built with Spoofax. You can edit Jasmin files with a Spoofax editor. The editor’s menu entries allow you to inspect the abstract syntax of Jasmin files, to generate Java class files from them, and to execute those class files. Your initial project will contain several Jasmin example programs which you should explore in order to get used to Jasmin’s syntax.

Material

We consider the following material to be useful for this milestone.

  1. Lecture on Virtual Machines

    In this lecture, we discussed the architecture of the JVM and some Java bytecode instructions. In the lecture we discussed approaches to code generation in Spoofax.

  2. Java Virtual Machine Specification

  3. Stratego documentation