|
mjc | ||||||||||
| 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.CContext
org.multijava.mjc.CClassContext
This class represents the context for a class during checking passes (checkInterface, checkInitializers, typecheck).
CContextType| Field Summary | |
protected CVariableInfoTable |
fieldInfo
|
private boolean |
hasInitializer
|
protected CClass |
self
|
| Fields inherited from class org.multijava.mjc.CContext |
contextNullity, cunit, parent |
| Fields inherited from class org.multijava.util.Utils |
DBG_LEVEL_HIGH, DBG_LEVEL_LOW, DBG_LEVEL_NO |
| Constructor Summary | |
CClassContext(CContextType parent,
CClass self)
|
|
| Method Summary | |
void |
addInitializer()
Add an initializer to this context |
void |
checkingComplete(JTypeDeclarationType decl,
CVariableInfoTable staticC,
CVariableInfoTable instanceC,
CVariableInfoTable[] constructorsC)
Verifies that all final and all non-null fields are initialized and all abstract methods are appropriately implemented. |
CConstructorContextType |
createConstructorContext(CMethod self)
|
CInitializerContextType |
createInitializerContext(CMethod self)
|
CMethodContextType |
createMethodContext(CMethod self)
|
CVariableInfoTable |
fieldInfo()
Returns the fieldInfo table. |
CVariableInfoTable |
fieldInfoTable()
Returns the current field information for the most recently checked member of this context. |
CMemberHost |
findNearestHost()
Returns the signature of the nearest lexically enclosing context that can host member declarations (i.e., a CClass or a CCompilationUnit). |
CClassContextType |
getClassContext()
getClassContext |
CClass |
getHostClass()
Returns the CClass representing the signature of the class containing this context. |
CClass |
getOwnerClass()
Returns the CClass representing the signature of the class that is the logical owner of this context. |
boolean |
hasInitializer()
Returns true if this class need initializers |
void |
initializeField(VariableDescriptor varDesc)
Marks the field with the given descriptor as definitely assigned to in this context. |
boolean |
isFieldDefinitelyAssigned(int pos)
Indicates whether the field in the given position is definitely assigned to in this context. |
boolean |
isInLoop()
Indicates whether this context is in a loop. |
CClass |
lookupClass(String name)
Searches for a class with the given simple name according the procedure in JLS2 6.5.5. |
CFieldAccessor |
lookupField(String ident,
CExpressionContextType context)
lookupField |
JLocalVariable |
lookupLocalVariable(String ident)
lookupLocalVariable |
CMethod |
lookupMethod(String ident,
CType[] params,
CClassContextType context)
Searches for the most specific method when no receiver is explicit at the call site. |
CMethodSet |
lookupMethodOrSet(String ident,
CType[] params,
CClassContextType context)
Searches for the most specific method(s) when no receiver is explicit at the call site. |
CFieldAccessor |
lookupOuterField(String ident,
CExpressionContextType context)
Searches for a field of the given name in the context surrounding the current lexical contour. |
JExpression |
lookupOuterLocalVariable(TokenReference ref,
String ident)
Finds a local variable with the given name that appears outside the current lexical contour. |
CTypeVariable |
lookupTypeVariable(String ident)
search for the type variable that are accessible |
void |
markAllFieldsAsInitialized()
|
void |
registerVisibleType(CType type)
Registers with the surrounding context that a reference to the given type occurs in this context. |
void |
replaceFieldInfoUpTo(int pos,
CVariableInfoTable replacement)
Replaces the local field info for fields in positions 0 up to pos with the info in replacement. |
void |
setFieldInfoTable(CVariableInfoTable fieldInfo)
Sets the field information for this to match that given by fieldInfo. |
| 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 |
| Methods inherited from interface org.multijava.mjc.CClassContextType |
resolveMaybeExtMethodRef |
| Field Detail |
protected CVariableInfoTable fieldInfo
private boolean hasInitializer
protected final CClass self
| Constructor Detail |
public CClassContext(CContextType parent,
CClass self)
parent - the parent context or null at top levelself - the corresponding clazz| Method Detail |
public void checkingComplete(JTypeDeclarationType decl,
CVariableInfoTable staticC,
CVariableInfoTable instanceC,
CVariableInfoTable[] constructorsC)
throws UnpositionedError
checkingComplete in interface CClassContextTypeUnpositionedError - if any checks fail public CMethodContextType createMethodContext(CMethod self)
createMethodContext in interface CClassContextTypepublic CConstructorContextType createConstructorContext(CMethod self)
createConstructorContext in interface CClassContextTypepublic CInitializerContextType createInitializerContext(CMethod self)
createInitializerContext in interface CClassContextTypepublic final boolean isInLoop()
isInLoop in interface CContextTypeisInLoop in class CContextpublic void addInitializer()
addInitializer in interface CClassContextTypepublic boolean hasInitializer()
hasInitializer in interface CClassContextTypepublic CVariableInfoTable fieldInfo()
fieldInfo in interface CClassContextType
public void replaceFieldInfoUpTo(int pos,
CVariableInfoTable replacement)
pos with the info in replacement.
replaceFieldInfoUpTo in interface CClassContextTypereplaceFieldInfoUpTo in class CContextpublic void initializeField(VariableDescriptor varDesc)
initializeField in interface CClassContextTypeinitializeField in class CContextpublic boolean isFieldDefinitelyAssigned(int pos)
isFieldDefinitelyAssigned in interface CClassContextTypeisFieldDefinitelyAssigned in class CContextpublic CVariableInfoTable fieldInfoTable()
typecheck method. That method mutates this
context to include the variable information extracted from the
statement being checked. Upon return from the
typecheck the caller calls
fieldInfoTable to extract the information. This
is kludgey and one wonders why the typecheck
methods doesn't just return the CVariableInfoTable
instance. !FIXME!
fieldInfoTable in interface CClassContextTypepublic void setFieldInfoTable(CVariableInfoTable fieldInfo)
fieldInfo. Called before typechecking
constructors with the argument equal to the field assignment
information after checking initializers.
setFieldInfoTable in interface CClassContextTypepublic void markAllFieldsAsInitialized()
markAllFieldsAsInitialized in interface CClassContextType
public CClass lookupClass(String name)
throws UnpositionedError
lookupClass in interface CClassContextTypelookupClass in class CContextname - the class name, without qualifiers
UnpositionedError - if search fails
public CTypeVariable lookupTypeVariable(String ident)
throws UnpositionedError
CClassContextType
lookupTypeVariable in interface CClassContextTypelookupTypeVariable in class CContextUnpositionedError
public CMethod lookupMethod(String ident,
CType[] params,
CClassContextType context)
throws UnpositionedError
lookupMethod in interface CClassContextTypelookupMethod in class CContextident - method nameparams - method parameterscontext - the context of the class containing
the method call
UnpositionedError - this error will be positioned soon
public CMethodSet lookupMethodOrSet(String ident,
CType[] params,
CClassContextType context)
throws UnpositionedError
lookupMethodOrSet in interface CClassContextTypelookupMethodOrSet in class CContextident - method nameparams - method parameterscontext - the context of the class containing
the method call
UnpositionedError - this error will be positioned soon
public CFieldAccessor lookupOuterField(String ident,
CExpressionContextType context)
throws UnpositionedError
lookupOuterField in interface CClassContextTypelookupOuterField in class CContextident - the name of the fieldcontext - the context of the field access
UnpositionedError - this error will be positioned soon
public CFieldAccessor lookupField(String ident,
CExpressionContextType context)
throws UnpositionedError
lookupField in interface CClassContextTypelookupField in class CContextident - the name of the fieldcontext - the context of the field access
UnpositionedError - this error will be positioned soon
public JExpression lookupOuterLocalVariable(TokenReference ref,
String ident)
lookupOuterLocalVariable in interface CClassContextTypelookupOuterLocalVariable in class CContextref - a token reference used to build a new
JOuterLocalVariableExpressionident - the name of the outer variable
public JLocalVariable lookupLocalVariable(String ident)
lookupLocalVariable in interface CContextTypelookupLocalVariable in class CContextident - the name of the local variable
public CClassContextType getClassContext()
getClassContext in interface CClassContextTypegetClassContext in class CContextpublic CClass getHostClass()
getHostClass in interface CClassContextTypepublic CClass getOwnerClass()
getOwnerClass in interface CClassContextTypeCClassContextType.getHostClass(),
org.multijava.mjc.CExtMethodContext#getHostClass()public CMemberHost findNearestHost()
CClass or a CCompilationUnit). Used
for access checks, this is slightly different than
getHostClass(). The later method returns an
anchor class signature for external methods, which is useful in
code generation and in typechecking external method bodies. On
the other hand, this method returns a
CCompilationUnit for external methods, which is
useful in checking access between two differently named generic
functions declared in the same compilation unit. !FIXME! It
may be possible to eliminate this method and just use
getHostClass now that private external methods are
duplicated in every anchor.
findNearestHost in interface CClassContextTypefindNearestHost in class CContextCMemberHost, i.e., this.self public void registerVisibleType(CType type)
registerVisibleType in interface CClassContextTyperegisterVisibleType in class CContext
|
mjc | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||