Package descriptions

 
1) Util  
 
Classes : BoolList  
	- contains a list of booleans  
	- each boolean is used as a flag assosiated with a  
	formal parameter , which tells if the parameter  
		- escapes ie is pushed onto the frame (true) 
		- doesn't escape ie is kept in a register (false) 
 
Note: in our case all the bools will be true 	 
 
	- used in SPIM.SPIMFrame 
   
2) Temp  
	 
2.1. Temp  
	- class which declares a temporary register  
	 
	new Temp() guarantees to return a new temporary at each call  
	new Temp(String s ) return a new temp register object bearing 
		the name s ( eg new Temp("fp")) 
 
2.2. Label 
	- class which declares a label  
	 
	new Label() guarantees to return a new label at each call  
 
 
3. Frame 
 
3.1. abstract Access 
 
	- abstract class which is extended by SPIM.InFrame(int offset)  
	and  SPIM.InReg(Temp.Temp) 
	- each Access object is either  - a local variable 
					- a formal parameter 
	  	which in our case will be InFrame objects  
	- contains the declaration of an abstract method  
	(see SPIM.InFrame for details) 
 
	public abstract Tree.Exp exp(Tree.Exp framePtr);  
 
 
3.2 AccessList 
	 
	- just a list of Access objects	 
 
3.3. abstract Frame 
	 
	- abstract class which contains the declarations of an abstract  
	Frame  
	- extended by SPIM.SPIMFrame 
 
 
Data and methods  

	- public int offset - current offset of the frame ; is
incremented by allocLocal when a variable is allocated on the frame
and by the constructor of the frame when the formals are pushed on the
frame
 
	- public Temp.Label name - label of the function owning this frame 
	- public AccessList formals - list of formals 
 
	 
	-abstract public Frame newFrame(Temp.Label name, Util.BoolList
formals) - method which constructs and returns a new Frame
 
  abstract public Access allocLocal(boolean escape);
	- method which allocs a local  
 
  abstract public int wordSize(); 
	- returns the word size of the machine  
 
  abstract public Temp.Temp RV();
	- returns the register which corresponds to the return value
register on the specific machine ( on MIPS v0)
 
  abstract public Temp.Temp FP(); 
	- returns the register which corresponds to the frame pointer 
register on the specific machine ( on MIPS fp) 
 
  abstract public Temp.Temp SP(); 
	- returns the register which corresponds to the stack pointer 
register on the specific machine ( on MIPS sp) 
 
  abstract public Temp.Temp RA(); 
	 - returns the register which corresponds to the return address 
register on the specific machine ( on MIPS ra) 
 
  abstract public Temp.Temp temporary(int i); 
	- dummy method to return i'th temporary of the specific  
machine  
 
 
4. SPIM - package that contains the machine specific details 
 
4.1. InFrame  
	 
	- extends the Frame.Frame class 
	- int offset : distance from the beginning of the frame, 
		where the Access resides  
	- InFrame(int o) - constructor	 
	- each InFrame is either a local variable or a formal, 
		which is saved in the function's frame at offset  
 
        public Tree.Exp exp(Tree.Exp framePtr) { 
                return new Tree.MEM(new Tree.BINOP(Tree.BINOP.PLUS, 
                                                   framePtr, 
                                                   new Tree.CONST(offset))); 
                 
                  } 
 
	- exp method above implements the intermidiate code for
accessing the current InFrame object ; framePtr is supposed to be the
frame pointer register ( just a Tree.TEMP)
	 
	- a new InFrame object is created whenever a new local or
formal is declared
	- exp method should be used for intermidiate code generation 
each time a variable is accessed 
 
4.2. SPIMFrame  
 
	- extends Frame.Frame   
	- what constructor does:  
		- saves the formals onto the frame	 
		- updates the current offset 
	- newFrame just constructs and returns a new SPIMFrame  
	- allocLocal - constructs a new Frame.Access ( InFrame or InReg ) 
		     - updates the current offset 	 
		- is called by allocLocal from Translate	 
 
5. Translate  
 
5.1. Level  
	- object for keeping the level of function declaration  
	nesting  
	- contains  
		- Frame.Frame frame - the frame of the function 
		- Level parent - the level of the parent  
		- AccessList formals - list of formals ( there are 
	Translate.Access-es , not Frame.Accesses) 
		 
	- constructor 
		- creates a new frame  
		- constructs an Access for each formal 
	 
	- Access allocLocal(boolean escape) 
		- calls the allocLocal in Frame.Frame and creates a  
	Translate.Access from the Frame.Accesses returned 
 
5.2. Access  
	- class which contains  
		- an Frame.Access object	 
		- its coresponding level  
 
5.3. Exp 
	- in the previous part of the project this was the part  
	from the ExpTy object which was null  
	- now in this kind of object must be kept the intermidiate  
	code represenation 
	 
	- contains a  
		Tree.Exp exp  - the intermidiate code tree 
	- method Tree.Exp unEx() just returns exp  
 
(Note:  this is the simpler Translate as suggested in text-book at  
page 178) 
 
5.4. Frag (page 177) is an abstract class which declares a list of  
fragments  
 
	- Extended by:  
	5.4.1. ProcFrag - one for each function ( in our simplifyied  
	case there's going to be just one) 
	5.4.2. DataFrag - one for each data fragment ( eg strings in  
	tiger should be gathered as a DataFrag and dumped at the end  
	of the assembly code as data declarations) 
 
5.5. Translate  
	- class which contains a private Frag list frags updated  
	each time the method  
		void procEntryExit(Level l , Tree.Exp body )  
	is called ; this method is  called once each time the  
	the intermediate code for the body of a function has been  
	generated  
    	  
	- getResult() method returns frag list  
		   
	 
		 
6. Semant  
 
	6.1.VarEntry 
	6.2.FunEntry  
 
	- must be updated as described at page 148 
 
	- now for a variable  i'm going to put into symbol table (  
	at declaration time) along with its type a Translate.Access which  
	contains an InFrame object and the nesting level of the function; 
	these will be usefull for intermediate code generation  
	when the variable is refered 
 
	6.3. Semant  
 
	- is the class where most of your action is going to happen 
	- I already implemented intermediate code generation for a 
	integer expression and for addition ( see the source) 
 
7. Tree 
	- package that contains the intermidiate code implementation 
	- see the text-book (page 157) for details