Description
Overview
For this assignment you will write a code generator that generates MIPS assembly code (suitable as input to the Spim interpreter) for Wumbo programs represented as abstract-syntax trees.
Specifications
General information
Getting started
Spim
Changes to old code
Non-obvious semantic issues
Suggestions for how to work on this assignment
General information
Similar to the fourth and fifth assignments, the code generator will be implemented by writing codeGen member functions for the various kinds of AST nodes. See the on-line Code Generation notes (as well as lecture notes) for lots of useful details.
In addition to implementing the code generator, you will also update the main program so that, if there are no errors (including type errors), the code generator is called after the type checker. The code generator should write code to the file named by the second command-line argument.
Note that your main program should no longer call the unparser, nor should it report that the program was parsed successfully.
Also note that you are not required to implement code generation for:
structs or anything struct-related (like dot-accesses)
repeat statement
Getting started
Start by downloading p6.zip. After unzipping it, you will see all the files required for the project.
Some useful code-generation methods can be found in the file Codegen.java. Note that to use the methods and constants defined in that file you will need to prefix the names with Codegen.; for example, you would write: Codegen.genPop(Codegen.T0) rather than genPop(T0). (Alternatively, you could put the declarations of the methods and constants in your ASTnode class; then you would not need the Codegen prefix.) Also note that a PrintWriter p is declared as a static public field in the Codegen class. The code-generation methods in Codegen.java all write to PrintWriter p, so you should use it when you open the output file in your main program (in P6.java); i.e., you should include:
CS536 Project 6 2020/5/1, 14:19
CS536 Project 6 2020/5/1, 14:19
CS536 Project 6 2020/5/1, 14:19
http://pages.cs.wisc.edu/~loris/cs536/asn/p6/p6.html Page 5 of 5
