public class

Context

extends Object
implements Constants
java.lang.Object
   ↳ sun.tools.tree.Context
Known Direct Subclasses

Class Overview

WARNING: The contents of this source file are not part of any supported API. Code that depends on them does so at its own risk: they are subject to change or removal without notice.

Summary

[Expand]
Inherited Constants
From interface sun.tools.java.Constants
From interface sun.tools.java.RuntimeConstants
[Expand]
Inherited Fields
From interface sun.tools.java.Constants
From interface sun.tools.java.RuntimeConstants
Public Constructors
Context(Context ctx, MemberDefinition field)
Create the initial context for a method The incoming context is inherited from
Context(Context ctx, ClassDefinition c)
Create a new context, for initializing a class.
Context(Context ctx)
Public Methods
boolean canReach(Environment env, MemberDefinition f)
Check if a field can reach another field (only considers forward references, not the access modifiers).
void checkBackBranch(Environment env, Statement loop, Vset vsEntry, Vset vsBack)
Raise an error if a blank final was definitely unassigned on entry to a loop, but has possibly been assigned on the back-branch.
int declare(Environment env, LocalMember local)
Declare local
int declareFieldNumber(MemberDefinition field)
Assign a number to a class field.
Expression findOuterLink(Environment env, long where, ClassDefinition reqc, MemberDefinition f, boolean needExactMatch)
Expression findOuterLink(Environment env, long where, MemberDefinition f)
Return a local expression which can serve as the base reference for the given field.
ClassDefinition findScope(Environment env, ClassDefinition reqc)
From which enclosing class do members of this type come?
Identifier getApparentClassName(Environment env, Identifier name)
Return the name of a lexically apparent type, skipping inherited members, and ignoring the current pacakge and imports.
final MemberDefinition getApparentField(Environment env, Identifier name)
Like getField, except that it skips over inherited fields.
Context getBreakContext(Identifier lbl)
Get the destination context of a break
Context getContinueContext(Identifier lbl)
Get the destination context of a continue
MemberDefinition getElement(int number)
Return the local field or member field corresponding to a number.
final MemberDefinition getField()
Return the field containing the present context.
final MemberDefinition getField(Environment env, Identifier name)
Get either a local variable, or a field in a current class
int getFieldNumber(MemberDefinition field)
Retrieve a number previously assigned by declareMember().
Context getLabelContext(Identifier lbl)
Get the context that corresponds to a label, return null if not found.
LocalMember getLocalClass(Identifier name)
Get a local class by name
LocalMember getLocalField(Identifier name)
Get a local variable by name
CheckContext getReturnContext()
Get the destination context of a return (the method body)
int getScopeNumber(ClassDefinition c)
Get the scope number for a reference to a member of this class (Larger scope numbers are more deeply nested.)
int getThisNumber()
Return the number of the innermost current instance reference.
CheckContext getTryExitContext()
Get the context of the innermost surrounding try-block.
final int getVarNumber()
boolean isInScope(LocalMember field)
Check if the given field is active in this context.
Expression makeReference(Environment env, LocalMember target)
Implement a reference (usually an uplevel one).
static Environment newEnvironment(Environment env, Context ctx)
Extend an environment with the given context.
UplevelReference noteReference(Environment env, LocalMember target)
Notice a reference (usually an uplevel one).
static boolean outerLinkExists(Environment env, ClassDefinition reqc, ClassDefinition thisc)
Is there a "this" of type reqc in scope?
final Vset removeAdditionalVars(Vset vset)
Remove variables from the vset set that are no longer part of this context.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Context (Context ctx, MemberDefinition field)

Create the initial context for a method The incoming context is inherited from

public Context (Context ctx, ClassDefinition c)

Create a new context, for initializing a class.

public Context (Context ctx)

Public Methods

public boolean canReach (Environment env, MemberDefinition f)

Check if a field can reach another field (only considers forward references, not the access modifiers).

