Class Expression

    • Constructor Detail

      • Expression

        Expression​(int op,
                   long where,
                   Type type)
        Constructor
    • Method Detail

      • getImplementation

        public Expression getImplementation()
        Type checking may assign a more complex implementation to an innocuous-looking expression (like an identifier). Return that implementation, or the original expression itself if there is no special implementation.

        This appears at present to be dead code, and is not called from within javac. Access to the implementation generally occurs within the same class, and thus uses the underlying field directly.

      • getType

        public Type getType()
      • precedence

        int precedence()
        Return the precedence of the operator
      • order

        public Expression order()
        Order the expression based on precedence
      • isConstant

        public boolean isConstant()
        Return true if constant, according to JLS 15.27. A constant expression must inline away to a literal constant.
      • getValue

        public java.lang.Object getValue()
        Return the constant value.
      • equals

        public boolean equals​(int i)
        Check if the expression is known to be equal to a given value. Returns false for any expression other than a literal constant, thus should be called only after simplification (inlining) has been performed.
      • equals

        public boolean equals​(boolean b)
      • equals

        public boolean equals​(Identifier id)
      • equals

        public boolean equals​(java.lang.String s)
      • isNull

        public boolean isNull()
        Check if the expression must be a null reference.
      • isNonNull

        public boolean isNonNull()
        Check if the expression cannot be a null reference.
      • equalsDefault

        public boolean equalsDefault()
        Check if the expression is equal to its default static value
      • fitsType

        public boolean fitsType​(Environment env,
                                Context ctx,
                                Type t)
        See if this expression fits in the given type. This is useful because some larger numbers fit into smaller types.

        If it is an "int" constant expression, inline it, if necessary, to examine its numerical value. See JLS 5.2 and 15.24.

      • fitsType

        @Deprecated
        public boolean fitsType​(Environment env,
                                Type t)
        Deprecated.
        (for backward compatibility)
      • checkValue

        public Vset checkValue​(Environment env,
                               Context ctx,
                               Vset vset,
                               java.util.Hashtable<java.lang.Object,​java.lang.Object> exp)
        Check an expression
      • checkInitializer

        public Vset checkInitializer​(Environment env,
                                     Context ctx,
                                     Vset vset,
                                     Type t,
                                     java.util.Hashtable<java.lang.Object,​java.lang.Object> exp)
      • check

        public Vset check​(Environment env,
                          Context ctx,
                          Vset vset,
                          java.util.Hashtable<java.lang.Object,​java.lang.Object> exp)
      • checkLHS

        public Vset checkLHS​(Environment env,
                             Context ctx,
                             Vset vset,
                             java.util.Hashtable<java.lang.Object,​java.lang.Object> exp)
      • getAssigner

        public FieldUpdater getAssigner​(Environment env,
                                        Context ctx)
        Return a FieldUpdater object to be used in updating the value of the location denoted by this, which must be an expression suitable for the left-hand side of an assignment. This is used for implementing assignments to private fields for which an access method is required. Returns null if no access method is needed, in which case the assignment is handled in the usual way, by direct access. Only simple assignment expressions are handled here Assignment operators and pre/post increment/decrement operators are are handled by 'getUpdater' below.

        Called during the checking phase.

      • getUpdater

        public FieldUpdater getUpdater​(Environment env,
                                       Context ctx)
        Return a FieldUpdater object to be used in updating the value of the location denoted by this, which must be an expression suitable for the left-hand side of an assignment. This is used for implementing the assignment operators and the increment/decrement operators on private fields that require an access method, e.g., uplevel from an inner class. Returns null if no access method is needed.

        Called during the checking phase.

      • checkAmbigName

        public Vset checkAmbigName​(Environment env,
                                   Context ctx,
                                   Vset vset,
                                   java.util.Hashtable<java.lang.Object,​java.lang.Object> exp,
                                   UnaryExpression loc)
        Check something that might be an AmbiguousName (refman 6.5.2). A string of dot-separated identifiers might be, in order of preference:
      • a variable name followed by fields or types
      • a type name followed by fields or types
      • a package name followed a type and then fields or types If a type name is found, it rewrites itself as a TypeExpression. If a node decides it can only be a package prefix, it sets its type to Type.tPackage. The caller must detect this and act appropriately to verify the full package name.