ESC/Java2
© 2003,2004,2005 David Cok and Joseph Kiniry
© 2005 UCD Dublin
© 2003,2004 Radboud University Nijmegen
© 1999,2000 Compaq Computer Corporation
© 1997,1998,1999 Digital Equipment Corporation
All Rights Reserved

javafe.tc
Class PrepTypeDeclaration

java.lang.Object
  extended byjavafe.tc.PrepTypeDeclaration
Direct Known Subclasses:
PrepTypeDeclaration

public class PrepTypeDeclaration
extends java.lang.Object

Does type name resolution and type checking at signature level of a type declaration, and infers the members of the declaration. Also resolves type names at the signature level. Assumes the TypeSig was previously in the "supertype links resolved" state.


Field Summary
protected  TypeSig _rootCache
           
protected  StackVector constructorSeq
           
protected  StackVector fieldSeq
           
protected  StackVector hiddenfieldSeq
           
static PrepTypeDeclaration inst
          A (possibly extended) instance of PrepTypeDeclaration.
protected  StackVector methodSeq
           
private  int numFields
           
private  java.util.LinkedList numList
           
private static ASTDecoration overridesDecoration
           
 
Constructor Summary
PrepTypeDeclaration()
           
 
Method Summary
protected  void addInheritedMembers(TypeSig type, TypeSig superType)
          Find all members of a supertype inherited by a type.
private  void addOverride(MethodDecl md, MethodDecl overrides)
          Decorates MethodDecl of prepped TypeDecls with a Set of methods that decl overrides or hides.
 void checkModifiers(int modifiers, int allowed, int loc, java.lang.String decl)
           
protected  void checkSuperInterfaces(TypeSig sig, TypeNameVec superInterfaces)
          Check superinterfaces and add their members to fieldSeq and methodSeq.
 void checkSuperTypeAccessible(TypeSig currentSig, TypeSig supertype, int loc)
          Check to make sure a supertype is accessible; reports an error to ErrorSet if not.
 void checkTypeModifiers(TypeDecl decl, TypeSig currentSig, boolean isClass)
          Check that the modifiers of a type are ok.
protected  boolean declaresFieldJava(TypeSig sig, Identifier id)
          Check if a type declares a field.
private  MethodDecl declaresMethod(TypeSig sig, Identifier id, Type[] argTypes)
          Check if a type declares a method.
protected  EnvForTypeSig getEnvForCurrentSig(TypeSig sig, boolean isStatic)
           
 Set getOverrides(MethodDecl md)
          Returns the set of all methods that md overrides, where md is considered to appear in those prepped subtypes of md.parent that inherit md.
 Set getOverrides(TypeDecl td, MethodDecl md)
          Returns the set of methods that md overrides, with md considered to appear in a particular type td.
 TypeSig getRootInterface()
          This routine constructs and returns the interface that all interfaces are de-facto subinterfaces of.
protected  void prepDo(TypeSig sig, TypeDecl decl)
           
protected  void prepEnd(TypeSig sig, TypeDecl decl)
           
protected  void prepStart(TypeSig sig, TypeDecl decl)
           
 void prepTypeSignature(TypeSig sig)
          Does type name resolution and type checking at signature level of a type declaration, and infers the members of the declaration.
 TypeSig processTypeNameAnnotations(TypeName tn, TypeSig sig, Env env)
           
protected  void startSupers()
           
protected  boolean superMemberAccessible(TypeSig type, TypeSig superType, int modifiers, ModifierPragmaVec pmodifiers)
          Check if a member is accessible from a direct subclass.
protected  void visitClassDecl(ClassDecl decl, TypeSig currentSig)
          Does signature-level checking and adds type members to fieldSeq and methodSeq.
protected  void visitConstructorDecl(ConstructorDecl x, TypeSig currentSig, boolean abstractMethodsOK, boolean inFinalClass, boolean inInterface)
          Visit ConstructorDecl, check it, and add it to constructorSeq.
protected  void visitFieldDecl(FieldDecl x, TypeSig currentSig, boolean abstractMethodsOK, boolean inFinalClass, boolean inInterface)
          Visit a FieldDecl, check it and add it to fieldSeq.
protected  void visitInterfaceDecl(InterfaceDecl decl, TypeSig currentSig)
          Does signature-level checking and adds type members to fieldSeq and methodSeq.
protected  void visitMethodDecl(MethodDecl x, TypeSig currentSig, boolean abstractMethodsOK, boolean inFinalClass, boolean inInterface)
          Visit a MethodDecl, check it and add it to methodSeq.
protected  void visitTypeDeclElem(TypeDeclElem e, TypeSig currentSig, boolean abstractMethodsOK, boolean inFinalClass, boolean inInterface)
          Visit a TypeDeclElem, check it and add it to fieldSeq or methodSeq, if appropriate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inst

public static PrepTypeDeclaration inst
A (possibly extended) instance of PrepTypeDeclaration.


overridesDecoration

private static ASTDecoration overridesDecoration

fieldSeq

protected StackVector fieldSeq

hiddenfieldSeq

protected StackVector hiddenfieldSeq

methodSeq

protected StackVector methodSeq

constructorSeq

protected StackVector constructorSeq

numFields

private int numFields

numList

private java.util.LinkedList numList

_rootCache

protected TypeSig _rootCache
Constructor Detail

PrepTypeDeclaration

public PrepTypeDeclaration()
Method Detail

prepTypeSignature

