Go to the first, previous, next, last section, table of contents.


Symbol Table Hierarchy

The SUIF symbol tables are organized in a hierarchy of nested scopes and maintained internally within a tree structure. Every table contains a list of the symbol tables that are its children, and each table also has a pointer back to its parent in the tree (except for the global symbol table which does not have a parent). The children method returns a pointer to the list of children and the parent method gets the pointer to the parent symbol table. Thus, to search through all of the enclosing scopes, one can follow the parent pointers back to the global symbol table, visiting all of the symbol tables along the way. The is_ancestor method provides an easy way to check if a given symbol table is an ancestor (i.e. an enclosing scope) of the current table.

Note that the symbol table hierarchy is not independent. The primary objects in a SUIF program are the files and the abstract syntax trees for the procedures. The symbol tables are always attached to these primary objects and are generally treated as if they are parts of those objects. For example, when a block of code is deleted the associated symbol table is automatically removed from the hierarchy and deleted.

The base_symtab class is the base class from which the other symbol table classes are derived, but it is an abstract class and cannot be used directly. There are four different derived symbol tables classes. They have much in common, but each is used at a different level in the hierarchy and thus has slightly different features.


Go to the first, previous, next, last section, table of contents.