Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| 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
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javafe.tc
Class TypeSig

    java.lang.Object
      javafe.ast.ASTNode
          javafe.ast.Type
              javafe.tc.TypeSig

All Implemented Interfaces:
  java.lang.Cloneable

Direct Known Subclasses:
  TypeSig

public class TypeSig
extends Type

Field Summary
`static int` | `CHECKED`
`static int` | `CREATED` * TypeSig states and transition functions: * *
`protected CompilationUnit` | `CU` The CompilationUnit we belong to; null iff myTypeDecl is null because of laziness.
`protected Env` | `enclosingEnv` Our enclosing Env; may be null for member types because of laziness.
`TypeSig` | `enclosingType` Our enclosing type or null iff we are a package-member type.
`protected FieldDeclVec` | `fields` After preparation, this field contains all field members of the `TypeDecl` associated with `this`, including inherited ones.
`protected FieldDeclVec` | `hiddenfields`
`static int` | `LINKSRESOLVED`
`private static java.util.Hashtable` | `map` The map from fully-qualified external names of package-member types to the TypeSigs representing them.
`boolean` | `member` Are we a direct member of a package or a type?
`protected MethodDeclVec` | `methods` After preparation, this field contains all method members of the `TypeDecl` associated with `this`, including inherited ones.
`protected TypeDecl` | `myTypeDecl` Our TypeDecl; may be null only for package-member type because of laziness.
`java.lang.String[]` | `packageName` The name of the package we belong to.
`static int` | `PARSED`
`static int` | `PREPPED`
`static int` | `RESOLVINGLINKS`
`static ASTDecoration` | `sigDecoration` Decorates `TypeDecl` nodes to point to `TypeSig` objects.
`java.lang.String` | `simpleName` Our simple name or null if we are an anonymous type.
`int` | `state` The current state of `this`.
`private TypeSig` | `superClass`
`static java.lang.String` | `THE_UNNAMED_PACKAGE`

Fields inherited from class javafe.ast.Type
`tmodifiers`

Fields inherited from class javafe.ast.ASTNode
``

Constructor Summary
`protected` | `TypeSig(java.lang.String[] packageName, java.lang.String simpleName, TypeDecl decl, CompilationUnit CU)` Create a TypeSig that represents an internal-use-only package-member type.
`protected` | `TypeSig(java.lang.String[] packageName, java.lang.String simpleName, TypeSig enclosingType, TypeDecl decl, CompilationUnit CU)` Create a TypeSig that represents a member type.
`protected` | `TypeSig(java.lang.String simpleName, Env enclosingEnv, TypeDecl decl)` Create a TypeSig that represents a non-member type.

