JML

org.multijava.mjc
Interface JTypeDeclarationType

All Superinterfaces:
Annotatable, Comparable, CompilerPassEnterable, JMemberDeclarationType, PhylumType
All Known Subinterfaces:
JClassDeclarationType, JInterfaceDeclarationType
All Known Implementing Classes:
JClassDeclaration, JInterfaceDeclaration, JmlClassDeclaration, JmlInterfaceDeclaration, JmlTypeDeclaration, JTypeDeclaration

public interface JTypeDeclarationType
extends JMemberDeclarationType, CompilerPassEnterable

This type represents a java class or interface in the syntax 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
 void cachePassParameters(CContextType context)
          Caches the arguments for the compiler passes.
 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(CContextType context)
          Checks the basic interfaces to make sure things generally look OK.
 CClassContextType createContext(CContextType parent)
          Creates a lexical context for typechecking and control flow analysis on this.
 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.
 ArrayList getAllMethods()
          Walks up the extends hierarchy and adds all methods to the ArrayList returned.
 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()
           
 ArrayList methods()
           
 long modifiers()
           
 CClass owner()
          Returns the logical owner of this type.
 void preprocessDependencies(CContextType context)
          Performs preliminary processing on compilation units and types.
 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 setIdent(String ident)
           
 void setInners(ArrayList v)
           
 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(CContextType context)
          Refactors this to include dispatchers for multimethods and other code necessary for running MultiJava code on a standard JVM.
 void typecheck(CContextType context)
          Typechecks this type declaration in the context in which it appears.
 void unsetStatic()
          Marks this type as non-static.
 
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, checkInitializers, checkInterface, getTokenReference, preprocessDependencies, resolveSpecializers, translateMJ, typecheck
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Method Detail

generateInterface

public void generateInterface(Main compiler,
                              CClass owner,
                              CMemberHost host,
                              String prefix,
                              boolean isAnon,
                              boolean isMember)
Generates a CSourceClass class signature singleton for this declaration.

Parameters:
compiler - the compiler instance for which this singleton is generated
owner - the class signature singleton for the logical outer class of this, or null if this is a top level declaration
host - the signature singleton of the context in which this is declared, a CCompilationUnit for top-level declarations
prefix - 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 classes
isAnon - 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

interfaces

public CClassType[] interfaces()
Returns the set of interfaces that this type implements or extends.


fieldsAndInits

public JPhylum[] fieldsAndInits()
Returns an array of the static and instance initializers for the type represented by this.


getAllMethods

public ArrayList getAllMethods()
Walks up the extends hierarchy and adds all methods to the ArrayList returned.

Returns:
a ArrayList that includes the CMethods for all methods in this class and all direct ancestors

methods

public ArrayList methods()

inners

public ArrayList inners()

setInners

public void setInners(ArrayList v)

isAtTopLevel

public boolean isAtTopLevel()
Returns:
true if this class is at top level

fields

public JFieldDeclarationType[] fields()

getDefaultConstructor

public JConstructorDeclarationType getDefaultConstructor()

setDefaultConstructor

public void setDefaultConstructor(JConstructorDeclarationType defaultConstructor)

setIdent

public void setIdent(String ident)

ident

public String ident()
Returns the identifier for this type declaration.

Specified by:
ident in interface JMemberDeclarationType
Returns:
the unqualified identifier for this type declaration

addMember

public void addMember(JMemberDeclarationType newMember)
Adds the given member to this type's interface and modifies sourceClass to include the new member

Parameters:
newMember - a member to be added to this type

owner

public CClass owner()
Returns the logical owner of this type.


modifiers

public long modifiers()
Specified by:
modifiers in interface JMemberDeclarationType
Returns:
the modifiers of this declaration

setStatic

public void setStatic()
Marks this type as static.

 requires (* this.generateInterface(...) has not been invoked *);
 requires_redundantly (*sourceClass == null*); // !FIXME! Fix annotation - sourceClass is defined in the implementing classes
 ensures org.multijava.util.Utils.hasFlag(modifiers(),Constants.ACC_STATIC); 
 


unsetStatic

public void unsetStatic()
Marks this type as non-static.


syntheticOuterThisInaccessible

public 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.


accumAllTypeSignatures

public void accumAllTypeSignatures(ArrayList accum)
Adds the signature CSourceClass of this, and of all nested types, to accum.


preprocessDependencies

public void preprocessDependencies(CContextType context)
                                     throws PositionedError
Performs preliminary processing on compilation units and types. Processes type imports so external methods' receiver types can be analyzed and supertypes can be resolved. Groups external methods by name, corresponding to the anchor classes that will eventually be generated. Mutates the name space management in CTopLevel to record a CGenericFunctionCollection singleton for each anchor class.

Throws:
PositionedError

checkInterface

public void checkInterface(CContextType context)
                             throws PositionedError
Checks the basic interfaces to make sure things generally look OK. This pass gathers information about the type signatures of everything (imported class files, classes being compiled, methods, fields, etc...) needed for the later passes. This information is stored in a CCompilationUnit instance and instances of CMember that are bound to the AST. Also adds things like the default constructor and the initializer method to the AST (these are suppressed during pretty-printing).

Parameters:
context - the context in which this decl appears
Throws:
PositionedError - an error with reference to the source file

checkInitializers

public void checkInitializers(CContextType context)
                                throws PositionedError
Checks the static initializers created during the checkInterface pass and performs some other checks that can be performed simply before full blown typechecking.

Parameters:
context - the context in which this class declaration appears
Throws:
PositionedError - if check fails

resolveSpecializers

public void resolveSpecializers(CContextType context)
                                  throws PositionedError
Computes the values of specializer expressions used to dispatch on compile-time constants.

Parameters:
context - the context in which this class declaration appears
Throws:
PositionedError - if the check fails

resolveTopMethods

public void resolveTopMethods()
                                throws PositionedError
Finds the top method of every declared method. Called after the resolveSpecializers pass. This cannot be done before then because the external generic function mappings are not complete until the end of the checkInterface pass and the constant value specializers are not known until after the resolveSpecializers pass. This must be done before the typecheck pass so that all specialized argument positions for generic functions are known for ambiguity checking.

Specified by:
resolveTopMethods in interface CompilerPassEnterable
Throws:
PositionedError

createContext

public CClassContextType createContext(CContextType parent)
Creates a lexical context for typechecking and control flow analysis on this.


typecheck

public void typecheck(CContextType context)
                        throws PositionedError
Typechecks this type declaration in the context in which it appears. Mutates the context to record the information learned during checking. Actually just updates the context by adding a CSourceClass representation of this. Overriding methods in subclasses of this handle the actual checks.

Parameters:
context - the context in which this type declaration appears
Throws:
PositionedError - if any checks fail

translateMJ

public void translateMJ(CContextType context)
Refactors this to include dispatchers for multimethods and other code necessary for running MultiJava code on a standard JVM.


cachePassParameters

public void cachePassParameters(CContextType context)
Caches the arguments for the compiler passes.

 ensures arePassParametersCached;
 

See Also:
CompilerPassEnterable

JML

JML is Copyright (C) 1998-2002 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. This release depends on code from the MultiJava project and is based in part on the Kopi project Copyright (C) 1990-99 DMS Decision Management Systems Ges.m.b.H.