public void checkBackBranch (Environment env, Statement loop, Vset vsEntry, Vset vsBack)

Raise an error if a blank final was definitely unassigned on entry to a loop, but has possibly been assigned on the back-branch. If this is the case, the loop may be assigning it multiple times.

public int declare (Environment env, LocalMember local)

Declare local

public int declareFieldNumber (MemberDefinition field)

Assign a number to a class field. (This is used to track definite assignment of some blank finals.)

public Expression findOuterLink (Environment env, long where, ClassDefinition reqc, MemberDefinition f, boolean needExactMatch)

public Expression findOuterLink (Environment env, long where, MemberDefinition f)

Return a local expression which can serve as the base reference for the given field. If the field is a constructor, return an expression for the implicit enclosing instance argument.

Return null if there is no need for such an argument, or if there was an error.

public ClassDefinition findScope (Environment env, ClassDefinition reqc)

From which enclosing class do members of this type come?

public Identifier getApparentClassName (Environment env, Identifier name)

Return the name of a lexically apparent type, skipping inherited members, and ignoring the current pacakge and imports. This is used for error checking.

public final MemberDefinition getApparentField (Environment env, Identifier name)

Like getField, except that it skips over inherited fields. Used for error checking.

public Context getBreakContext (Identifier lbl)

Get the destination context of a break

public Context getContinueContext (Identifier lbl)

Get the destination context of a continue

public MemberDefinition getElement (int number)

Return the local field or member field corresponding to a number. Return null if there is no such field.

public final MemberDefinition getField ()

Return the field containing the present context.

public final MemberDefinition getField (Environment env, Identifier name)

Get either a local variable, or a field in a current class

public int getFieldNumber (MemberDefinition field)

Retrieve a number previously assigned by declareMember(). Return -1 if there was no such assignment in this context.

public Context getLabelContext (Identifier lbl)

Get the context that corresponds to a label, return null if not found.

public LocalMember getLocalClass (Identifier name)

Get a local class by name

public LocalMember getLocalField (Identifier name)

Get a local variable by name

public CheckContext getReturnContext ()

Get the destination context of a return (the method body)

public int getScopeNumber (ClassDefinition c)

Get the scope number for a reference to a member of this class (Larger scope numbers are more deeply nested.)

See Also
  • LocalMember#scopeNumber

public int getThisNumber ()

Return the number of the innermost current instance reference.

public CheckContext getTryExitContext ()

Get the context of the innermost surrounding try-block. Consider only try-blocks contained within the same method. (There could be others when searching from within a method of a local class, but they are irrelevant to our purpose.) This is used for recording DA/DU information preceding all abnormal transfers of control: break, continue, return, and throw.

public final int getVarNumber ()

public boolean isInScope (LocalMember field)

Check if the given field is active in this context.

public Expression makeReference (Environment env, LocalMember target)

Implement a reference (usually an uplevel one). Call noteReference() first, to make sure the reference lists are up to date.

The resulting expression tree does not need checking; it can be code-generated right away. If the reference is not uplevel, the result is an IDENT or THIS.

public static Environment newEnvironment (Environment env, Context ctx)

Extend an environment with the given context. The resulting environment behaves the same as the given one, except that resolveName() takes into account local class names in this context.

public UplevelReference noteReference (Environment env, LocalMember target)

Notice a reference (usually an uplevel one). Update the references list of every enclosing class which is enclosed by the scope of the target. Update decisions about which uplevels to make into fields. Return the uplevel reference descriptor, or null if it's local.

The target must be in scope in this context. So, call this method only from the check phase. (In other phases, the context may be less complete.)

This can and should be called both before and after classes are frozen. It should be a no-op, and will raise a compiler error if not.

public static boolean outerLinkExists (Environment env, ClassDefinition reqc, ClassDefinition thisc)

Is there a "this" of type reqc in scope?

public final Vset removeAdditionalVars (Vset vset)

Remove variables from the vset set that are no longer part of this context.