dpt.symbtab
Class Definition

java.lang.Object
  |
  +--dpt.symbtab.Definition
Direct Known Subclasses:
ArrayDef, LabelDef, MultiDef, ScopedDef, VariableDef

abstract class Definition
extends java.lang.Object
implements Reportable

This abstract class represents a symbol definition in a Java source file. All symbols used in our Java symbol table stem from this definition.


Field Summary
private  Occurrence definition
          A file location where the item was defined
private  java.lang.String name
          The name of the symbol
private  ScopedDef parentScope
          The scope that contains this symbol
private  JavaVector references
          A list of references to this symbol
(package private) static int ST_CL
           
(package private) static int ST_FU
           
(package private) static int ST_FU_EXT
           
(package private) static int ST_IF
           
(package private) static int ST_IMPL
           
(package private) static int ST_IMPORT
           
(package private) static int ST_PAC
           
(package private) static int ST_SUB
           
(package private) static int ST_SUPER
           
(package private) static int ST_VAR
           
 
Constructor Summary
(package private) Definition(java.lang.String name, Occurrence occ, ScopedDef parentScope)
          Constructor for the base of a symbol definition
 
Method Summary
(package private)  void addReference(Occurrence occ)
          Add a location of a reference to the symbol to our reference list
(package private)  java.lang.String ExtractClass(java.lang.String sName)
           
(package private)  java.lang.String ExtractClass(java.lang.String sName, boolean bRight)
           
(package private)  java.lang.String ExtractName(java.lang.String sName)
           
(package private)  java.lang.String ExtractPackage(java.lang.String sName, int nTypName)
           
(package private)  java.lang.String ExtractPackage(java.lang.String sName, int nTypName, boolean bRight)
           
(package private)  java.lang.String getDef()
          Get a String representation of the location where this symbol was defined
abstract  java.lang.String GetItem(int TypID)
           
abstract  java.util.Vector GetItems(int TypID, java.lang.String modifier)
           
abstract  java.lang.String GetLocation(int TypID, java.lang.String sName)
           
(package private)  java.lang.String getName()
          Get the basic name of the symbol
(package private)  Occurrence getOccurrence()
          Get the information about where the symbol was defined
(package private)  ScopedDef getParentScope()
          Get the symbol that contains the definition of this symbol
(package private)  java.lang.String getQualifiedName()
          Get the fully-qualified name of the symbol Keep building the name by recursively calling the parentScope's getQualifiedName() method...
(package private)  java.util.Vector GetReferences()
           
(package private)  boolean isSuperClassOf(Definition def)
          Determine if this symbol represents a class that is a superclass of another symbol.
(package private)  void listReferences(IndentingPrintWriter out)
          return a String representation of this class for printing
(package private)  Definition lookup(java.lang.String name)
          The "default" lookup routine.
(package private)  Definition lookup(java.lang.String name, int numParams)
          Lookup a method in our scope.
abstract  void report(IndentingPrintWriter out)
          An abstract method used to write information about this definition to a report file.
(package private)  void resolveTypes(SymbolTable symbolTable)
          This method resolves any references to other symbols.
(package private)  void setParentScope(ScopedDef parentScope)
          Set a reference to the symbol that syntactically contains this symbol.
 java.lang.String toString()
          return a String representation of this class for printing Note that this version of toString() is used by nearly all of the subclasses of Definition.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

ST_VAR

static final int ST_VAR

ST_CL

static final int ST_CL

ST_FU

static final int ST_FU

ST_PAC

static final int ST_PAC

ST_IF

static final int ST_IF

ST_SUPER

static final int ST_SUPER

ST_SUB

static final int ST_SUB

ST_IMPORT

static final int ST_IMPORT

ST_IMPL

static final int ST_IMPL

ST_FU_EXT

static final int ST_FU_EXT

definition

private Occurrence definition
A file location where the item was defined

parentScope

private ScopedDef parentScope
The scope that contains this symbol

references

private JavaVector references
A list of references to this symbol

name

private java.lang.String name
The name of the symbol
Constructor Detail

Definition

Definition(java.lang.String name,
           Occurrence occ,
           ScopedDef parentScope)
Constructor for the base of a symbol definition
Method Detail

addReference

void addReference(Occurrence occ)
Add a location of a reference to the symbol to our reference list

getDef

java.lang.String getDef()
Get a String representation of the location where this symbol was defined

getName

java.lang.String getName()
Get the basic name of the symbol

getOccurrence

Occurrence getOccurrence()
Get the information about where the symbol was defined

getParentScope

ScopedDef getParentScope()
Get the symbol that contains the definition of this symbol

getQualifiedName

java.lang.String getQualifiedName()
Get the fully-qualified name of the symbol Keep building the name by recursively calling the parentScope's getQualifiedName() method...

isSuperClassOf

boolean isSuperClassOf(Definition def)
Determine if this symbol represents a class that is a superclass of another symbol. For most symbols, this is false (because most symbols are not classes...). This method will be overridden for classes and interfaces.

listReferences

void listReferences(IndentingPrintWriter out)
return a String representation of this class for printing

GetReferences

java.util.Vector GetReferences()

lookup

Definition lookup(java.lang.String name)
The "default" lookup routine. This is used to search for a name within the scope of another symbol. This version of the lookup method is a convenience that just passes -1 as the parameter count (meaning look the name up as a non-method symbol

lookup

Definition lookup(java.lang.String name,
                  int numParams)
Lookup a method in our scope. Because this is only a valid operation for scoped definitions, we default this to throw an exception that states so

report

public abstract void report(IndentingPrintWriter out)
An abstract method used to write information about this definition to a report file.
Specified by:
report in interface Reportable

GetItem

public abstract java.lang.String GetItem(int TypID)
Specified by:
GetItem in interface Reportable

GetLocation

public abstract java.lang.String GetLocation(int TypID,
                                             java.lang.String sName)
Specified by:
GetLocation in interface Reportable

GetItems

public abstract java.util.Vector GetItems(int TypID,
                                          java.lang.String modifier)
Specified by:
GetItems in interface Reportable

ExtractName

java.lang.String ExtractName(java.lang.String sName)

ExtractClass

java.lang.String ExtractClass(java.lang.String sName)

ExtractClass

java.lang.String ExtractClass(java.lang.String sName,
                              boolean bRight)

ExtractPackage

java.lang.String ExtractPackage(java.lang.String sName,
                                int nTypName)

ExtractPackage

java.lang.String ExtractPackage(java.lang.String sName,
                                int nTypName,
                                boolean bRight)

resolveTypes

void resolveTypes(SymbolTable symbolTable)
This method resolves any references to other symbols. At this level there is nothing to resolve, so do nothing.

setParentScope

void setParentScope(ScopedDef parentScope)
Set a reference to the symbol that syntactically contains this symbol.

toString

public java.lang.String toString()
return a String representation of this class for printing Note that this version of toString() is used by nearly all of the subclasses of Definition.
Overrides:
toString in class java.lang.Object