Class CgenClassTable

java.lang.Object
  extended by SymbolTable
      extended by CgenClassTable

 class CgenClassTable
extends SymbolTable

This class is used for representing the inheritance tree during code generation. You will need to fill in some of its methods and potentially extend it in other useful ways.


Field Summary
private  int boolclasstag
           
private  int intclasstag
           
private  java.util.Vector nds
          All classes in the program, represented as CgenNode
private  java.io.PrintStream str
          This is the stream to which assembly instructions are output
private  int stringclasstag
           
 
Constructor Summary
CgenClassTable(Classes cls, java.io.PrintStream str)
          Constructs a new class table and invokes the code generator
 
Method Summary
private  void buildInheritanceTree()
           
 void code()
          This method is the meat of the code generator.
private  void codeBools(int classtag)
          Emits code definitions for boolean constants.
private  void codeConstants()
          Emits code to reserve space for and initialize all of the constants.
private  void codeGlobalData()
          Emits code to start the .data segment and to declare the global names.
private  void codeGlobalText()
          Emits code to start the .text segment and to declare the global names.
private  void codeSelectGc()
          Generates GC choice constants (pointers to GC functions)
private  void installBasicClasses()
          Creates data structures representing basic Cool classes (Object, IO, Int, Bool, String).
private  void installClass(CgenNode nd)
           
private  void installClasses(Classes cs)
           
 CgenNode root()
          Gets the root of the inheritance tree
private  void setRelations(CgenNode nd)
           
 
Methods inherited from class SymbolTable
addId, enterScope, exitScope, lookup, probe, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

nds

private java.util.Vector nds
All classes in the program, represented as CgenNode


str

private java.io.PrintStream str
This is the stream to which assembly instructions are output


stringclasstag

private int stringclasstag

intclasstag

private int intclasstag

boolclasstag

private int boolclasstag
Constructor Detail

CgenClassTable

public CgenClassTable(Classes cls,
                      java.io.PrintStream str)
Constructs a new class table and invokes the code generator

Method Detail

codeGlobalData

private void codeGlobalData()
Emits code to start the .data segment and to declare the global names.


codeGlobalText

private void codeGlobalText()
Emits code to start the .text segment and to declare the global names.


codeBools

private void codeBools(int classtag)
Emits code definitions for boolean constants.


codeSelectGc

private void codeSelectGc()
Generates GC choice constants (pointers to GC functions)


codeConstants

private void codeConstants()
Emits code to reserve space for and initialize all of the constants. Class names should have been added to the string table (in the supplied code, is is done during the construction of the inheritance graph), and code for emitting string constants as a side effect adds the string's length to the integer table. The constants are emmitted by running through the stringtable and inttable and producing code for each entry.


installBasicClasses

private void installBasicClasses()
Creates data structures representing basic Cool classes (Object, IO, Int, Bool, String). Please note: as is this method does not do anything useful; you will need to edit it to make if do what you want.


installClass

private void installClass(CgenNode nd)

installClasses

private void installClasses(Classes cs)

buildInheritanceTree

private void buildInheritanceTree()

setRelations

private void setRelations(CgenNode nd)

code

public void code()
This method is the meat of the code generator. It is to be filled in programming assignment 5


root

public CgenNode root()
Gets the root of the inheritance tree