CS451/651
Compilers
Bill Campbell
Spring 2009
Programming Exercise 5: Analysis and Code Generation I
Your job here is to implement analysis and code generation for the following
constructs, which you parsed in programming exercise 3. You will want to see Chapter
7 of our text, and Chapter 7 (and other chapters) of the JVM Spec: http://java.sun.com/docs/books/jvms/second_edition/html/VMSpecTOC.doc.html.
1. Interfaces, and necessary modifications to class declarations to implement the implements clause.
2. Conditional expressions.
3. The switch statement.
It’s probably best to write a set of test programs first. Then you can compile them with javac to see what it generates for code. And you have some measure as to when you are done. (Welcome to extreme programming.)
Hand in hard copy of your program, your test program and their results, and your narrative no later than 4:00 p.m., Wednesday, April 22. And, as usual, put your tree in p5/ of your course directory.
Your narrative will be very important in this assignment, since there are things left unsaid. This assignment makes use of many classes, I strongly suggest that you start out on this assignment immediately; there is lots of programming to do, there is lots of testing to do, and probably there will be lots of repairing to do. And, of course there is lots of writing to do. Have fun!