|
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.CTopLevel
This class is a facade for an instance of TypeLoader (or a subclass). It acts like a "class loader"; it keeps track of which classes and external generic functions referenced in a compilation session are being generated from source and which are being read from disk as class files. It also handles the loading of such classes and external generic functions from disk. in general all cached operations on types and type signatures are directed through this facade.
| Field Summary | |
private static Main |
compiler
|
private static Main |
FROMCLASSES
|
private static Map |
gfCollSingletonMap
Maps from qualified names to CGenericFunctionCollection singletons. |
static int |
IS_GEN_FUNC
A constant return value for whichIsThis(String,java.io.File). |
static int |
IS_NEITHER
A constant return value for whichIsThis(String,java.io.File). |
static int |
IS_TYPE
A constant return value for whichIsThis(String,java.io.File). |
private static HashSet |
pendingGFs
|
private static TypeLoader |
typeLoader
|
| Fields inherited from class org.multijava.util.Utils |
DBG_LEVEL_HIGH, DBG_LEVEL_LOW, DBG_LEVEL_NO |
| Constructor Summary | |
CTopLevel()
|
|
| Method Summary | |
static boolean |
addClass(CClass clazz)
Adds the given class to the table of available classes. |
static boolean |
addGFCollection(CGenericFunctionCollection coll)
Adds the given generic function collection singleton to the map. |
static void |
addTypeRep(String qName,
CClassType typeRep)
Adds the given type representation, which must represent a fully qualified type name, to the cache. |
static boolean |
classExists(String qName)
Checks whether a class with the given name is available in the class path. |
static FileFinder |
fileFinder()
Returns the FileFinder instance that is used by the current session when searching for classes and generic functions. |
static File |
findSourceFile(String name)
|
static 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. |
static Main |
getCompiler()
Returns the top level compiler. |
static Main |
getFromClassesCompiler()
|
static CClassType |
getTypeRep(String name,
boolean isFullyQualified)
return the lightweight type representation of the class with the given name, generating a new one if necessary. |
static CClassType |
getTypeRep(String name,
CClassType[][] arguments,
boolean isFullyQualified)
Returns the lightweight type representation of the class with the given name, generating a new one if necessary. |
static CClassType |
getTypeRep(String name,
CUniverse univ,
boolean isFullyQualified)
getTypeRep with a universe parameter and no arguments. |
static CClassType |
getTypeRep(String name,
CUniverse univ,
CClassType[][] arguments,
boolean isFullyQualified)
getTypeRep with a universe parameter and arguments. |
(package private) static void |
initSession(Main compiler,
TypeLoader loader)
Removes all non-trusted, cached information from this compilation sessions so that new declarations can be processed. |
static boolean |
isClassLoaded(String qName)
Returns true if the class with the given fully-qualified name has already been read and loaded. |
static boolean |
isDeclaredInDifferentSourceFiles(boolean isUnique,
CClass clazz)
Determines whether the given Class, using its fully qualified name, has been declared in more one file. |
static boolean |
isGFLoaded(String qName)
Returns true if the generic function with the given fully-qualified name has already been read and loaded. |
static CClass |
loadClass(String qName)
Loads type definition; uses the FileFinder supplied in initSession to determine which file is loaded for the given name. |
static CGenericFunctionCollection |
lookupGFCollection(String qualifiedIdent)
Finds the generic function collection singleton for the given fully qualified name. |
static CClassType |
lookupTypeRep(String qName)
|
static void |
registerPendingGFCollection(String qName)
Registers that the external generic function with the given fully qualified name has been parsed and, barring an error during the preprocessDependencies pass, will be available to other compilation units. |
static CClass |
reloadClass(CClass clazz)
Reloads the specified class if this class has been defined during a previous compilation session. |
static int |
whichIsThis(String qName,
File f)
Checks whether the source code contain in the given file declares a type or an external generic function of the given name. |
| 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 |
public static final int IS_TYPE
whichIsThis(String,java.io.File).
public static final int IS_GEN_FUNC
whichIsThis(String,java.io.File).
public static final int IS_NEITHER
whichIsThis(String,java.io.File).
private static Main compiler
private static final Main FROMCLASSES
private static Map gfCollSingletonMap
CGenericFunctionCollection singletons.
private static HashSet pendingGFs
private static TypeLoader typeLoader
| Constructor Detail |
public CTopLevel()
| Method Detail |
public static CClassType getTypeRep(String name,
CClassType[][] arguments,
boolean isFullyQualified)
name - the name of the classisFullyQualified - the name is known to be fully qualified
public static CClassType getTypeRep(String name,
boolean isFullyQualified)
public static CClassType getTypeRep(String name,
CUniverse univ,
boolean isFullyQualified)
public static CClassType getTypeRep(String name,
CUniverse univ,
CClassType[][] arguments,
boolean isFullyQualified)
public static void addTypeRep(String qName,
CClassType typeRep)
requires qName != null && typeRep != null && (* all separators in qName are '/' not '.' *);
public static CClass loadClass(String qName)
requires qName != null && (* any separators in qName are slashes ('/'), not dots ('.') *); modifies typeLoader;
qName - the fully qualified name of the type to load.
public static boolean isDeclaredInDifferentSourceFiles(boolean isUnique,
CClass clazz)
requires clazz != null;
public static CClass reloadClass(CClass clazz)
public static boolean isClassLoaded(String qName)
requires qName != null && (* any separators in qName are slashes ('/'), not dots ('.') *);
qName - the fully qualified name of the type to load.public static boolean addClass(CClass clazz)
requires clazz != null; modifies typeLoader;
public static boolean classExists(String qName)
qName - the fully qualified name of the type with slash separators
not dots
public static void registerPendingGFCollection(String qName)
requires qName != null && qName.length() > 0 && (* any separators in qName are slashes ('/'), not dots ('.') *);
MJTopLevelMethodDeclaration.registerPendingGFCollection(String)public static boolean addGFCollection(CGenericFunctionCollection coll)
public static CGenericFunctionCollection lookupGFCollection(String qualifiedIdent)
qualifiedIdent - the fully qualified name of the collection
public static CClassType lookupTypeRep(String qName)
public static boolean isGFLoaded(String qName)
requires qName != null && (* any separators in qName are slashes ('/'), not dots ('.') *);
public static int whichIsThis(String qName,
File f)
qName - the fully qualified name of the class or generic function
expected in ff - the source code file to check
IS_TYPE if the code in f declares a type
named qName,
IS_GEN_FUNC if the code in f declares
an external generic function named qName, and
IS_NEITHER otherwise.
static void initSession(Main compiler,
TypeLoader loader)
Main.initSession(TypeLoader)
method for session initialization.
requires loader != null; modifies CTopLevel.compiler; modifies typeLoader; modifies gfCollSingletonMap, pendingGFs; ensures CTopLevel.compiler == compiler && CTopLevel.typeLoader == loader;
public static Main getCompiler()
null if called after initSession() is
invoked with a null first argument.
public static Main getFromClassesCompiler()
public static FileFinder fileFinder()
public static File findSourceFile(String name)
public static void forgetEverythingAbout(File f,
JCompilationUnitType cunit)
|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||