public void prepTypeSignature(TypeSig sig)
Does type name resolution and type checking at signature level of a type declaration, and infers the members of the declaration. Sets the "methods" and "fields" fields of the TypeSig appropriately.


prepStart

protected void prepStart(TypeSig sig,
                         TypeDecl decl)

prepDo

protected void prepDo(TypeSig sig,
                      TypeDecl decl)

prepEnd

protected void prepEnd(TypeSig sig,
                       TypeDecl decl)

addOverride

private void addOverride(MethodDecl md,
                         MethodDecl overrides)
Decorates MethodDecl of prepped TypeDecls with a Set of methods that decl overrides or hides. This is *NOT* transtitive!


getOverrides

public Set getOverrides(MethodDecl md)
Returns the set of all methods that md overrides, where md is considered to appear in those prepped subtypes of md.parent that inherit md. Warning: This set may expand as additional subtypes of md.parent are prepped. Warning: If you want the set of methods that md overrides, with md considered to appear in a particular type td, use getOverrides(TypeDecl, MethodDecl) instead!


getOverrides

public Set getOverrides(TypeDecl td,
                        MethodDecl md)
Returns the set of methods that md overrides, with md considered to appear in a particular type td.

This routine may result in td being prepped.


visitClassDecl

protected void visitClassDecl(ClassDecl decl,
                              TypeSig currentSig)
Does signature-level checking and adds type members to fieldSeq and methodSeq.


checkTypeModifiers

public void checkTypeModifiers(TypeDecl decl,
                               TypeSig currentSig,
                               boolean isClass)
Check that the modifiers of a type are ok.

decl is the TypeDecl for the type, and currentSig its TypeSig.

isClass should be true iff the TypeDecl is a ClassDecl.


visitInterfaceDecl

protected void visitInterfaceDecl(InterfaceDecl decl,
                                  TypeSig currentSig)
Does signature-level checking and adds type members to fieldSeq and methodSeq.


startSupers

protected void startSupers()

checkSuperInterfaces

protected void checkSuperInterfaces(TypeSig sig,
                                    TypeNameVec superInterfaces)
Check superinterfaces and add their members to fieldSeq and methodSeq.


visitTypeDeclElem

protected void visitTypeDeclElem(TypeDeclElem e,
                                 TypeSig currentSig,
                                 boolean abstractMethodsOK,
                                 boolean inFinalClass,
                                 boolean inInterface)
Visit a TypeDeclElem, check it and add it to fieldSeq or methodSeq, if appropriate


visitFieldDecl

protected void visitFieldDecl(FieldDecl x,
                              TypeSig currentSig,
                              boolean abstractMethodsOK,
                              boolean inFinalClass,
                              boolean inInterface)
Visit a FieldDecl, check it and add it to fieldSeq.


visitMethodDecl

protected void visitMethodDecl(MethodDecl x,
                               TypeSig currentSig,
                               boolean abstractMethodsOK,
                               boolean inFinalClass,
                               boolean inInterface)
Visit a MethodDecl, check it and add it to methodSeq.


visitConstructorDecl

protected void visitConstructorDecl(ConstructorDecl x,
                                    TypeSig currentSig,
                                    boolean abstractMethodsOK,
                                    boolean inFinalClass,
                                    boolean inInterface)
Visit ConstructorDecl, check it, and add it to constructorSeq.


addInheritedMembers

protected void addInheritedMembers(TypeSig type,
                                   TypeSig superType)
Find all members of a supertype inherited by a type. Adds these members to fieldSeq and methodSeq. The order in which superTypes are added is crucial. See the comment below marked by a <<>>


superMemberAccessible

protected boolean superMemberAccessible(TypeSig type,
                                        TypeSig superType,
                                        int modifiers,
                                        ModifierPragmaVec pmodifiers)
Check if a member is accessible from a direct subclass.


declaresFieldJava

protected boolean declaresFieldJava(TypeSig sig,
                                    Identifier id)
Check if a type declares a field.


declaresMethod

private MethodDecl declaresMethod(TypeSig sig,
                                  Identifier id,
                                  Type[] argTypes)
Check if a type declares a method.


checkModifiers

public void checkModifiers(int modifiers,
                           int allowed,
                           int loc,
                           java.lang.String decl)

checkSuperTypeAccessible

public void checkSuperTypeAccessible(TypeSig currentSig,
                                     TypeSig supertype,
                                     int loc)
Check to make sure a supertype is accessible; reports an error to ErrorSet if not.

Here, supertype is a supertype of currentSig; this fact is declared at loc. E.g., loc is the location of the supertype name in the extends or implements clause of currentSig.


getRootInterface

public TypeSig getRootInterface()
This routine constructs and returns the interface that all interfaces are de-facto subinterfaces of.

This interface is not an actual Java interface, but rather a made up one. Its locations will be valid, but misleading.

The root interface is composed of all the public methods of java.lang.Object turned into abstract methods.


processTypeNameAnnotations

public TypeSig processTypeNameAnnotations(TypeName tn,
                                          TypeSig sig,
                                          Env env)

getEnvForCurrentSig

protected EnvForTypeSig getEnvForCurrentSig(TypeSig sig,
                                            boolean isStatic)

ESC/Java2
© 2003,2004,2005 David Cok and Joseph Kiniry
© 2005 UCD Dublin
© 2003,2004 Radboud University Nijmegen
© 1999,2000 Compaq Computer Corporation
© 1997,1998,1999 Digital Equipment Corporation
All Rights Reserved

The ESC/Java2 Project Homepage