/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* 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.
*/
public
/**
* Constructor
*/
}
/**
* 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.
* <p>
* 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.
*/
return this;
}
return type;
}
/**
* Return the precedence of the operator
*/
int precedence() {
}
/**
* Order the expression based on precedence
*/
return this;
}
/**
* Return true if constant, according to JLS 15.27.
* A constant expression must inline away to a literal constant.
*/
public boolean isConstant() {
return false;
}
/**
* Return the constant value.
*/
return null;
}
/**
* 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 equals(int i) {
return false;
}
public boolean equals(boolean b) {
return false;
}
return false;
}
return false;
}
/**
* Check if the expression must be a null reference.
*/
public boolean isNull() {
return false;
}
/**
* Check if the expression cannot be a null reference.
*/
public boolean isNonNull() {
return false;
}
/**
* Check if the expression is equal to its default static value
*/
public boolean equalsDefault() {
return false;
}
/**
* Convert an expresion to a type
*/
}
/**
* Convert an expresion to a type in a context where a qualified
* type name is expected, e.g., in the prefix of a qualified type
* name.
*/
/*-----------------------------------------------------*
Type toQualifiedType(Environment env, Context ctx) {
env.error(where, "invalid.type.expr");
return Type.tError;
}
*-----------------------------------------------------*/
/**
* See if this expression fits in the given type.
* This is useful because some larger numbers fit into
* smaller types.
* <p>
* If it is an "int" constant expression, inline it, if necessary,
* to examine its numerical value. See JLS 5.2 and 15.24.
*/
try {
return true;
}
// Tentative inlining is harmless for constant expressions.
if (n != this && n instanceof ConstantExpression) {
}
}
return false;
} catch (ClassNotFound e) {
return false;
}
}
/** @deprecated (for backward compatibility) */
}
/**
* Check an expression
*/
return vset;
}
}
throw new CompilerError("check failed");
}
return vset;
}
/**
* Return a <code>FieldUpdater</code> object to be used in updating the
* value of the location denoted by <code>this</code>, 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
* are handled by 'getUpdater' below.
* <p>
* Called during the checking phase.
*/
throw new CompilerError("getAssigner lhs");
}
/**
* Return a <code>FieldUpdater</code> object to be used in updating the value of the
* location denoted by <code>this</code>, which must be an expression suitable for the
* left-hand side of an assignment. This is used for implementing the assignment
* access method, e.g., uplevel from an inner class. Returns null if no access method
* is needed.
* <p>
* Called during the checking phase.
*/
throw new CompilerError("getUpdater lhs");
}
if (outside instanceof IncDecExpression)
else
return vset;
}
/**
* Check something that might be an AmbiguousName (refman 6.5.2).
* A string of dot-separated identifiers might be, in order of preference:
* <nl>
* <li> a variable name followed by fields or types
* <li> a type name followed by fields or types
* <li> a package name followed a type and then fields or types
* </nl>
* If a type name is found, it rewrites itself as a <tt>TypeExpression</tt>.
* If a node decides it can only be a package prefix, it sets its
* type to <tt>Type.tPackage</tt>. The caller must detect this
* and act appropriately to verify the full package name.
* @arg loc the expression containing the ambiguous expression
*/
}
/**
* 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.
*/
return cvars;
}
/*
* Check a condition.
*
* cvars is modified so that
* cvar.vsTrue indicates variables with a known value if result = true
* cvars.vsFalse indicates variables with a known value if !result
*
* The default action is to simply call checkValue on the expression, and
* to see both vsTrue and vsFalse to the result.
*/
// unshare side effects:
}
/**
* 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.
*/
return this;
}
/**
* 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.
*/
return this;
}
/**
* 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.
*/
return null;
}
return this;
}
/**
* 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.
*/
// This (supposedly constant) expression refuses to yield
// a value. This can happen, in particular, when we are
// trying to evaluate a division by zero. It can also
// happen in cases where isConstant() is able to classify
// expressions as constant that the compiler's inlining
// mechanisms aren't able to evaluate; this is rare,
// and all such cases that we have found so far
// (e.g. 4082814, 4106244) have been plugged up.
//
// We return a null to indicate that we have failed to
// evaluate the concatenation.
return null;
}
// For boolean and character expressions, getValue() returns
// an Integer. We need to take care, when appending the result
// of getValue(), that we preserve the type.
// Fix for 4103959, 4102672.
} else {
}
return buffer;
}
return null;
}
/**
* 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.
*/
return 1;
}
/**
* Code
*/
} else {
}
}
} else {
throw new CompilerError("codeValue");
}
}
switch (type.getTypeCode()) {
case TC_VOID:
break;
case TC_DOUBLE:
case TC_LONG:
break;
default:
break;
}
}
throw new CompilerError("invalid lhs");
}
throw new CompilerError("invalid load");
}
throw new CompilerError("invalid store");
}
/**
* Convert this expression to a string.
*/
throws ClassNotFound, AmbiguousMember
{
return;
}
// Make sure it's a non-null string.
// FIX FOR 4071548
// We use 'String.valueOf' to do the conversion, in order to
// correctly handle null references and efficiently handle
// primitive types. For reference types, we force the argument
// to be interpreted as of 'Object' type, thus avoiding the
// the special-case overloading of 'valueOf' for character arrays.
// This special treatment would conflict with JLS 15.17.1.1.
// Reference type
// Convert non-string object to string. If object is
// a string, we don't need to convert it, except in the
// case that it is null, which is handled below.
}
// FIX FOR 4030173
// If the argument was null, then value is "null", but if the
// argument was not null, 'toString' was called and could have
// returned null. We call 'valueOf' again to make sure that
// the result is a non-null string. See JLS 15.17.1.1. The
// approach taken here minimizes code size -- open code would
// be faster. The 'toString' method for an array class cannot
// be overridden, thus we know that it will never return null.
}
} else {
// Primitive type
MemberDefinition f =
}
}
/**
* 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
{
if (needBuffer) {
// need to create the string buffer
if (equals("")) {
// make an empty string buffer
} else {
// optimize by initializing the buffer with the string
}
} else {
// append this item to the string buffer
// FIX FOR 4071548
// 'StringBuffer.append' converts its argument as if by
// 'valueOf', treating character arrays specially. This
// violates JLS 15.17.1.1, which requires that concatenation
// convert non-primitive arguments using 'toString'. We force
// the treatment of all reference types as type 'Object', thus
// invoking an overloading of 'append' that has the required
// semantics.
: type };
}
}
/**
* Code
*/
switch (items) {
case 0:
return;
case 1:
switch (depth) {
case 0:
return;
case 1:
return;
case 2:
return;
}
break;
case 2:
switch (depth) {
case 0:
return;
case 1:
return;
case 2:
return;
}
break;
}
}
int from = f.getTypeCode();
int to = t.getTypeCode();
switch (to) {
case TC_BOOLEAN:
if (from != TC_BOOLEAN) {
break;
}
return;
case TC_BYTE:
}
return;
case TC_CHAR:
}
return;
case TC_SHORT:
}
return;
case TC_INT:
switch (from) {
case TC_BYTE:
case TC_CHAR:
case TC_SHORT:
case TC_INT:
return;
case TC_LONG:
return;
case TC_FLOAT:
return;
case TC_DOUBLE:
return;
}
break;
case TC_LONG:
switch (from) {
case TC_BYTE:
case TC_CHAR:
case TC_SHORT:
case TC_INT:
return;
case TC_LONG:
return;
case TC_FLOAT:
return;
case TC_DOUBLE:
return;
}
break;
case TC_FLOAT:
switch (from) {
case TC_BYTE:
case TC_CHAR:
case TC_SHORT:
case TC_INT:
return;
case TC_LONG:
return;
case TC_FLOAT:
return;
case TC_DOUBLE:
return;
}
break;
case TC_DOUBLE:
switch (from) {
case TC_BYTE:
case TC_CHAR:
case TC_SHORT:
case TC_INT:
return;
case TC_LONG:
return;
case TC_FLOAT:
return;
case TC_DOUBLE:
return;
}
break;
case TC_CLASS:
switch (from) {
case TC_NULL:
return;
case TC_CLASS:
case TC_ARRAY:
try {
if (!env.implicitCast(f, t)) {
}
} catch (ClassNotFound e) {
throw new CompilerError(e);
}
return;
}
break;
case TC_ARRAY:
switch (from) {
case TC_NULL:
return;
case TC_CLASS:
case TC_ARRAY:
try {
if (!env.implicitCast(f, t)) {
}
return;
} catch (ClassNotFound e) {
throw new CompilerError(e);
}
}
break;
}
}
/**
* Check if the first thing is a constructor invocation
*/
return null;
}
/**
* Create a copy of the expression for method inlining
*/
return (Expression)clone();
}
/**
* Print
*/
}
}