1 /*******************************************************************************
2 * Copyright (c) 2000, 2005 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
12 package net.sourceforge.phpdt.core.dom;
15 * Abstract base class of AST nodes that represent expressions.
16 * There are several kinds of expressions.
21 * IntegerLiteral (includes decimal, hex, and octal forms; and long)
22 * FloatingPointLiteral (includes both float and double)
32 * ParenthesizedExpression
33 * ClassInstanceCreation
37 * SuperMethodInvocation
40 * InstanceofExpression
41 * ConditionalExpression
45 * VariableDeclarationExpression
51 public abstract class Expression extends ASTNode {
54 * Creates a new AST node for an expression owned by the given AST.
56 * N.B. This constructor is package-private.
59 * @param ast the AST that is to own this node
66 * Resolves and returns the compile-time constant expression value as
67 * specified in JLS2 15.28, if this expression has one. Constant expression
68 * values are unavailable unless bindings are requested when the AST is
69 * being built. If the type of the value is a primitive type, the result
70 * is the boxed equivalent (i.e., int returned as an <code>Integer</code>);
71 * if the type of the value is <code>String</code>, the result is the string
72 * itself. If the expression does not have a compile-time constant expression
73 * value, the result is <code>null</code>.
75 * Resolving constant expressions takes into account the value of simple
76 * and qualified names that refer to constant variables (JLS2 4.12.4).
79 * Note 1: enum constants are not considered constant expressions.
80 * The result is always <code>null</code> for these.
83 * Note 2: Compile-time constant expressions cannot denote <code>null</code>.
84 * So technically {@link NullLiteral} nodes are not constant expressions.
85 * The result is <code>null</code> for these nonetheless.
88 * @return the constant expression value, or <code>null</code> if this
89 * expression has no constant expression value or if bindings were not
90 * requested when the AST was created
93 public final Object resolveConstantExpressionValue() {
94 return this.ast.getBindingResolver().resolveConstantExpressionValue(this);
98 * Resolves and returns the binding for the type of this expression.
100 * Note that bindings are generally unavailable unless requested when the
101 * AST is being built.
104 * @return the binding for the type of this expression, or
105 * <code>null</code> if the type cannot be resolved
107 public final ITypeBinding resolveTypeBinding() {
108 return this.ast.getBindingResolver().resolveExpressionType(this);
112 * Returns whether this expression node is the site of a boxing
113 * conversion (JLS3 5.1.7). This information is available only
114 * when bindings are requested when the AST is being built.
116 * @return <code>true</code> if this expression is the site of a
117 * boxing conversion, or <code>false</code> if either no boxing conversion
118 * is involved or if bindings were not requested when the AST was created
121 public final boolean resolveBoxing() {
122 return this.ast.getBindingResolver().resolveBoxing(this);
126 * Returns whether this expression node is the site of an unboxing
127 * conversion (JLS3 5.1.8). This information is available only
128 * when bindings are requested when the AST is being built.
130 * @return <code>true</code> if this expression is the site of an
131 * unboxing conversion, or <code>false</code> if either no unboxing
132 * conversion is involved or if bindings were not requested when the
136 public final boolean resolveUnboxing() {
137 return this.ast.getBindingResolver().resolveUnboxing(this);