|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectSymbolTable
CgenClassTable
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 | |
void |
addId(AbstractSymbol id,
java.lang.Object info)
Adds a new entry to the symbol table. |
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) |
void |
enterScope()
Enters a new scope. |
void |
exitScope()
Exits the most recently entered scope. |
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)
|
java.lang.Object |
lookup(AbstractSymbol sym)
Looks up an item through all scopes of the symbol table. |
java.lang.Object |
probe(AbstractSymbol sym)
Probes the symbol table. |
CgenNode |
root()
Gets the root of the inheritance tree |
private void |
setRelations(CgenNode nd)
|
java.lang.String |
toString()
Gets the string representation of the symbol table. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private java.util.Vector nds
private java.io.PrintStream str
private int stringclasstag
private int intclasstag
private int boolclasstag
Constructor Detail |
public CgenClassTable(Classes cls, java.io.PrintStream str)
Method Detail |
private void codeGlobalData()
private void codeGlobalText()
private void codeBools(int classtag)
private void codeSelectGc()
private void codeConstants()
private void installBasicClasses()
private void installClass(CgenNode nd)
private void installClasses(Classes cs)
private void buildInheritanceTree()
private void setRelations(CgenNode nd)
public void code()
public CgenNode root()
public void enterScope()
public void exitScope()
public void addId(AbstractSymbol id, java.lang.Object info)
id
- the symbolinfo
- the data asosciated with idpublic java.lang.Object lookup(AbstractSymbol sym)
null
.
sym
- the symbol
public java.lang.Object probe(AbstractSymbol sym)
sym
. If found, return the information field.
If not return null
.
sym
- the symbol
public java.lang.String toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |