1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler.impl;
13 import net.sourceforge.phpdt.internal.compiler.ast.OperatorIds;
14 import net.sourceforge.phpdt.internal.compiler.lookup.TypeIds;
15 import net.sourceforge.phpdt.internal.compiler.problem.ShouldNotImplement;
16 import net.sourceforge.phpdt.internal.compiler.util.Util;
18 public abstract class Constant implements TypeIds, OperatorIds {
20 public static final Constant NotAConstant = new DoubleConstant(Double.NaN);
22 public static final IntConstant Zero = new IntConstant(0);
24 public static final IntConstant Two = new IntConstant(2);
26 public static final IntConstant One = new IntConstant(1);
28 public boolean booleanValue() {
30 throw new ShouldNotImplement(Util.bind(
31 "constant.cannotCastedInto", typeName(), "boolean")); //$NON-NLS-1$ //$NON-NLS-2$
34 public byte byteValue() {
36 throw new ShouldNotImplement(Util.bind(
37 "constant.cannotCastedInto", typeName(), "byte")); //$NON-NLS-1$ //$NON-NLS-2$
40 public final Constant castTo(int conversionToTargetType) {
41 // the cast is an int of the form
42 // (castId<<4)+typeId (in order to follow the
43 // user written style (cast)expression ....
45 if (this == NotAConstant)
47 switch (conversionToTargetType) {
50 // TARGET TYPE <- FROM TYPE
51 // case (T_undefined<<4)+T_undefined : return NotAConstant;
52 // case (T_undefined<<4)+T_byte : return NotAConstant;
53 // case (T_undefined<<4)+T_long : return NotAConstant;
54 // case (T_undefined<<4)+T_short : return NotAConstant;
55 // case (T_undefined<<4)+T_void : return NotAConstant;
56 // case (T_undefined<<4)+T_String : return NotAConstant;
57 // case (T_undefined<<4)+T_Object : return NotAConstant;
58 // case (T_undefined<<4)+T_double : return NotAConstant;
59 // case (T_undefined<<4)+T_float : return NotAConstant;
60 // case (T_undefined<<4)+T_boolean : return NotAConstant;
61 // case (T_undefined<<4)+T_char : return NotAConstant;
62 // case (T_undefined<<4)+T_int : return NotAConstant;
64 // case (T_byte<<4)+T_undefined : return NotAConstant;
65 case (T_byte << 4) + T_byte:
67 case (T_byte << 4) + T_long:
68 return Constant.fromValue((byte) this.longValue());
69 case (T_byte << 4) + T_short:
70 return Constant.fromValue((byte) this.shortValue());
71 // case (T_byte<<4)+T_void : return NotAConstant;
72 // case (T_byte<<4)+T_String : return NotAConstant;
73 // case (T_byte<<4)+T_Object : return NotAConstant;
74 case (T_byte << 4) + T_double:
75 return Constant.fromValue((byte) this.doubleValue());
76 case (T_byte << 4) + T_float:
77 return Constant.fromValue((byte) this.floatValue());
78 // case (T_byte<<4)+T_boolean : return NotAConstant;
79 case (T_byte << 4) + T_char:
80 return Constant.fromValue((byte) this.charValue());
81 case (T_byte << 4) + T_int:
82 return Constant.fromValue((byte) this.intValue());
84 // case (T_long<<4)+T_undefined : return NotAConstant;
85 case (T_long << 4) + T_byte:
86 return Constant.fromValue((long) this.byteValue());
87 case (T_long << 4) + T_long:
89 case (T_long << 4) + T_short:
90 return Constant.fromValue((long) this.shortValue());
91 // case (T_long<<4)+T_void : return NotAConstant;
92 // case (T_long<<4)+T_String : return NotAConstant;
93 // case (T_long<<4)+T_Object : return NotAConstant;
94 case (T_long << 4) + T_double:
95 return Constant.fromValue((long) this.doubleValue());
96 case (T_long << 4) + T_float:
97 return Constant.fromValue((long) this.floatValue());
98 // case (T_long<<4)+T_boolean : return NotAConstant;
99 case (T_long << 4) + T_char:
100 return Constant.fromValue((long) this.charValue());
101 case (T_long << 4) + T_int:
102 return Constant.fromValue((long) this.intValue());
104 // case (T_short<<4)+T_undefined : return NotAConstant;
105 case (T_short << 4) + T_byte:
106 return Constant.fromValue((short) this.byteValue());
107 case (T_short << 4) + T_long:
108 return Constant.fromValue((short) this.longValue());
109 case (T_short << 4) + T_short:
111 // case (T_short<<4)+T_void : return NotAConstant;
112 // case (T_short<<4)+T_String : return NotAConstant;
113 // case (T_short<<4)+T_Object : return NotAConstant;
114 case (T_short << 4) + T_double:
115 return Constant.fromValue((short) this.doubleValue());
116 case (T_short << 4) + T_float:
117 return Constant.fromValue((short) this.floatValue());
118 // case (T_short<<4)+T_boolean : return NotAConstant;
119 case (T_short << 4) + T_char:
120 return Constant.fromValue((short) this.charValue());
121 case (T_short << 4) + T_int:
122 return Constant.fromValue((short) this.intValue());
124 // case (T_void<<4)+T_undefined : return NotAConstant;
125 // case (T_void<<4)+T_byte : return NotAConstant;
126 // case (T_void<<4)+T_long : return NotAConstant;
127 // case (T_void<<4)+T_short : return NotAConstant;
128 // case (T_void<<4)+T_void : return NotAConstant;
129 // case (T_void<<4)+T_String : return NotAConstant;
130 // case (T_void<<4)+T_Object : return NotAConstant;
131 // case (T_void<<4)+T_double : return NotAConstant;
132 // case (T_void<<4)+T_float : return NotAConstant;
133 // case (T_void<<4)+T_boolean : return NotAConstant;
134 // case (T_void<<4)+T_char : return NotAConstant;
135 // case (T_void<<4)+T_int : return NotAConstant;
137 // case (T_String<<4)+T_undefined : return NotAConstant;
138 // case (T_String<<4)+T_byte : return NotAConstant;
139 // case (T_String<<4)+T_long : return NotAConstant;
140 // case (T_String<<4)+T_short : return NotAConstant;
141 // case (T_String<<4)+T_void : return NotAConstant;
142 case (T_String << 4) + T_String:
144 // case (T_String<<4)+T_Object : return NotAConstant;
145 // case (T_String<<4)+T_double : return NotAConstant;
146 // case (T_String<<4)+T_float : return NotAConstant;
147 // case (T_String<<4)+T_boolean : return NotAConstant;
148 // case (T_String<<4)+T_char : return NotAConstant;
149 // case (T_String<<4)+T_int : return NotAConstant;
151 // case (T_Object<<4)+T_undefined : return NotAConstant;
152 // case (T_Object<<4)+T_byte : return NotAConstant;
153 // case (T_Object<<4)+T_long : return NotAConstant;
154 // case (T_Object<<4)+T_short : return NotAConstant;
155 // case (T_Object<<4)+T_void : return NotAConstant;
156 // case (T_Object<<4)+T_String : return NotAConstant;
157 // case (T_Object<<4)+T_Object : return NotAConstant;
158 // case (T_Object<<4)+T_double : return NotAConstant;
159 // case (T_Object<<4)+T_float : return NotAConstant;
160 // case (T_Object<<4)+T_boolean : return NotAConstant;
161 // case (T_Object<<4)+T_char : return NotAConstant;
162 // case (T_Object<<4)+T_int : return NotAConstant;
164 // case (T_double<<4)+T_undefined : return NotAConstant;
165 case (T_double << 4) + T_byte:
166 return Constant.fromValue((double) this.byteValue());
167 case (T_double << 4) + T_long:
168 return Constant.fromValue((double) this.longValue());
169 case (T_double << 4) + T_short:
170 return Constant.fromValue((double) this.shortValue());
171 // case (T_double<<4)+T_void : return NotAConstant;
172 // case (T_double<<4)+T_String : return NotAConstant;
173 // case (T_double<<4)+T_Object : return NotAConstant;
174 case (T_double << 4) + T_double:
176 case (T_double << 4) + T_float:
177 return Constant.fromValue((double) this.floatValue());
178 // case (T_double<<4)+T_boolean : return NotAConstant;
179 case (T_double << 4) + T_char:
180 return Constant.fromValue((double) this.charValue());
181 case (T_double << 4) + T_int:
182 return Constant.fromValue((double) this.intValue());
184 // case (T_float<<4)+T_undefined : return NotAConstant;
185 case (T_float << 4) + T_byte:
186 return Constant.fromValue((float) this.byteValue());
187 case (T_float << 4) + T_long:
188 return Constant.fromValue((float) this.longValue());
189 case (T_float << 4) + T_short:
190 return Constant.fromValue((float) this.shortValue());
191 // case (T_float<<4)+T_void : return NotAConstant;
192 // case (T_float<<4)+T_String : return NotAConstant;
193 // case (T_float<<4)+T_Object : return NotAConstant;
194 case (T_float << 4) + T_double:
195 return Constant.fromValue((float) this.doubleValue());
196 case (T_float << 4) + T_float:
198 // case (T_float<<4)+T_boolean : return NotAConstant;
199 case (T_float << 4) + T_char:
200 return Constant.fromValue((float) this.charValue());
201 case (T_float << 4) + T_int:
202 return Constant.fromValue((float) this.intValue());
204 // case (T_boolean<<4)+T_undefined : return NotAConstant;
205 // case (T_boolean<<4)+T_byte : return NotAConstant;
206 // case (T_boolean<<4)+T_long : return NotAConstant;
207 // case (T_boolean<<4)+T_short : return NotAConstant;
208 // case (T_boolean<<4)+T_void : return NotAConstant;
209 // case (T_boolean<<4)+T_String : return NotAConstant;
210 // case (T_boolean<<4)+T_Object : return NotAConstant;
211 // case (T_boolean<<4)+T_double : return NotAConstant;
212 // case (T_boolean<<4)+T_float : return NotAConstant;
213 case (T_boolean << 4) + T_boolean:
215 // case (T_boolean<<4)+T_char : return NotAConstant;
216 // case (T_boolean<<4)+T_int : return NotAConstant;
218 // case (T_char<<4)+T_undefined : return NotAConstant;
219 case (T_char << 4) + T_byte:
220 return Constant.fromValue((char) this.byteValue());
221 case (T_char << 4) + T_long:
222 return Constant.fromValue((char) this.longValue());
223 case (T_char << 4) + T_short:
224 return Constant.fromValue((char) this.shortValue());
225 // case (T_char<<4)+T_void : return NotAConstant;
226 // case (T_char<<4)+T_String : return NotAConstant;
227 // case (T_char<<4)+T_Object : return NotAConstant;
228 case (T_char << 4) + T_double:
229 return Constant.fromValue((char) this.doubleValue());
230 case (T_char << 4) + T_float:
231 return Constant.fromValue((char) this.floatValue());
232 // case (T_char<<4)+T_boolean : return NotAConstant;
233 case (T_char << 4) + T_char:
235 case (T_char << 4) + T_int:
236 return Constant.fromValue((char) this.intValue());
238 // case (T_int<<4)+T_undefined : return NotAConstant;
239 case (T_int << 4) + T_byte:
240 return Constant.fromValue((int) this.byteValue());
241 case (T_int << 4) + T_long:
242 return Constant.fromValue((int) this.longValue());
243 case (T_int << 4) + T_short:
244 return Constant.fromValue((int) this.shortValue());
245 // case (T_int<<4)+T_void : return NotAConstant;
246 // case (T_int<<4)+T_String : return NotAConstant;
247 // case (T_int<<4)+T_Object : return NotAConstant;
248 case (T_int << 4) + T_double:
249 return Constant.fromValue((int) this.doubleValue());
250 case (T_int << 4) + T_float:
251 return Constant.fromValue((int) this.floatValue());
252 // case (T_int<<4)+T_boolean : return NotAConstant;
253 case (T_int << 4) + T_char:
254 return Constant.fromValue((int) this.charValue());
255 case (T_int << 4) + T_int:
263 public char charValue() {
265 throw new ShouldNotImplement(Util.bind(
266 "constant.cannotCastedInto", typeName(), "char")); //$NON-NLS-1$ //$NON-NLS-2$
269 public static final Constant computeConstantOperation(Constant cst, int id,
274 return Constant.fromValue(!cst.booleanValue());
277 case MINUS: // the two special -9223372036854775808L and -2147483648 are
278 // inlined at parseTime
282 if ((f = cst.floatValue()) == 0.0f) { // positive and negative
284 if (Float.floatToIntBits(f) == 0)
285 return Constant.fromValue(-0.0f);
287 return Constant.fromValue(0.0f);
289 break; // default case
292 if ((d = cst.doubleValue()) == 0.0d) { // positive and negative
294 if (Double.doubleToLongBits(d) == 0)
295 return Constant.fromValue(-0.0d);
297 return Constant.fromValue(0.0d);
299 break; // default case
301 return computeConstantOperationMINUS(Zero, T_int, operator, cst, id);
305 return Constant.fromValue(~cst.charValue());
307 return Constant.fromValue(~cst.byteValue());
309 return Constant.fromValue(~cst.shortValue());
311 return Constant.fromValue(~cst.intValue());
313 return Constant.fromValue(~cst.longValue());
322 public static final Constant computeConstantOperation(Constant left,
323 int leftId, int operator, Constant right, int rightId) {
327 return computeConstantOperationAND(left, leftId, operator, right,
330 return computeConstantOperationAND_AND(left, leftId, operator,
333 return computeConstantOperationDIVIDE(left, leftId, operator,
336 return computeConstantOperationGREATER(left, leftId, operator,
339 return computeConstantOperationGREATER_EQUAL(left, leftId,
340 operator, right, rightId);
342 return computeConstantOperationLEFT_SHIFT(left, leftId, operator,
345 return computeConstantOperationLESS(left, leftId, operator, right,
348 return computeConstantOperationLESS_EQUAL(left, leftId, operator,
351 return computeConstantOperationMINUS(left, leftId, operator, right,
354 return computeConstantOperationMULTIPLY(left, leftId, operator,
357 return computeConstantOperationOR(left, leftId, operator, right,
360 return computeConstantOperationOR_OR(left, leftId, operator, right,
363 return computeConstantOperationPLUS(left, leftId, operator, right,
366 return computeConstantOperationREMAINDER(left, leftId, operator,
369 return computeConstantOperationRIGHT_SHIFT(left, leftId, operator,
371 case UNSIGNED_RIGHT_SHIFT:
372 return computeConstantOperationUNSIGNED_RIGHT_SHIFT(left, leftId,
373 operator, right, rightId);
375 return computeConstantOperationXOR(left, leftId, operator, right,
383 public static final Constant computeConstantOperationAND(Constant left,
384 int leftId, int operator, Constant right, int rightId) {
388 return Constant.fromValue(left.booleanValue()
389 & right.booleanValue());
393 return Constant.fromValue(left.charValue() & right.charValue());
395 return Constant.fromValue(left.charValue() & right.byteValue());
398 .fromValue(left.charValue() & right.shortValue());
400 return Constant.fromValue(left.charValue() & right.intValue());
402 return Constant.fromValue(left.charValue() & right.longValue());
408 return Constant.fromValue(left.byteValue() & right.charValue());
410 return Constant.fromValue(left.byteValue() & right.byteValue());
413 .fromValue(left.byteValue() & right.shortValue());
415 return Constant.fromValue(left.byteValue() & right.intValue());
417 return Constant.fromValue(left.byteValue() & right.longValue());
424 .fromValue(left.shortValue() & right.charValue());
427 .fromValue(left.shortValue() & right.byteValue());
429 return Constant.fromValue(left.shortValue()
430 & right.shortValue());
432 return Constant.fromValue(left.shortValue() & right.intValue());
435 .fromValue(left.shortValue() & right.longValue());
441 return Constant.fromValue(left.intValue() & right.charValue());
443 return Constant.fromValue(left.intValue() & right.byteValue());
445 return Constant.fromValue(left.intValue() & right.shortValue());
447 return Constant.fromValue(left.intValue() & right.intValue());
449 return Constant.fromValue(left.intValue() & right.longValue());
455 return Constant.fromValue(left.longValue() & right.charValue());
457 return Constant.fromValue(left.longValue() & right.byteValue());
460 .fromValue(left.longValue() & right.shortValue());
462 return Constant.fromValue(left.longValue() & right.intValue());
464 return Constant.fromValue(left.longValue() & right.longValue());
471 public static final Constant computeConstantOperationAND_AND(Constant left,
472 int leftId, int operator, Constant right, int rightId) {
474 return Constant.fromValue(left.booleanValue() && right.booleanValue());
477 public static final Constant computeConstantOperationDIVIDE(Constant left,
478 int leftId, int operator, Constant right, int rightId) {
479 // division by zero must be handled outside this method (error
486 return Constant.fromValue(left.charValue() / right.charValue());
489 .fromValue(left.charValue() / right.floatValue());
491 return Constant.fromValue(left.charValue()
492 / right.doubleValue());
494 return Constant.fromValue(left.charValue() / right.byteValue());
497 .fromValue(left.charValue() / right.shortValue());
499 return Constant.fromValue(left.charValue() / right.intValue());
501 return Constant.fromValue(left.charValue() / right.longValue());
508 .fromValue(left.floatValue() / right.charValue());
510 return Constant.fromValue(left.floatValue()
511 / right.floatValue());
513 return Constant.fromValue(left.floatValue()
514 / right.doubleValue());
517 .fromValue(left.floatValue() / right.byteValue());
519 return Constant.fromValue(left.floatValue()
520 / right.shortValue());
522 return Constant.fromValue(left.floatValue() / right.intValue());
525 .fromValue(left.floatValue() / right.longValue());
531 return Constant.fromValue(left.doubleValue()
532 / right.charValue());
534 return Constant.fromValue(left.doubleValue()
535 / right.floatValue());
537 return Constant.fromValue(left.doubleValue()
538 / right.doubleValue());
540 return Constant.fromValue(left.doubleValue()
541 / right.byteValue());
543 return Constant.fromValue(left.doubleValue()
544 / right.shortValue());
547 .fromValue(left.doubleValue() / right.intValue());
549 return Constant.fromValue(left.doubleValue()
550 / right.longValue());
556 return Constant.fromValue(left.byteValue() / right.charValue());
559 .fromValue(left.byteValue() / right.floatValue());
561 return Constant.fromValue(left.byteValue()
562 / right.doubleValue());
564 return Constant.fromValue(left.byteValue() / right.byteValue());
567 .fromValue(left.byteValue() / right.shortValue());
569 return Constant.fromValue(left.byteValue() / right.intValue());
571 return Constant.fromValue(left.byteValue() / right.longValue());
578 .fromValue(left.shortValue() / right.charValue());
580 return Constant.fromValue(left.shortValue()
581 / right.floatValue());
583 return Constant.fromValue(left.shortValue()
584 / right.doubleValue());
587 .fromValue(left.shortValue() / right.byteValue());
589 return Constant.fromValue(left.shortValue()
590 / right.shortValue());
592 return Constant.fromValue(left.shortValue() / right.intValue());
595 .fromValue(left.shortValue() / right.longValue());
601 return Constant.fromValue(left.intValue() / right.charValue());
603 return Constant.fromValue(left.intValue() / right.floatValue());
606 .fromValue(left.intValue() / right.doubleValue());
608 return Constant.fromValue(left.intValue() / right.byteValue());
610 return Constant.fromValue(left.intValue() / right.shortValue());
612 return Constant.fromValue(left.intValue() / right.intValue());
614 return Constant.fromValue(left.intValue() / right.longValue());
620 return Constant.fromValue(left.longValue() / right.charValue());
623 .fromValue(left.longValue() / right.floatValue());
625 return Constant.fromValue(left.longValue()
626 / right.doubleValue());
628 return Constant.fromValue(left.longValue() / right.byteValue());
631 .fromValue(left.longValue() / right.shortValue());
633 return Constant.fromValue(left.longValue() / right.intValue());
635 return Constant.fromValue(left.longValue() / right.longValue());
643 public static final Constant computeConstantOperationEQUAL_EQUAL(
644 Constant left, int leftId, int operator, Constant right, int rightId) {
648 if (rightId == T_boolean) {
649 return Constant.fromValue(left.booleanValue() == right
657 .fromValue(left.charValue() == right.charValue());
659 return Constant.fromValue(left.charValue() == right
662 return Constant.fromValue(left.charValue() == right
666 .fromValue(left.charValue() == right.byteValue());
668 return Constant.fromValue(left.charValue() == right
671 return Constant.fromValue(left.charValue() == right.intValue());
674 .fromValue(left.charValue() == right.longValue());
680 return Constant.fromValue(left.floatValue() == right
683 return Constant.fromValue(left.floatValue() == right
686 return Constant.fromValue(left.floatValue() == right
689 return Constant.fromValue(left.floatValue() == right
692 return Constant.fromValue(left.floatValue() == right
696 .fromValue(left.floatValue() == right.intValue());
698 return Constant.fromValue(left.floatValue() == right
705 return Constant.fromValue(left.doubleValue() == right
708 return Constant.fromValue(left.doubleValue() == right
711 return Constant.fromValue(left.doubleValue() == right
714 return Constant.fromValue(left.doubleValue() == right
717 return Constant.fromValue(left.doubleValue() == right
720 return Constant.fromValue(left.doubleValue() == right
723 return Constant.fromValue(left.doubleValue() == right
731 .fromValue(left.byteValue() == right.charValue());
733 return Constant.fromValue(left.byteValue() == right
736 return Constant.fromValue(left.byteValue() == right
740 .fromValue(left.byteValue() == right.byteValue());
742 return Constant.fromValue(left.byteValue() == right
745 return Constant.fromValue(left.byteValue() == right.intValue());
748 .fromValue(left.byteValue() == right.longValue());
754 return Constant.fromValue(left.shortValue() == right
757 return Constant.fromValue(left.shortValue() == right
760 return Constant.fromValue(left.shortValue() == right
763 return Constant.fromValue(left.shortValue() == right
766 return Constant.fromValue(left.shortValue() == right
770 .fromValue(left.shortValue() == right.intValue());
772 return Constant.fromValue(left.shortValue() == right
779 return Constant.fromValue(left.intValue() == right.charValue());
782 .fromValue(left.intValue() == right.floatValue());
784 return Constant.fromValue(left.intValue() == right
787 return Constant.fromValue(left.intValue() == right.byteValue());
790 .fromValue(left.intValue() == right.shortValue());
792 return Constant.fromValue(left.intValue() == right.intValue());
794 return Constant.fromValue(left.intValue() == right.longValue());
801 .fromValue(left.longValue() == right.charValue());
803 return Constant.fromValue(left.longValue() == right
806 return Constant.fromValue(left.longValue() == right
810 .fromValue(left.longValue() == right.byteValue());
812 return Constant.fromValue(left.longValue() == right
815 return Constant.fromValue(left.longValue() == right.intValue());
818 .fromValue(left.longValue() == right.longValue());
822 if (rightId == T_String) {
823 // String are interned in th compiler==>thus if two string
825 // get to be compared, it is an equal on the vale which is done
826 return Constant.fromValue(((StringConstant) left)
827 .compileTimeEqual((StringConstant) right));
831 if (rightId == T_String) {
832 return Constant.fromValue(false);
834 if (rightId == T_null) {
835 return Constant.fromValue(true);
840 return Constant.fromValue(false);
843 public static final Constant computeConstantOperationGREATER(Constant left,
844 int leftId, int operator, Constant right, int rightId) {
850 return Constant.fromValue(left.charValue() > right.charValue());
853 .fromValue(left.charValue() > right.floatValue());
855 return Constant.fromValue(left.charValue() > right
858 return Constant.fromValue(left.charValue() > right.byteValue());
861 .fromValue(left.charValue() > right.shortValue());
863 return Constant.fromValue(left.charValue() > right.intValue());
865 return Constant.fromValue(left.charValue() > right.longValue());
872 .fromValue(left.floatValue() > right.charValue());
874 return Constant.fromValue(left.floatValue() > right
877 return Constant.fromValue(left.floatValue() > right
881 .fromValue(left.floatValue() > right.byteValue());
883 return Constant.fromValue(left.floatValue() > right
886 return Constant.fromValue(left.floatValue() > right.intValue());
889 .fromValue(left.floatValue() > right.longValue());
895 return Constant.fromValue(left.doubleValue() > right
898 return Constant.fromValue(left.doubleValue() > right
901 return Constant.fromValue(left.doubleValue() > right
904 return Constant.fromValue(left.doubleValue() > right
907 return Constant.fromValue(left.doubleValue() > right
911 .fromValue(left.doubleValue() > right.intValue());
913 return Constant.fromValue(left.doubleValue() > right
920 return Constant.fromValue(left.byteValue() > right.charValue());
923 .fromValue(left.byteValue() > right.floatValue());
925 return Constant.fromValue(left.byteValue() > right
928 return Constant.fromValue(left.byteValue() > right.byteValue());
931 .fromValue(left.byteValue() > right.shortValue());
933 return Constant.fromValue(left.byteValue() > right.intValue());
935 return Constant.fromValue(left.byteValue() > right.longValue());
942 .fromValue(left.shortValue() > right.charValue());
944 return Constant.fromValue(left.shortValue() > right
947 return Constant.fromValue(left.shortValue() > right
951 .fromValue(left.shortValue() > right.byteValue());
953 return Constant.fromValue(left.shortValue() > right
956 return Constant.fromValue(left.shortValue() > right.intValue());
959 .fromValue(left.shortValue() > right.longValue());
965 return Constant.fromValue(left.intValue() > right.charValue());
967 return Constant.fromValue(left.intValue() > right.floatValue());
970 .fromValue(left.intValue() > right.doubleValue());
972 return Constant.fromValue(left.intValue() > right.byteValue());
974 return Constant.fromValue(left.intValue() > right.shortValue());
976 return Constant.fromValue(left.intValue() > right.intValue());
978 return Constant.fromValue(left.intValue() > right.longValue());
984 return Constant.fromValue(left.longValue() > right.charValue());
987 .fromValue(left.longValue() > right.floatValue());
989 return Constant.fromValue(left.longValue() > right
992 return Constant.fromValue(left.longValue() > right.byteValue());
995 .fromValue(left.longValue() > right.shortValue());
997 return Constant.fromValue(left.longValue() > right.intValue());
999 return Constant.fromValue(left.longValue() > right.longValue());
1004 return NotAConstant;
1007 public static final Constant computeConstantOperationGREATER_EQUAL(
1008 Constant left, int leftId, int operator, Constant right, int rightId) {
1015 .fromValue(left.charValue() >= right.charValue());
1017 return Constant.fromValue(left.charValue() >= right
1020 return Constant.fromValue(left.charValue() >= right
1024 .fromValue(left.charValue() >= right.byteValue());
1026 return Constant.fromValue(left.charValue() >= right
1029 return Constant.fromValue(left.charValue() >= right.intValue());
1032 .fromValue(left.charValue() >= right.longValue());
1038 return Constant.fromValue(left.floatValue() >= right
1041 return Constant.fromValue(left.floatValue() >= right
1044 return Constant.fromValue(left.floatValue() >= right
1047 return Constant.fromValue(left.floatValue() >= right
1050 return Constant.fromValue(left.floatValue() >= right
1054 .fromValue(left.floatValue() >= right.intValue());
1056 return Constant.fromValue(left.floatValue() >= right
1063 return Constant.fromValue(left.doubleValue() >= right
1066 return Constant.fromValue(left.doubleValue() >= right
1069 return Constant.fromValue(left.doubleValue() >= right
1072 return Constant.fromValue(left.doubleValue() >= right
1075 return Constant.fromValue(left.doubleValue() >= right
1078 return Constant.fromValue(left.doubleValue() >= right
1081 return Constant.fromValue(left.doubleValue() >= right
1089 .fromValue(left.byteValue() >= right.charValue());
1091 return Constant.fromValue(left.byteValue() >= right
1094 return Constant.fromValue(left.byteValue() >= right
1098 .fromValue(left.byteValue() >= right.byteValue());
1100 return Constant.fromValue(left.byteValue() >= right
1103 return Constant.fromValue(left.byteValue() >= right.intValue());
1106 .fromValue(left.byteValue() >= right.longValue());
1112 return Constant.fromValue(left.shortValue() >= right
1115 return Constant.fromValue(left.shortValue() >= right
1118 return Constant.fromValue(left.shortValue() >= right
1121 return Constant.fromValue(left.shortValue() >= right
1124 return Constant.fromValue(left.shortValue() >= right
1128 .fromValue(left.shortValue() >= right.intValue());
1130 return Constant.fromValue(left.shortValue() >= right
1137 return Constant.fromValue(left.intValue() >= right.charValue());
1140 .fromValue(left.intValue() >= right.floatValue());
1142 return Constant.fromValue(left.intValue() >= right
1145 return Constant.fromValue(left.intValue() >= right.byteValue());
1148 .fromValue(left.intValue() >= right.shortValue());
1150 return Constant.fromValue(left.intValue() >= right.intValue());
1152 return Constant.fromValue(left.intValue() >= right.longValue());
1159 .fromValue(left.longValue() >= right.charValue());
1161 return Constant.fromValue(left.longValue() >= right
1164 return Constant.fromValue(left.longValue() >= right
1168 .fromValue(left.longValue() >= right.byteValue());
1170 return Constant.fromValue(left.longValue() >= right
1173 return Constant.fromValue(left.longValue() >= right.intValue());
1176 .fromValue(left.longValue() >= right.longValue());
1181 return NotAConstant;
1184 public static final Constant computeConstantOperationLEFT_SHIFT(
1185 Constant left, int leftId, int operator, Constant right, int rightId) {
1192 .fromValue(left.charValue() << right.charValue());
1195 .fromValue(left.charValue() << right.byteValue());
1197 return Constant.fromValue(left.charValue() << right
1200 return Constant.fromValue(left.charValue() << right.intValue());
1203 .fromValue(left.charValue() << right.longValue());
1210 .fromValue(left.byteValue() << right.charValue());
1213 .fromValue(left.byteValue() << right.byteValue());
1215 return Constant.fromValue(left.byteValue() << right
1218 return Constant.fromValue(left.byteValue() << right.intValue());
1221 .fromValue(left.byteValue() << right.longValue());
1227 return Constant.fromValue(left.shortValue() << right
1230 return Constant.fromValue(left.shortValue() << right
1233 return Constant.fromValue(left.shortValue() << right
1237 .fromValue(left.shortValue() << right.intValue());
1239 return Constant.fromValue(left.shortValue() << right
1246 return Constant.fromValue(left.intValue() << right.charValue());
1248 return Constant.fromValue(left.intValue() << right.byteValue());
1251 .fromValue(left.intValue() << right.shortValue());
1253 return Constant.fromValue(left.intValue() << right.intValue());
1255 return Constant.fromValue(left.intValue() << right.longValue());
1262 .fromValue(left.longValue() << right.charValue());
1265 .fromValue(left.longValue() << right.byteValue());
1267 return Constant.fromValue(left.longValue() << right
1270 return Constant.fromValue(left.longValue() << right.intValue());
1273 .fromValue(left.longValue() << right.longValue());
1278 return NotAConstant;
1281 public static final Constant computeConstantOperationLESS(Constant left,
1282 int leftId, int operator, Constant right, int rightId) {
1288 return Constant.fromValue(left.charValue() < right.charValue());
1291 .fromValue(left.charValue() < right.floatValue());
1293 return Constant.fromValue(left.charValue() < right
1296 return Constant.fromValue(left.charValue() < right.byteValue());
1299 .fromValue(left.charValue() < right.shortValue());
1301 return Constant.fromValue(left.charValue() < right.intValue());
1303 return Constant.fromValue(left.charValue() < right.longValue());
1310 .fromValue(left.floatValue() < right.charValue());
1312 return Constant.fromValue(left.floatValue() < right
1315 return Constant.fromValue(left.floatValue() < right
1319 .fromValue(left.floatValue() < right.byteValue());
1321 return Constant.fromValue(left.floatValue() < right
1324 return Constant.fromValue(left.floatValue() < right.intValue());
1327 .fromValue(left.floatValue() < right.longValue());
1333 return Constant.fromValue(left.doubleValue() < right
1336 return Constant.fromValue(left.doubleValue() < right
1339 return Constant.fromValue(left.doubleValue() < right
1342 return Constant.fromValue(left.doubleValue() < right
1345 return Constant.fromValue(left.doubleValue() < right
1349 .fromValue(left.doubleValue() < right.intValue());
1351 return Constant.fromValue(left.doubleValue() < right
1358 return Constant.fromValue(left.byteValue() < right.charValue());
1361 .fromValue(left.byteValue() < right.floatValue());
1363 return Constant.fromValue(left.byteValue() < right
1366 return Constant.fromValue(left.byteValue() < right.byteValue());
1369 .fromValue(left.byteValue() < right.shortValue());
1371 return Constant.fromValue(left.byteValue() < right.intValue());
1373 return Constant.fromValue(left.byteValue() < right.longValue());
1380 .fromValue(left.shortValue() < right.charValue());
1382 return Constant.fromValue(left.shortValue() < right
1385 return Constant.fromValue(left.shortValue() < right
1389 .fromValue(left.shortValue() < right.byteValue());
1391 return Constant.fromValue(left.shortValue() < right
1394 return Constant.fromValue(left.shortValue() < right.intValue());
1397 .fromValue(left.shortValue() < right.longValue());
1403 return Constant.fromValue(left.intValue() < right.charValue());
1405 return Constant.fromValue(left.intValue() < right.floatValue());
1408 .fromValue(left.intValue() < right.doubleValue());
1410 return Constant.fromValue(left.intValue() < right.byteValue());
1412 return Constant.fromValue(left.intValue() < right.shortValue());
1414 return Constant.fromValue(left.intValue() < right.intValue());
1416 return Constant.fromValue(left.intValue() < right.longValue());
1422 return Constant.fromValue(left.longValue() < right.charValue());
1425 .fromValue(left.longValue() < right.floatValue());
1427 return Constant.fromValue(left.longValue() < right
1430 return Constant.fromValue(left.longValue() < right.byteValue());
1433 .fromValue(left.longValue() < right.shortValue());
1435 return Constant.fromValue(left.longValue() < right.intValue());
1437 return Constant.fromValue(left.longValue() < right.longValue());
1442 return NotAConstant;
1445 public static final Constant computeConstantOperationLESS_EQUAL(
1446 Constant left, int leftId, int operator, Constant right, int rightId) {
1453 .fromValue(left.charValue() <= right.charValue());
1455 return Constant.fromValue(left.charValue() <= right
1458 return Constant.fromValue(left.charValue() <= right
1462 .fromValue(left.charValue() <= right.byteValue());
1464 return Constant.fromValue(left.charValue() <= right
1467 return Constant.fromValue(left.charValue() <= right.intValue());
1470 .fromValue(left.charValue() <= right.longValue());
1476 return Constant.fromValue(left.floatValue() <= right
1479 return Constant.fromValue(left.floatValue() <= right
1482 return Constant.fromValue(left.floatValue() <= right
1485 return Constant.fromValue(left.floatValue() <= right
1488 return Constant.fromValue(left.floatValue() <= right
1492 .fromValue(left.floatValue() <= right.intValue());
1494 return Constant.fromValue(left.floatValue() <= right
1501 return Constant.fromValue(left.doubleValue() <= right
1504 return Constant.fromValue(left.doubleValue() <= right
1507 return Constant.fromValue(left.doubleValue() <= right
1510 return Constant.fromValue(left.doubleValue() <= right
1513 return Constant.fromValue(left.doubleValue() <= right
1516 return Constant.fromValue(left.doubleValue() <= right
1519 return Constant.fromValue(left.doubleValue() <= right
1527 .fromValue(left.byteValue() <= right.charValue());
1529 return Constant.fromValue(left.byteValue() <= right
1532 return Constant.fromValue(left.byteValue() <= right
1536 .fromValue(left.byteValue() <= right.byteValue());
1538 return Constant.fromValue(left.byteValue() <= right
1541 return Constant.fromValue(left.byteValue() <= right.intValue());
1544 .fromValue(left.byteValue() <= right.longValue());
1550 return Constant.fromValue(left.shortValue() <= right
1553 return Constant.fromValue(left.shortValue() <= right
1556 return Constant.fromValue(left.shortValue() <= right
1559 return Constant.fromValue(left.shortValue() <= right
1562 return Constant.fromValue(left.shortValue() <= right
1566 .fromValue(left.shortValue() <= right.intValue());
1568 return Constant.fromValue(left.shortValue() <= right
1575 return Constant.fromValue(left.intValue() <= right.charValue());
1578 .fromValue(left.intValue() <= right.floatValue());
1580 return Constant.fromValue(left.intValue() <= right
1583 return Constant.fromValue(left.intValue() <= right.byteValue());
1586 .fromValue(left.intValue() <= right.shortValue());
1588 return Constant.fromValue(left.intValue() <= right.intValue());
1590 return Constant.fromValue(left.intValue() <= right.longValue());
1597 .fromValue(left.longValue() <= right.charValue());
1599 return Constant.fromValue(left.longValue() <= right
1602 return Constant.fromValue(left.longValue() <= right
1606 .fromValue(left.longValue() <= right.byteValue());
1608 return Constant.fromValue(left.longValue() <= right
1611 return Constant.fromValue(left.longValue() <= right.intValue());
1614 .fromValue(left.longValue() <= right.longValue());
1618 return NotAConstant;
1621 public static final Constant computeConstantOperationMINUS(Constant left,
1622 int leftId, int operator, Constant right, int rightId) {
1628 return Constant.fromValue(left.charValue() - right.charValue());
1631 .fromValue(left.charValue() - right.floatValue());
1633 return Constant.fromValue(left.charValue()
1634 - right.doubleValue());
1636 return Constant.fromValue(left.charValue() - right.byteValue());
1639 .fromValue(left.charValue() - right.shortValue());
1641 return Constant.fromValue(left.charValue() - right.intValue());
1643 return Constant.fromValue(left.charValue() - right.longValue());
1650 .fromValue(left.floatValue() - right.charValue());
1652 return Constant.fromValue(left.floatValue()
1653 - right.floatValue());
1655 return Constant.fromValue(left.floatValue()
1656 - right.doubleValue());
1659 .fromValue(left.floatValue() - right.byteValue());
1661 return Constant.fromValue(left.floatValue()
1662 - right.shortValue());
1664 return Constant.fromValue(left.floatValue() - right.intValue());
1667 .fromValue(left.floatValue() - right.longValue());
1673 return Constant.fromValue(left.doubleValue()
1674 - right.charValue());
1676 return Constant.fromValue(left.doubleValue()
1677 - right.floatValue());
1679 return Constant.fromValue(left.doubleValue()
1680 - right.doubleValue());
1682 return Constant.fromValue(left.doubleValue()
1683 - right.byteValue());
1685 return Constant.fromValue(left.doubleValue()
1686 - right.shortValue());
1689 .fromValue(left.doubleValue() - right.intValue());
1691 return Constant.fromValue(left.doubleValue()
1692 - right.longValue());
1698 return Constant.fromValue(left.byteValue() - right.charValue());
1701 .fromValue(left.byteValue() - right.floatValue());
1703 return Constant.fromValue(left.byteValue()
1704 - right.doubleValue());
1706 return Constant.fromValue(left.byteValue() - right.byteValue());
1709 .fromValue(left.byteValue() - right.shortValue());
1711 return Constant.fromValue(left.byteValue() - right.intValue());
1713 return Constant.fromValue(left.byteValue() - right.longValue());
1720 .fromValue(left.shortValue() - right.charValue());
1722 return Constant.fromValue(left.shortValue()
1723 - right.floatValue());
1725 return Constant.fromValue(left.shortValue()
1726 - right.doubleValue());
1729 .fromValue(left.shortValue() - right.byteValue());
1731 return Constant.fromValue(left.shortValue()
1732 - right.shortValue());
1734 return Constant.fromValue(left.shortValue() - right.intValue());
1737 .fromValue(left.shortValue() - right.longValue());
1743 return Constant.fromValue(left.intValue() - right.charValue());
1745 return Constant.fromValue(left.intValue() - right.floatValue());
1748 .fromValue(left.intValue() - right.doubleValue());
1750 return Constant.fromValue(left.intValue() - right.byteValue());
1752 return Constant.fromValue(left.intValue() - right.shortValue());
1754 return Constant.fromValue(left.intValue() - right.intValue());
1756 return Constant.fromValue(left.intValue() - right.longValue());
1762 return Constant.fromValue(left.longValue() - right.charValue());
1765 .fromValue(left.longValue() - right.floatValue());
1767 return Constant.fromValue(left.longValue()
1768 - right.doubleValue());
1770 return Constant.fromValue(left.longValue() - right.byteValue());
1773 .fromValue(left.longValue() - right.shortValue());
1775 return Constant.fromValue(left.longValue() - right.intValue());
1777 return Constant.fromValue(left.longValue() - right.longValue());
1782 return NotAConstant;
1785 public static final Constant computeConstantOperationMULTIPLY(
1786 Constant left, int leftId, int operator, Constant right, int rightId) {
1792 return Constant.fromValue(left.charValue() * right.charValue());
1795 .fromValue(left.charValue() * right.floatValue());
1797 return Constant.fromValue(left.charValue()
1798 * right.doubleValue());
1800 return Constant.fromValue(left.charValue() * right.byteValue());
1803 .fromValue(left.charValue() * right.shortValue());
1805 return Constant.fromValue(left.charValue() * right.intValue());
1807 return Constant.fromValue(left.charValue() * right.longValue());
1814 .fromValue(left.floatValue() * right.charValue());
1816 return Constant.fromValue(left.floatValue()
1817 * right.floatValue());
1819 return Constant.fromValue(left.floatValue()
1820 * right.doubleValue());
1823 .fromValue(left.floatValue() * right.byteValue());
1825 return Constant.fromValue(left.floatValue()
1826 * right.shortValue());
1828 return Constant.fromValue(left.floatValue() * right.intValue());
1831 .fromValue(left.floatValue() * right.longValue());
1837 return Constant.fromValue(left.doubleValue()
1838 * right.charValue());
1840 return Constant.fromValue(left.doubleValue()
1841 * right.floatValue());
1843 return Constant.fromValue(left.doubleValue()
1844 * right.doubleValue());
1846 return Constant.fromValue(left.doubleValue()
1847 * right.byteValue());
1849 return Constant.fromValue(left.doubleValue()
1850 * right.shortValue());
1853 .fromValue(left.doubleValue() * right.intValue());
1855 return Constant.fromValue(left.doubleValue()
1856 * right.longValue());
1862 return Constant.fromValue(left.byteValue() * right.charValue());
1865 .fromValue(left.byteValue() * right.floatValue());
1867 return Constant.fromValue(left.byteValue()
1868 * right.doubleValue());
1870 return Constant.fromValue(left.byteValue() * right.byteValue());
1873 .fromValue(left.byteValue() * right.shortValue());
1875 return Constant.fromValue(left.byteValue() * right.intValue());
1877 return Constant.fromValue(left.byteValue() * right.longValue());
1884 .fromValue(left.shortValue() * right.charValue());
1886 return Constant.fromValue(left.shortValue()
1887 * right.floatValue());
1889 return Constant.fromValue(left.shortValue()
1890 * right.doubleValue());
1893 .fromValue(left.shortValue() * right.byteValue());
1895 return Constant.fromValue(left.shortValue()
1896 * right.shortValue());
1898 return Constant.fromValue(left.shortValue() * right.intValue());
1901 .fromValue(left.shortValue() * right.longValue());
1907 return Constant.fromValue(left.intValue() * right.charValue());
1909 return Constant.fromValue(left.intValue() * right.floatValue());
1912 .fromValue(left.intValue() * right.doubleValue());
1914 return Constant.fromValue(left.intValue() * right.byteValue());
1916 return Constant.fromValue(left.intValue() * right.shortValue());
1918 return Constant.fromValue(left.intValue() * right.intValue());
1920 return Constant.fromValue(left.intValue() * right.longValue());
1926 return Constant.fromValue(left.longValue() * right.charValue());
1929 .fromValue(left.longValue() * right.floatValue());
1931 return Constant.fromValue(left.longValue()
1932 * right.doubleValue());
1934 return Constant.fromValue(left.longValue() * right.byteValue());
1937 .fromValue(left.longValue() * right.shortValue());
1939 return Constant.fromValue(left.longValue() * right.intValue());
1941 return Constant.fromValue(left.longValue() * right.longValue());
1945 return NotAConstant;
1948 public static final Constant computeConstantOperationOR(Constant left,
1949 int leftId, int operator, Constant right, int rightId) {
1953 return Constant.fromValue(left.booleanValue()
1954 | right.booleanValue());
1958 return Constant.fromValue(left.charValue() | right.charValue());
1960 return Constant.fromValue(left.charValue() | right.byteValue());
1963 .fromValue(left.charValue() | right.shortValue());
1965 return Constant.fromValue(left.charValue() | right.intValue());
1967 return Constant.fromValue(left.charValue() | right.longValue());
1973 return Constant.fromValue(left.byteValue() | right.charValue());
1975 return Constant.fromValue(left.byteValue() | right.byteValue());
1978 .fromValue(left.byteValue() | right.shortValue());
1980 return Constant.fromValue(left.byteValue() | right.intValue());
1982 return Constant.fromValue(left.byteValue() | right.longValue());
1989 .fromValue(left.shortValue() | right.charValue());
1992 .fromValue(left.shortValue() | right.byteValue());
1994 return Constant.fromValue(left.shortValue()
1995 | right.shortValue());
1997 return Constant.fromValue(left.shortValue() | right.intValue());
2000 .fromValue(left.shortValue() | right.longValue());
2006 return Constant.fromValue(left.intValue() | right.charValue());
2008 return Constant.fromValue(left.intValue() | right.byteValue());
2010 return Constant.fromValue(left.intValue() | right.shortValue());
2012 return Constant.fromValue(left.intValue() | right.intValue());
2014 return Constant.fromValue(left.intValue() | right.longValue());
2020 return Constant.fromValue(left.longValue() | right.charValue());
2022 return Constant.fromValue(left.longValue() | right.byteValue());
2025 .fromValue(left.longValue() | right.shortValue());
2027 return Constant.fromValue(left.longValue() | right.intValue());
2029 return Constant.fromValue(left.longValue() | right.longValue());
2034 return NotAConstant;
2037 public static final Constant computeConstantOperationOR_OR(Constant left,
2038 int leftId, int operator, Constant right, int rightId) {
2040 return Constant.fromValue(left.booleanValue() || right.booleanValue());
2043 public static final Constant computeConstantOperationPLUS(Constant left,
2044 int leftId, int operator, Constant right, int rightId) {
2048 if (rightId == T_String) {
2049 return Constant.fromValue(left.stringValue()
2050 + right.stringValue());
2053 if (rightId == T_String) {
2054 return Constant.fromValue(left.stringValue()
2055 + right.stringValue());
2061 return Constant.fromValue(left.charValue() + right.charValue());
2064 .fromValue(left.charValue() + right.floatValue());
2066 return Constant.fromValue(left.charValue()
2067 + right.doubleValue());
2069 return Constant.fromValue(left.charValue() + right.byteValue());
2072 .fromValue(left.charValue() + right.shortValue());
2074 return Constant.fromValue(left.charValue() + right.intValue());
2076 return Constant.fromValue(left.charValue() + right.longValue());
2078 return Constant.fromValue(left.stringValue()
2079 + right.stringValue());
2086 .fromValue(left.floatValue() + right.charValue());
2088 return Constant.fromValue(left.floatValue()
2089 + right.floatValue());
2091 return Constant.fromValue(left.floatValue()
2092 + right.doubleValue());
2095 .fromValue(left.floatValue() + right.byteValue());
2097 return Constant.fromValue(left.floatValue()
2098 + right.shortValue());
2100 return Constant.fromValue(left.floatValue() + right.intValue());
2103 .fromValue(left.floatValue() + right.longValue());
2105 return Constant.fromValue(left.stringValue()
2106 + right.stringValue());
2112 return Constant.fromValue(left.doubleValue()
2113 + right.charValue());
2115 return Constant.fromValue(left.doubleValue()
2116 + right.floatValue());
2118 return Constant.fromValue(left.doubleValue()
2119 + right.doubleValue());
2121 return Constant.fromValue(left.doubleValue()
2122 + right.byteValue());
2124 return Constant.fromValue(left.doubleValue()
2125 + right.shortValue());
2128 .fromValue(left.doubleValue() + right.intValue());
2130 return Constant.fromValue(left.doubleValue()
2131 + right.longValue());
2133 return Constant.fromValue(left.stringValue()
2134 + right.stringValue());
2140 return Constant.fromValue(left.byteValue() + right.charValue());
2143 .fromValue(left.byteValue() + right.floatValue());
2145 return Constant.fromValue(left.byteValue()
2146 + right.doubleValue());
2148 return Constant.fromValue(left.byteValue() + right.byteValue());
2151 .fromValue(left.byteValue() + right.shortValue());
2153 return Constant.fromValue(left.byteValue() + right.intValue());
2155 return Constant.fromValue(left.byteValue() + right.longValue());
2157 return Constant.fromValue(left.stringValue()
2158 + right.stringValue());
2166 .fromValue(left.shortValue() + right.charValue());
2168 return Constant.fromValue(left.shortValue()
2169 + right.floatValue());
2171 return Constant.fromValue(left.shortValue()
2172 + right.doubleValue());
2175 .fromValue(left.shortValue() + right.byteValue());
2177 return Constant.fromValue(left.shortValue()
2178 + right.shortValue());
2180 return Constant.fromValue(left.shortValue() + right.intValue());
2183 .fromValue(left.shortValue() + right.longValue());
2185 return Constant.fromValue(left.stringValue()
2186 + right.stringValue());
2192 return Constant.fromValue(left.intValue() + right.charValue());
2194 return Constant.fromValue(left.intValue() + right.floatValue());
2197 .fromValue(left.intValue() + right.doubleValue());
2199 return Constant.fromValue(left.intValue() + right.byteValue());
2201 return Constant.fromValue(left.intValue() + right.shortValue());
2203 return Constant.fromValue(left.intValue() + right.intValue());
2205 return Constant.fromValue(left.intValue() + right.longValue());
2207 return Constant.fromValue(left.stringValue()
2208 + right.stringValue());
2214 return Constant.fromValue(left.longValue() + right.charValue());
2217 .fromValue(left.longValue() + right.floatValue());
2219 return Constant.fromValue(left.longValue()
2220 + right.doubleValue());
2222 return Constant.fromValue(left.longValue() + right.byteValue());
2225 .fromValue(left.longValue() + right.shortValue());
2227 return Constant.fromValue(left.longValue() + right.intValue());
2229 return Constant.fromValue(left.longValue() + right.longValue());
2231 return Constant.fromValue(left.stringValue()
2232 + right.stringValue());
2238 return Constant.fromValue(left.stringValue()
2239 + right.stringValue());
2241 return Constant.fromValue(left.stringValue()
2242 + right.stringValue());
2244 return Constant.fromValue(left.stringValue()
2245 + right.stringValue());
2247 return Constant.fromValue(left.stringValue()
2248 + right.stringValue());
2250 return Constant.fromValue(left.stringValue()
2251 + right.stringValue());
2253 return Constant.fromValue(left.stringValue()
2254 + right.stringValue());
2256 return Constant.fromValue(left.stringValue()
2257 + right.stringValue());
2259 return Constant.fromValue(left.stringValue()
2260 + right.stringValue());
2262 return Constant.fromValue(left.stringValue()
2263 + right.stringValue());
2269 return Constant.fromValue(left.stringValue()
2270 + right.stringValue());
2272 return Constant.fromValue(left.stringValue()
2273 + right.stringValue());
2275 return Constant.fromValue(left.stringValue()
2276 + right.stringValue());
2278 return Constant.fromValue(left.stringValue()
2279 + right.stringValue());
2281 return Constant.fromValue(left.stringValue()
2282 + right.stringValue());
2284 return Constant.fromValue(left.stringValue()
2285 + right.stringValue());
2287 return Constant.fromValue(left.stringValue()
2288 + right.stringValue());
2290 return Constant.fromValue(left.stringValue()
2291 + right.stringValue());
2296 return NotAConstant;
2299 public static final Constant computeConstantOperationREMAINDER(
2300 Constant left, int leftId, int operator, Constant right, int rightId) {
2306 return Constant.fromValue(left.charValue() % right.charValue());
2309 .fromValue(left.charValue() % right.floatValue());
2311 return Constant.fromValue(left.charValue()
2312 % right.doubleValue());
2314 return Constant.fromValue(left.charValue() % right.byteValue());
2317 .fromValue(left.charValue() % right.shortValue());
2319 return Constant.fromValue(left.charValue() % right.intValue());
2321 return Constant.fromValue(left.charValue() % right.longValue());
2328 .fromValue(left.floatValue() % right.charValue());
2330 return Constant.fromValue(left.floatValue()
2331 % right.floatValue());
2333 return Constant.fromValue(left.floatValue()
2334 % right.doubleValue());
2337 .fromValue(left.floatValue() % right.byteValue());
2339 return Constant.fromValue(left.floatValue()
2340 % right.shortValue());
2342 return Constant.fromValue(left.floatValue() % right.intValue());
2345 .fromValue(left.floatValue() % right.longValue());
2351 return Constant.fromValue(left.doubleValue()
2352 % right.charValue());
2354 return Constant.fromValue(left.doubleValue()
2355 % right.floatValue());
2357 return Constant.fromValue(left.doubleValue()
2358 % right.doubleValue());
2360 return Constant.fromValue(left.doubleValue()
2361 % right.byteValue());
2363 return Constant.fromValue(left.doubleValue()
2364 % right.shortValue());
2367 .fromValue(left.doubleValue() % right.intValue());
2369 return Constant.fromValue(left.doubleValue()
2370 % right.longValue());
2376 return Constant.fromValue(left.byteValue() % right.charValue());
2379 .fromValue(left.byteValue() % right.floatValue());
2381 return Constant.fromValue(left.byteValue()
2382 % right.doubleValue());
2384 return Constant.fromValue(left.byteValue() % right.byteValue());
2387 .fromValue(left.byteValue() % right.shortValue());
2389 return Constant.fromValue(left.byteValue() % right.intValue());
2391 return Constant.fromValue(left.byteValue() % right.longValue());
2398 .fromValue(left.shortValue() % right.charValue());
2400 return Constant.fromValue(left.shortValue()
2401 % right.floatValue());
2403 return Constant.fromValue(left.shortValue()
2404 % right.doubleValue());
2407 .fromValue(left.shortValue() % right.byteValue());
2409 return Constant.fromValue(left.shortValue()
2410 % right.shortValue());
2412 return Constant.fromValue(left.shortValue() % right.intValue());
2415 .fromValue(left.shortValue() % right.longValue());
2421 return Constant.fromValue(left.intValue() % right.charValue());
2423 return Constant.fromValue(left.intValue() % right.floatValue());
2426 .fromValue(left.intValue() % right.doubleValue());
2428 return Constant.fromValue(left.intValue() % right.byteValue());
2430 return Constant.fromValue(left.intValue() % right.shortValue());
2432 return Constant.fromValue(left.intValue() % right.intValue());
2434 return Constant.fromValue(left.intValue() % right.longValue());
2440 return Constant.fromValue(left.longValue() % right.charValue());
2443 .fromValue(left.longValue() % right.floatValue());
2445 return Constant.fromValue(left.longValue()
2446 % right.doubleValue());
2448 return Constant.fromValue(left.longValue() % right.byteValue());
2451 .fromValue(left.longValue() % right.shortValue());
2453 return Constant.fromValue(left.longValue() % right.intValue());
2455 return Constant.fromValue(left.longValue() % right.longValue());
2460 return NotAConstant;
2463 public static final Constant computeConstantOperationRIGHT_SHIFT(
2464 Constant left, int leftId, int operator, Constant right, int rightId) {
2471 .fromValue(left.charValue() >> right.charValue());
2474 .fromValue(left.charValue() >> right.byteValue());
2476 return Constant.fromValue(left.charValue() >> right
2479 return Constant.fromValue(left.charValue() >> right.intValue());
2482 .fromValue(left.charValue() >> right.longValue());
2489 .fromValue(left.byteValue() >> right.charValue());
2492 .fromValue(left.byteValue() >> right.byteValue());
2494 return Constant.fromValue(left.byteValue() >> right
2497 return Constant.fromValue(left.byteValue() >> right.intValue());
2500 .fromValue(left.byteValue() >> right.longValue());
2506 return Constant.fromValue(left.shortValue() >> right
2509 return Constant.fromValue(left.shortValue() >> right
2512 return Constant.fromValue(left.shortValue() >> right
2516 .fromValue(left.shortValue() >> right.intValue());
2518 return Constant.fromValue(left.shortValue() >> right
2525 return Constant.fromValue(left.intValue() >> right.charValue());
2527 return Constant.fromValue(left.intValue() >> right.byteValue());
2530 .fromValue(left.intValue() >> right.shortValue());
2532 return Constant.fromValue(left.intValue() >> right.intValue());
2534 return Constant.fromValue(left.intValue() >> right.longValue());
2541 .fromValue(left.longValue() >> right.charValue());
2544 .fromValue(left.longValue() >> right.byteValue());
2546 return Constant.fromValue(left.longValue() >> right
2549 return Constant.fromValue(left.longValue() >> right.intValue());
2552 .fromValue(left.longValue() >> right.longValue());
2557 return NotAConstant;
2560 public static final Constant computeConstantOperationUNSIGNED_RIGHT_SHIFT(
2561 Constant left, int leftId, int operator, Constant right, int rightId) {
2567 return Constant.fromValue(left.charValue() >>> right
2570 return Constant.fromValue(left.charValue() >>> right
2573 return Constant.fromValue(left.charValue() >>> right
2577 .fromValue(left.charValue() >>> right.intValue());
2579 return Constant.fromValue(left.charValue() >>> right
2586 return Constant.fromValue(left.byteValue() >>> right
2589 return Constant.fromValue(left.byteValue() >>> right
2592 return Constant.fromValue(left.byteValue() >>> right
2596 .fromValue(left.byteValue() >>> right.intValue());
2598 return Constant.fromValue(left.byteValue() >>> right
2605 return Constant.fromValue(left.shortValue() >>> right
2608 return Constant.fromValue(left.shortValue() >>> right
2611 return Constant.fromValue(left.shortValue() >>> right
2614 return Constant.fromValue(left.shortValue() >>> right
2617 return Constant.fromValue(left.shortValue() >>> right
2625 .fromValue(left.intValue() >>> right.charValue());
2628 .fromValue(left.intValue() >>> right.byteValue());
2630 return Constant.fromValue(left.intValue() >>> right
2633 return Constant.fromValue(left.intValue() >>> right.intValue());
2636 .fromValue(left.intValue() >>> right.longValue());
2642 return Constant.fromValue(left.longValue() >>> right
2645 return Constant.fromValue(left.longValue() >>> right
2648 return Constant.fromValue(left.longValue() >>> right
2652 .fromValue(left.longValue() >>> right.intValue());
2654 return Constant.fromValue(left.longValue() >>> right
2660 return NotAConstant;
2663 public static final Constant computeConstantOperationXOR(Constant left,
2664 int leftId, int operator, Constant right, int rightId) {
2668 return Constant.fromValue(left.booleanValue()
2669 ^ right.booleanValue());
2673 return Constant.fromValue(left.charValue() ^ right.charValue());
2675 return Constant.fromValue(left.charValue() ^ right.byteValue());
2678 .fromValue(left.charValue() ^ right.shortValue());
2680 return Constant.fromValue(left.charValue() ^ right.intValue());
2682 return Constant.fromValue(left.charValue() ^ right.longValue());
2688 return Constant.fromValue(left.byteValue() ^ right.charValue());
2690 return Constant.fromValue(left.byteValue() ^ right.byteValue());
2693 .fromValue(left.byteValue() ^ right.shortValue());
2695 return Constant.fromValue(left.byteValue() ^ right.intValue());
2697 return Constant.fromValue(left.byteValue() ^ right.longValue());
2704 .fromValue(left.shortValue() ^ right.charValue());
2707 .fromValue(left.shortValue() ^ right.byteValue());
2709 return Constant.fromValue(left.shortValue()
2710 ^ right.shortValue());
2712 return Constant.fromValue(left.shortValue() ^ right.intValue());
2715 .fromValue(left.shortValue() ^ right.longValue());
2721 return Constant.fromValue(left.intValue() ^ right.charValue());
2723 return Constant.fromValue(left.intValue() ^ right.byteValue());
2725 return Constant.fromValue(left.intValue() ^ right.shortValue());
2727 return Constant.fromValue(left.intValue() ^ right.intValue());
2729 return Constant.fromValue(left.intValue() ^ right.longValue());
2735 return Constant.fromValue(left.longValue() ^ right.charValue());
2737 return Constant.fromValue(left.longValue() ^ right.byteValue());
2740 .fromValue(left.longValue() ^ right.shortValue());
2742 return Constant.fromValue(left.longValue() ^ right.intValue());
2744 return Constant.fromValue(left.longValue() ^ right.longValue());
2748 return NotAConstant;
2751 public double doubleValue() {
2753 throw new ShouldNotImplement(Util.bind(
2754 "constant.cannotCastedInto", typeName(), "double")); //$NON-NLS-2$ //$NON-NLS-1$
2757 public float floatValue() {
2759 throw new ShouldNotImplement(Util.bind(
2760 "constant.cannotCastedInto", typeName(), "float")); //$NON-NLS-2$ //$NON-NLS-1$
2763 // public static Constant fromValue(byte value) {
2765 // return new ByteConstant(value);
2768 // public static Constant fromValue(char value) {
2770 // return new CharConstant(value);
2773 public static Constant fromValue(double value) {
2775 return new DoubleConstant(value);
2778 // public static Constant fromValue(float value) {
2780 // return new FloatConstant(value);
2783 public static Constant fromValue(int value) {
2785 return new IntConstant(value);
2788 // public static Constant fromValue(long value) {
2790 // return new LongConstant(value);
2793 public static Constant fromValue(String value) {
2795 return new StringConstant(value);
2798 // public static Constant fromValue(short value) {
2800 // return new ShortConstant(value);
2803 public static Constant fromValue(boolean value) {
2805 return new BooleanConstant(value);
2808 public int intValue() {
2810 throw new ShouldNotImplement(Util.bind(
2811 "constant.cannotCastedInto", typeName(), "int")); //$NON-NLS-2$ //$NON-NLS-1$
2814 public long longValue() {
2816 throw new ShouldNotImplement(Util.bind(
2817 "constant.cannotCastedInto", typeName(), "long")); //$NON-NLS-2$ //$NON-NLS-1$
2820 public short shortValue() {
2822 throw new ShouldNotImplement(Util.bind(
2823 "constant.cannotConvertedTo", typeName(), "short")); //$NON-NLS-2$ //$NON-NLS-1$
2826 public String stringValue() {
2828 throw new ShouldNotImplement(Util.bind(
2829 "constant.cannotConvertedTo", typeName(), "String")); //$NON-NLS-1$ //$NON-NLS-2$
2832 public String toString() {
2834 if (this == NotAConstant)
2835 return "(Constant) NotAConstant"; //$NON-NLS-1$
2836 return super.toString();
2839 public abstract int typeID();
2841 public String typeName() {
2844 return "int"; //$NON-NLS-1$
2846 return "byte"; //$NON-NLS-1$
2848 return "short"; //$NON-NLS-1$
2850 return "char"; //$NON-NLS-1$
2852 return "float"; //$NON-NLS-1$
2854 return "double"; //$NON-NLS-1$
2856 return "boolean"; //$NON-NLS-1$
2858 return "long";//$NON-NLS-1$
2860 return "java.lang.String"; //$NON-NLS-1$
2862 return "null"; //$NON-NLS-1$
2864 return "unknown"; //$NON-NLS-1$