Class UplevelReference

java.lang.Object
org.glassfish.rmic.tools.tree.UplevelReference
All Implemented Interfaces:
Constants, RuntimeConstants

public class UplevelReference extends Object implements Constants
A reference from one scope to another. 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.
  • Field Details

    • client

      The class in which the reference occurs.
    • target

      LocalMember target
      The field being referenced. It is always a final argument or a final local variable. (An uplevel reference to a field of a class C is fetched through an implicit uplevel reference to C.this, which is an argument.)
    • localArgument

      LocalMember localArgument
      The local variable which bears a copy of the target's value, for all methods of the client class. Its name is "this$C" for this.C or "val$x" for other target variables x.

      This local variable is always a constructor argument, and is therefore usable only in the constructor and in initializers. All other methods use the local field.

      See Also:
    • localField

      MemberDefinition localField
      A private synthetic field of the client class which bears a copy of the target's value. The compiler tries to avoid creating it if possible. The field has the same name and type as the localArgument.
      See Also:
    • next

      The next item on the references list of the client.
  • Constructor Details

  • Method Details

    • insertInto

      public UplevelReference insertInto(UplevelReference references)
      Insert self into a list of references. Maintain "isEarlierThan" as an invariant of the list. This is important (a) to maximize stability of signatures, and (b) to allow uplevel "this" parameters to come at the front of every argument list they appear in.
    • isEarlierThan

      public final boolean isEarlierThan(UplevelReference other)
      Tells if self precedes the other in the canonical ordering.
    • getTarget

      public final LocalMember getTarget()
      the target of this reference
    • getLocalArgument

      public final LocalMember getLocalArgument()
      the local argument for this reference
    • getLocalField

      public final MemberDefinition getLocalField()
      the field allocated in the client for this reference
    • getLocalField

      public final MemberDefinition getLocalField(Environment env)
      Get the local field, creating one if necessary. The client class must not be frozen.
    • getClient

      public final ClassDefinition getClient()
      the client class
    • getNext

      public final UplevelReference getNext()
      the next reference in the client's list
    • isClientOuterField

      public boolean isClientOuterField()
      Tell if this uplevel reference is the up-level "this" pointer of an inner class. Such references are treated differently than others, because they affect constructor calls across compilation units.
    • localArgumentAvailable

      public boolean localArgumentAvailable(Environment env, Context ctx)
      Tell if my local argument is directly available in this context. If not, the uplevel reference will have to be via a class field.

      This must be called in a context which is local to the client of the uplevel reference.

    • noteReference

      public void noteReference(Environment env, Context ctx)
      Process an uplevel reference. The only decision to make at this point is whether to build a "localField" instance variable, which is done (lazily) when localArgumentAvailable() proves false.
    • makeLocalField

      private void makeLocalField(Environment env)
    • makeLocalReference

      public Expression makeLocalReference(Environment env, Context ctx)
      Assuming noteReference() is all taken care of, build an uplevel reference.

      This must be called in a context which is local to the client of the uplevel reference.

    • makeFieldReference

      public Expression makeFieldReference(Environment env, Context ctx)
      As with makeLocalReference(), build a locally-usable reference. Ignore the availability of local arguments; always use a class field.
    • willCodeArguments

      public void willCodeArguments(Environment env, Context ctx)
      During the inline phase, call this on a list of references for which the code phase will later emit arguments. It will make sure that any "double-uplevel" values needed by the callee are also present at the call site.

      If any reference is a "ClientOuterField", it is skipped by this method (and by willCodeArguments). This is because

    • codeArguments

      public void codeArguments(Environment env, Context ctx, Assembler asm, long where, MemberDefinition conField)
      Code is being generated for a call to a constructor of the client class. Push an argument for the constructor.
    • codeInitialization

      public void codeInitialization(Environment env, Context ctx, Assembler asm, long where, MemberDefinition conField)
      Code is being generated for a constructor of the client class. Emit code which initializes the instance.
    • toString

      public String toString()
      Overrides:
      toString in class Object