Method Summary
`void` | `accept(Visitor v)` Accept a visit from `v`.
`java.lang.Object` | `accept(VisitorArgResult v, java.lang.Object o)`
`void` | `check()` Check invariants of a TypeSig, raising an exception if they don't hold.
`java.lang.Object` | `childAt(int i)` Return the first-but-ith child of a node.
`int` | `childCount()` * ASTNode functions: * *
`static void` | `clear()`
`void` | `deepCheck()` Check invariants of a TypeSig, raising an exception if they don't hold.
`(package private) static TypeSig` | `get(java.lang.String[] P, java.lang.String T)` If a TypeSig representing the package-member type named P.T has been created, return it; otherwise, create such a TypeSig then return it.
`CompilationUnit` | `getCompilationUnit()` Get the non-null CompilationUnit we are associated with.
`Env` | `getEnclosingEnv()` Return our enclosing environment.
`int` | `getEndLoc()`
`EnvForTypeSig` | `getEnv(boolean staticContext)` Return an environment for use in checking code inside us.
`java.lang.String` | `getExternalName()` Return our exact fully-qualified external name as a human-readable string suitable for display.
`FieldDeclVec` | `getFields(boolean allFields)` Returns all fields of the type declaration associated with `this`, including inherited ones.
`FieldDeclVec` | `getFieldsRaw()`
`FieldDeclVec` | `getHiddenFields()`
`private static java.lang.String` | `getKey(java.lang.String[] P, java.lang.String T)` Compute the key for map for fully-qualified type P.T.
`MethodDeclVec` | `getMethods()` Similar to `getFields`, except for methods.
`java.lang.String` | `getPackageName()` Return our package name as a human-readable string suitable for display.
`static TypeSig` | `getRawSig(TypeName n)` Gets the TypeSig recorded by `setSig`, or null.
`static TypeSig` | `getSig(TypeDecl d)` The myTypeDecl field maps TypeSigs to TypeDecls.
`static TypeSig` | `getSig(TypeName n)` Gets the TypeSig recorded by `setSig`.
`int` | `getStartLoc()`
`int` | `getTag()` Return the tag of a node.
`TypeDecl` | `getTypeDecl()` Get the non-null TypeDecl we are associated with.
`java.lang.String` | `getTypeName()` Return our exact type name, omitting the package name, as a human-readable string suitable for display.
`boolean` | `hasField(Identifier id)` TBW
`MethodDecl` | `hasMethod(Identifier id, Type[] args)`
`boolean` | `inSamePackageAs(TypeSig s)`
`boolean` | `isPreloaded()` Is our TypeDecl already loaded?
`boolean` | `isStatic()` Are we (possibly implicitly) static?
`boolean` | `isSubtypeOf(TypeSig s2)`
`boolean` | `isTopLevelType()` Are we a top-level type?
`(package private) void` | `load(TypeDecl decl, CompilationUnit CU)` Load the non-null TypeDecl decl as our TypeDecl.
`static TypeSig` | `lookup(java.lang.String[] P, java.lang.String T)` If a TypeSig representing the package-member type named P.T has been created, return it; otherwise, return null.
`ConstructorDecl` | `lookupConstructor(Type[] args, TypeSig caller)` TBW
`FieldDecl` | `lookupField(Identifier id, TypeSig caller)` TBW
`TypeSig` | `lookupLocalType(TypeSig caller, Identifier id)` Do we have a type member named id (*not* including inherited type members)?
`MethodDecl` | `lookupMethod(Identifier id, Type[] args, TypeSig caller)` TBW
`TypeSig` | `lookupType(TypeSig caller, Identifier id, int loc)` Do we have a type member named id (including inherited type members)?
`private void` | `preload()` Ensure that we have loaded our TypeDecl, invoking OutsideEnv if needed to load a TypeDecl into us via load below.
`void` | `prep()` Transition `this` to the "prepped" state.
`void` | `resolveSupertypeLinks()` Transition `this` to the supertype links resolved state.
`protected void` | `setDecl(TypeDecl decl, CompilationUnit CU)` Protected routine used to associate a TypeSig with a TypeDecl.
`static void` | `setSig(TypeName n, TypeSig sig)`
`TypeSig` | `superClass()`
`java.util.Collection` | `superInterfaces()`
`java.lang.String` | `toString()` Returns a String that represents the value of this Object.
`void` | `typecheck()` Transition `this` to the "checked" state.
`void` | `typecheckSuperTypes()` Typecheck the superclass of the current classtype being typecheck and typecheck all interfaces that the current classtype implements.

Methods inherited from class javafe.ast.ASTNode
`clone, clone, getDecorations, setDecorations`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### packageName

    public java.lang.String[] packageName

  The name of the package we belong to. Always non-null.

### enclosingType

    public TypeSig enclosingType

  Our enclosing type or null iff we are a package-member type.

### simpleName

    public java.lang.String simpleName

  Our simple name or null if we are an anonymous type.

### member

    public boolean member

  Are we a direct member of a package or a type?

  (Otherwise, we are a block-level type or an anonymous type.)

### enclosingEnv

    protected Env enclosingEnv

  Our enclosing Env; may be null for member types because of laziness. Use TypeSig.getEnclosingEnv() to obtain an always non-null version of this.

### myTypeDecl

    protected TypeDecl myTypeDecl

  Our TypeDecl; may be null only for package-member type because of laziness. Use getTypeDecl() to obtain an always non-null version of this.

  This variable should be set only using setDecl.

### CU

    protected CompilationUnit CU

  The CompilationUnit we belong to; null iff myTypeDecl is null because of laziness. Use getCompilationUnit() to obtain an always non-null version of this.

