Package org.glassfish.rmic.tools.tree
Class Expression
- java.lang.Object
-
- org.glassfish.rmic.tools.tree.Node
-
- org.glassfish.rmic.tools.tree.Expression
-
- All Implemented Interfaces:
java.lang.Cloneable
,Constants
,RuntimeConstants
- Direct Known Subclasses:
ConstantExpression
,IdentifierExpression
,InlineMethodExpression
,InlineNewInstanceExpression
,ThisExpression
,TypeExpression
,UnaryExpression
public class Expression extends Node
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 Summary
Fields Modifier and Type Field Description (package private) Type
type
-
Fields inherited from interface org.glassfish.rmic.tools.java.Constants
ABSTRACT, ACCM_CLASS, ACCM_FIELD, ACCM_INNERCLASS, ACCM_MEMBER, ACCM_METHOD, ADD, AND, ARRAY, ARRAYACCESS, ASGADD, ASGBITAND, ASGBITOR, ASGBITXOR, ASGDIV, ASGLSHIFT, ASGMUL, ASGREM, ASGRSHIFT, ASGSUB, ASGURSHIFT, ASSIGN, ATT_ALL, ATT_ALLCLASSES, ATT_CODE, BITAND, BITNOT, BITOR, BITXOR, BOOLEAN, BOOLEANVAL, BREAK, BYTE, BYTEVAL, CASE, CAST, CATCH, CHAR, CHARVAL, CLASS, COLON, COMMA, COMMENT, COND, CONST, CONTINUE, CONVERT, CS_BINARY, CS_CHECKED, CS_COMPILED, CS_NOTFOUND, CS_PARSED, CS_SOURCE, CS_UNDECIDED, CS_UNDEFINED, CT_BLOCK, CT_BRANCH_FALSE, CT_BRANCH_TRUE, CT_CASE, CT_FIKT_METHOD, CT_FIKT_RET, CT_FIRST_KIND, CT_LAST_KIND, CT_METHOD, CT_SWITH_WO_DEF, DEC, DECLARATION, DEFAULT, DIV, DO, DOUBLE, DOUBLEVAL, ELSE, EQ, ERROR, EXPR, EXPRESSION, EXTENDS, F_COVDATA, F_COVERAGE, F_DEBUG_LINES, F_DEBUG_SOURCE, F_DEBUG_VARS, F_DEPENDENCIES, F_DEPRECATION, F_DUMP, F_ERRORSREPORTED, F_OPT, F_OPT_INTERCLASS, F_PRINT_DEPENDENCIES, F_STRICTDEFAULT, F_VERBOSE, F_VERSION12, F_WARNINGS, FALSE, FIELD, FINAL, FINALLY, FLOAT, FLOATVAL, FOR, GE, GOTO, GT, idAppend, idClass, idClassInit, idClone, idCode, idConstantValue, idCoverageTable, idDeprecated, idDocumentation, IDENT, idExceptions, idFinallyReturnValue, idGetClass, idInit, idInnerClasses, idJavaIoSerializable, idJavaLang, idJavaLangClass, idJavaLangCloneable, idJavaLangError, idJavaLangException, idJavaLangObject, idJavaLangRuntimeException, idJavaLangString, idJavaLangStringBuffer, idJavaLangThrowable, idLength, idLineNumberTable, idLocalVariableTable, idNew, idNull, idSourceFile, idStar, idSuper, idSynthetic, idThis, idToString, idTYPE, idValueOf, IF, IMPLEMENTS, IMPORT, INC, INLINEMETHOD, INLINENEWINSTANCE, INLINERETURN, INSTANCEOF, INT, INTERFACE, INTVAL, LBRACE, LE, LENGTH, LONG, LONGVAL, LPAREN, LSHIFT, LSQBRACKET, LT, M_ABSTRACT, M_ANONYMOUS, M_DEPRECATED, M_FINAL, M_INLINEABLE, M_INTERFACE, M_LOCAL, M_NATIVE, M_PRIVATE, M_PROTECTED, M_PUBLIC, M_STATIC, M_STRICTFP, M_SYNCHRONIZED, M_SYNTHETIC, M_TRANSIENT, M_VOLATILE, MAXFILESIZE, MAXLINENUMBER, METHOD, MM_CLASS, MM_FIELD, MM_MEMBER, MM_METHOD, MUL, NATIVE, NE, NEG, NEW, NEWARRAY, NEWFROMNAME, NEWINSTANCE, NOT, NULL, opNames, opPrecedence, OR, PACKAGE, paraDeprecated, POS, POSTDEC, POSTINC, PREDEC, prefixAccess, prefixArray, prefixClass, prefixLoc, prefixThis, prefixVal, PREINC, PRIVATE, PROTECTED, PUBLIC, QUESTIONMARK, RBRACE, REM, RETURN, RPAREN, RSHIFT, RSQBRACKET, SEMICOLON, SHORT, SHORTVAL, SIG_INNERCLASS, SIGC_INNERCLASS, STAT, STATIC, STRICTFP, STRINGVAL, SUB, SUPER, SWITCH, SYNCHRONIZED, TC_ARRAY, TC_BOOLEAN, TC_BYTE, TC_CHAR, TC_CLASS, TC_DOUBLE, TC_ERROR, TC_FLOAT, TC_INT, TC_LONG, TC_METHOD, TC_NULL, TC_SHORT, TC_VOID, THIS, THROW, THROWS, TM_ARRAY, TM_BOOLEAN, TM_BYTE, TM_CHAR, TM_CLASS, TM_DOUBLE, TM_ERROR, TM_FLOAT, TM_INT, TM_INT32, TM_INTEGER, TM_LONG, TM_METHOD, TM_NULL, TM_NUM32, TM_NUM64, TM_NUMBER, TM_REAL, TM_REFERENCE, TM_SHORT, TM_VOID, tracing, TRANSIENT, TRUE, TRY, TYPE, URSHIFT, VARDECLARATION, VOID, VOLATILE, WHEREOFFSETBITS, WHILE
-
Fields inherited from interface org.glassfish.rmic.tools.java.RuntimeConstants
ACC_ABSTRACT, ACC_FINAL, ACC_INTERFACE, ACC_NATIVE, ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC, ACC_STATIC, ACC_STRICT, ACC_SUPER, ACC_SYNCHRONIZED, ACC_TRANSIENT, ACC_VOLATILE, CONSTANT_CLASS, CONSTANT_DOUBLE, CONSTANT_FIELD, CONSTANT_FLOAT, CONSTANT_INTEGER, CONSTANT_INTERFACEMETHOD, CONSTANT_INVOKEDYNAMIC, CONSTANT_LONG, CONSTANT_METHOD, CONSTANT_METHODHANDLE, CONSTANT_METHODTYPE, CONSTANT_NAMEANDTYPE, CONSTANT_STRING, CONSTANT_UNICODE, CONSTANT_UTF8, JAVA_DEFAULT_MINOR_VERSION, JAVA_DEFAULT_VERSION, JAVA_MAGIC, JAVA_MAX_SUPPORTED_MINOR_VERSION, JAVA_MAX_SUPPORTED_VERSION, JAVA_MIN_SUPPORTED_VERSION, opc_aaload, opc_aastore, opc_aconst_null, opc_aload, opc_aload_0, opc_aload_1, opc_aload_2, opc_aload_3, opc_anewarray, opc_areturn, opc_arraylength, opc_astore, opc_astore_0, opc_astore_1, opc_astore_2, opc_astore_3, opc_athrow, opc_baload, opc_bastore, opc_bipush, opc_breakpoint, opc_caload, opc_castore, opc_checkcast, opc_d2f, opc_d2i, opc_d2l, opc_dadd, opc_daload, opc_dastore, opc_dcmpg, opc_dcmpl, opc_dconst_0, opc_dconst_1, opc_ddiv, opc_dead, opc_dload, opc_dload_0, opc_dload_1, opc_dload_2, opc_dload_3, opc_dmul, opc_dneg, opc_drem, opc_dreturn, opc_dstore, opc_dstore_0, opc_dstore_1, opc_dstore_2, opc_dstore_3, opc_dsub, opc_dup, opc_dup_x1, opc_dup_x2, opc_dup2, opc_dup2_x1, opc_dup2_x2, opc_f2d, opc_f2i, opc_f2l, opc_fadd, opc_faload, opc_fastore, opc_fcmpg, opc_fcmpl, opc_fconst_0, opc_fconst_1, opc_fconst_2, opc_fdiv, opc_fload, opc_fload_0, opc_fload_1, opc_fload_2, opc_fload_3, opc_fmul, opc_fneg, opc_frem, opc_freturn, opc_fstore, opc_fstore_0, opc_fstore_1, opc_fstore_2, opc_fstore_3, opc_fsub, opc_getfield, opc_getstatic, opc_goto, opc_goto_w, opc_i2b, opc_i2c, opc_i2d, opc_i2f, opc_i2l, opc_i2s, opc_iadd, opc_iaload, opc_iand, opc_iastore, opc_iconst_0, opc_iconst_1, opc_iconst_2, opc_iconst_3, opc_iconst_4, opc_iconst_5, opc_iconst_m1, opc_idiv, opc_if_acmpeq, opc_if_acmpne, opc_if_icmpeq, opc_if_icmpge, opc_if_icmpgt, opc_if_icmple, opc_if_icmplt, opc_if_icmpne, opc_ifeq, opc_ifge, opc_ifgt, opc_ifle, opc_iflt, opc_ifne, opc_ifnonnull, opc_ifnull, opc_iinc, opc_iload, opc_iload_0, opc_iload_1, opc_iload_2, opc_iload_3, opc_imul, opc_ineg, opc_instanceof, opc_invokedynamic, opc_invokeinterface, opc_invokespecial, opc_invokestatic, opc_invokevirtual, opc_ior, opc_irem, opc_ireturn, opc_ishl, opc_ishr, opc_istore, opc_istore_0, opc_istore_1, opc_istore_2, opc_istore_3, opc_isub, opc_iushr, opc_ixor, opc_jsr, opc_jsr_w, opc_l2d, opc_l2f, opc_l2i, opc_label, opc_ladd, opc_laload, opc_land, opc_lastore, opc_lcmp, opc_lconst_0, opc_lconst_1, opc_ldc, opc_ldc_w, opc_ldc2_w, opc_ldiv, opc_lload, opc_lload_0, opc_lload_1, opc_lload_2, opc_lload_3, opc_lmul, opc_lneg, opc_lookupswitch, opc_lor, opc_lrem, opc_lreturn, opc_lshl, opc_lshr, opc_lstore, opc_lstore_0, opc_lstore_1, opc_lstore_2, opc_lstore_3, opc_lsub, opc_lushr, opc_lxor, opc_monitorenter, opc_monitorexit, opc_multianewarray, opc_new, opc_newarray, opc_nop, opc_pop, opc_pop2, opc_putfield, opc_putstatic, opc_ret, opc_return, opc_saload, opc_sastore, opc_sipush, opc_swap, opc_tableswitch, opc_try, opc_wide, opcLengths, opcNames, SIG_ARRAY, SIG_BOOLEAN, SIG_BYTE, SIG_CHAR, SIG_CLASS, SIG_DOUBLE, SIG_ENDCLASS, SIG_ENDMETHOD, SIG_FLOAT, SIG_INT, SIG_LONG, SIG_METHOD, SIG_PACKAGE, SIG_SHORT, SIG_VOID, SIGC_ARRAY, SIGC_BOOLEAN, SIGC_BYTE, SIGC_CHAR, SIGC_CLASS, SIGC_DOUBLE, SIGC_ENDCLASS, SIGC_ENDMETHOD, SIGC_FLOAT, SIGC_INT, SIGC_LONG, SIGC_METHOD, SIGC_PACKAGE, SIGC_SHORT, SIGC_VOID, T_BOOLEAN, T_BYTE, T_CHAR, T_CLASS, T_DOUBLE, T_FLOAT, T_INT, T_LONG, T_SHORT
-
-
Constructor Summary
Constructors Constructor Description Expression(int op, long where, Type type)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Vset
check(Environment env, Context ctx, Vset vset, java.util.Hashtable<java.lang.Object,java.lang.Object> exp)
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).Vset
checkAssignOp(Environment env, Context ctx, Vset vset, java.util.Hashtable<java.lang.Object,java.lang.Object> exp, Expression outside)
ConditionVars
checkCondition(Environment env, Context ctx, Vset vset, java.util.Hashtable<java.lang.Object,java.lang.Object> exp)
Check a condition.void
checkCondition(Environment env, Context ctx, Vset vset, java.util.Hashtable<java.lang.Object,java.lang.Object> exp, ConditionVars cvars)
Vset
checkInitializer(Environment env, Context ctx, Vset vset, Type t, java.util.Hashtable<java.lang.Object,java.lang.Object> exp)
Vset
checkLHS(Environment env, Context ctx, Vset vset, java.util.Hashtable<java.lang.Object,java.lang.Object> exp)
Vset
checkValue(Environment env, Context ctx, Vset vset, java.util.Hashtable<java.lang.Object,java.lang.Object> exp)
Check an expressionvoid
code(Environment env, Context ctx, Assembler asm)
(package private) void
codeAppend(Environment env, Context ctx, Assembler asm, ClassDeclaration sbClass, boolean needBuffer)
Convert this expression to a string and append it to the string buffer on the top of the stack.(package private) void
codeBranch(Environment env, Context ctx, Assembler asm, Label lbl, boolean whenTrue)
Code(package private) void
codeConversion(Environment env, Context ctx, Assembler asm, Type f, Type t)
(package private) void
codeDup(Environment env, Context ctx, Assembler asm, int items, int depth)
Code(package private) void
codeLoad(Environment env, Context ctx, Assembler asm)
(package private) int
codeLValue(Environment env, Context ctx, Assembler asm)
(package private) void
codeStore(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 inliningint
costInline(int thresh, Environment env, Context ctx)
The cost of inlining this expression.(package private) void
ensureString(Environment env, Context ctx, Assembler asm)
Convert this expression to a string.boolean
equals(boolean b)
boolean
equals(int i)
Check if the expression is known to be equal to a given value.boolean
equals(java.lang.String s)
boolean
equals(Identifier id)
boolean
equalsDefault()
Check if the expression is equal to its default static value(package private) Expression
eval()
Evaluate.Expression
firstConstructor()
Check if the first thing is a constructor invocationboolean
fitsType(Environment env, Type t)
Deprecated.(for backward compatibility)boolean
fitsType(Environment env, Context ctx, Type t)
See if this expression fits in the given type.FieldUpdater
getAssigner(Environment env, Context ctx)
Return aFieldUpdater
object to be used in updating the value of the location denoted bythis
, 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 aFieldUpdater
object to be used in updating the value of the location denoted bythis
, which must be an expression suitable for the left-hand side of an assignment.java.lang.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)
protected java.lang.StringBuffer
inlineValueSB(Environment env, Context ctx, java.lang.StringBuffer buffer)
Attempt to evaluate this expression.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(package private) int
precedence()
Return the precedence of the operatorvoid
print(java.io.PrintStream out)
Print(package private) Expression
simplify()
Simplify.(package private) Type
toType(Environment env, Context ctx)
Convert an expresion to a type
-
-
-
Field Detail
-
type
Type type
-
-
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
-
toType
Type toType(Environment env, Context ctx)
Convert an expresion to a type
-
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 aFieldUpdater
object to be used in updating the value of the location denoted bythis
, 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 aFieldUpdater
object to be used in updating the value of the location denoted bythis
, 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.
-
checkAssignOp
public Vset checkAssignOp(Environment env, Context ctx, Vset vset, java.util.Hashtable<java.lang.Object,java.lang.Object> exp, Expression outside)
-
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
TypeExpression
. If a node decides it can only be a package prefix, it sets its type toType.tPackage
. The caller must detect this and act appropriately to verify the full package name.
-
checkCondition
public ConditionVars checkCondition(Environment env, Context ctx, Vset vset, java.util.Hashtable<java.lang.Object,java.lang.Object> 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.
-
checkCondition
public void checkCondition(Environment env, Context ctx, Vset vset, java.util.Hashtable<java.lang.Object,java.lang.Object> exp, ConditionVars cvars)
-
eval
Expression eval()
Evaluate. Attempt to compute the value of an expression node. If all operands are literal constants of the same kind (e.g., IntegerExpression nodes), a new constant node of the proper type is returned representing the value as computed at compile-time. Otherwise, the original node 'this' is returned.
-
simplify
Expression simplify()
Simplify. Attempt to simplify an expression node by returning a semantically- equivalent expression that is presumably less costly to execute. There is some overlap with the intent of 'eval', as compile-time evaluation of conditional expressions and the short-circuit boolean operators is performed here. Other simplifications include logical identities involving logical negation and comparisons. If no simplification is possible, the original node 'this' is returned. It is assumed that the children of the node have previously been recursively simplified and evaluated. A result of 'null' indicates that the expression may be elided entirely.
-
inline
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.
-
inlineValue
public Expression inlineValue(Environment env, Context ctx)
-
inlineValueSB
protected java.lang.StringBuffer inlineValueSB(Environment env, Context ctx, java.lang.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.
-
inlineLHS
public Expression inlineLHS(Environment env, Context ctx)
-
costInline
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.
-
codeBranch
void codeBranch(Environment env, Context ctx, Assembler asm, Label lbl, boolean whenTrue)
Code
-
codeValue
public void codeValue(Environment env, Context ctx, Assembler asm)
-
code
public void code(Environment env, Context ctx, Assembler asm)
-
codeLValue
int codeLValue(Environment env, Context ctx, Assembler asm)
-
codeLoad
void codeLoad(Environment env, Context ctx, Assembler asm)
-
codeStore
void codeStore(Environment env, Context ctx, Assembler asm)
-
ensureString
void ensureString(Environment env, Context ctx, Assembler asm) throws ClassNotFound, AmbiguousMember
Convert this expression to a string.- Throws:
ClassNotFound
AmbiguousMember
-
codeAppend
void codeAppend(Environment env, Context ctx, Assembler asm, ClassDeclaration sbClass, boolean needBuffer) throws ClassNotFound, AmbiguousMember
Convert this expression to a string and append it to the string buffer on the top of the stack. If the needBuffer argument is true, the string buffer needs to be created, initialized, and pushed on the stack, first.- Throws:
ClassNotFound
AmbiguousMember
-
codeDup
void codeDup(Environment env, Context ctx, Assembler asm, int items, int depth)
Code
-
codeConversion
void codeConversion(Environment env, Context ctx, Assembler asm, Type f, Type t)
-
firstConstructor
public Expression firstConstructor()
Check if the first thing is a constructor invocation
-
copyInline
public Expression copyInline(Context ctx)
Create a copy of the expression for method inlining
-
-