117 @Override
118 public boolean apply(Node n) {
119 return n instanceof ConstantNode;
120 }
121 };
122
123 public static NodePredicate isConstantPredicate() {
124 return IS_CONSTANT;
125 }
126
127 /**
128 * Checks whether this value represents the null constant.
129 *
130 * @return {@code true} if this value represents the null constant
131 */
132 public final boolean isNullConstant() {
133 JavaConstant value = asJavaConstant();
134 return value != null && value.isNull();
135 }
136
137 /**
138 * Convert this value to a constant if it is a constant, otherwise return null.
139 *
140 * @return the {@link JavaConstant} represented by this value if it is a constant; {@code null}
141 * otherwise
142 */
143 public final Constant asConstant() {
144 if (this instanceof ConstantNode) {
145 return ((ConstantNode) this).getValue();
146 } else {
147 return null;
148 }
149 }
150
151 public final boolean isJavaConstant() {
152 return isConstant() && asConstant() instanceof JavaConstant;
153 }
154
155 public final JavaConstant asJavaConstant() {
156 Constant value = asConstant();
|
117 @Override
118 public boolean apply(Node n) {
119 return n instanceof ConstantNode;
120 }
121 };
122
123 public static NodePredicate isConstantPredicate() {
124 return IS_CONSTANT;
125 }
126
127 /**
128 * Checks whether this value represents the null constant.
129 *
130 * @return {@code true} if this value represents the null constant
131 */
132 public final boolean isNullConstant() {
133 JavaConstant value = asJavaConstant();
134 return value != null && value.isNull();
135 }
136
137 public final boolean isDefaultConstant() {
138 Constant value = asConstant();
139 return value != null && value.isDefaultForKind();
140 }
141
142 /**
143 * Convert this value to a constant if it is a constant, otherwise return null.
144 *
145 * @return the {@link JavaConstant} represented by this value if it is a constant; {@code null}
146 * otherwise
147 */
148 public final Constant asConstant() {
149 if (this instanceof ConstantNode) {
150 return ((ConstantNode) this).getValue();
151 } else {
152 return null;
153 }
154 }
155
156 public final boolean isJavaConstant() {
157 return isConstant() && asConstant() instanceof JavaConstant;
158 }
159
160 public final JavaConstant asJavaConstant() {
161 Constant value = asConstant();
|