|
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 |
java.lang.Objectjavafe.tc.Env
javafe.tc.EnvForCU
EnvForCUs are used to create an Env for a CompilationUnit.
Field Summary | |
protected CompilationUnit |
CU
Our CompilationUnit. |
Fields inherited from class javafe.tc.Env |
prefixSize, typeEnv, whereDecoration |
Constructor Summary | |
EnvForCU(CompilationUnit CU)
Create an environment for a CompilationUnit. |
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. |
static TypeSig |
lookupWithoutInheritence(TypeSig caller,
java.lang.String[] N,
java.lang.String I)
Attempt to lookup the type N.I without using inheritence in the outside environment. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected CompilationUnit CU
Constructor Detail |
public EnvForCU(CompilationUnit CU)
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 Env
public TypeSig getEnclosingInstance()
Note: this is considered a current instance, not an enclosing instance, even inside its methods.
getEnclosingInstance
in class Env
public 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 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 Env
public boolean isDuplicate(Identifier id)
isDuplicate
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 Env
public static TypeSig lookupWithoutInheritence(TypeSig caller, java.lang.String[] N, java.lang.String I)
This routine does not check that the resulting type (if any) is actually accessable, unless caller is non-null.
public 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 Env
public void display()
display
in class Env
|
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 |