|
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.util.compiler.Phylum
org.multijava.mjc.JPhylum
org.multijava.mjc.JMemberDeclaration
org.multijava.mjc.JTypeDeclaration
This class represents a java class or interface in the syntax tree
| Nested Class Summary | |
protected static class |
JTypeDeclaration.WrapResult
This nested class is used to return the results from
dispatcherWrapMethods |
| Field Summary | |
protected CContextType |
cachedContext
|
private JConstructorDeclarationType |
defaultConstructor
|
private JFieldDeclarationType[] |
fields
The fields declared within the type represented by this, extracted from fieldsAndInits at initialization time. |
protected JPhylum[] |
fieldsAndInits
The fields and initializers of this type, passed together because the order matters for class and object initialization. |
protected String |
ident
|
protected ArrayList |
inners
Stores the nested and inner types and private generic functions of the type or generic function represented by this. |
protected JInitializerDeclaration |
instanceInit
|
protected CClassType[] |
interfaces
|
protected ArrayList |
methods
|
protected long |
modifiers
|
private JFieldDeclarationType |
outerThis
|
protected CSourceClass |
sourceClass
|
protected JInitializerDeclaration |
statInit
|
protected CTypeVariable[] |
typevariables
|
protected boolean |
uniqueSourceClass
Used to detect whether there are duplicated declarations on the same name. |
| Fields inherited from class org.multijava.mjc.JMemberDeclaration |
|
| Fields inherited from class org.multijava.mjc.JPhylum |
EMPTY |
| Fields inherited from class org.multijava.util.compiler.Phylum |
|
| Fields inherited from class org.multijava.util.Utils |
DBG_LEVEL_HIGH, DBG_LEVEL_LOW, DBG_LEVEL_NO |
| Constructor Summary | |
JTypeDeclaration(TokenReference where,
long modifiers,
String ident,
CTypeVariable[] typevariables,
CClassType[] interfaces,
ArrayList methods,
ArrayList inners,
JPhylum[] fieldsAndInits,
JavadocComment javadoc,
JavaStyleComment[] comments)
Constructs a type declaration in the parsing tree. |
|
| Method Summary | |
void |
accumAllTypeSignatures(ArrayList accum)
Adds the signature CSourceClass of this, and of all nested types, to accum. |
void |
addMember(JMemberDeclarationType newMember)
Adds the given member to this type's interface and modifies sourceClass to include the new member |
private void |
addOuterThis()
This method establishes a fabricated field to store a reference to an outer class of this. |
private void |
addRMJMethodAnnotation(CMethod method,
CMethod topConcreteMethod,
boolean anyInherited)
|
private void |
annotateInterfaceMethods(CMethod topConcreteMethod,
CMethodSet methods,
boolean anyInherited)
|
protected void |
annotateInternalInterfaceMethods(CContextType context)
|
private void |
annotateInternalInterfaceMethodsFor(CMethod topConcreteMethod,
CContextType context)
|
void |
cachePassParameters(CContextType context)
Caches the arguments for the compiler passes. |
protected static JMethodDeclarationType |
checkForDups(JMethodDeclarationType[] methods)
Returns the first method in the given array of methods that duplicates the signature of an earlier method or null if no duplicates exist. |
protected static JMethodDeclarationType |
checkForSameSignature(JMethodDeclarationType[] methods)
|
void |
checkInitializers()
Invokes the checkInitializers method of the implementing class using previously cached arguments. |
void |
checkInitializers(CContextType context)
Checks the static initializers created during the checkInterface pass and performs some other checks that can be performed simply before full blown typechecking. |
void |
checkInterface()
Invokes the checkInterface method of the implementing class using previously cached arguments. |
void |
checkInterface(CContextType context)
Checks the basic interfaces to make sure things generally look OK. |
int |
compareTo(Object o)
Compares this to a given object. |
abstract CClassContextType |
createContext(CContextType parent)
Creates a lexical context for typechecking and control flow analysis on this. |
protected JTypeDeclaration.WrapResult |
dispatcherWrapMethods(CContextType context,
JMethodDeclarationType[] methodDecls)
Builds a collection of methods for code generation. |
private void |
extractFields()
Extracts the field declarations from fieldsAndInits. |
JFieldDeclarationType[] |
fields()
|
JPhylum[] |
fieldsAndInits()
Returns an array of the static and instance initializers for the type represented by this. |
void |
generateInterface(Main compiler,
CClass owner,
CMemberHost host,
String prefix,
boolean isAnon,
boolean isMember)
Generates a CSourceClass class signature singleton
for this declaration and then registers the signature with
CTopLevel. |
ArrayList |
getAllMethods()
Walks up the extends hierarchy and adds all methods to the returned ArrayList. |
JConstructorDeclarationType |
getDefaultConstructor()
|
String |
ident()
Returns the identifier for this type declaration. |
ArrayList |
inners()
|
CClassType[] |
interfaces()
Returns the set of interfaces that this type implements or extends. |
boolean |
isAtTopLevel()
|
boolean |
isDeclaredInDifferentSourceFiles()
Determines whether this class is declared in more than one source file and returns a flag indicating this. |
protected CSourceClass |
makeSignature(Main compiler,
CClass owner,
CMemberHost host,
String prefix,
boolean isAnon,
boolean isMember)
Generates the signature object for this. |
ArrayList |
methods()
|
protected JMethodDeclarationType[] |
methodsToBeWrapped()
Returns an array of the methods to be considered for refactoring into dispatchers during the translateMJ pass. |
long |
modifiers()
|
CClass |
owner()
Returns the logical owner of this type. |
void |
preprocessDependencies()
Performs preliminary processing on compilation units and types. |
abstract void |
preprocessDependencies(CContextType context)
Performs preliminary processing on compilation units and types. |
void |
preprocessDependencies(CContextType context,
CClassType superClassType)
Performs preliminary processing on compilation units and types. |
private void |
recordInternalTopMethod(CMethod methodSig,
CMethodSet topConcreteMethods)
|
protected boolean |
registerSignature()
Registers the signature of this declaration with the name space manager in CTopLevel. |
void |
resolveExtMethods(CContextType context)
Makes sure that all in-scope external generic functions are added to the appropriate augmentation maps before top method searches occur in later passes. |
void |
resolveSpecializers()
Resolves value specializer expressions to the compile-time constants they represent. |
abstract void |
resolveSpecializers(CContextType context)
Computes the values of specializer expressions used to dispatch on compile-time constants. |
void |
resolveTopMethods()
Finds the top method of every declared method. |
void |
setDefaultConstructor(JConstructorDeclarationType defaultConstructor)
|
void |
setFields(JPhylum[] fieldsAndInits)
|
void |
setFieldsOnly(JFieldDeclarationType[] fields)
|
void |
setIdent(String ident)
|
void |
setInners(ArrayList i)
|
void |
setMethods(ArrayList m)
|
void |
setStatic()
Marks this type as static. |
void |
syntheticOuterThisInaccessible()
Records the fact that even though the class is an inner class, we should not generate an outer this for it, because the outer this is not accessible. |
void |
translateMJ()
Invokes the translateMJ method of the implementing class using previously cached arguments. |
void |
translateMJ(CContextType context)
Refactors this to include dispatchers for multimethods and other code necessary for running MultiJava code on a standard JVM. |
void |
typecheck()
Invokes the typecheck method of the implementing class using previously cached arguments. |
void |
typecheck(CContextType context)
Typechecks this type declaration in the context in which it appears. |
CTypeVariable[] |
typevariables()
Returns the type variables of this class. |
protected CWarning |
uniqueSourceWarning()
Returns the appropriate warning message when another class has been declared whose signature matches the signature of this. |
void |
unsetStatic()
Marks this type as non-static. |
| Methods inherited from class org.multijava.mjc.JMemberDeclaration |
accept, genComments, getCClass, getField, getMethod, isDeprecated, javadocComment, setInterface |
| Methods inherited from class org.multijava.mjc.JPhylum |
check, check, check, check, fail, fail, fail, warn, warn, warn, warn |
| Methods inherited from class org.multijava.util.compiler.Phylum |
getTokenReference, setTokenReference |
| 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.JMemberDeclarationType |
accept, genComments, getCClass, getField, getMethod, isDeprecated |
| Methods inherited from interface org.multijava.util.compiler.PhylumType |
getTokenReference, setTokenReference |
| Methods inherited from interface org.multijava.javadoc.Annotatable |
javadocComment |
| Methods inherited from interface org.multijava.mjc.CompilerPassEnterable |
accept, getTokenReference |
| Field Detail |
protected CContextType cachedContext
protected long modifiers
protected String ident
protected JPhylum[] fieldsAndInits
JFieldDeclarationType or JClassBlock.
private JFieldDeclarationType[] fields
protected ArrayList methods
protected ArrayList inners
protected CClassType[] interfaces
private JFieldDeclarationType outerThis
private JConstructorDeclarationType defaultConstructor
protected JInitializerDeclaration statInit
protected JInitializerDeclaration instanceInit
protected CSourceClass sourceClass
protected boolean uniqueSourceClass
protected CTypeVariable[] typevariables
| Constructor Detail |
public JTypeDeclaration(TokenReference where,
long modifiers,
String ident,
CTypeVariable[] typevariables,
CClassType[] interfaces,
ArrayList methods,
ArrayList inners,
JPhylum[] fieldsAndInits,
JavadocComment javadoc,
JavaStyleComment[] comments)
where - the line of this node in the source codemodifiers - the list of modifiers of this classident - the short name of this typetypevariables - the type variables of this typeinterfaces - the names of this types's interfacesmethods - a list of JMethodDeclarationTypes
giving the methods of this typeinners - a list of JTypeDeclarationTypes giving the
inner classes (and interfaces) of this typefieldsAndInits - the fields and initializers of this type,
passed together because the order matters
for class and object initialization, members
of the array should be instances of
JFieldDeclarationType or
JClassBlockjavadoc - javadoc commentscomments - regular java commentsJMethodDeclarationType,
JFieldDeclarationType,
JClassBlock| Method Detail |
public void generateInterface(Main compiler,
CClass owner,
CMemberHost host,
String prefix,
boolean isAnon,
boolean isMember)
CSourceClass class signature singleton
for this declaration and then registers the signature with
CTopLevel.
generateInterface in interface JTypeDeclarationTypecompiler - the compiler instance for which this singleton is
generatedowner - the class signature singleton for the logical outer
class of this, or null if this is a top level
declarationhost - the signature singleton of the context in which this
is declared, a CCompilationUnit for
top-level declarationsprefix - the prefix prepended to this declaration's
identifier to achieve the fully qualified
name, just the package name (using '/'
separators) for top-level classes, package
name plus $-delimited outer class names plus
synthetic index for inner classesisAnon - true if this is an anonymous class, in which
case the fully qualified name is just
prefix isMember - true if this is a member type, i.e., a nested type
that is not a local type or an anonymous class
protected CSourceClass makeSignature(Main compiler,
CClass owner,
CMemberHost host,
String prefix,
boolean isAnon,
boolean isMember)
compiler - the compiler instance for which this signature is
generatedowner - the class signature singleton for the logical outer
class of this, or null if this is a top level
declarationhost - the signature singleton of the context in which this
is declared, a CCompilationUnit for
top-level declarationsprefix - the prefix prepended to this declaration's
identifier to achieve the fully qualified
name, just the package name (using '/'
separators) for top-level classes, package
name plus $-delimited outer class names plus
synthetic index for inner classesisAnon - true if this is an anonymous class, in which
case the fully qualified name is just
prefix isMember - true if this is a member type, i.e., a nested type
that is not a local type or an anonymous classprotected boolean registerSignature()
CTopLevel.
requires sourceClass != null;
CTopLevel.addClass(CClass)public CTypeVariable[] typevariables()
public CClassType[] interfaces()
JTypeDeclarationType
interfaces in interface JTypeDeclarationTypepublic JPhylum[] fieldsAndInits()
fieldsAndInits in interface JTypeDeclarationTypepublic ArrayList getAllMethods()
getAllMethods in interface JTypeDeclarationTypepublic ArrayList methods()
methods in interface JTypeDeclarationTypepublic void setMethods(ArrayList m)
public ArrayList inners()
inners in interface JTypeDeclarationTypepublic void setInners(ArrayList i)
setInners in interface JTypeDeclarationTypepublic boolean isAtTopLevel()
isAtTopLevel in interface JTypeDeclarationTypepublic JFieldDeclarationType[] fields()
fields in interface JTypeDeclarationTypepublic JConstructorDeclarationType getDefaultConstructor()
getDefaultConstructor in interface JTypeDeclarationTypepublic void setDefaultConstructor(JConstructorDeclarationType defaultConstructor)
setDefaultConstructor in interface JTypeDeclarationTypepublic void setIdent(String ident)
setIdent in interface JTypeDeclarationTypepublic String ident()
ident in interface JTypeDeclarationTypepublic void addMember(JMemberDeclarationType newMember)
addMember in interface JTypeDeclarationTypenewMember - a member to be added to this typepublic void setFields(JPhylum[] fieldsAndInits)
public void setFieldsOnly(JFieldDeclarationType[] fields)
public CClass owner()
owner in interface JTypeDeclarationTypepublic long modifiers()
modifiers in interface JTypeDeclarationTypepublic void setStatic()
also requires (* this.generateInterface(...) has not been invoked *); requires_redundantly sourceClass == null; ensures hasFlag(modifiers,ACC_STATIC);
setStatic in interface JTypeDeclarationTypepublic void unsetStatic()
also ensures !hasFlag(modifiers,ACC_STATIC);
unsetStatic in interface JTypeDeclarationTypepublic void syntheticOuterThisInaccessible()
syntheticOuterThisInaccessible in interface JTypeDeclarationTypepublic void accumAllTypeSignatures(ArrayList accum)
accumAllTypeSignatures in interface JTypeDeclarationType
public abstract void preprocessDependencies(CContextType context)
throws PositionedError
preprocessDependencies in interface JTypeDeclarationTypePositionedError
public void preprocessDependencies(CContextType context,
CClassType superClassType)
throws PositionedError
PositionedError
public void checkInterface(CContextType context)
throws PositionedError
checkInterface in interface JTypeDeclarationTypecontext - the context in which this
decl appears
PositionedError - an error with reference to the
source fileprotected static JMethodDeclarationType checkForDups(JMethodDeclarationType[] methods)
requires (* checkInterface has already been called on each element of methods *);
protected static JMethodDeclarationType checkForSameSignature(JMethodDeclarationType[] methods)
protected CWarning uniqueSourceWarning()
public void resolveExtMethods(CContextType context)
public void checkInitializers(CContextType context)
throws PositionedError
checkInitializers in interface JTypeDeclarationTypecontext - the context in which this class
declaration appears
PositionedError - if check fails public boolean isDeclaredInDifferentSourceFiles()
ensures (* \result == true if declared in two different source files, otherwise \result == false *);
public void resolveTopMethods()
throws PositionedError
resolveTopMethods in interface JTypeDeclarationTypePositionedError
public abstract void resolveSpecializers(CContextType context)
throws PositionedError
resolveSpecializers in interface JTypeDeclarationTypecontext - the context in which this class
declaration appears
PositionedError - if the check fails private void addOuterThis()
outerThis field of this
declaration and is also passed to sourceClass for
code generation. If this declaration is immediately enclosed
by an external method then the fabricated field will reference
the _this_ synthetic receiver argument of the external method.
The value of the field in either case is set at run-time via a
synthetic parameter of this class's constructor.
public abstract CClassContextType createContext(CContextType parent)
createContext in interface JTypeDeclarationType
public void typecheck(CContextType context)
throws PositionedError
typecheck in interface JTypeDeclarationTypecontext - the context in which this type declaration appears
PositionedError - if any checks fail public void translateMJ(CContextType context)
translateMJ in interface JTypeDeclarationTypeprotected JMethodDeclarationType[] methodsToBeWrapped()
translateMJ(CContextType)
protected final JTypeDeclaration.WrapResult dispatcherWrapMethods(CContextType context,
JMethodDeclarationType[] methodDecls)
Builds a collection of methods for code generation. Finds the sets of multimethods that belong to the same generic function or otherwise require a dispatcher method and generates such a method for each set. Regular Java methods (those not requiring a dispatcher) and generated methods (e.g., default constructors) are also included in the result. An array of inner dispatcher classes, one for each overridden external generic function, is also part of the result.
(This method would be private but is declared protected and final to allow for unit testing.)
context - the context in which these method declarations
appear, used for finding the top method of
each generic functionmethodDecls - an array of the methods to be generated
translateMJ(CContextType)private void extractFields()
fieldsAndInits.
fieldsAndInits
public int compareTo(Object o)
throws ClassCastException
also ensures (* \result == lexically ordered according to the type name *); also requires o != null && !(o instanceof JTypeDeclaration); signals_only ClassCastException;
compareTo in interface Comparableo - an Object value to compare to this
ClassCastException - if o is incomparable to thispublic void cachePassParameters(CContextType context)
also ensures arePassParametersCached;
cachePassParameters in interface JTypeDeclarationTypeCompilerPassEnterable
public void preprocessDependencies()
throws PositionedError
preprocessDependencies in interface CompilerPassEnterablePositionedError
public void checkInterface()
throws PositionedError
CompilerPassEnterablerequires arePassParametersCached;
checkInterface in interface CompilerPassEnterablePositionedError
public void checkInitializers()
throws PositionedError
CompilerPassEnterablerequires arePassParametersCached;
checkInitializers in interface CompilerPassEnterablePositionedError
public void resolveSpecializers()
throws PositionedError
CompilerPassEnterable
resolveSpecializers in interface CompilerPassEnterablePositionedError
public void typecheck()
throws PositionedError
CompilerPassEnterablerequires arePassParametersCached;
typecheck in interface CompilerPassEnterablePositionedErrorpublic void translateMJ()
CompilerPassEnterablerequires arePassParametersCached;
translateMJ in interface CompilerPassEnterable
protected void annotateInternalInterfaceMethods(CContextType context)
throws UnpositionedError
UnpositionedError
private void recordInternalTopMethod(CMethod methodSig,
CMethodSet topConcreteMethods)
throws UnpositionedError
UnpositionedError
private void annotateInternalInterfaceMethodsFor(CMethod topConcreteMethod,
CContextType context)
throws UnpositionedError
UnpositionedError
private void annotateInterfaceMethods(CMethod topConcreteMethod,
CMethodSet methods,
boolean anyInherited)
private void addRMJMethodAnnotation(CMethod method,
CMethod topConcreteMethod,
boolean anyInherited)
|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||