util
Class ClassTreeNode

java.lang.Object
  extended by util.ClassTreeNode

public class ClassTreeNode
extends java.lang.Object

The ClassTreeNode class represents a node in the class hierarchy tree. To perform semantic analysis the class hierarchy tree must be constructed and used when building the environment and type checking. A ClassTreeNode represents one class in the class hierarchy tree and contains all the relevant information about that class (AST node, parent, children, symbol table, etc.).

See Also:
SemanticAnalyzer

Constructor Summary
ClassTreeNode(Class_ astNode, boolean builtin, boolean extendable, java.util.Hashtable<java.lang.String,ClassTreeNode> classMap)
          ClassTreeNode constructor
 
Method Summary
 void addChild(ClassTreeNode child)
          Add an immediate subclass to this class Also makes child's parent this class (if not already)
 Class_ getASTNode()
          Get the AST node for this class
 java.util.Iterator<ClassTreeNode> getChildrenList()
          Get an iterator of class tree nodes representing the immediate subclasses of this class
 SymbolTable getMethodSymbolTable()
          Get the method symbol table of the class
 java.lang.String getName()
          Get the name of the class
 int getNumChildren()
          Get the number of children of this class
 int getNumDescendants()
          Get the number of descendants (strict subclasses) of this class
 ClassTreeNode getParent()
          Get the parent class tree node of the class
 SymbolTable getVarSymbolTable()
          Get the variable symbol table of the class
 boolean isBuiltIn()
          Is this class built-in?
 boolean isExtendable()
          Is this class extendable?
 ClassTreeNode lookupClass(java.lang.String className)
          Lookup a class tree node
 void setParent(ClassTreeNode parent)
          Set the parent class tree node of this class Also adds this class to list of parent's children (if not already there) In addition, sets variable and method symbol tables to the parent's symbol tables
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassTreeNode

public ClassTreeNode(Class_ astNode,
                     boolean builtin,
                     boolean extendable,
                     java.util.Hashtable<java.lang.String,ClassTreeNode> classMap)
ClassTreeNode constructor

Parameters:
astNode - the AST node for this class
builtin - boolean indicating whether this class was built-in
extendable - boolean indicating whether this class is extendable
classMap - class map for accessing class tree nodes
Method Detail

getName

public java.lang.String getName()
Get the name of the class

Returns:
the name of this class

getASTNode

public Class_ getASTNode()
Get the AST node for this class

Returns:
AST node for this class

isBuiltIn

public boolean isBuiltIn()
Is this class built-in?

Returns:
boolean indicating whether this class was built-in

isExtendable

public boolean isExtendable()
Is this class extendable?

Returns:
boolean indicating whether this class is extendable

getParent

public ClassTreeNode getParent()
Get the parent class tree node of the class

Returns:
parent class tree node

setParent

public void setParent(ClassTreeNode parent)
Set the parent class tree node of this class Also adds this class to list of parent's children (if not already there) In addition, sets variable and method symbol tables to the parent's symbol tables

Parameters:
parent - the class tree node of the parent class

addChild

public void addChild(ClassTreeNode child)
Add an immediate subclass to this class Also makes child's parent this class (if not already)

Parameters:
child - the class tree node of the immediate subclass

getChildrenList

public java.util.Iterator<ClassTreeNode> getChildrenList()
Get an iterator of class tree nodes representing the immediate subclasses of this class

Returns:
list of children

getNumChildren

public int getNumChildren()
Get the number of children of this class

Returns:
number of children

getNumDescendants

public int getNumDescendants()
Get the number of descendants (strict subclasses) of this class

Returns:
number of descendants (strict subclasses)

getVarSymbolTable

public SymbolTable getVarSymbolTable()
Get the variable symbol table of the class

Returns:
variable symbol table

getMethodSymbolTable

public SymbolTable getMethodSymbolTable()
Get the method symbol table of the class

Returns:
method symbol table

lookupClass

public ClassTreeNode lookupClass(java.lang.String className)
Lookup a class tree node

Parameters:
className - the name of the class to lookup
Returns:
corresponding class tree node (null if not found)