net.mtu.eggplant.dbc
Class Symtab

java.lang.Object
  extended bynet.mtu.eggplant.dbc.Symtab

public class Symtab
extends Object

Class that keeps track of all classes and interfaces parsed in this run. This is the place where most of the work for instrumentation gets done. All lookups are done here.

Version:
$Revision: 1.11 $

Constructor Summary
Symtab(Configuration config)
           
 
Method Summary
 void addCodeFragment(CodeFragment cf)
          Associate this CodeFragment with the current file begin parsed.
 void addImport(String className, String packageName)
          Add to the list of imports for this class.
 void finishClass(CodePoint cp)
          Take all of the assertion methods that have been cached up and dump them out with this class.
 void finishFile(boolean writeFile)
          Just resets the internal pointers to files to be the last file we pushed on the file stack, or null if no other files are being processed.
 void finishMethod(CodePointPair startEnd, Set thrownExceptions)
          Finishes the method that is currently being parsed.
 Configuration getConfiguration()
           
 AssertClass getCurrentClass()
          Accessor for the currnet class being instrumented.
 net.mtu.eggplant.dbc.InstrumentedFile getCurrentFile()
           
 AssertMethod getCurrentMethod()
          Get at the method that's currently being parsed.
 String getCurrentPackageName()
           
 void instrument(net.mtu.eggplant.dbc.InstrumentedFile ifile)
          instrument a file we've parsed.
 boolean isDestinationOlderThanCurrentFile(String packageName)
           
 void setCurrentPackageName(String packageName)
          set the package the the next class(es) belong to
 void startClass(String name, List invariants, boolean isInterface, boolean isAnonymous, String superclass)
          Push a class onto the stack of classes to handle inner classes.
 boolean startFile(File f)
          Start a file.
 void startMethod(String name, List preConditions, List postConditions, List params, String retType, Set mods)
          Creates a new AssertMethod object for the current class and sets this as the current method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Symtab

public Symtab(Configuration config)
PreConditions
(config != null)
Method Detail

getConfiguration

public final Configuration getConfiguration()
Returns:
the configuration object used with this symbol table.

setCurrentPackageName

public final void setCurrentPackageName(String packageName)
set the package the the next class(es) belong to


getCurrentPackageName

public final String getCurrentPackageName()
Returns:
the package that we're currently defining classes for

getCurrentFile

public final net.mtu.eggplant.dbc.InstrumentedFile getCurrentFile()

startFile

public boolean startFile(File f)
Start a file. Sets this file as the current one and saves the state of the current file being processed, if there is one, nothing happens if this file has already been seen.

Returns:
false if the file has already been seen.

finishFile

public void finishFile(boolean writeFile)
Just resets the internal pointers to files to be the last file we pushed on the file stack, or null if no other files are being processed.


startClass

public void startClass(String name,
                       List invariants,
                       boolean isInterface,
                       boolean isAnonymous,
                       String superclass)
Push a class onto the stack of classes to handle inner classes. By the time this method has been called all of the imports have been seen as well as the superclass and the implemented/extended interfaces.

Parameters:
name - the name of the class, can be null in the case of anonomous classes
invariants - the invariants for this class, ordered as they appear in the source file
PreConditions
(invariants != null)

finishClass

public void finishClass(CodePoint cp)
Take all of the assertion methods that have been cached up and dump them out with this class. This should dump out pre and post methods for each method defined as well as a checkInvariants method.

Parameters:
cp - the point that represents the closing curly brace of the class, the checkInvariant method will be inserted here.
PreConditions
(cp != null)

getCurrentClass

public final AssertClass getCurrentClass()
Accessor for the currnet class being instrumented.

Returns:
the current class being parsed, may return null

instrument

public void instrument(net.mtu.eggplant.dbc.InstrumentedFile ifile)
instrument a file we've parsed.


addCodeFragment

public void addCodeFragment(CodeFragment cf)
Associate this CodeFragment with the current file begin parsed.

Parameters:
cf - fragment of code that needs to be inserted
PreConditions
(cf != null)

addImport

public void addImport(String className,
                      String packageName)
Add to the list of imports for this class.

Parameters:
className - the name of class from the import statement, null if a star import
packageName - the name of the package package from the import statement

startMethod

public void startMethod(String name,
                        List preConditions,
                        List postConditions,
                        List params,
                        String retType,
                        Set mods)
Creates a new AssertMethod object for the current class and sets this as the current method.

Parameters:
name - the name of this method, null for a constructor
preConditions - the preconditions for this method
postConditions - the postconditions for this method
params - Set of StringPairs, (class, parameter name)
retType - the return type of this method, null signals this method is a constructor
mods - the modifiers for the method, Set of Strings
PreConditions
(preConditions != null && net.mtu.eggplant.util.JPSCollections.elementsInstanceOf(postConditions, AssertToken.class)), (postConditions != null && net.mtu.eggplant.util.JPSCollections.elementsInstanceOf(preConditions, AssertToken.class)), (params != null && net.mtu.eggplant.util.JPSCollections.elementsInstanceOf(StringPair.class)), (mods != null && net.mtu.eggplant.util.JPSCollections.elementsInstanceOf(String.class))

finishMethod

public void finishMethod(CodePointPair startEnd,
                         Set thrownExceptions)
Finishes the method that is currently being parsed. This will pop a method off the method stack, if one exists. This will also set the method entrance and add a method exit if the method is void.

Parameters:
startEnd - two code points representing the opening and closing braces of the method, these points are equal if the method is abstract/native
thrownExceptions - list of exceptions this method declares in it's throws clause, null if no exceptions are declared
PreConditions
(startEnd != null)

getCurrentMethod

public AssertMethod getCurrentMethod()
Get at the method that's currently being parsed.


isDestinationOlderThanCurrentFile

public boolean isDestinationOlderThanCurrentFile(String packageName)
Returns:
true if the destination for the current file is older than the source file, or doesn't exist. Which means that we should parse this file.