coins.sym
Class SymTableImpl

java.lang.Object
  extended bycoins.sym.SymTableImpl
All Implemented Interfaces:
SymTable

public class SymTableImpl
extends java.lang.Object
implements SymTable

SymTableImpl -- Symbol tabel class implementing SymTable.


Field Summary
protected  int fDbgLevel
           
protected  Sym firstSym
          Symbols in this symbol table
 java.lang.String fTableName
           
 IoRoot ioRoot
           
protected  Sym lastSym
           
protected  Sym ownerSym
           
 SymRoot symRoot
           
 
Constructor Summary
SymTableImpl(SymRoot pSymRoot)
           
 
Method Summary
 Sym define(java.lang.String pInternedName, int pSymKind, Sym pDefinedIn)
          define Define a new symbol specified by the parameter pUniqueName in the current symbol table.
 Sym defineUnique(java.lang.String pInternedName, int pSymKind, Sym pDefinedIn)
          defineUnique Define a new symbol specified by the parameter pUniqueName in the current symbol table without traversing ancestor symbol tables.
 java.lang.String generateConstName(Sym pOldSym, int index)
           
 Sym generateDerivedSym(Sym pBaseSym)
          generateDerivedSym Generate a symbol having the same type and kind as that of pSym in this symbol table.
 Elem generateElem(Type pType, Sym pDefinedIn)
          generateElem Generate an element of type pType in this symbol table.
 Label generateLabel()
          generateLabel Generate an internal label in subpSymTable().
 Param generateParam(Type pType, Sym pDefinedIn)
          generateParam Generate a parameter of type pType in subpSymTable().
 Sym generateSym(Type pType, int pSymKind, java.lang.String pPrefix, Sym pDefinedIn)
          generateSym Generate a symbol of type pType in this symbol table (to be used as block name, etc.).
 java.lang.String generateSymName(java.lang.String pHeader)
          Generate symbol name which is unique in this SymTable and its ancestors.
 Sym generateTag()
          generateTag Generate a tag name in subpSymTable().
 Sym generateTag(java.lang.String pTagName)
           
 java.lang.String generateUniqueName(Sym pOldSym, Subp pSubp)
          Generate unique name for symbols in the form of subprogramName_originalName_n, where, subprogramName is the name of the subprogram defining the symbol ("" for global symbol), oroginalName is the name of the symbol, n is sequence number (1, 2, 3, ...) attached to avoid duplication if there are same names declared in one subprogram.
 Var generateVar(Type pType)
          generateVar Generate a variable of type pType in the symbol table of current subprogram symRoot.subpCurrent (to be used as temporal variable, etc.).
 Var generateVar(Type pType, Sym pDefinedIn)
          generateVar Generate a variable of type pType in this symbol table (to be used as temporal variable, etc.).
 SymTable getBrother()
          getBrother
 SymTable getFirstChild()
          getFirstChild
 Sym getFirstSym()
          getFirstSym Get the first symbol recorded in this symbol table.
 Sym getOwner()
          getOwner Get the owner node to which this symbol table is attached.
 java.lang.String getOwnerName()
          getOwnerName Get the name of the owner of this symbol table.
 SymTable getParent()
          getParent Get parent symbol table of this table.
 Subp getSubp()
          getSubp Get the subprogram to which this symbol table is attached or in which the owner of this symbol table is contained.
 int getSymCount()
          getSymCount Get the number of symbols recorded in the symbol table.
 SymIterator getSymIterator()
          getSymIterator Get iterator to scan all symbols recorded in this symbol table.
 SymNestIterator getSymNestIterator()
          getSymNestIterator (##6) Get iterator to scan all symbols recorded in this symbol table and its children.
 SymTableIterator getSymTableIterator()
          getSymTableIterator (##10) Get iterator to scan all symbols tables starting from this symbol table and its children.
 boolean isInThisSymTable(Sym pSym)
          isInThisSymTable
 void linkSym(Sym pNewSym)
          linkSym Link pNewSym as the last symbol of this symbol table.
 java.lang.String makeNewName(java.lang.String pOldName, java.lang.String lSubpName, int index)
           
 SymTable popSymTable()
          popSymTable Close this (current) symbol table and make its ancestor symbol table as the current symbol table if this has the ancestor.
 void printSymTable()
          printSymTable (##2) Print symbols in this symbol table using toString().
 void printSymTableAll(SymTable pSymTable)
          printSymTableAll (##2) Print symbols in pSymTable and all its descendent symbol tables using printSymTable.
 void printSymTableAllDetail()
          printSymTableAllDetail with no param.
 void printSymTableAllDetail(SymTable pSymTable)
          printSymTableAllDetail (##2) Print symbols in pSymTable and all its descendent symbol tables using printSymTableDetail.
 void printSymTableDetail()
          printSymTableDetail Print this symbol table.
 SymTable pushSymTable(Sym pOwner)
          pushSymTable Make this (current) symbol table as an ancestor symbol table and create a new symbol table making it as the current symbol table.
 Sym redefine(Sym pSym, int pSymKind, Sym pDefinedIn)
          redefine Create a new symbol that has the name same as this symbol but having the symbol kind indicated by the parameter pSymKind in the current symbol table.
 SymTable reopenSymTable(SymTable pPreviousSymTable)
          reopenSymTable Push this (current) symbol table as the ancestor symbol table and make the symbol table specified by the parameter as the new current symbol table.
 Sym search(java.lang.String pInternedName)
          search Search the symbol specified by the parameter pInternedName in the current symbol table and its ancestors.
 Sym search(java.lang.String pName, int symkind)
          search Search a symbol named pName starting from this symbol table and upward (ancestors).
 Sym searchLocal(java.lang.String pName, int symkind)
          searchLocal Search a symbol named pName withis this symbol table without traversing other symbol table.
 Sym searchLocal(java.lang.String pInternedName, int pSymKind, boolean pSpecifiedKind)
          searchLocal Search the symbol which is specified by parameter pInternedName.
 SymTableEntry searchLocalEntry(java.lang.String pInternedName, int pSymKind, boolean pSpecifiedKind)
           
 Sym searchOrAdd(java.lang.String pInternedName, int pSymKind, Sym pDefinedIn, boolean pWithinThisTable, boolean pSpecifiedKind)
          searchOrAdd Search the symbol which is specified by parameter pInternedName, pSymKind.
 SymTableEntry searchOrAddEntry(java.lang.String pInternedName, int pSymKind, Sym pDefinedIn, boolean pWithinThisTable, boolean pSpecifiedKind)
          searchOrAddEntry Search a symbol table entry where a symbol is to be placed.
 Sym searchOrAddSym(Sym s)
          searchOrAddSym Add symbol s to this symbol table.
 Sym searchSymOfThisKind(Sym pSym, int pSymKind)
          searchSymOfThisKind Search for the symbol having the same name as the parameter pSym and its kind is same to pSymKind in the same manner as Search.
 SymTable searchTableHaving(Sym s)
          searchTableHaving Search a symbol symbol table containing the symbol named pName starting from this symbol table and upward (ancestors).
 void setUniqueNameToAllSym()
          setUniqueNameToAllSym Set unique name to all symbols of the kind Var, Param, Subp, Label in the whole compile unit.
 SymTable subpSymTable()
          subpSymTable Get the symbol table of current subprogram.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

symRoot

public final SymRoot symRoot

ioRoot

public final IoRoot ioRoot

fTableName

public java.lang.String fTableName

firstSym

protected Sym firstSym
Symbols in this symbol table


lastSym

protected Sym lastSym

ownerSym

protected Sym ownerSym

fDbgLevel

protected final int fDbgLevel
Constructor Detail

SymTableImpl

public SymTableImpl(SymRoot pSymRoot)
Method Detail

pushSymTable

public SymTable pushSymTable(Sym pOwner)
Description copied from interface: SymTable
pushSymTable Make this (current) symbol table as an ancestor symbol table and create a new symbol table making it as the current symbol table. Linkage between the new current symbol table and the ancestor symbol table is made and the new current symbol table is made a direct descendant symbol table of the ancestor. "this" should be the current symbol table that is to be made as the ancestor. If pOwner is a subprogram, then symRoot.subpCurrent is set to pOwner and symRoot.symTableCurrentSubp is set to the created symbol tablbe.

Specified by:
pushSymTable in interface SymTable
Parameters:
pOwner - Symbol owning the the new SymTable (subprogram, etc.), null if no symbol corresponds.
Returns:
the newly created current symbol table.

popSymTable

public SymTable popSymTable()
popSymTable Close this (current) symbol table and make its ancestor symbol table as the current symbol table if this has the ancestor. The closed symbol table can be reopened by reopenSymTable. "this" should be the current symbol table to be closed.

Specified by:
popSymTable in interface SymTable
Returns:
the ancestor symbol table that is resumed as the current symbol table. If this has no ancestor, then return null.

reopenSymTable

public SymTable reopenSymTable(SymTable pPreviousSymTable)
reopenSymTable Push this (current) symbol table as the ancestor symbol table and make the symbol table specified by the parameter as the new current symbol table. "this" should be the current symbol table that is to be made as the ancestor.

Specified by:
reopenSymTable in interface SymTable
Parameters:
pPreviousSymTable - a symbol table that was once a direct descendant symbol table of this symbol table.
Returns:
pPreviousSymTable that is made as the new current symbol table.

getParent

public SymTable getParent()
Description copied from interface: SymTable
getParent Get parent symbol table of this table.

Specified by:
getParent in interface SymTable

getFirstChild

public SymTable getFirstChild()
Description copied from interface: SymTable
getFirstChild

Specified by:
getFirstChild in interface SymTable
Returns:
the first child symbol table of this. If there is no child, return null.

getBrother

public SymTable getBrother()
Description copied from interface: SymTable
getBrother

Specified by:
getBrother in interface SymTable
Returns:
the next brother symbol table of this. If there is no next brother, return null.

defineUnique

public Sym defineUnique(java.lang.String pInternedName,
                        int pSymKind,
                        Sym pDefinedIn)
defineUnique Define a new symbol specified by the parameter pUniqueName in the current symbol table without traversing ancestor symbol tables. If there is already a symbol with the same name as pUniqueName, then it is treated as an erronous call and no new symbol is created. "this" should be the current symbol table.

Specified by:
defineUnique in interface SymTable
Parameters:
pSymKind - kind of the symbol to be created (see GlobalConstants).
pDefinedIn - symbol representing language construct such as subprogram name or structure name that encloses the definition of the symbol to be defined. If there is no such construct, specify null. (See definedIn().)
pInternedName - unique string representing the symbol to be defined.
Returns:
the new symbol having the name same to pUniqueName and whose symbol kind is pSymKind. If there is already a symbol with the same name as pUniqueName, then return null. Note: If pSymKind is either Sym.KIND_SUBP, Sym.KIND_VAR, Sym.KIND_ELEM, or Sym.KIND_CONST, etc. then either Subp, Var, Param, Elem, or Const instance is created each respectively. Several linkages are made between the defined symbol and pDefinedIn symbol (see definedIn(), FirstParam(), FirstLocalVar(), FirstElem(), NextVar(), NextSubp(), etc.) These rules are applied also to Define and redefine.

define

public Sym define(java.lang.String pInternedName,
                  int pSymKind,
                  Sym pDefinedIn)
define Define a new symbol specified by the parameter pUniqueName in the current symbol table. If there is already an old symbol with the same name as pUniqueName and with the same kind as pSymKind in this symbol table, then no new symbol is created and the old symbol is returned. Ancestor symbol tables are not traversed to find the same symbol. "this" should be the current symbol table.

Specified by:
define in interface SymTable
Parameters:
pSymKind - kind of the symbol to be created (see GlobalConstants).
pDefinedIn - language construct symbol that encloses the definition of pUniqueName. If there is no such construct, specify null.
pInternedName - unique string representing the symbol to be defined.
Returns:
the symbol having the name same to pUniqueName and whose symbol kind is pSymKind. If there is already a symbol with the same name as pUniqueName and the same kind as pSymKind, then return it.

search

public Sym search(java.lang.String pInternedName)
search Search the symbol specified by the parameter pInternedName in the current symbol table and its ancestors. The symbol is searched in the current symbol table first, and if not found, then searched in its direct ancestor, and if not found again, then searched in ancestor's ancestor, and so on. If there are more than one symbols having the same name then the one encountered first in the above search process is returned. "this" should be the current symbol table. See searchSymOfThisKind and redefine.

Specified by:
search in interface SymTable
Parameters:
pInternedName - unique string representing the symbol to be searched.
Returns:
the symbol having the name same to pInternedName, where the symbol kind of the returned symbol may differ from that of pUniqueName given this time. If there is no same symbol then return null.

searchLocal

public Sym searchLocal(java.lang.String pInternedName,
                       int pSymKind,
                       boolean pSpecifiedKind)
searchLocal Search the symbol which is specified by parameter pInternedName. If pSpecifiedKind is ture, search the symbol which is same as pInternedName and pSymKind. And Searching is current symbol table only.

Specified by:
searchLocal in interface SymTable
Parameters:
pInternedName - symbol name which is Interned.
pSymKind - symbol kind.
pSpecifiedKind - If ture, search by name and kind.
Returns:
Sym The symbol's name is same as pInternedName. If pSpecifiedKind is ture, kind is also same kind.

searchLocalEntry

public SymTableEntry searchLocalEntry(java.lang.String pInternedName,
                                      int pSymKind,
                                      boolean pSpecifiedKind)

searchOrAdd

public Sym searchOrAdd(java.lang.String pInternedName,
                       int pSymKind,
                       Sym pDefinedIn,
                       boolean pWithinThisTable,
                       boolean pSpecifiedKind)
searchOrAdd Search the symbol which is specified by parameter pInternedName, pSymKind. If pWithinThisTable is false search all parents symbol table are as well as searched. If pSpecifiedKind is ture, search the symbol which is same as pInternedName and pSymKind. If the symbol is found and then return it. If not, make new symbol, then add to this symbol table.

Specified by:
searchOrAdd in interface SymTable
Parameters:
pSpecifiedKind - If ture, search the symbol which is same name as pInternedName and same kind as pSymKind.
Returns:
Sym found symbol or generated symbol.

searchOrAddEntry

public SymTableEntry searchOrAddEntry(java.lang.String pInternedName,
                                      int pSymKind,
                                      Sym pDefinedIn,
                                      boolean pWithinThisTable,
                                      boolean pSpecifiedKind)
Description copied from interface: SymTable
searchOrAddEntry Search a symbol table entry where a symbol is to be placed. This enables to get a SymTable slot to which a symbol is to be placed and then create the symbol object whereas searchOrAdd creates a symbol object in it if the symbol is not yet created.

Specified by:
searchOrAddEntry in interface SymTable
Returns:
a symbol table entry to which pInternedName is to be recorded; This is used to get blank symbol table entry corresponding to pInternedName and then write a symbol object to the entry by setEntrySym of SymTableEntry.

linkSym

public void linkSym(Sym pNewSym)
Description copied from interface: SymTable
linkSym Link pNewSym as the last symbol of this symbol table. Set fRecordedIn of pNewSym as this symbol table.

Specified by:
linkSym in interface SymTable

searchSymOfThisKind

public Sym searchSymOfThisKind(Sym pSym,
                               int pSymKind)
searchSymOfThisKind Search for the symbol having the same name as the parameter pSym and its kind is same to pSymKind in the same manner as Search. If one is found then it is returned. If not found, then null is returned. "this" should be the current symbol table.

Specified by:
searchSymOfThisKind in interface SymTable
Parameters:
pSym - a symbol having the same name as the one to be searched.
pSymKind - kind of the symbol to be searched (see GlobalConstants).
Returns:
the symbol whose name and kind are the same to those of pSym, or return null if not found.

redefine

public Sym redefine(Sym pSym,
                    int pSymKind,
                    Sym pDefinedIn)
redefine Create a new symbol that has the name same as this symbol but having the symbol kind indicated by the parameter pSymKind in the current symbol table. "this" should be the current symbol table. Usage of redefine: If the source language permits the same name to be defined as a name of different kind in the same scope, then Search may return a symbol having the same name but with different kind. In that case, search ancestors again by searchSymOfThisKind and if not found, then use redefine to define the symbol as the new one of pSymKind. For example, enumerator may have the same name as that of some subprogram in C.

Specified by:
redefine in interface SymTable
Parameters:
pSymKind - symbol kind of the symbol to be created.
pDefinedIn - language construct symbol that encloses the definition of pSym. If there is no such construct, specify null.
Returns:
the created symbol.

subpSymTable

public SymTable subpSymTable()
Description copied from interface: SymTable
subpSymTable Get the symbol table of current subprogram. If this SymTable is a SymTable defined inside a subprogram, then get the SymTable of the enclosing subprogram. If current subprogram is not yet defined, then get symTableRoot. This method is used in generating temporal variable, etc.

Specified by:
subpSymTable in interface SymTable

generateVar

public Var generateVar(Type pType)
generateVar Generate a variable of type pType in the symbol table of current subprogram symRoot.subpCurrent (to be used as temporal variable, etc.). If subpCurrent is null, the variable is recorded in symTableRoot.

Specified by:
generateVar in interface SymTable
Parameters:
pType - type of the variable to be generated.
Returns:
the generated variable.

generateVar

public Var generateVar(Type pType,
                       Sym pDefinedIn)
generateVar Generate a variable of type pType in this symbol table (to be used as temporal variable, etc.). "this" should be the current symbol table.

Specified by:
generateVar in interface SymTable
Parameters:
pType - type of the variable to be generated.
pDefinedIn - language construct symbol that encloses the definition of the generated variable. If there is no such construct, specify null.
Returns:
the generated variable.

generateParam

public Param generateParam(Type pType,
                           Sym pDefinedIn)
Description copied from interface: SymTable
generateParam Generate a parameter of type pType in subpSymTable(). The name starts with "_param". Anonymous parameter should be given a name (by generateParam). "this" should be symTableCurrentSubp.

Specified by:
generateParam in interface SymTable
Parameters:
pType - type of the parameter to be generated.
pDefinedIn - Subprogram defining the parameter.
Returns:
the generated parameter.

generateElem

public Elem generateElem(Type pType,
                         Sym pDefinedIn)
Description copied from interface: SymTable
generateElem Generate an element of type pType in this symbol table. The name starts with "_elem". "this" should be the current symbol table.

Specified by:
generateElem in interface SymTable
Parameters:
pType - type of the element to be generated.
pDefinedIn - language construct symbol that encloses the definition of the element (structure or union name).
Returns:
the generated element.

generateLabel

public Label generateLabel()
Description copied from interface: SymTable
generateLabel Generate an internal label in subpSymTable(). The name starts with "_lab".

Specified by:
generateLabel in interface SymTable
Returns:
the generated label.

generateTag

public Sym generateTag()
Description copied from interface: SymTable
generateTag Generate a tag name in subpSymTable(). The name starts with "_tag".

Specified by:
generateTag in interface SymTable
Returns:
the generated tag symbol.

generateTag

public Sym generateTag(java.lang.String pTagName)
Specified by:
generateTag in interface SymTable

generateSym

public Sym generateSym(Type pType,
                       int pSymKind,
                       java.lang.String pPrefix,
                       Sym pDefinedIn)
generateSym Generate a symbol of type pType in this symbol table (to be used as block name, etc.). "this" should be the current symbol table.

Specified by:
generateSym in interface SymTable
Parameters:
pType - type of the symbol to be generated.
pSymKind - symbol kind number of the symbol to be generated.
pPrefix - prefix to be attached to the symbol name.
pDefinedIn - language construct symbol that encloses the definition of the generated variable. If there is no such construct, specify null.
Returns:
the generated symbol. As for variable, parameter, element, label, use generateVar, generateParam, generateElem, generateLabel.

generateDerivedSym

public Sym generateDerivedSym(Sym pBaseSym)
Description copied from interface: SymTable
generateDerivedSym Generate a symbol having the same type and kind as that of pSym in this symbol table. The generated name has a name beginning with the name of pSym preceeded by "_" and ending with one of suffixes _1, _2, _3, ... . The suffix is selected so that the same name does not appear in the symbol table. "this" should be symTableCurrentSubp or symTableCurrent.

Specified by:
generateDerivedSym in interface SymTable
Returns:
the generated symbol.

generateSymName

public java.lang.String generateSymName(java.lang.String pHeader)
Generate symbol name which is unique in this SymTable and its ancestors.

Specified by:
generateSymName in interface SymTable
Parameters:
pHeader - is a string to be used as header of the generated name.
Returns:
the generated name

getSymIterator

public SymIterator getSymIterator()
Description copied from interface: SymTable
getSymIterator Get iterator to scan all symbols recorded in this symbol table.

Specified by:
getSymIterator in interface SymTable

getSymNestIterator

public SymNestIterator getSymNestIterator()
Description copied from interface: SymTable
getSymNestIterator (##6) Get iterator to scan all symbols recorded in this symbol table and its children.

Specified by:
getSymNestIterator in interface SymTable

getSymTableIterator

public SymTableIterator getSymTableIterator()
Description copied from interface: SymTable
getSymTableIterator (##10) Get iterator to scan all symbols tables starting from this symbol table and its children.

Specified by:
getSymTableIterator in interface SymTable

getFirstSym

public Sym getFirstSym()
Description copied from interface: SymTable
getFirstSym Get the first symbol recorded in this symbol table. The rest of symbols can be get by getNextSym() of Sym interface. This method is not necessary when SymIterator is used.

Specified by:
getFirstSym in interface SymTable

isInThisSymTable

public boolean isInThisSymTable(Sym pSym)
Description copied from interface: SymTable
isInThisSymTable

Specified by:
isInThisSymTable in interface SymTable
Parameters:
pSym - Any symbol.
Returns:
true if pSym is contained in this SymTable otherwise return false;

toString

public java.lang.String toString()

printSymTableAll

public void printSymTableAll(SymTable pSymTable)
Description copied from interface: SymTable
printSymTableAll (##2) Print symbols in pSymTable and all its descendent symbol tables using printSymTable.

Specified by:
printSymTableAll in interface SymTable
Parameters:
pSymTable - any symbol table.

printSymTableAllDetail

public void printSymTableAllDetail()
Description copied from interface: SymTable
printSymTableAllDetail with no param. Print symbols in pSymTable and all its descendent symbol tables using printSymTableDetail. This also print symRoot.symTableConst. and if dbgSym.getLevel() > 3, print symRoot.symTableUnique, too.

Specified by:
printSymTableAllDetail in interface SymTable

printSymTableAllDetail

public void printSymTableAllDetail(SymTable pSymTable)
Description copied from interface: SymTable
printSymTableAllDetail (##2) Print symbols in pSymTable and all its descendent symbol tables using printSymTableDetail.

Specified by:
printSymTableAllDetail in interface SymTable
Parameters:
pSymTable - any symbol table.

printSymTable

public void printSymTable()
Description copied from interface: SymTable
printSymTable (##2) Print symbols in this symbol table using toString().

Specified by:
printSymTable in interface SymTable

printSymTableDetail

public void printSymTableDetail()
printSymTableDetail Print this symbol table. printDetail: After executing printSymTable(), print other attributes. "this" may be any symbol table.

Specified by:
printSymTableDetail in interface SymTable

getOwner

public Sym getOwner()
Description copied from interface: SymTable
getOwner Get the owner node to which this symbol table is attached.

Specified by:
getOwner in interface SymTable
Returns:
the owner symbol (subprogram, block name, struct, union, etc.).

getOwnerName

public java.lang.String getOwnerName()
Description copied from interface: SymTable
getOwnerName Get the name of the owner of this symbol table.

Specified by:
getOwnerName in interface SymTable
Returns:
the owner name. If the owner is null, return "null".

getSubp

public Subp getSubp()
Description copied from interface: SymTable
getSubp Get the subprogram to which this symbol table is attached or in which the owner of this symbol table is contained.

Specified by:
getSubp in interface SymTable
Returns:
the subprogram owning or containing this symbol table.

getSymCount

public int getSymCount()
Description copied from interface: SymTable
getSymCount Get the number of symbols recorded in the symbol table. (It will not be decreased even if a symbol is deleted.) Empty symbol table will return 0.

Specified by:
getSymCount in interface SymTable

searchOrAddSym

public Sym searchOrAddSym(Sym s)
searchOrAddSym Add symbol s to this symbol table. If there is already the symbol in this table, then return it without adding the symbol. //## previous version public Sym entry(Sym s)

Specified by:
searchOrAddSym in interface SymTable
Parameters:
s - Symbol to be searched or added.
Returns:
the symbol found or added.

search

public Sym search(java.lang.String pName,
                  int symkind)
search Search a symbol named pName starting from this symbol table and upward (ancestors).

Specified by:
search in interface SymTable
Parameters:
pName - name of the symbol to be serached.
symkind - symbol kind (Sym.KIND_VAR, etc.).
Returns:
the symbol if found, null otherwise.

searchLocal

public Sym searchLocal(java.lang.String pName,
                       int symkind)
searchLocal Search a symbol named pName withis this symbol table without traversing other symbol table.

Specified by:
searchLocal in interface SymTable
Parameters:
pName - name of the symbol to be serached.
symkind - symbol kind (Sym.KIND_VAR, etc.).
Returns:
the symbol if found in this symbol table, null otherwise.

searchTableHaving

public SymTable searchTableHaving(Sym s)
searchTableHaving Search a symbol symbol table containing the symbol named pName starting from this symbol table and upward (ancestors).

Specified by:
searchTableHaving in interface SymTable
Parameters:
s - Symbol to be searched if it is contained in some symbol table.
Returns:
the symbol table containing the symbol s if found, null otherwise.

makeNewName

public java.lang.String makeNewName(java.lang.String pOldName,
                                    java.lang.String lSubpName,
                                    int index)

generateUniqueName

public java.lang.String generateUniqueName(Sym pOldSym,
                                           Subp pSubp)
Description copied from interface: SymTable
Generate unique name for symbols in the form of subprogramName_originalName_n, where, subprogramName is the name of the subprogram defining the symbol ("" for global symbol), oroginalName is the name of the symbol, n is sequence number (1, 2, 3, ...) attached to avoid duplication if there are same names declared in one subprogram.

Specified by:
generateUniqueName in interface SymTable
Parameters:
pOldSym -
pSubp -
Returns:
unique name string.

generateConstName

public java.lang.String generateConstName(Sym pOldSym,
                                          int index)

setUniqueNameToAllSym

public void setUniqueNameToAllSym()
Description copied from interface: SymTable
setUniqueNameToAllSym Set unique name to all symbols of the kind Var, Param, Subp, Label in the whole compile unit. This operation is performed for all symbol tables under symTableRoot. Normally, this should be called only once after generating HIR for all subprograms and immediately before generating LIR (by ConvToNewLIR).

Specified by:
setUniqueNameToAllSym in interface SymTable