Assignment 3: Data Representation

(graded, group assignment)

Your task in this assignment is to implement a compiler phase for the CPS data representation and closure conversion transformations. In the new assignment3 branch you will find a template for this compiler phase in class l3.CPSDataRepresenter. You will also have to implement the CPSHoister transformation to bring all function bodies to the top level. You can use the helper methods in class CPSDataRepresenter and object BitTwiddling.

This assignment relies on the correct implementation of the previous one (the CL3ToCPSTranslator class), and the reference implementation will not be revealed. You will have to merge the changes you made for assignment 2 into the new source tree. To do so, use:

 git fetch origin git checkout assignment3 git merge assignment2 cd l3/compiler sbt clean update compile test git push origin assignment3 

You should be able to do this without merge conflicts or compilation errors. If you get into trouble with git, ask the TA.


From this assignment on, you will choose the shapes for the trees you generate. You should inspect them visually and decide whether or not they are correct and optimal. The Repository application will not have whitebox tests, but it will still have an extensive blackbox test suite to ensure the correctness of the programs you generate.

Although we will not test tree shapes, we still encourage you to do so for every transformation rule you write. You have the necessary infrastructure in l3.test.CPSDataRepresentation_Whitebox so it’s a matter of just writing the source code and the resulting tree. It is usually an effort that pays off.