### sigDecoration

    public static final ASTDecoration sigDecoration

  Decorates `TypeDecl` nodes to point to `TypeSig` objects.

### map

    private static final java.util.Hashtable map

  The map from fully-qualified external names of package-member types to the TypeSigs representing them.

  Invariant: map's range includes all existing package-member TypeSigs; map sends getKey(P,T) to the unique package-member TypeSig with external name P.T.

  The domain type of map is String and its range type is (non-null) TypeSigs.

### THE_UNNAMED_PACKAGE

    public static final java.lang.String THE_UNNAMED_PACKAGE

See Also:
  Constant Field Values

### CREATED

    public static final int CREATED

  * TypeSig states and transition functions: * *

  See Also:
    Constant Field Values

### PARSED

    public static final int PARSED

See Also:
  Constant Field Values

### RESOLVINGLINKS

    public static final int RESOLVINGLINKS

See Also:
  Constant Field Values

### LINKSRESOLVED

    public static final int LINKSRESOLVED

See Also:
  Constant Field Values

### PREPPED

    public static final int PREPPED

See Also:
  Constant Field Values

### CHECKED

    public static final int CHECKED

See Also:
  Constant Field Values

### state

    public int state

  The current state of `this`. Must be one of `CREATED`, `PARSED`, `LINKSRESOLVED`, `PREPPED`, or `CHECKED`. In most circumstances, this field should not be written to; rather, methods of `TypeSig` should be called to effect changes to it. This field must never be decreased after creation time.

### fields

    protected FieldDeclVec fields

  After preparation, this field contains all field members of the `TypeDecl` associated with `this`, including inherited ones.

### hiddenfields

    protected FieldDeclVec hiddenfields

### methods

    protected MethodDeclVec methods

  After preparation, this field contains all method members of the `TypeDecl` associated with `this`, including inherited ones.

### superClass

    private TypeSig superClass

Constructor Detail

### TypeSig

    protected TypeSig(java.lang.String simpleName,
                      Env enclosingEnv,
                      TypeDecl decl)

  Create a TypeSig that represents a non-member type.

  We represent a block-level type if simpleName is non-null, and an anonymous type otherwise.

### TypeSig

    protected TypeSig(java.lang.String[] packageName,
                      java.lang.String simpleName,
                      TypeSig enclosingType,
                      TypeDecl decl,
                      CompilationUnit CU)

  Create a TypeSig that represents a member type.

  This constructor is designed to be private to TypeSig; It is protected to support the Types inst pattern, but clients should use OutsideEnv.lookup[Deffered] and getSig to get TypeSig's representing member types.

  We represent a package-member type if enclosingType is non-null, and a type-member type otherwise.

  Note: packageName should never be modified by the caller after this call.

  CU must be the CompilationUnit that decl belongs to.

### TypeSig

    protected TypeSig(java.lang.String[] packageName,
                      java.lang.String simpleName,
                      TypeDecl decl,
                      CompilationUnit CU)

  Create a TypeSig that represents an internal-use-only package-member type. Such types do not have external names and should be avoided if at all possible since they are kludges.

  This constructor should only be used by PrepTypeDeclaration.getRootInterface().

  Note: packageName should never be modified by the caller after this call.

  CU must be the CompilationUnit that decl belongs to.

Method Detail

### getSig

    public static TypeSig getSig(TypeDecl d)

  The myTypeDecl field maps TypeSigs to TypeDecls. The getSig(TypeDecl) function provides the reverse mapping.

  Precondition: d has already been associated with a TypeSig.

### setDecl

    protected void setDecl(TypeDecl decl,
                           CompilationUnit CU)

  Protected routine used to associate a TypeSig with a TypeDecl.

  It automatically creates TypeSigs for any (indirect) members of decl and associates them properly.

  CU must be the CompilationUnit that decl belongs to.

### clear

    public static final void clear()

### getKey

    private static java.lang.String getKey(java.lang.String[] P,
                                           java.lang.String T)

  Compute the key for map for fully-qualified type P.T.

