public class

Expression

extends Node
java.lang.Object
   ↳ sun.tools.tree.Node
     ↳ sun.tools.tree.Expression
Known Direct Subclasses
Known Indirect 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 Methods
Vset check(Environment env, Context ctx, Vset vset, Hashtable exp)
Vset checkAmbigName(Environment env, Context ctx, Vset vset, Hashtable exp, UnaryExpression loc)
Check something that might be an AmbiguousName (refman 6.5.2).
Vset checkAssignOp(Environment env, Context ctx, Vset vset, Hashtable exp, Expression outside)
ConditionVars checkCondition(Environment env, Context ctx, Vset vset, Hashtable exp)
Check a condition.
void checkCondition(Environment env, Context ctx, Vset vset, Hashtable exp, ConditionVars cvars)
Vset checkInitializer(Environment env, Context ctx, Vset vset, Type t, Hashtable exp)
Vset checkLHS(Environment env, Context ctx, Vset vset, Hashtable exp)
Vset checkValue(Environment env, Context ctx, Vset vset, Hashtable exp)
Check an expression
void code(Environment env, Context ctx, Assembler asm)
void codeValue(Environment env, Context ctx, Assembler asm)
Expression copyInline(Context ctx)
Create a copy of the expression for method inlining
int costInline(int thresh, Environment env, Context ctx)
The cost of inlining this expression.
boolean equals(String s)
boolean equals(boolean b)
boolean equals(Identifier id)
boolean equals(int i)
Check if the expression is known to be equal to a given value.
boolean equalsDefault()
Check if the expression is equal to its default static value
Expression firstConstructor()
Check if the first thing is a constructor invocation
boolean fitsType(Environment env, Context ctx, Type t)
See if this expression fits in the given type.
boolean fitsType(Environment env, Type t)
This method is deprecated. (for backward compatibility)
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.
Expression getImplementation()
Type checking may assign a more complex implementation to an innocuous-looking expression (like an identifier).
Type getType()
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.
Object getValue()
Return the constant value.
Expression inline(Environment env, Context ctx)
Inline.
Expression inlineLHS(Environment env, Context ctx)
Expression inlineValue(Environment env, Context ctx)
boolean isConstant()
Return true if constant, according to JLS 15.27.
boolean isNonNull()
Check if the expression cannot be a null reference.
boolean isNull()
Check if the expression must be a null reference.
Expression order()
Order the expression based on precedence
void print(PrintStream out)
Print
Protected Methods
StringBuffer inlineValueSB(Environment env, Context ctx, StringBuffer buffer)
Attempt to evaluate this expression.
[Expand]
Inherited Methods
From class sun.tools.tree.Node
From class java.lang.Object

Public Methods

public Vset check (Environment env, Context ctx, Vset vset, Hashtable exp)

public Vset checkAmbigName (Environment env, Context ctx, Vset vset, Hashtable 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.

  • public Vset checkAssignOp (Environment env, Context ctx, Vset vset, Hashtable exp, Expression outside)

    public ConditionVars checkCondition (Environment env, Context ctx, Vset vset, Hashtable exp)

    Check a condition. Return a ConditionVars(), which indicates when which variables are set if the condition is true, and which are set if the condition is false.

    public void checkCondition (Environment env, Context ctx, Vset vset, Hashtable exp, ConditionVars cvars)

    public Vset checkInitializer (Environment env, Context ctx, Vset vset, Type t, Hashtable exp)

    public Vset checkLHS (Environment env, Context ctx, Vset vset, Hashtable exp)

    public Vset checkValue (Environment env, Context ctx, Vset vset, Hashtable exp)

    Check an expression

    public void code (Environment env, Context ctx, Assembler asm)

    public void codeValue (Environment env, Context ctx, Assembler asm)

    public Expression copyInline (Context ctx)

    Create a copy of the expression for method inlining

    public int costInline (int thresh, Environment env, Context ctx)

    The cost of inlining this expression. This cost controls the inlining of methods, and does not determine the compile-time simplifications performed by 'inline' and friends.

    public boolean equals (String s)

    public boolean equals (boolean b)

    public boolean equals (Identifier id)

    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.

    public boolean equalsDefault ()

    Check if the expression is equal to its default static value

    public Expression firstConstructor ()

    Check if the first thing is a constructor invocation

    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.

    public boolean fitsType (Environment env, Type t)

    This method is deprecated.
    (for backward compatibility)

    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.

    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.

    public Type getType ()

    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.

    public Object getValue ()

    Return the constant value.

    public Expression inline (Environment env, Context ctx)

    Inline. Recursively simplify each child of an expression node, destructively replacing the child with the simplified result. Also attempts to simplify the current node 'this', and returns the simplified result. The name 'inline' is somthing of a misnomer, as these methods are responsible for compile-time expression simplification in general. The 'eval' and 'simplify' methods apply to a single expression node only -- it is 'inline' and 'inlineValue' that drive the simplification of entire expressions.

    public Expression inlineLHS (Environment env, Context ctx)

    public Expression inlineValue (Environment env, Context ctx)

    public boolean isConstant ()

    Return true if constant, according to JLS 15.27. A constant expression must inline away to a literal constant.

    public boolean isNonNull ()

    Check if the expression cannot be a null reference.

    public boolean isNull ()

    Check if the expression must be a null reference.

    public Expression order ()

    Order the expression based on precedence

    public void print (PrintStream out)

    Print

    Protected Methods

    protected StringBuffer inlineValueSB (Environment env, Context ctx, StringBuffer buffer)

    Attempt to evaluate this expression. If this expression yields a value, append it to the StringBuffer `buffer'. If this expression cannot be evaluated at this time (for example if it contains a division by zero, a non-constant subexpression, or a subexpression which "refuses" to evaluate) then return `null' to indicate failure. It is anticipated that this method will be called to evaluate concatenations of compile-time constant strings. The call originates from AddExpression#inlineValue(). See AddExpression#inlineValueSB() for detailed comments.