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. We provide you with a Jasmin editor which was built with Spoofax.

Usage

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. The GitHub repository contains various example programs. You should explore them 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, some Java bytecode instructions, and different approaches to code generation in Spoofax.

  2. Java Virtual Machine Specification

    Oracle provides an online version of the Java Virtual Machine Specification. Chapters 3 and 6 are particularly helpful for this milestone. Furthermore, you can find a comprehensive list of Java Bytecode instructions in the English Wikipedia.

  1. Stratego documentation

    The Stratego language is described in the Stratego language manual. Useful strategies in the Stratego standard library are described with examples in Stratego library manual. A complete listing of all strategies in the Stratego standard library can be found in the API documentation.