mjc

org.multijava.mjc
Interface CCompilationUnitContextType

All Superinterfaces:
CContextType
All Known Implementing Classes:
CCompilationUnitContext

public interface CCompilationUnitContextType
extends CContextType

This class represents the context for a compilation unit during checking passes (checkInterface, checkInitializers, typecheck).

See Also:
CContextType

Method Summary
 void classToGenerate(CSourceClass clazz)
          Adds a class to generate
 CBinaryClassContext createBinaryClassContext(CBinaryClass clazz)
           
 boolean equals(Object o)
          Indicates whether this is equal to a given object.
 CVariableState fieldInfo(int pos)
          Fields cannot be declared in the context of a compilation unit (yet), consequently we do not expect to invoke this method on a compilation unit 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()
          getClass
 CCompilationUnitContextType getCompilationUnit()
          Returns the compilation unit context for this context.
 Main getCompiler()
          Gets the compiler
 CFlowControlContextType getFlowControlContext()
          Returns the nearest control flow context (where control flow information is stored.)
 CMethodContextType getMethodContext()
          getMethod
 CContextType getParentContext()
          getParentContext
 int hashCode()
          Returns the hash code for this, equivalent to this.cunit.hashCode().
 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)
          searches for a field with the given identifier
 CMethod lookupMethod(String name, CType[] params, CClassContextType context)
          Searches for the most specific method applicable to the given identifier and argument type tuple, in the current context.
 CMethodSet lookupMethodOrSet(String name, CType[] params, CClassContextType context)
          Searches for the most specific method(s) applicable to the given identifier and argument type tuple, in the current context.
 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.
 void registerVisibleMethod(CMethod method)
          Registers that a declaration of the given method occurs within the compilation unit.
 void registerVisibleType(CType type)
          Registers that a reference to the given type occurs within the compilation unit.
 void reportTrouble(Exception trouble)
          Adds an trouble into the list and eats it This method should be called after a try catch block after catching exception or directly without exception thrown
 void resolveMaybeExtMethodRef(String ident)
          Searches for any imported external generic functions.
 
Methods inherited from interface org.multijava.mjc.CContextType
addFANonNull, addFANonNulls, addFANull, addFANulls, adoptNullityInfo, arithmeticMode, catchUp, check, check, check, check, createClassContext, createExtMethodContext, createInterfaceContext, declaredOutsideOfLoop, declares, dumpNonNulls, fail, fail, getCMethod, getFANonNulls, getFANulls, initializeField, isBeforeSuperConstructorCall, isFANonNull, isFieldDefinitelyAssigned, isInConstructor, isInInitializer, isInLoop, isPure, isStatic, lookupField, lookupLocalVariable, lookupMethod, lookupMethodOrSet, lookupOuterField, lookupTypeVariable, mergeNullityInfo, modUtil, registerGFDecl, removeAllFANullity, removeFANonNull, replaceFieldInfoUpTo
 

Method Detail

fieldInfo

public CVariableState fieldInfo(int pos)
Fields cannot be declared in the context of a compilation unit (yet), consequently we do not expect to invoke this method on a compilation unit context.

Throws:
UnsupportedOperationException

lookupClass

public CClass lookupClass(String name)
                            throws UnpositionedError
Searches for a class with the given simple name according the procedure in JLS2 6.5.5.

Specified by:
lookupClass in interface CContextType
Parameters:
name - the class name, without qualifiers
Returns:
the class if found, null otherwise
Throws:
UnpositionedError - if search fails

lookupMethod

public CMethod lookupMethod(String name,
                            CType[] params,
                            CClassContextType context)
                              throws UnpositionedError
Searches for the most specific method applicable to the given identifier and argument type tuple, in the current context.

Specified by:
lookupMethod in interface CContextType
Parameters:
name - method name
params - method parameter types
context - the context of the class containing the method call
Throws:
UnpositionedError - if the result is ambiguous

lookupMethodOrSet

public CMethodSet lookupMethodOrSet(String name,
                                    CType[] params,
                                    CClassContextType context)
                                      throws UnpositionedError
Searches for the most specific method(s) applicable to the given identifier and argument type tuple, in the current context.

Specified by:
lookupMethodOrSet in interface CContextType
Parameters:
name - method name
params - method parameter types
context - the context of the class containing the method call
Throws:
UnpositionedError - if the result is ambiguous

