For each method in each class, you will create a Frame.Frame object.
Since you are compiling for a MIPS processor your frame objects will be of type Mips.MipsFrame. The variables in each method will be referenced as temporaries (Temp.Temp objects) in the IR tree. In the intermediate tree language a temporary is similar to a register on an actual processor. You will need to implement methods in the Frame class to allocate temporaries for variables. There are two such methods: allocFormal() (to allocate temporaries for formal variables) and allocLocal() (to allocate temporaries for local variables). Each of these methods will return a Frame.Access object which stores the name of the temporary allocated. Because we trust a register allocation phase to take care of assigning all of our registers in a later pass, the Frame.Access object returned at this point will always be a Mips.InReg object. You will need to maintain a symbol table to bind the variable names with the corresponding Frame.Access objects.The IR Tree is made of objects of two main types: Tree.Exp and Tree.Stm. These classes are both abstract, and the objects in the trees will be made of objects of types which inherit from Tree.Exp or Tree.Stm. Classes that extend Tree.Exp are : BINOP, CALL, CONST, ESEQ, MEM, NAME, TEMP. Classes that extend Tree.Stm are : CJUMP, EXP, JUMP, LABEL, MOVE, SEQ.
Tree.SEQ will be used to link together a sequence of statements. For
example, if you have statements stm1,stm2,stm3. You will link them
together by calling:
For each method in each class you will create a Frame.Frame and a method body (a tree rooted at a Tree.Stm). The Frame.Frame and the body together form a fragment (in this case a Translate.ProcFrag). Each Translate.ProcFrag will be added to a linked list (called frags) to be printed out when the pass is complete.
The return type of each visitor is Translate.Exp. Do not confuse
this with the Tree.Exp. Translate.Exp is another abstract class,
and the four classes that extend Translate.Exp are:
Each of these subclasses of abstract class Translate.Exp have three
methods to convert Translate.Exp objects to Tree.Exp and Tree.Stm objects :
You will use these methods to convert from Translate.Exp objects to Tree.Exp objects. For example: If you have an Translate.Ex object called "x" and need to convert it to a Tree.Stm, you will need to call x.unNx().