|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.multijava.mjc.CCompilationUnit
This class handles namespace management for a compilation unit. Based on the imports and package of a compilation unit, this class includes methods for resolving partially-qualified names. This class also tracks the external members declared in a compilation unit.
| Field Summary | |
private ArrayList |
directlyVisibleTypes
The set of reference types that are directly visible in this compilation unit. |
private JClassOrGFImportType[] |
importedClasses
|
private JClassOrGFImportType[] |
importedGFs
|
private JPackageImportType[] |
importedPackages
|
private Hashtable |
loadedClasses
Maps from type names to classes. |
private CGFCollectionMap |
loadedGFCollections
Maps from identifiers to sets of external generic function collections that are in scope and loaded for this compilation unit. |
private static TokenReference |
NO_TOKEN
Used for error reporting. |
private String |
packageName
|
private HashSet |
resolvedGFNames
Tracks the names of the generic functions for which we have completed the package and import-on-demand search. |
private HashSet |
visibleMethods
Tracks the methods that are referenced within this. |
| Constructor Summary | |
CCompilationUnit(String packageName)
Constructs a minimal compilation unit context for hosting CBinaryClasses. |
|
| Method Summary | |
boolean |
descendsFrom(CClass maybeSuper)
Indicates whether this host is a subclass of the given class, where "subclass" is the reflexive, transitive closure of the extends relation. |
Collection |
directlyVisibleTypes()
Returns the set of (non-reference) types that are directly visible in this compilation unit. |
CMemberHost |
host()
Returns the host of this host, that is, the context in which this host is declared. |
String |
ident()
Gives the identifier for this host, or null for a compilation unit. |
JClassOrGFImportType[] |
importedClasses()
|
JPackageImportType[] |
importedPackages()
|
boolean |
isAccessibleFrom(CMemberHost from)
Indicates whether this is accessible from the given host. |
boolean |
isClass()
Indicates whether this host is a class. |
boolean |
isCompilationUnit()
Indicates whether this host is a compilation unit |
boolean |
isDefinedInside(CMemberHost maybeOutside)
Indicates whether this is defined inside the given host. |
boolean |
isInnerClass()
Indicates whether this host is an inner class, i.e., a non-static member class. |
boolean |
isNestedType()
Indicates whether this host is a nested type, i.e., a member type, a type declared within another type. |
CClass |
lookupClass(String name,
CContextType context)
Searches for a class with the given simple name according the procedure in JLS2 6.5.5. |
boolean |
nestedDescendsFrom(CClass maybeOuterSuper)
Returns true if this host is a subclass of the given class or if some host of this host is a subclass of the given class. |
String |
packageName()
Gives the package name for this host. |
(package private) void |
registerGFDecl(String ident,
CGenericFunctionCollection coll)
Registers the declaration of an external generic function in this compilation unit. |
void |
registerVisibleMethod(CMethod method)
Registers that a declaration of the given method occurs in the compilation unit represented by this. |
void |
registerVisibleType(CType type)
Registers that a reference to the given type occurs in the compilation unit represented by this. |
void |
resolveMaybeExtMethodRef(CCompilationUnitContextType context,
String name)
Searches for any imported external generic functions. |
void |
update(JClassOrGFImportType[] importedClasses,
JClassOrGFImportType[] importedGFs,
JPackageImportType[] importedPackages,
Hashtable loadedClasses,
CGFCollectionMap loadedGFCollections)
Updates the compilation unit after completion of grouping open methods. |
Collection |
visibleMethods()
Returns a string representation of this. |
Collection |
visibleTypes()
Returns the set of (non-reference) types that are directly or transitively visible in this compilation unit. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private final String packageName
private JClassOrGFImportType[] importedClasses
private JClassOrGFImportType[] importedGFs
private JPackageImportType[] importedPackages
private Hashtable loadedClasses
CClassType
and have had checkType called on them.
CClassType,
JCompilationUnit,
JCompilationUnit.allLoadedClassesprivate CGFCollectionMap loadedGFCollections
alias to this field in
JCompilatoinUnitprivate HashSet resolvedGFNames
resolveMaybeExtMethodRef(CCompilationUnitContextType,String)private HashSet visibleMethods
private ArrayList directlyVisibleTypes
private static final TokenReference NO_TOKEN
| Constructor Detail |
public CCompilationUnit(String packageName)
CBinaryClasses.
packageName - the packageName of the compilation unit | Method Detail |
public CClass lookupClass(String name,
CContextType context)
throws UnpositionedError
name - the class name, without qualifierscontext - used for error reporting
UnpositionedError - if search fails
public void resolveMaybeExtMethodRef(CCompilationUnitContextType context,
String name)
context - the compilation unit context in which the generic
functions found are to be visiblename - the name of the generic function to search for
void registerGFDecl(String ident,
CGenericFunctionCollection coll)
public void registerVisibleMethod(CMethod method)
public void registerVisibleType(CType type)
public void update(JClassOrGFImportType[] importedClasses,
JClassOrGFImportType[] importedGFs,
JPackageImportType[] importedPackages,
Hashtable loadedClasses,
CGFCollectionMap loadedGFCollections)
importedClasses - the single-type importsimportedGFs - the single-GF importsimportedPackages - the import-on-demand importsloadedClasses - the classes actually loaded by this,
initialized in JCompilationUnit
based on declarations and
imports, and then maintained here for
other referencesloadedGFCollections - the external GFs actually loadedJCompilationUnitType.checkInterface( Main )public boolean isAccessibleFrom(CMemberHost from)
isAccessibleFrom in interface CMemberHostfrom - the host that wants access
public boolean isDefinedInside(CMemberHost maybeOutside)
isDefinedInside in interface CMemberHostmaybeOutside - the host that this may be inside
public boolean descendsFrom(CClass maybeSuper)
descendsFrom in interface CMemberHostmaybeSuper - the potential superclasspublic boolean nestedDescendsFrom(CClass maybeOuterSuper)
nestedDescendsFrom in interface CMemberHostmaybeOuterSuper - the potential superclass public boolean isClass()
isClass in interface CMemberHostpublic boolean isNestedType()
isNestedType in interface CMemberHostpublic boolean isInnerClass()
isInnerClass in interface CMemberHostpublic boolean isCompilationUnit()
isCompilationUnit in interface CMemberHostpublic String ident()
ident in interface CMemberHostpublic String packageName()
packageName in interface CMemberHostpublic CMemberHost host()
host in interface CMemberHostpublic Collection visibleMethods()
public Collection directlyVisibleTypes()
public Collection visibleTypes()
public JClassOrGFImportType[] importedClasses()
public JPackageImportType[] importedPackages()
|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||