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 EnvForLocals

    java.lang.Object
      javafe.tc.Env
          javafe.tc.EnvForLocals

All Implemented Interfaces:
  java.lang.Cloneable

public class EnvForLocals
extends Env
implements java.lang.Cloneable

EnvForLocals are used to extend an existing Env with one new local binding, either a local variable definition or a formal parameter.

See EnvForLocalType for how to extend an existing Env with one new local type binding.

Field Summary
`protected GenericVarDecl` | `decl` The new local binding.
`protected Env` | `parent` Our parent environment

Fields inherited from class javafe.tc.Env
`prefixSize, typeEnv, whereDecoration`

Constructor Summary
`EnvForLocals(Env parent, GenericVarDecl decl)` Create a environment from an existing one by adding a new local binding.
`EnvForLocals(Env parent, GenericVarDecl decl, boolean warnAboutDuplication)`

Method Summary
`Env` | `asStaticContext()` Returns a new Env that acts the same as us, except that its current instance (if any) is not accessible.
`void` | `display()` Display information about us to System.out.
`TypeSig` | `getEnclosingClass()` Return the intermost class enclosing the code that is checked in this environment.
`TypeSig` | `getEnclosingInstance()` If there is an enclosing instance in scope, then return the (exact) type of the innermost such instance.
`boolean` | `isDuplicate(Identifier id)`
`boolean` | `isStaticContext()` Is there a current instance in scope?
`ASTNode` | `locateFieldOrLocal(Identifier id)` Locate the lexically innermost field or local variable declaration.
`TypeSig` | `locateMethod(Identifier id)` Locate the lexically innermost method named id.
`TypeSig` | `lookupSimpleTypeName(TypeSig caller, Identifier id, int loc)` Attempt to lookup a simple TypeName in this environment to get the TypeSig it denotes.

Methods inherited from class javafe.tc.Env
`canAccessInstance, disambiguateExprName, disambiguateMethodName, disambiguateTypeOrFieldName, findTypeNamePrefix, getInferredThisExpr, getInnermostInstance, getObjectDesignator, lookupEnclosingInstance, lookupTypeName, processTypeNameAnnotations, resolveType, resolveTypeName, whereDeclared`

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

Field Detail

### parent

    protected Env parent

  Our parent environment

### decl

    protected GenericVarDecl decl

  The new local binding.

Constructor Detail

### EnvForLocals

    public EnvForLocals(Env parent,
                        GenericVarDecl decl)

  Create a environment from an existing one by adding a new local binding.

  We report an error to ErrorSet if the new local binding is a redefinition of a local binding not hidden by a field.

### EnvForLocals

    public EnvForLocals(Env parent,
                        GenericVarDecl decl,
                        boolean warnAboutDuplication)

Method Detail

### isStaticContext

    public boolean isStaticContext()

  Is there a current instance in scope?

  E.g., is "this" (or ".this") legal here?

  This is also refered to as "are we in a static context?". The legality of super also depends on this result.

  The legality of C.this, C != is different; see canAccessInstance(-).

  Specified by:
    `isStaticContext` in class `Env`

### getEnclosingClass

    public TypeSig getEnclosingClass()

  Return the intermost class enclosing the code that is checked in this environment.

  May return null if there is no enclosing class (aka, for environments for CompilationUnits).

  If isStaticContext() returns true, then this is the type of "this".

  Specified by:
    `getEnclosingClass` in class `Env`

### getEnclosingInstance

    public TypeSig getEnclosingInstance()

  If there is an enclosing instance in scope, then return the (exact) type of the innermost such instance.

  Note: this is considered a current instance, not an enclosing instance, even inside its methods.

  Specified by:
    `getEnclosingInstance` in class `Env`

### asStaticContext

    public Env asStaticContext()

  Returns a new Env that acts the same as us, except that its current instance (if any) is not accessible.

  Note: this routine is somewhat inefficient and should be avoided unless an unknown environment needs to be coerced in this way.

  Specified by:
    `asStaticContext` in class `Env`

### lookupSimpleTypeName

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

  Attempt to lookup a simple TypeName in this environment to get the TypeSig it denotes. Returns null if no such type exists.

  This routine does not check that the resulting type (if any) is actually accessable.

  If id is ambiguous, then if loc != Location.NULL then a fatal error is reported at that location via ErrorSet else one of its possible meanings is returned.

  Specified by:
    `lookupSimpleTypeName` in class `Env`

### locateFieldOrLocal

    public ASTNode locateFieldOrLocal(Identifier id)

  Locate the lexically innermost field or local variable declaration.

  Let d be the lexically innermost field or local variable declaration (including formals) of id (if any such declaration exists). Then this routine returns:

  d (a LocalVarDecl or FormalParaDecl) if d is a local variable declaration the class C that lexically encloses us and contains the (inherited) field d if d is a field declaration null if d does not exist Note: inherited fields are considered to lexically enclose the code of their subclasses. We give the class containing the field instead of the field itself to postpone dealing with multiple fields named id visible in the same class.

  In the field case, id disambiguates to C[.this].id.

  Specified by:
    `locateFieldOrLocal` in class `Env`

### isDuplicate

    public boolean isDuplicate(Identifier id)

  Overrides:
    `isDuplicate` in class `Env`

### locateMethod

    public TypeSig locateMethod(Identifier id)

  Locate the lexically innermost method named id.

  Returns the TypeSig for the innermost lexically enclosing type that has a method named id or null if no such type exists.

  Note: inherited methods are considered to lexically enclose the code of their subclasses.

  id disambiguates to C[.this].id.

  Specified by:
    `locateMethod` in class `Env`

### display

    public void display()

  Display information about us to System.out. This function is intended only for debugging use.

  Specified by:
    `display` in class `Env`

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