|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.multijava.util.Utils
org.multijava.mjc.TypeLoader
org.jmlspecs.checker.JmlTypeLoader
This class acts as a symbol table and a cache for types, type signatures, and external generic functions. It includes methods to load unknown type signatures. It maintains a mapping from fully qualified names to the CClass instances representing their signatures. Specifically the mapping is from a fully qualified type name to a set of instances that can be sorted. In MultiJava that set is a singleton set; however, for tools like JML where a single fully qualified name can refer to a specification and one or more refinements to that specification, the set may contain multiple items.
| Field Summary | |
private static CClass |
currentHostClass
|
private HashMap |
fileASTs
A mapping from files to the ASTs parsed from those files. |
private static HashSet |
filesProcessed
|
private HashMap |
incompleteTasksByQName
|
private static JmlTypeLoader |
singletonInstance
|
private static HashMap |
typeDeclASTs
A mapping from CClass to JmlTypeDeclaration
for traversal of "extends" and "implements" hierarchies. |
| Fields inherited from class org.multijava.mjc.TypeLoader |
compilationSessionTypeCache, fileFinder, vmSessionTypeCache |
| Fields inherited from class org.multijava.util.Utils |
DBG_LEVEL_HIGH, DBG_LEVEL_LOW, DBG_LEVEL_NO |
| Constructor Summary | |
private |
JmlTypeLoader()
|
protected |
JmlTypeLoader(JmlFileFinder finder)
Creates an instance with the given file finder. |
| Method Summary | |
void |
activatePartiallyProcessedTask(JmlCompilationUnit cUnit)
Reactivate the task for the compilation unit cUnit. |
void |
activateSymbolTableBuild(String qName)
Reactivate the task for the qualified type name qName. |
void |
activateSymbolTableBuild(JmlCompilationUnit cUnit)
Reactivate the task for the compilation unit cUnit
if the symbol table has not been built. |
void |
activateTypeCheck(String qName)
Reactivate the task for the qualified type name qName. |
void |
activateTypeCheck(JmlCompilationUnit cUnit)
Reactivate the task for the compilation unit cUnit
if the symbol table has not been built. |
boolean |
addToTypeCache(CClass typ)
Adds the given source class to the table of available classes. |
void |
addTypeDeclAST(JmlTypeDeclaration decl)
Adds a JML type declaration into the database. |
protected boolean |
checkUniqueness(CClass typ,
CClass last)
Returns true if typ is a legal unique type declaration. |
protected ClassInfo |
createClassInfo(String qName)
Creates and returns a class info object by reading the symbol file for the class with the given fully qualified name qName. |
protected void |
forgetEverythingAbout(File f,
JCompilationUnitType cunit)
Called by Main when the given file, from which the given compilation unit AST was derived, did not contain an expected result; this method removes all cached info. for the file. |
JCompilationUnitType |
getCUnitAST(File f)
Returns the AST parsed from the given file, or null if no AST is cached for the given file (either because the file has not been parsed or because no AST was created when parsing the file. |
static CClass |
getCurrentHostClass()
Returns the nearest host class to the current context. |
protected String |
getFileIdent(File f)
Returns the Java identifier associated with the name of the file contained in this file. |
static JmlTypeLoader |
getJmlSingleton()
|
JmlCompilationUnit |
getSuspendedCUnit(String qName)
Look for partially processed compilation unit (if suspended) for the qualified type name qName. |
void |
initSession()
Empties the compilation session caches to prepare for a new compilation session. |
JmlInterfaceDeclaration[] |
interfacesOf(JmlTypeDeclaration typeDecl)
Returns the interfaces of a given JML type declaration. |
boolean |
isDeclaredInDifferentSourceFiles(boolean isUnique,
CClass clazz)
Determines whether the given Class, using its fully qualified name, has been declared in more than one file. |
protected boolean |
isTrusted(String qName)
Returns true if the information for the type or package of the given qualified name should be retained for subsequent compilation sessions. |
protected void |
loadMostRefinedType(JmlSourceClass sourceClass)
Loads the "most refined" source class of this type. |
JCompilationUnitType |
putCUnitAST(File f,
JCompilationUnitType cunit)
Records a mapping from the given file to the given AST. |
JmlTypeDeclaration |
refinedDeclOf(JmlTypeDeclaration cdecl)
Returns the refined declaration of a given JML class declaration. |
CClass |
reloadType(CClass sourceClass)
|
protected void |
removeFromTypeCache(CClass typ)
Removes the qualified name of the given source class from the table of loaded classes (so it can be reloaded without causing conflicts). |
void |
removePartiallyProcessedTask(JmlCompilationUnit cUnit)
|
void |
savePartiallyProcessedTask(JmlCompilationUnit cUnit)
Save the task in case it needs to be reactivated. |
static void |
setCurrentHostClass(CClass sourceClass)
Records the host class nearest to the current context which is used by the method reloadType. |
JmlClassDeclaration |
superClassOf(JmlClassDeclaration cdecl)
Returns the superclass of a given JML class declaration. |
JmlClassDeclaration |
superClassOf(CClass cls)
Returns the superclass of a given JML class declaration. |
JmlTypeDeclaration |
typeDeclarationOf(CClass typ)
Returns the JML type declaration corresponding to the given source class; null is returned if no corresponding JML type
declaration is found in the database. |
| Methods inherited from class org.multijava.mjc.TypeLoader |
addTypeRep, classExists, fileFinder, find, findSourceFile, getSingleton, getTypeRep, isTypeLoaded, loadType, lookupType, lookupTypeRep, signatureCompleted |
| Methods inherited from class org.multijava.util.Utils |
assertTrue, assertTrue, combineArrays, escapeString, escapeString, fail, fail, getFilePath, hasFlag, hasOtherFlags, parsePathParts, relativePathTo, splitQualifiedName, splitQualifiedName, stripJavaModifiers, stripNonJavaModifiers, stripPrivateModifier, unescapeString, vectorToArray, vectorToIntArray |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private static HashSet filesProcessed
private HashMap fileASTs
private HashMap incompleteTasksByQName
private static HashMap typeDeclASTs
CClass to JmlTypeDeclaration
for traversal of "extends" and "implements" hierarchies.
invariant typeDeclASTs != null;
private static CClass currentHostClass
private static JmlTypeLoader singletonInstance
| Constructor Detail |
private JmlTypeLoader()
protected JmlTypeLoader(JmlFileFinder finder)
| Method Detail |
public static JmlTypeLoader getJmlSingleton()
public void initSession()
initSession in class TypeLoaderpublic boolean addToTypeCache(CClass typ)
also requires typ != null; modifies compilationSessionTypeCache, filesProcessed;
addToTypeCache in class TypeLoaderpublic JmlCompilationUnit getSuspendedCUnit(String qName)
qName.
public void activateSymbolTableBuild(String qName)
qName.
public void activateSymbolTableBuild(JmlCompilationUnit cUnit)
cUnit
if the symbol table has not been built.
public void activateTypeCheck(String qName)
qName.
public void activateTypeCheck(JmlCompilationUnit cUnit)
cUnit
if the symbol table has not been built.
public void activatePartiallyProcessedTask(JmlCompilationUnit cUnit)
cUnit.
public void savePartiallyProcessedTask(JmlCompilationUnit cUnit)
public void removePartiallyProcessedTask(JmlCompilationUnit cUnit)
protected boolean checkUniqueness(CClass typ,
CClass last)
checkUniqueness in class TypeLoadertyp - a type to be added to the cachelast - the previous cache entry mapped to by typ.qualifiedName()
protected void forgetEverythingAbout(File f,
JCompilationUnitType cunit)
forgetEverythingAbout in class TypeLoaderprotected void removeFromTypeCache(CClass typ)
also requires typ != null; modifies compilationSessionTypeCache, vmSessionTypeCache, filesProcessed;
removeFromTypeCache in class TypeLoaderpublic static void setCurrentHostClass(CClass sourceClass)
reloadType.
This is needed so typechecking of refinement chains are
handled properly.
public static CClass getCurrentHostClass()
public CClass reloadType(CClass sourceClass)
also requires sourceClass != null;
reloadType in class TypeLoaderprotected final void loadMostRefinedType(JmlSourceClass sourceClass)
requires sourceClass != null; modifies compilationSessionTypeCache, vmSessionTypeCache, filesProcessed;
protected String getFileIdent(File f)
public boolean isDeclaredInDifferentSourceFiles(boolean isUnique,
CClass clazz)
also requires clazz != null;
isDeclaredInDifferentSourceFiles in class TypeLoader
public final JCompilationUnitType putCUnitAST(File f,
JCompilationUnitType cunit)
public final JCompilationUnitType getCUnitAST(File f)
public final void addTypeDeclAST(JmlTypeDeclaration decl)
typeDecl.getCClass() != null.
requires decl != null && decl.getCClass() != null && !typeDeclASTs.containsKey(decl);
public final JmlTypeDeclaration typeDeclarationOf(CClass typ)
null is returned if no corresponding JML type
declaration is found in the database.
requires typ != null;
public final JmlTypeDeclaration refinedDeclOf(JmlTypeDeclaration cdecl)
null is returned.
requires cdecl != null && cdecl.getCClass() != null;
public final JmlClassDeclaration superClassOf(JmlClassDeclaration cdecl)
null is returned.
requires cdecl != null && cdecl.getCClass() != null;
public final JmlClassDeclaration superClassOf(CClass cls)
null is returned.
requires cls != null;
public final JmlInterfaceDeclaration[] interfacesOf(JmlTypeDeclaration typeDecl)
requires typeDecl != null && typeDecl.getCClass() != null;
protected boolean isTrusted(String qName)
also requires qName != null && (* package separators in qName are '/' not '.' *);
isTrusted in class TypeLoaderprotected ClassInfo createClassInfo(String qName)
qName. If no symbol file is found, null is
returned. This method also creates a binary class object and
adds it to the system cache. This method is overriden here to
create JML-specific class info object and binary class object.
createClassInfo in class TypeLoader
|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||