### lookup

    public static TypeSig lookup(java.lang.String[] P,
                                 java.lang.String T)

  If a TypeSig representing the package-member type named P.T has been created, return it; otherwise, return null.

  This function should only be called by OutsideEnv.

### get

    static TypeSig get(java.lang.String[] P,
                       java.lang.String T)

  If a TypeSig representing the package-member type named P.T has been created, return it; otherwise, create such a TypeSig then return it.

  This function should only be called by OutsideEnv.

### getTypeDecl

    public TypeDecl getTypeDecl()

  Get the non-null TypeDecl we are associated with.

  (Under the covers, for package-member types, this method may cause `OutsideEnv` to parse the `TypeDecl` in question, but this should be transparent to most clients.)

### getCompilationUnit

    public CompilationUnit getCompilationUnit()

  Get the non-null CompilationUnit we are associated with.

  (Under the covers, for package-member types, this method may cause `OutsideEnv` to parse the type in question, but this should be transparent to most clients.)

### preload

    private void preload()

  Ensure that we have loaded our TypeDecl, invoking OutsideEnv if needed to load a TypeDecl into us via load below. We abort via an assertion failure if OutsideEnv fails to load us.

### isPreloaded

    public boolean isPreloaded()

  Is our TypeDecl already loaded?

### load

    void load(TypeDecl decl,
              CompilationUnit CU)

  Load the non-null TypeDecl decl as our TypeDecl. This method is used by OutsideEnv to install a TypeDecl in us once it has been loaded.

  If we have already been loaded with a different TypeDecl, then an appropriate fatal error results.

  Note: This method should *only* be called by OutsideEnv.load.

  CU must be the CompilationUnit that decl belongs to.

### getPackageName

    public java.lang.String getPackageName()

  Return our package name as a human-readable string suitable for display. If we are in the unnamed package, the constant THE_UNNAMED_PACKAGE is returned.

### getTypeName

    public java.lang.String getTypeName()

  Return our exact type name, omitting the package name, as a human-readable string suitable for display.

### getExternalName

    public java.lang.String getExternalName()

  Return our exact fully-qualified external name as a human-readable string suitable for display. The package name is omitted if it is the unnamed package.

### toString

    public java.lang.String toString()

  Returns a String that represents the value of this Object.

  Specified by:
    `toString` in class `ASTNode`

### childCount

    public int childCount()

  * ASTNode functions: * *

  Specified by:
    `childCount` in class `ASTNode`

### childAt

    public java.lang.Object childAt(int i)

  Description copied from class: `ASTNode`
  Return the first-but-ith child of a node.

  Specified by:
    `childAt` in class `ASTNode`

### getTag

    public int getTag()

  Description copied from class: `ASTNode`
  Return the tag of a node.

  Specified by:
    `getTag` in class `ASTNode`

### accept

    public void accept(Visitor v)

  Description copied from class: `ASTNode`
  Accept a visit from `v`. This method simply calls the method of `v` corresponding to the allocated type of `this`, passing `this` as the argument. See the design patterns book.

  Specified by:
    `accept` in class `ASTNode`

### accept

    public java.lang.Object accept(VisitorArgResult v,
                                   java.lang.Object o)

  Specified by:
    `accept` in class `ASTNode`

### getStartLoc

    public int getStartLoc()

  Specified by:
    `getStartLoc` in class `ASTNode`

### getEndLoc

    public int getEndLoc()

  Overrides:
    `getEndLoc` in class `ASTNode`

### lookupType

    public TypeSig lookupType(TypeSig caller,
                              Identifier id,
                              int loc)

  Do we have a type member named id (including inherited type members)?

  If we have exactly one such type member, then return it. If we have no such type member, return null. If we have more than one such type member, then if loc != Location.NULL then a fatal error is reported at that location via ErrorSet else one of the relevant type members is returned.

  If caller is null, this routine does not check that the resulting type (if any) is accessible. If caller is not null, then the resulting type is checked to be accessible from the caller.

### lookupLocalType

    public TypeSig lookupLocalType(TypeSig caller,
                                   Identifier id)

  Do we have a type member named id (*not* including inherited type members)? If so, return it; otherwise, return null.

  If caller is null, then this routine does not check that the resulting type (if any) is actually accessable. If caller is non_null, then the resulting type is checked that it is accessible from the caller.