lookupField

public CFieldAccessor lookupField(String ident,
                                  CExpressionContextType context)
                                    throws UnpositionedError
searches for a field with the given identifier

Specified by:
lookupField in interface CContextType
Returns:
a field from an ident in current context
Throws:
UnpositionedError - this error will be positioned soon

lookupOuterLocalVariable

public JExpression lookupOuterLocalVariable(TokenReference ref,
                                            String ident)
Finds a local variable with the given name that appears outside the current lexical contour.

Specified by:
lookupOuterLocalVariable in interface CContextType
Parameters:
ref - a token reference used to build a new JOuterLocalVariableExpression
ident - the name of the outer variable
Returns:
a variable from an ident in the surrounding context, or null if not found

lookupOuterField

public CFieldAccessor lookupOuterField(String ident,
                                       CExpressionContextType context)
                                         throws UnpositionedError
Searches for a field of the given name in the context surrounding the current lexical contour.

Specified by:
lookupOuterField in interface CContextType
Parameters:
ident - the name of the field
context - the context of the field access
Returns:
a variable from a field in the surrounding context, or null if none is found
Throws:
UnpositionedError - this error will be positioned soon

resolveMaybeExtMethodRef

public void resolveMaybeExtMethodRef(String ident)
Searches for any imported external generic functions.

Specified by:
resolveMaybeExtMethodRef in interface CContextType
Parameters:
ident - the name of the generic function to search for

registerVisibleMethod

public void registerVisibleMethod(CMethod method)
Registers that a declaration of the given method occurs within the compilation unit.

Specified by:
registerVisibleMethod in interface CContextType

registerVisibleType

public void registerVisibleType(CType type)
Registers that a reference to the given type occurs within the compilation unit.

Specified by:
registerVisibleType in interface CContextType

getParentContext

public CContextType getParentContext()
getParentContext

Specified by:
getParentContext in interface CContextType
Returns:
the parent

getClassContext

public CClassContextType getClassContext()
getClass

Specified by:
getClassContext in interface CContextType
Returns:
the near parent of type CClassContextType

getMethodContext

public CMethodContextType getMethodContext()
getMethod

Specified by:
getMethodContext in interface CContextType
Returns:
the near parent of type CMethodContextType

getCompilationUnit

public CCompilationUnitContextType getCompilationUnit()
Description copied from interface: CContextType
Returns the compilation unit context for this context. This only makes sense for contexts that do not themselves represent compilation units. I.e., in classes that represent compilation unit context this should be overridden.

Specified by:
getCompilationUnit in interface CContextType
Returns:
the compilation unit

getFlowControlContext

public CFlowControlContextType getFlowControlContext()
Returns the nearest control flow context (where control flow information is stored.)

Specified by:
getFlowControlContext in interface CContextType
Returns:
the nearest parent of type CFlowControlContextType

findNearestHost

public CMemberHost findNearestHost()
Returns the signature of the nearest lexically enclosing context that can host member declarations (i.e., a 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 duplciated in every anchor.

Specified by:
findNearestHost in interface CContextType
Returns:
the nearest parent that can be coerced to a CMemberHost, i.e., this.cunit

createBinaryClassContext

public CBinaryClassContext createBinaryClassContext(CBinaryClass clazz)

reportTrouble

public void reportTrouble(Exception trouble)
Adds an trouble into the list and eats it This method should be called after a try catch block after catching exception or directly without exception thrown

Specified by:
reportTrouble in interface CContextType
Parameters:
trouble - the trouble

getCompiler

public Main getCompiler()
Gets the compiler

Specified by:
getCompiler in interface CContextType

classToGenerate

public void classToGenerate(CSourceClass clazz)
Adds a class to generate

Specified by:
classToGenerate in interface CContextType
Parameters:
clazz - the class to be generated

equals

public boolean equals(Object o)
Indicates whether this is equal to a given object.

Parameters:
o - the object to compare against
Returns:
true iff o is another CCompilationUnitContextType formed around an identical (i.e., ==) CCompilationUnit

hashCode

public int hashCode()
Returns the hash code for this, equivalent to this.cunit.hashCode().

Returns:
the hash code for this

mjc

mjc is Copyright (C) 2000-2004 by Iowa State University and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. mjc is based in part on the Kopi project Copyright (C) 1990-99 DMS Decision Management Systems Ges.m.b.H.