|
ESC/Java2 © 2003,2004,2005,2006 David Cok and Joseph Kiniry © 2005,2006 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 | ||||||||||
java.lang.Objectjavafe.tc.Env
javafe.tc.EnvForLocals
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected Env parent
protected GenericVarDecl decl
| Constructor Detail |
public EnvForLocals(Env parent,
GenericVarDecl decl)
We report an error to ErrorSet if the new local binding is a redefinition of a local binding not hidden by a field.
public EnvForLocals(Env parent,
GenericVarDecl decl,
boolean warnAboutDuplication)
| Method Detail |
public boolean isStaticContext()
E.g., is "this" (or "
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 !=
isStaticContext in class Env
public TypeSig getEnclosingClass()
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".
getEnclosingClass in class Envpublic TypeSig getEnclosingInstance()
Note: this is considered a current instance, not an enclosing instance, even inside its methods.
getEnclosingInstance in class Envpublic Env asStaticContext()
Note: this routine is somewhat inefficient and should be avoided unless an unknown environment needs to be coerced in this way.
asStaticContext in class Env
public TypeSig lookupSimpleTypeName(TypeSig caller,
Identifier id,
int loc)
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.
lookupSimpleTypeName in class Envpublic ASTNode locateFieldOrLocal(Identifier id)
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.
locateFieldOrLocal in class Envpublic boolean isDuplicate(Identifier id)
isDuplicate in class Envpublic TypeSig locateMethod(Identifier 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.
locateMethod in class Envpublic void display()
display in class Env
|
ESC/Java2 © 2003,2004,2005,2006 David Cok and Joseph Kiniry © 2005,2006 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 | ||||||||||