### getEnclosingEnv

    public Env getEnclosingEnv()

  Return our enclosing environment.

### getEnv

    public EnvForTypeSig getEnv(boolean staticContext)

  Return an environment for use in checking code inside us.

  Our instance members are considered accessible iff staticContext is false.

### isStatic

    public boolean isStatic()

  Are we (possibly implicitly) static?

  This differs from using Modifiers.isStatic because it does not rely on Prep'ing having added the static modifier where implicit so we can be used by Prep itself.

### isTopLevelType

    public boolean isTopLevelType()

  Are we a top-level type?

  True iff either we are a package-level type or a static member of a top-level type.

  Note: This may be called during any state; it may bump TypeSigs to the Parsed state.

### resolveSupertypeLinks

    public void resolveSupertypeLinks()

  Transition `this` to the supertype links resolved state.

  See the TypeSig type comments for details of what this involves.

  A fatal error may be reported if we cannot resolve a supertype name, or detect a cycle in the type hierarchy.

### prep

    public void prep()

  Transition `this` to the "prepped" state.

  A prepped declaration has all of the `TypeName` nodes defining the types of its members resolved. For a field declaration, this means resolving the `type` field; For a routine declaration, this means resolving `TypeName`s that occur in the `args`, `raises`, and `returnType` fields.

  See the TypeSig type comments for more details of what this involves.

### typecheck

    public void typecheck()

  Transition `this` to the "checked" state.

  See the TypeSig type comments for details of what this involves.

  A fatal error may be reported if we cannot resolve a supertype name, or detect a cycle in the type hierarchy.

### typecheckSuperTypes

    public void typecheckSuperTypes()

  Typecheck the superclass of the current classtype being typecheck and typecheck all interfaces that the current classtype implements.

### getFields

    public FieldDeclVec getFields(boolean allFields)

  Returns all fields of the type declaration associated with `this`, including inherited ones. (If `this` has not been prepped yet, this method will prep it (possibly triggering parsing and/or processing of other types).) If allFields is true, then all declared fields, including hidden and inaccessible fields, are returned; if allFields is false, then only visible fields are returned.

### getFieldsRaw

    public FieldDeclVec getFieldsRaw()

### getHiddenFields

    public FieldDeclVec getHiddenFields()

### getMethods

    public MethodDeclVec getMethods()

  Similar to `getFields`, except for methods.

### lookupConstructor

    public ConstructorDecl lookupConstructor(Type[] args,
                                             TypeSig caller)
                                      throws LookupException

  TBW

  Throws:
    `LookupException`

### lookupField

    public FieldDecl lookupField(Identifier id,
                                 TypeSig caller)
                          throws LookupException

  TBW

  Throws:
    `LookupException`

### hasField

    public boolean hasField(Identifier id)

  TBW

### hasMethod

    public MethodDecl hasMethod(Identifier id,
                                Type[] args)

### lookupMethod

    public MethodDecl lookupMethod(Identifier id,
                                   Type[] args,
                                   TypeSig caller)
                            throws LookupException

  TBW

  Throws:
    `LookupException`

### getRawSig

    public static TypeSig getRawSig(TypeName n)

  Gets the TypeSig recorded by `setSig`, or null.

### getSig

    public static TypeSig getSig(TypeName n)

  Gets the TypeSig recorded by `setSig`. Precondition: n has been resolved.

### setSig

    public static void setSig(TypeName n,
                              TypeSig sig)

### isSubtypeOf

    public final boolean isSubtypeOf(TypeSig s2)

### inSamePackageAs

    public final boolean inSamePackageAs(TypeSig s)

### check

    public void check()

  Check invariants of a TypeSig, raising an exception if they don't hold.

  Overrides:
    `check` in class `Type`

### deepCheck

    public void deepCheck()

  Check invariants of a TypeSig, raising an exception if they don't hold.

### superClass

    public TypeSig superClass()

### superInterfaces

    public java.util.Collection superInterfaces()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| 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
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

The ESC/Java2 Project Homepage