*** empty log message ***
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / impl / Constant.java
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
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler.impl;
12
13 import net.sourceforge.phpdt.internal.compiler.lookup.TypeIds;
14 import net.sourceforge.phpdt.internal.compiler.problem.ShouldNotImplement;
15 import net.sourceforge.phpdt.internal.compiler.util.Util;
16 import net.sourceforge.phpeclipse.internal.compiler.ast.OperatorIds;
17
18 public abstract class Constant implements TypeIds, OperatorIds {
19         
20         public static final Constant NotAConstant = new DoubleConstant(Double.NaN);
21
22         public static final IntConstant Zero = new IntConstant(0);
23         public static final IntConstant Two = new IntConstant(2);
24         public static final IntConstant One = new IntConstant(1);
25         
26         public boolean booleanValue() {
27
28                 throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto",typeName(),"boolean")); //$NON-NLS-1$ //$NON-NLS-2$
29         }
30
31         public byte byteValue() {
32
33                 throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto",typeName(),"byte")); //$NON-NLS-1$ //$NON-NLS-2$
34         }
35
36         public final Constant castTo(int conversionToTargetType){
37                 //the cast is an int of the form
38                 // (castId<<4)+typeId (in order to follow the
39                 //user written style (cast)expression ....
40         
41                 if (this == NotAConstant) return NotAConstant;
42                 switch(conversionToTargetType){
43                         case T_undefined :                                              return this;
44         //            TARGET TYPE  <- FROM TYPE
45         //          case (T_undefined<<4)+T_undefined    : return NotAConstant;  
46         //          case (T_undefined<<4)+T_byte                 : return NotAConstant;   
47         //          case (T_undefined<<4)+T_long                 : return NotAConstant;   
48         //          case (T_undefined<<4)+T_short                : return NotAConstant;   
49         //          case (T_undefined<<4)+T_void                 : return NotAConstant;   
50         //          case (T_undefined<<4)+T_String       : return NotAConstant;   
51         //          case (T_undefined<<4)+T_Object       : return NotAConstant;   
52         //          case (T_undefined<<4)+T_double       : return NotAConstant;   
53         //          case (T_undefined<<4)+T_float                : return NotAConstant;   
54         //          case (T_undefined<<4)+T_boolean      : return NotAConstant;   
55         //          case (T_undefined<<4)+T_char                 : return NotAConstant;   
56         //          case (T_undefined<<4)+T_int                  : return NotAConstant;   
57                 
58         //          case (T_byte<<4)+T_undefined         : return NotAConstant;   
59                     case (T_byte<<4)+T_byte              : return this;  
60                     case (T_byte<<4)+T_long              : return Constant.fromValue((byte)this.longValue()); 
61                     case (T_byte<<4)+T_short             : return Constant.fromValue((byte)this.shortValue());    
62         //          case (T_byte<<4)+T_void              : return NotAConstant;   
63         //          case (T_byte<<4)+T_String            : return NotAConstant;   
64         //          case (T_byte<<4)+T_Object            : return NotAConstant;   
65                     case (T_byte<<4)+T_double            : return Constant.fromValue((byte)this.doubleValue());    
66                     case (T_byte<<4)+T_float             : return Constant.fromValue((byte)this.floatValue());    
67         //          case (T_byte<<4)+T_boolean           : return NotAConstant;   
68                     case (T_byte<<4)+T_char              : return Constant.fromValue((byte)this.charValue());    
69                     case (T_byte<<4)+T_int               : return Constant.fromValue((byte)this.intValue());    
70         
71         //          case (T_long<<4)+T_undefined         : return NotAConstant;   
72                     case (T_long<<4)+T_byte              : return Constant.fromValue((long)this.byteValue()); 
73                     case (T_long<<4)+T_long              : return this; 
74                     case (T_long<<4)+T_short             : return Constant.fromValue((long)this.shortValue()); 
75         //          case (T_long<<4)+T_void              : return NotAConstant;   
76         //          case (T_long<<4)+T_String            : return NotAConstant;   
77         //          case (T_long<<4)+T_Object            : return NotAConstant;   
78                     case (T_long<<4)+T_double            : return Constant.fromValue((long)this.doubleValue());   
79                     case (T_long<<4)+T_float             : return Constant.fromValue((long)this.floatValue());  
80         //          case (T_long<<4)+T_boolean           : return NotAConstant;   
81                     case (T_long<<4)+T_char              : return Constant.fromValue((long)this.charValue()); 
82                     case (T_long<<4)+T_int               : return Constant.fromValue((long)this.intValue()); 
83         
84         //          case (T_short<<4)+T_undefined        : return NotAConstant;   
85                     case (T_short<<4)+T_byte             : return Constant.fromValue((short)this.byteValue());
86                     case (T_short<<4)+T_long             : return Constant.fromValue((short)this.longValue()); 
87                     case (T_short<<4)+T_short            : return this;  
88         //          case (T_short<<4)+T_void             : return NotAConstant;   
89         //          case (T_short<<4)+T_String           : return NotAConstant;   
90         //          case (T_short<<4)+T_Object           : return NotAConstant;   
91                     case (T_short<<4)+T_double           : return Constant.fromValue((short)this.doubleValue());   
92                     case (T_short<<4)+T_float            : return Constant.fromValue((short)this.floatValue());   
93         //          case (T_short<<4)+T_boolean          : return NotAConstant;   
94                     case (T_short<<4)+T_char             : return Constant.fromValue((short)this.charValue());  
95                     case (T_short<<4)+T_int              : return Constant.fromValue((short)this.intValue());  
96         
97         //          case (T_void<<4)+T_undefined         : return NotAConstant;   
98         //          case (T_void<<4)+T_byte              : return NotAConstant;   
99         //          case (T_void<<4)+T_long              : return NotAConstant;   
100         //          case (T_void<<4)+T_short             : return NotAConstant;   
101         //          case (T_void<<4)+T_void              : return NotAConstant;   
102         //          case (T_void<<4)+T_String            : return NotAConstant;   
103         //          case (T_void<<4)+T_Object            : return NotAConstant;   
104         //          case (T_void<<4)+T_double            : return NotAConstant;   
105         //          case (T_void<<4)+T_float             : return NotAConstant;   
106         //          case (T_void<<4)+T_boolean           : return NotAConstant;   
107         //          case (T_void<<4)+T_char              : return NotAConstant;   
108         //          case (T_void<<4)+T_int               : return NotAConstant;   
109         
110         //          case (T_String<<4)+T_undefined   : return NotAConstant;   
111         //          case (T_String<<4)+T_byte            : return NotAConstant;   
112         //          case (T_String<<4)+T_long            : return NotAConstant;   
113         //          case (T_String<<4)+T_short           : return NotAConstant;   
114         //          case (T_String<<4)+T_void            : return NotAConstant;   
115                     case (T_String<<4)+T_String          : return this;   
116         //          case (T_String<<4)+T_Object          : return NotAConstant;   
117         //          case (T_String<<4)+T_double          : return NotAConstant;   
118         //          case (T_String<<4)+T_float           : return NotAConstant;   
119         //          case (T_String<<4)+T_boolean         : return NotAConstant;   
120         //          case (T_String<<4)+T_char            : return NotAConstant;   
121         //          case (T_String<<4)+T_int             : return NotAConstant;   
122         
123         //          case (T_Object<<4)+T_undefined      : return NotAConstant;   
124         //          case (T_Object<<4)+T_byte                   : return NotAConstant;   
125         //          case (T_Object<<4)+T_long                   : return NotAConstant;   
126         //          case (T_Object<<4)+T_short                  : return NotAConstant;   
127         //          case (T_Object<<4)+T_void                   : return NotAConstant;   
128         //          case (T_Object<<4)+T_String                 : return NotAConstant;   
129         //          case (T_Object<<4)+T_Object                 : return NotAConstant;   
130         //          case (T_Object<<4)+T_double                 : return NotAConstant;   
131         //          case (T_Object<<4)+T_float                  : return NotAConstant;   
132         //          case (T_Object<<4)+T_boolean                : return NotAConstant;   
133         //          case (T_Object<<4)+T_char                   : return NotAConstant;   
134         //          case (T_Object<<4)+T_int                    : return NotAConstant;   
135         
136         //          case (T_double<<4)+T_undefined      : return NotAConstant;   
137                     case (T_double<<4)+T_byte                   : return Constant.fromValue((double)this.byteValue());   
138                     case (T_double<<4)+T_long                   : return Constant.fromValue((double)this.longValue());   
139                     case (T_double<<4)+T_short                  : return Constant.fromValue((double)this.shortValue());   
140         //          case (T_double<<4)+T_void                   : return NotAConstant;   
141         //          case (T_double<<4)+T_String                 : return NotAConstant;   
142         //          case (T_double<<4)+T_Object                 : return NotAConstant;   
143                     case (T_double<<4)+T_double                 : return this;   
144                     case (T_double<<4)+T_float                  : return Constant.fromValue((double)this.floatValue());   
145         //          case (T_double<<4)+T_boolean                : return NotAConstant;   
146                     case (T_double<<4)+T_char                   : return Constant.fromValue((double)this.charValue());   
147                     case (T_double<<4)+T_int                    : return Constant.fromValue((double)this.intValue());  
148         
149         //          case (T_float<<4)+T_undefined        : return NotAConstant;   
150                     case (T_float<<4)+T_byte             : return Constant.fromValue((float)this.byteValue());   
151                     case (T_float<<4)+T_long             : return Constant.fromValue((float)this.longValue());   
152                     case (T_float<<4)+T_short            : return Constant.fromValue((float)this.shortValue());   
153         //          case (T_float<<4)+T_void             : return NotAConstant;   
154         //          case (T_float<<4)+T_String           : return NotAConstant;   
155         //          case (T_float<<4)+T_Object           : return NotAConstant;   
156                     case (T_float<<4)+T_double           : return Constant.fromValue((float)this.doubleValue());   
157                     case (T_float<<4)+T_float            : return this;   
158         //          case (T_float<<4)+T_boolean          : return NotAConstant;   
159                     case (T_float<<4)+T_char             : return Constant.fromValue((float)this.charValue());   
160                     case (T_float<<4)+T_int              : return Constant.fromValue((float)this.intValue());   
161         
162         //          case (T_boolean<<4)+T_undefined              : return NotAConstant;   
163         //          case (T_boolean<<4)+T_byte                           : return NotAConstant;   
164         //          case (T_boolean<<4)+T_long                           : return NotAConstant;   
165         //          case (T_boolean<<4)+T_short                          : return NotAConstant;   
166         //          case (T_boolean<<4)+T_void                           : return NotAConstant;   
167         //          case (T_boolean<<4)+T_String                         : return NotAConstant;   
168         //          case (T_boolean<<4)+T_Object                         : return NotAConstant;   
169         //          case (T_boolean<<4)+T_double                         : return NotAConstant;   
170         //          case (T_boolean<<4)+T_float                          : return NotAConstant;   
171                     case (T_boolean<<4)+T_boolean                        : return this;  
172         //          case (T_boolean<<4)+T_char                           : return NotAConstant;   
173         //          case (T_boolean<<4)+T_int                            : return NotAConstant;   
174                 
175         //          case (T_char<<4)+T_undefined         : return NotAConstant;   
176                     case (T_char<<4)+T_byte              : return Constant.fromValue((char)this.byteValue());  
177                     case (T_char<<4)+T_long              : return Constant.fromValue((char)this.longValue());  
178                     case (T_char<<4)+T_short             : return Constant.fromValue((char)this.shortValue());  
179         //          case (T_char<<4)+T_void              : return NotAConstant;   
180         //          case (T_char<<4)+T_String            : return NotAConstant;   
181         //          case (T_char<<4)+T_Object            : return NotAConstant;   
182                     case (T_char<<4)+T_double            : return Constant.fromValue((char)this.doubleValue());   
183                     case (T_char<<4)+T_float             : return Constant.fromValue((char)this.floatValue());   
184         //          case (T_char<<4)+T_boolean           : return NotAConstant;   
185                     case (T_char<<4)+T_char              : return this;  
186                     case (T_char<<4)+T_int               : return Constant.fromValue((char)this.intValue());  
187                 
188         //          case (T_int<<4)+T_undefined          : return NotAConstant;   
189                     case (T_int<<4)+T_byte               : return Constant.fromValue((int)this.byteValue());  
190                     case (T_int<<4)+T_long               : return Constant.fromValue((int)this.longValue());  
191                     case (T_int<<4)+T_short              : return Constant.fromValue((int)this.shortValue());  
192         //          case (T_int<<4)+T_void               : return NotAConstant;   
193         //          case (T_int<<4)+T_String             : return NotAConstant;   
194         //          case (T_int<<4)+T_Object             : return NotAConstant;   
195                     case (T_int<<4)+T_double             : return Constant.fromValue((int)this.doubleValue());   
196                     case (T_int<<4)+T_float              : return Constant.fromValue((int)this.floatValue());   
197         //          case (T_int<<4)+T_boolean            : return NotAConstant;   
198                     case (T_int<<4)+T_char               : return Constant.fromValue((int)this.charValue());  
199                     case (T_int<<4)+T_int                        : return this;  
200         
201                 }
202         
203                 return NotAConstant;
204         }
205         
206         public char charValue() {
207                 
208                 throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto",typeName(),"char")); //$NON-NLS-1$ //$NON-NLS-2$
209         }
210         
211         public static final Constant computeConstantOperation(Constant cst, int id, int operator) {
212
213                 switch (operator) {
214                         case NOT        :       
215                                                         return Constant.fromValue(!cst.booleanValue());
216                         case PLUS       :       return cst; 
217                         case MINUS      :       //the two special -9223372036854775808L and -2147483648 are inlined at parseTime
218                                                         switch (id){
219                                                                 case T_float  : float f;
220                                                                                                 if ( (f= cst.floatValue()) == 0.0f)
221                                                                                                 { //positive and negative 0....
222                                                                                                         if (Float.floatToIntBits(f) == 0)
223                                                                                                                 return Constant.fromValue(-0.0f);
224                                                                                                         else
225                                                                                                                 return Constant.fromValue(0.0f);}
226                                                                                                 break; //default case
227                                                                 case T_double : double d;
228                                                                                                 if ( (d= cst.doubleValue()) == 0.0d)
229                                                                                                 { //positive and negative 0....
230                                                                                                         if (Double.doubleToLongBits(d) == 0)
231                                                                                                                 return Constant.fromValue(-0.0d);
232                                                                                                         else
233                                                                                                                 return Constant.fromValue(0.0d);}
234                                                                                                 break; //default case
235                                                         }
236                                                         return computeConstantOperationMINUS(Zero,T_int,operator,cst,id);
237                         case TWIDDLE:   
238                                 switch (id){
239                                         case T_char :   return Constant.fromValue(~ cst.charValue());
240                                         case T_byte:    return Constant.fromValue(~ cst.byteValue());
241                                         case T_short:   return Constant.fromValue(~ cst.shortValue());
242                                         case T_int:             return Constant.fromValue(~ cst.intValue());
243                                         case T_long:    return Constant.fromValue(~ cst.longValue());
244                                         default : return NotAConstant;
245                                 } 
246                         default : return NotAConstant;
247                 }
248         } 
249
250         public static final Constant computeConstantOperation(Constant left, int leftId, int operator, Constant right, int rightId) {
251
252                 switch (operator) {
253                         case AND                : return computeConstantOperationAND            (left,leftId,operator,right,rightId);
254                         case AND_AND    : return computeConstantOperationAND_AND        (left,leftId,operator,right,rightId);
255                         case DIVIDE     : return computeConstantOperationDIVIDE         (left,leftId,operator,right,rightId);
256                         case GREATER    : return computeConstantOperationGREATER        (left,leftId,operator,right,rightId);
257                         case GREATER_EQUAL      : return computeConstantOperationGREATER_EQUAL(left,leftId,operator,right,rightId);
258                         case LEFT_SHIFT : return computeConstantOperationLEFT_SHIFT     (left,leftId,operator,right,rightId);
259                         case LESS               : return computeConstantOperationLESS           (left,leftId,operator,right,rightId);
260                         case LESS_EQUAL : return computeConstantOperationLESS_EQUAL     (left,leftId,operator,right,rightId);
261                         case MINUS              : return computeConstantOperationMINUS          (left,leftId,operator,right,rightId);
262                         case MULTIPLY   : return computeConstantOperationMULTIPLY       (left,leftId,operator,right,rightId);
263                         case OR                 : return computeConstantOperationOR                     (left,leftId,operator,right,rightId);
264                         case OR_OR              : return computeConstantOperationOR_OR          (left,leftId,operator,right,rightId);
265                         case PLUS               : return computeConstantOperationPLUS           (left,leftId,operator,right,rightId);
266                         case REMAINDER  : return computeConstantOperationREMAINDER      (left,leftId,operator,right,rightId);
267                         case RIGHT_SHIFT: return computeConstantOperationRIGHT_SHIFT(left,leftId,operator,right,rightId);
268                         case UNSIGNED_RIGHT_SHIFT: return computeConstantOperationUNSIGNED_RIGHT_SHIFT(left,leftId,operator,right,rightId);
269                         case XOR                : return computeConstantOperationXOR            (left,leftId,operator,right,rightId);
270         
271                         default : return NotAConstant;
272                 }
273         }
274         
275         public static final Constant computeConstantOperationAND(Constant left, int leftId, int operator, Constant right, int rightId) {
276                 
277                 switch (leftId){
278                         case T_boolean :                return Constant.fromValue(left.booleanValue() & right.booleanValue());
279                         case T_char :
280                                 switch (rightId){
281                                         case T_char :   return Constant.fromValue(left.charValue() & right.charValue());
282                                         case T_byte:    return Constant.fromValue(left.charValue() & right.byteValue());
283                                         case T_short:   return Constant.fromValue(left.charValue() & right.shortValue());
284                                         case T_int:             return Constant.fromValue(left.charValue() & right.intValue());
285                                         case T_long:    return Constant.fromValue(left.charValue() & right.longValue());
286                                 }
287                         break;
288                         case T_byte :
289                                 switch (rightId){
290                                         case T_char :   return Constant.fromValue(left.byteValue() & right.charValue());
291                                         case T_byte:    return Constant.fromValue(left.byteValue() & right.byteValue());
292                                         case T_short:   return Constant.fromValue(left.byteValue() & right.shortValue());
293                                         case T_int:             return Constant.fromValue(left.byteValue() & right.intValue());
294                                         case T_long:    return Constant.fromValue(left.byteValue() & right.longValue());
295                                 }
296                         break;
297                         case T_short :
298                                 switch (rightId){
299                                         case T_char :   return Constant.fromValue(left.shortValue() & right.charValue());
300                                         case T_byte:    return Constant.fromValue(left.shortValue() & right.byteValue());
301                                         case T_short:   return Constant.fromValue(left.shortValue() & right.shortValue());
302                                         case T_int:             return Constant.fromValue(left.shortValue() & right.intValue());
303                                         case T_long:    return Constant.fromValue(left.shortValue() & right.longValue());
304                                 }
305                         break;
306                         case T_int :
307                                 switch (rightId){
308                                         case T_char :   return Constant.fromValue(left.intValue() & right.charValue());
309                                         case T_byte:    return Constant.fromValue(left.intValue() & right.byteValue());
310                                         case T_short:   return Constant.fromValue(left.intValue() & right.shortValue());
311                                         case T_int:             return Constant.fromValue(left.intValue() & right.intValue());
312                                         case T_long:    return Constant.fromValue(left.intValue() & right.longValue());
313                                 }
314                         break;
315                         case T_long :
316                                 switch (rightId){
317                                         case T_char :   return Constant.fromValue(left.longValue() & right.charValue());
318                                         case T_byte:    return Constant.fromValue(left.longValue() & right.byteValue());
319                                         case T_short:   return Constant.fromValue(left.longValue() & right.shortValue());
320                                         case T_int:             return Constant.fromValue(left.longValue() & right.intValue());
321                                         case T_long:    return Constant.fromValue(left.longValue() & right.longValue());
322                                 }
323                         }
324                 
325                 return NotAConstant;
326         } 
327                 
328         public static final Constant computeConstantOperationAND_AND(Constant left, int leftId, int operator, Constant right, int rightId) {
329         
330                 return Constant.fromValue(left.booleanValue() && right.booleanValue());
331         }
332                 
333         public static final Constant computeConstantOperationDIVIDE(Constant left, int leftId, int operator, Constant right, int rightId) {
334                 // division by zero must be handled outside this method (error reporting)
335         
336                 switch (leftId){
337                         case T_char :
338                                 switch (rightId){
339                                         case T_char :   return Constant.fromValue(left.charValue() / right.charValue());
340                                         case T_float:   return Constant.fromValue(left.charValue() / right.floatValue());
341                                         case T_double:  return Constant.fromValue(left.charValue() / right.doubleValue());
342                                         case T_byte:    return Constant.fromValue(left.charValue() / right.byteValue());
343                                         case T_short:   return Constant.fromValue(left.charValue() / right.shortValue());
344                                         case T_int:             return Constant.fromValue(left.charValue() / right.intValue());
345                                         case T_long:    return Constant.fromValue(left.charValue() / right.longValue());
346                                 }
347                         break;
348                         case T_float :
349                                 switch (rightId){
350                                         case T_char :   return Constant.fromValue(left.floatValue() / right.charValue());
351                                         case T_float:   return Constant.fromValue(left.floatValue() / right.floatValue());
352                                         case T_double:  return Constant.fromValue(left.floatValue() / right.doubleValue());
353                                         case T_byte:    return Constant.fromValue(left.floatValue() / right.byteValue());
354                                         case T_short:   return Constant.fromValue(left.floatValue() / right.shortValue());
355                                         case T_int:             return Constant.fromValue(left.floatValue() / right.intValue());
356                                         case T_long:    return Constant.fromValue(left.floatValue() / right.longValue());
357                                 }
358                         break;
359                         case T_double :
360                                 switch (rightId){
361                                         case T_char :   return Constant.fromValue(left.doubleValue() / right.charValue());
362                                         case T_float:   return Constant.fromValue(left.doubleValue() / right.floatValue());
363                                         case T_double:  return Constant.fromValue(left.doubleValue() / right.doubleValue());
364                                         case T_byte:    return Constant.fromValue(left.doubleValue() / right.byteValue());
365                                         case T_short:   return Constant.fromValue(left.doubleValue() / right.shortValue());
366                                         case T_int:             return Constant.fromValue(left.doubleValue() / right.intValue());
367                                         case T_long:    return Constant.fromValue(left.doubleValue() / right.longValue());
368                                 }
369                         break;
370                         case T_byte :
371                                 switch (rightId){
372                                         case T_char :   return Constant.fromValue(left.byteValue() / right.charValue());
373                                         case T_float:   return Constant.fromValue(left.byteValue() / right.floatValue());
374                                         case T_double:  return Constant.fromValue(left.byteValue() / right.doubleValue());
375                                         case T_byte:    return Constant.fromValue(left.byteValue() / right.byteValue());
376                                         case T_short:   return Constant.fromValue(left.byteValue() / right.shortValue());
377                                         case T_int:             return Constant.fromValue(left.byteValue() / right.intValue());
378                                         case T_long:    return Constant.fromValue(left.byteValue() / right.longValue());
379                                 }
380                         break;
381                         case T_short :
382                                 switch (rightId){
383                                         case T_char :   return Constant.fromValue(left.shortValue() / right.charValue());
384                                         case T_float:   return Constant.fromValue(left.shortValue() / right.floatValue());
385                                         case T_double:  return Constant.fromValue(left.shortValue() / right.doubleValue());
386                                         case T_byte:    return Constant.fromValue(left.shortValue() / right.byteValue());
387                                         case T_short:   return Constant.fromValue(left.shortValue() / right.shortValue());
388                                         case T_int:             return Constant.fromValue(left.shortValue() / right.intValue());
389                                         case T_long:    return Constant.fromValue(left.shortValue() / right.longValue());
390                                 }
391                         break;
392                         case T_int :
393                                 switch (rightId){
394                                         case T_char :   return Constant.fromValue(left.intValue() / right.charValue());
395                                         case T_float:   return Constant.fromValue(left.intValue() / right.floatValue());
396                                         case T_double:  return Constant.fromValue(left.intValue() / right.doubleValue());
397                                         case T_byte:    return Constant.fromValue(left.intValue() / right.byteValue());
398                                         case T_short:   return Constant.fromValue(left.intValue() / right.shortValue());
399                                         case T_int:             return Constant.fromValue(left.intValue() / right.intValue());
400                                         case T_long:    return Constant.fromValue(left.intValue() / right.longValue());
401                                 }
402                         break;
403                         case T_long :
404                                 switch (rightId){
405                                         case T_char :   return Constant.fromValue(left.longValue() / right.charValue());
406                                         case T_float:   return Constant.fromValue(left.longValue() / right.floatValue());
407                                         case T_double:  return Constant.fromValue(left.longValue() / right.doubleValue());
408                                         case T_byte:    return Constant.fromValue(left.longValue() / right.byteValue());
409                                         case T_short:   return Constant.fromValue(left.longValue() / right.shortValue());
410                                         case T_int:             return Constant.fromValue(left.longValue() / right.intValue());
411                                         case T_long:    return Constant.fromValue(left.longValue() / right.longValue());
412                                 }
413         
414                         }
415                 
416                 return NotAConstant;
417         } 
418                 
419         public static final Constant computeConstantOperationEQUAL_EQUAL(Constant left, int leftId, int operator, Constant right, int rightId) {
420                 
421                 switch (leftId){
422                         case T_boolean :
423                                 if (rightId == T_boolean) {
424                                         return Constant.fromValue(left.booleanValue() == right.booleanValue());
425                                 }
426                         break;
427                         case T_char :
428                                 switch (rightId){
429                                         case T_char :   return Constant.fromValue(left.charValue() == right.charValue());
430                                         case T_float:   return Constant.fromValue(left.charValue() == right.floatValue());
431                                         case T_double:  return Constant.fromValue(left.charValue() == right.doubleValue());
432                                         case T_byte:    return Constant.fromValue(left.charValue() == right.byteValue());
433                                         case T_short:   return Constant.fromValue(left.charValue() == right.shortValue());
434                                         case T_int:             return Constant.fromValue(left.charValue() == right.intValue());
435                                         case T_long:    return Constant.fromValue(left.charValue() == right.longValue());}
436                         break;
437                         case T_float :
438                                 switch (rightId){
439                                         case T_char :   return Constant.fromValue(left.floatValue() == right.charValue());
440                                         case T_float:   return Constant.fromValue(left.floatValue() == right.floatValue());
441                                         case T_double:  return Constant.fromValue(left.floatValue() == right.doubleValue());
442                                         case T_byte:    return Constant.fromValue(left.floatValue() == right.byteValue());
443                                         case T_short:   return Constant.fromValue(left.floatValue() == right.shortValue());
444                                         case T_int:             return Constant.fromValue(left.floatValue() == right.intValue());
445                                         case T_long:    return Constant.fromValue(left.floatValue() == right.longValue());
446                                 }
447                         break;
448                         case T_double :
449                                 switch (rightId){
450                                         case T_char :   return Constant.fromValue(left.doubleValue() == right.charValue());
451                                         case T_float:   return Constant.fromValue(left.doubleValue() == right.floatValue());
452                                         case T_double:  return Constant.fromValue(left.doubleValue() == right.doubleValue());
453                                         case T_byte:    return Constant.fromValue(left.doubleValue() == right.byteValue());
454                                         case T_short:   return Constant.fromValue(left.doubleValue() == right.shortValue());
455                                         case T_int:             return Constant.fromValue(left.doubleValue() == right.intValue());
456                                         case T_long:    return Constant.fromValue(left.doubleValue() == right.longValue());
457                                 }
458                         break;
459                         case T_byte :
460                                 switch (rightId){
461                                         case T_char :   return Constant.fromValue(left.byteValue() == right.charValue());
462                                         case T_float:   return Constant.fromValue(left.byteValue() == right.floatValue());
463                                         case T_double:  return Constant.fromValue(left.byteValue() == right.doubleValue());
464                                         case T_byte:    return Constant.fromValue(left.byteValue() == right.byteValue());
465                                         case T_short:   return Constant.fromValue(left.byteValue() == right.shortValue());
466                                         case T_int:             return Constant.fromValue(left.byteValue() == right.intValue());
467                                         case T_long:    return Constant.fromValue(left.byteValue() == right.longValue());
468                                 }
469                         break;                  
470                         case T_short :
471                                 switch (rightId){
472                                         case T_char :   return Constant.fromValue(left.shortValue() == right.charValue());
473                                         case T_float:   return Constant.fromValue(left.shortValue() == right.floatValue());
474                                         case T_double:  return Constant.fromValue(left.shortValue() == right.doubleValue());
475                                         case T_byte:    return Constant.fromValue(left.shortValue() == right.byteValue());
476                                         case T_short:   return Constant.fromValue(left.shortValue() == right.shortValue());
477                                         case T_int:             return Constant.fromValue(left.shortValue() == right.intValue());
478                                         case T_long:    return Constant.fromValue(left.shortValue() == right.longValue());
479                                 }
480                         break;
481                         case T_int :
482                                 switch (rightId){
483                                         case T_char :   return Constant.fromValue(left.intValue() == right.charValue());
484                                         case T_float:   return Constant.fromValue(left.intValue() == right.floatValue());
485                                         case T_double:  return Constant.fromValue(left.intValue() == right.doubleValue());
486                                         case T_byte:    return Constant.fromValue(left.intValue() == right.byteValue());
487                                         case T_short:   return Constant.fromValue(left.intValue() == right.shortValue());
488                                         case T_int:             return Constant.fromValue(left.intValue() == right.intValue());
489                                         case T_long:    return Constant.fromValue(left.intValue() == right.longValue());
490                                 }
491                         break;          
492                         case T_long :
493                                 switch (rightId){
494                                         case T_char :   return Constant.fromValue(left.longValue() == right.charValue());
495                                         case T_float:   return Constant.fromValue(left.longValue() == right.floatValue());
496                                         case T_double:  return Constant.fromValue(left.longValue() == right.doubleValue());
497                                         case T_byte:    return Constant.fromValue(left.longValue() == right.byteValue());
498                                         case T_short:   return Constant.fromValue(left.longValue() == right.shortValue());
499                                         case T_int:             return Constant.fromValue(left.longValue() == right.intValue());
500                                         case T_long:    return Constant.fromValue(left.longValue() == right.longValue());
501                                 }
502                         break;
503                         case T_String :
504                                 if (rightId == T_String) {
505                                         //String are interned in th compiler==>thus if two string constant
506                                         //get to be compared, it is an equal on the vale which is done
507                                         return Constant.fromValue(((StringConstant)left).compileTimeEqual((StringConstant)right));
508                                 }
509                         break;  
510                         case T_null :
511                                 if (rightId == T_String) { 
512                                         return Constant.fromValue(false);
513                                 } else {
514                                         if (rightId == T_null) { 
515                                                 return Constant.fromValue(true);
516                                         }
517                                 }
518                         }
519                 
520                 return Constant.fromValue(false);
521         }
522                 
523         public static final Constant computeConstantOperationGREATER(Constant left, int leftId, int operator, Constant right, int rightId) {
524                 
525                 switch (leftId){
526                         case T_char : 
527                                 switch (rightId){
528                                         case T_char :   return Constant.fromValue(left.charValue() > right.charValue());
529                                         case T_float:   return Constant.fromValue(left.charValue() > right.floatValue());
530                                         case T_double:  return Constant.fromValue(left.charValue() > right.doubleValue());
531                                         case T_byte:    return Constant.fromValue(left.charValue() > right.byteValue());
532                                         case T_short:   return Constant.fromValue(left.charValue() > right.shortValue());
533                                         case T_int:             return Constant.fromValue(left.charValue() > right.intValue());
534                                         case T_long:    return Constant.fromValue(left.charValue() > right.longValue());
535                                 }
536                         break;
537                         case T_float :
538                                 switch (rightId){
539                                         case T_char :   return Constant.fromValue(left.floatValue() > right.charValue());
540                                         case T_float:   return Constant.fromValue(left.floatValue() > right.floatValue());
541                                         case T_double:  return Constant.fromValue(left.floatValue() > right.doubleValue());
542                                         case T_byte:    return Constant.fromValue(left.floatValue() > right.byteValue());
543                                         case T_short:   return Constant.fromValue(left.floatValue() > right.shortValue());
544                                         case T_int:             return Constant.fromValue(left.floatValue() > right.intValue());
545                                         case T_long:    return Constant.fromValue(left.floatValue() > right.longValue());
546                                 }
547                         break;
548                         case T_double :
549                                 switch (rightId){
550                                         case T_char :   return Constant.fromValue(left.doubleValue() > right.charValue());
551                                         case T_float:   return Constant.fromValue(left.doubleValue() > right.floatValue());
552                                         case T_double:  return Constant.fromValue(left.doubleValue() > right.doubleValue());
553                                         case T_byte:    return Constant.fromValue(left.doubleValue() > right.byteValue());
554                                         case T_short:   return Constant.fromValue(left.doubleValue() > right.shortValue());
555                                         case T_int:             return Constant.fromValue(left.doubleValue() > right.intValue());
556                                         case T_long:    return Constant.fromValue(left.doubleValue() > right.longValue());
557                                 }
558                         break;
559                         case T_byte :
560                                 switch (rightId){
561                                         case T_char :   return Constant.fromValue(left.byteValue() > right.charValue());
562                                         case T_float:   return Constant.fromValue(left.byteValue() > right.floatValue());
563                                         case T_double:  return Constant.fromValue(left.byteValue() > right.doubleValue());
564                                         case T_byte:    return Constant.fromValue(left.byteValue() > right.byteValue());
565                                         case T_short:   return Constant.fromValue(left.byteValue() > right.shortValue());
566                                         case T_int:             return Constant.fromValue(left.byteValue() > right.intValue());
567                                         case T_long:    return Constant.fromValue(left.byteValue() > right.longValue());
568                                 }
569                         break;                  
570                         case T_short :
571                                 switch (rightId){
572                                         case T_char :   return Constant.fromValue(left.shortValue() > right.charValue());
573                                         case T_float:   return Constant.fromValue(left.shortValue() > right.floatValue());
574                                         case T_double:  return Constant.fromValue(left.shortValue() > right.doubleValue());
575                                         case T_byte:    return Constant.fromValue(left.shortValue() > right.byteValue());
576                                         case T_short:   return Constant.fromValue(left.shortValue() > right.shortValue());
577                                         case T_int:             return Constant.fromValue(left.shortValue() > right.intValue());
578                                         case T_long:    return Constant.fromValue(left.shortValue() > right.longValue());
579                                 }
580                         break;
581                         case T_int :
582                                 switch (rightId){
583                                         case T_char :   return Constant.fromValue(left.intValue() > right.charValue());
584                                         case T_float:   return Constant.fromValue(left.intValue() > right.floatValue());
585                                         case T_double:  return Constant.fromValue(left.intValue() > right.doubleValue());
586                                         case T_byte:    return Constant.fromValue(left.intValue() > right.byteValue());
587                                         case T_short:   return Constant.fromValue(left.intValue() > right.shortValue());
588                                         case T_int:             return Constant.fromValue(left.intValue() > right.intValue());
589                                         case T_long:    return Constant.fromValue(left.intValue() > right.longValue());
590                                 }
591                         break;          
592                         case T_long :
593                                 switch (rightId){
594                                         case T_char :   return Constant.fromValue(left.longValue() > right.charValue());
595                                         case T_float:   return Constant.fromValue(left.longValue() > right.floatValue());
596                                         case T_double:  return Constant.fromValue(left.longValue() > right.doubleValue());
597                                         case T_byte:    return Constant.fromValue(left.longValue() > right.byteValue());
598                                         case T_short:   return Constant.fromValue(left.longValue() > right.shortValue());
599                                         case T_int:             return Constant.fromValue(left.longValue() > right.intValue());
600                                         case T_long:    return Constant.fromValue(left.longValue() > right.longValue());
601                                 }
602                                 
603                         }
604                 
605                 return NotAConstant;
606         }
607
608         public static final Constant computeConstantOperationGREATER_EQUAL(Constant left, int leftId, int operator, Constant right, int rightId) {
609                 
610                 switch (leftId){
611                         case T_char : 
612                                 switch (rightId){
613                                         case T_char :   return Constant.fromValue(left.charValue() >= right.charValue());
614                                         case T_float:   return Constant.fromValue(left.charValue() >= right.floatValue());
615                                         case T_double:  return Constant.fromValue(left.charValue() >= right.doubleValue());
616                                         case T_byte:    return Constant.fromValue(left.charValue() >= right.byteValue());
617                                         case T_short:   return Constant.fromValue(left.charValue() >= right.shortValue());
618                                         case T_int:             return Constant.fromValue(left.charValue() >= right.intValue());
619                                         case T_long:    return Constant.fromValue(left.charValue() >= right.longValue());
620                                 }
621                         break;
622                         case T_float :
623                                 switch (rightId){
624                                         case T_char :   return Constant.fromValue(left.floatValue() >= right.charValue());
625                                         case T_float:   return Constant.fromValue(left.floatValue() >= right.floatValue());
626                                         case T_double:  return Constant.fromValue(left.floatValue() >= right.doubleValue());
627                                         case T_byte:    return Constant.fromValue(left.floatValue() >= right.byteValue());
628                                         case T_short:   return Constant.fromValue(left.floatValue() >= right.shortValue());
629                                         case T_int:             return Constant.fromValue(left.floatValue() >= right.intValue());
630                                         case T_long:    return Constant.fromValue(left.floatValue() >= right.longValue());
631                                 }
632                         break;
633                         case T_double :
634                                 switch (rightId){
635                                         case T_char :   return Constant.fromValue(left.doubleValue() >= right.charValue());
636                                         case T_float:   return Constant.fromValue(left.doubleValue() >= right.floatValue());
637                                         case T_double:  return Constant.fromValue(left.doubleValue() >= right.doubleValue());
638                                         case T_byte:    return Constant.fromValue(left.doubleValue() >= right.byteValue());
639                                         case T_short:   return Constant.fromValue(left.doubleValue() >= right.shortValue());
640                                         case T_int:             return Constant.fromValue(left.doubleValue() >= right.intValue());
641                                         case T_long:    return Constant.fromValue(left.doubleValue() >= right.longValue());
642                                 }
643                         break;
644                         case T_byte :
645                                 switch (rightId){
646                                         case T_char :   return Constant.fromValue(left.byteValue() >= right.charValue());
647                                         case T_float:   return Constant.fromValue(left.byteValue() >= right.floatValue());
648                                         case T_double:  return Constant.fromValue(left.byteValue() >= right.doubleValue());
649                                         case T_byte:    return Constant.fromValue(left.byteValue() >= right.byteValue());
650                                         case T_short:   return Constant.fromValue(left.byteValue() >= right.shortValue());
651                                         case T_int:             return Constant.fromValue(left.byteValue() >= right.intValue());
652                                         case T_long:    return Constant.fromValue(left.byteValue() >= right.longValue());
653                                 }
654                         break;                  
655                         case T_short :
656                                 switch (rightId){
657                                         case T_char :   return Constant.fromValue(left.shortValue() >= right.charValue());
658                                         case T_float:   return Constant.fromValue(left.shortValue() >= right.floatValue());
659                                         case T_double:  return Constant.fromValue(left.shortValue() >= right.doubleValue());
660                                         case T_byte:    return Constant.fromValue(left.shortValue() >= right.byteValue());
661                                         case T_short:   return Constant.fromValue(left.shortValue() >= right.shortValue());
662                                         case T_int:             return Constant.fromValue(left.shortValue() >= right.intValue());
663                                         case T_long:    return Constant.fromValue(left.shortValue() >= right.longValue());
664                                 }
665                         break;
666                         case T_int :
667                                 switch (rightId){
668                                         case T_char :   return Constant.fromValue(left.intValue() >= right.charValue());
669                                         case T_float:   return Constant.fromValue(left.intValue() >= right.floatValue());
670                                         case T_double:  return Constant.fromValue(left.intValue() >= right.doubleValue());
671                                         case T_byte:    return Constant.fromValue(left.intValue() >= right.byteValue());
672                                         case T_short:   return Constant.fromValue(left.intValue() >= right.shortValue());
673                                         case T_int:             return Constant.fromValue(left.intValue() >= right.intValue());
674                                         case T_long:    return Constant.fromValue(left.intValue() >= right.longValue());
675                                 }
676                         break;          
677                         case T_long :
678                                 switch (rightId){
679                                         case T_char :   return Constant.fromValue(left.longValue() >= right.charValue());
680                                         case T_float:   return Constant.fromValue(left.longValue() >= right.floatValue());
681                                         case T_double:  return Constant.fromValue(left.longValue() >= right.doubleValue());
682                                         case T_byte:    return Constant.fromValue(left.longValue() >= right.byteValue());
683                                         case T_short:   return Constant.fromValue(left.longValue() >= right.shortValue());
684                                         case T_int:             return Constant.fromValue(left.longValue() >= right.intValue());
685                                         case T_long:    return Constant.fromValue(left.longValue() >= right.longValue());
686                                 }
687                                 
688                         }
689                 
690                 return NotAConstant;
691         }  
692                 
693         public static final Constant computeConstantOperationLEFT_SHIFT(Constant left, int leftId, int operator, Constant right, int rightId) {
694                 
695                 switch (leftId){
696                         case T_char :
697                                 switch (rightId){
698                                         case T_char :   return Constant.fromValue(left.charValue() << right.charValue());
699                                         case T_byte:    return Constant.fromValue(left.charValue() << right.byteValue());
700                                         case T_short:   return Constant.fromValue(left.charValue() << right.shortValue());
701                                         case T_int:             return Constant.fromValue(left.charValue() << right.intValue());
702                                         case T_long:    return Constant.fromValue(left.charValue() << right.longValue());
703                                 }
704                         break;
705                         case T_byte :
706                                 switch (rightId){
707                                         case T_char :   return Constant.fromValue(left.byteValue() << right.charValue());
708                                         case T_byte:    return Constant.fromValue(left.byteValue() << right.byteValue());
709                                         case T_short:   return Constant.fromValue(left.byteValue() << right.shortValue());
710                                         case T_int:             return Constant.fromValue(left.byteValue() << right.intValue());
711                                         case T_long:    return Constant.fromValue(left.byteValue() << right.longValue());
712                                 }
713                         break;
714                         case T_short :
715                                 switch (rightId){
716                                         case T_char :   return Constant.fromValue(left.shortValue() << right.charValue());
717                                         case T_byte:    return Constant.fromValue(left.shortValue() << right.byteValue());
718                                         case T_short:   return Constant.fromValue(left.shortValue() << right.shortValue());
719                                         case T_int:             return Constant.fromValue(left.shortValue() << right.intValue());
720                                         case T_long:    return Constant.fromValue(left.shortValue() << right.longValue());
721                                 }
722                         break;
723                         case T_int :
724                                 switch (rightId){
725                                         case T_char :   return Constant.fromValue(left.intValue() << right.charValue());
726                                         case T_byte:    return Constant.fromValue(left.intValue() << right.byteValue());
727                                         case T_short:   return Constant.fromValue(left.intValue() << right.shortValue());
728                                         case T_int:             return Constant.fromValue(left.intValue() << right.intValue());
729                                         case T_long:    return Constant.fromValue(left.intValue() << right.longValue());
730                                 }
731                         break;
732                         case T_long :
733                                 switch (rightId){
734                                         case T_char :   return Constant.fromValue(left.longValue() << right.charValue());
735                                         case T_byte:    return Constant.fromValue(left.longValue() << right.byteValue());
736                                         case T_short:   return Constant.fromValue(left.longValue() << right.shortValue());
737                                         case T_int:             return Constant.fromValue(left.longValue() << right.intValue());
738                                         case T_long:    return Constant.fromValue(left.longValue() << right.longValue());
739                                 }
740         
741                         }
742         
743                 return NotAConstant;
744         } 
745                 
746         public static final Constant computeConstantOperationLESS(Constant left, int leftId, int operator, Constant right, int rightId) { 
747                 
748                 switch (leftId){
749                         case T_char : 
750                                 switch (rightId){
751                                         case T_char :   return Constant.fromValue(left.charValue() < right.charValue());
752                                         case T_float:   return Constant.fromValue(left.charValue() < right.floatValue());
753                                         case T_double:  return Constant.fromValue(left.charValue() < right.doubleValue());
754                                         case T_byte:    return Constant.fromValue(left.charValue() < right.byteValue());
755                                         case T_short:   return Constant.fromValue(left.charValue() < right.shortValue());
756                                         case T_int:             return Constant.fromValue(left.charValue() < right.intValue());
757                                         case T_long:    return Constant.fromValue(left.charValue() < right.longValue());
758                                 }
759                         break;
760                         case T_float :
761                                 switch (rightId){
762                                         case T_char :   return Constant.fromValue(left.floatValue() < right.charValue());
763                                         case T_float:   return Constant.fromValue(left.floatValue() < right.floatValue());
764                                         case T_double:  return Constant.fromValue(left.floatValue() < right.doubleValue());
765                                         case T_byte:    return Constant.fromValue(left.floatValue() < right.byteValue());
766                                         case T_short:   return Constant.fromValue(left.floatValue() < right.shortValue());
767                                         case T_int:             return Constant.fromValue(left.floatValue() < right.intValue());
768                                         case T_long:    return Constant.fromValue(left.floatValue() < right.longValue());
769                                 }
770                         break;
771                         case T_double :
772                                 switch (rightId){
773                                         case T_char :   return Constant.fromValue(left.doubleValue() < right.charValue());
774                                         case T_float:   return Constant.fromValue(left.doubleValue() < right.floatValue());
775                                         case T_double:  return Constant.fromValue(left.doubleValue() < right.doubleValue());
776                                         case T_byte:    return Constant.fromValue(left.doubleValue() < right.byteValue());
777                                         case T_short:   return Constant.fromValue(left.doubleValue() < right.shortValue());
778                                         case T_int:             return Constant.fromValue(left.doubleValue() < right.intValue());
779                                         case T_long:    return Constant.fromValue(left.doubleValue() < right.longValue());
780                                 }
781                         break;
782                         case T_byte :
783                                 switch (rightId){
784                                         case T_char :   return Constant.fromValue(left.byteValue() < right.charValue());
785                                         case T_float:   return Constant.fromValue(left.byteValue() < right.floatValue());
786                                         case T_double:  return Constant.fromValue(left.byteValue() < right.doubleValue());
787                                         case T_byte:    return Constant.fromValue(left.byteValue() < right.byteValue());
788                                         case T_short:   return Constant.fromValue(left.byteValue() < right.shortValue());
789                                         case T_int:             return Constant.fromValue(left.byteValue() < right.intValue());
790                                         case T_long:    return Constant.fromValue(left.byteValue() < right.longValue());
791                                 }
792                         break;                  
793                         case T_short :
794                                 switch (rightId){
795                                         case T_char :   return Constant.fromValue(left.shortValue() < right.charValue());
796                                         case T_float:   return Constant.fromValue(left.shortValue() < right.floatValue());
797                                         case T_double:  return Constant.fromValue(left.shortValue() < right.doubleValue());
798                                         case T_byte:    return Constant.fromValue(left.shortValue() < right.byteValue());
799                                         case T_short:   return Constant.fromValue(left.shortValue() < right.shortValue());
800                                         case T_int:             return Constant.fromValue(left.shortValue() < right.intValue());
801                                         case T_long:    return Constant.fromValue(left.shortValue() < right.longValue());
802                                 }
803                         break;
804                         case T_int :
805                                 switch (rightId){
806                                         case T_char :   return Constant.fromValue(left.intValue() < right.charValue());
807                                         case T_float:   return Constant.fromValue(left.intValue() < right.floatValue());
808                                         case T_double:  return Constant.fromValue(left.intValue() < right.doubleValue());
809                                         case T_byte:    return Constant.fromValue(left.intValue() < right.byteValue());
810                                         case T_short:   return Constant.fromValue(left.intValue() < right.shortValue());
811                                         case T_int:             return Constant.fromValue(left.intValue() < right.intValue());
812                                         case T_long:    return Constant.fromValue(left.intValue() < right.longValue());
813                                 }
814                         break;          
815                         case T_long :
816                                 switch (rightId){
817                                         case T_char :   return Constant.fromValue(left.longValue() < right.charValue());
818                                         case T_float:   return Constant.fromValue(left.longValue() < right.floatValue());
819                                         case T_double:  return Constant.fromValue(left.longValue() < right.doubleValue());
820                                         case T_byte:    return Constant.fromValue(left.longValue() < right.byteValue());
821                                         case T_short:   return Constant.fromValue(left.longValue() < right.shortValue());
822                                         case T_int:             return Constant.fromValue(left.longValue() < right.intValue());
823                                         case T_long:    return Constant.fromValue(left.longValue() < right.longValue());
824                                 }
825                                 
826                         }
827                 
828                 return NotAConstant;
829         }
830                 
831         public static final Constant computeConstantOperationLESS_EQUAL(Constant left, int leftId, int operator, Constant right, int rightId) {
832                 
833                 switch (leftId){
834                         case T_char : 
835                                 switch (rightId){
836                                         case T_char :   return Constant.fromValue(left.charValue() <= right.charValue());
837                                         case T_float:   return Constant.fromValue(left.charValue() <= right.floatValue());
838                                         case T_double:  return Constant.fromValue(left.charValue() <= right.doubleValue());
839                                         case T_byte:    return Constant.fromValue(left.charValue() <= right.byteValue());
840                                         case T_short:   return Constant.fromValue(left.charValue() <= right.shortValue());
841                                         case T_int:             return Constant.fromValue(left.charValue() <= right.intValue());
842                                         case T_long:    return Constant.fromValue(left.charValue() <= right.longValue());
843                                 }
844                         break;
845                         case T_float :
846                                 switch (rightId){
847                                         case T_char :   return Constant.fromValue(left.floatValue() <= right.charValue());
848                                         case T_float:   return Constant.fromValue(left.floatValue() <= right.floatValue());
849                                         case T_double:  return Constant.fromValue(left.floatValue() <= right.doubleValue());
850                                         case T_byte:    return Constant.fromValue(left.floatValue() <= right.byteValue());
851                                         case T_short:   return Constant.fromValue(left.floatValue() <= right.shortValue());
852                                         case T_int:             return Constant.fromValue(left.floatValue() <= right.intValue());
853                                         case T_long:    return Constant.fromValue(left.floatValue() <= right.longValue());
854                                 }
855                         break;
856                         case T_double :
857                                 switch (rightId){
858                                         case T_char :   return Constant.fromValue(left.doubleValue() <= right.charValue());
859                                         case T_float:   return Constant.fromValue(left.doubleValue() <= right.floatValue());
860                                         case T_double:  return Constant.fromValue(left.doubleValue() <= right.doubleValue());
861                                         case T_byte:    return Constant.fromValue(left.doubleValue() <= right.byteValue());
862                                         case T_short:   return Constant.fromValue(left.doubleValue() <= right.shortValue());
863                                         case T_int:             return Constant.fromValue(left.doubleValue() <= right.intValue());
864                                         case T_long:    return Constant.fromValue(left.doubleValue() <= right.longValue());
865                                 }
866                         break;
867                         case T_byte :
868                                 switch (rightId){
869                                         case T_char :   return Constant.fromValue(left.byteValue() <= right.charValue());
870                                         case T_float:   return Constant.fromValue(left.byteValue() <= right.floatValue());
871                                         case T_double:  return Constant.fromValue(left.byteValue() <= right.doubleValue());
872                                         case T_byte:    return Constant.fromValue(left.byteValue() <= right.byteValue());
873                                         case T_short:   return Constant.fromValue(left.byteValue() <= right.shortValue());
874                                         case T_int:             return Constant.fromValue(left.byteValue() <= right.intValue());
875                                         case T_long:    return Constant.fromValue(left.byteValue() <= right.longValue());
876                                 }
877                         break;                  
878                         case T_short :
879                                 switch (rightId){
880                                         case T_char :   return Constant.fromValue(left.shortValue() <= right.charValue());
881                                         case T_float:   return Constant.fromValue(left.shortValue() <= right.floatValue());
882                                         case T_double:  return Constant.fromValue(left.shortValue() <= right.doubleValue());
883                                         case T_byte:    return Constant.fromValue(left.shortValue() <= right.byteValue());
884                                         case T_short:   return Constant.fromValue(left.shortValue() <= right.shortValue());
885                                         case T_int:             return Constant.fromValue(left.shortValue() <= right.intValue());
886                                         case T_long:    return Constant.fromValue(left.shortValue() <= right.longValue());
887                                 }
888                         break;
889                         case T_int :
890                                 switch (rightId){
891                                         case T_char :   return Constant.fromValue(left.intValue() <= right.charValue());
892                                         case T_float:   return Constant.fromValue(left.intValue() <= right.floatValue());
893                                         case T_double:  return Constant.fromValue(left.intValue() <= right.doubleValue());
894                                         case T_byte:    return Constant.fromValue(left.intValue() <= right.byteValue());
895                                         case T_short:   return Constant.fromValue(left.intValue() <= right.shortValue());
896                                         case T_int:             return Constant.fromValue(left.intValue() <= right.intValue());
897                                         case T_long:    return Constant.fromValue(left.intValue() <= right.longValue());
898                                 }
899                         break;          
900                         case T_long :
901                                 switch (rightId){
902                                         case T_char :   return Constant.fromValue(left.longValue() <= right.charValue());
903                                         case T_float:   return Constant.fromValue(left.longValue() <= right.floatValue());
904                                         case T_double:  return Constant.fromValue(left.longValue() <= right.doubleValue());
905                                         case T_byte:    return Constant.fromValue(left.longValue() <= right.byteValue());
906                                         case T_short:   return Constant.fromValue(left.longValue() <= right.shortValue());
907                                         case T_int:             return Constant.fromValue(left.longValue() <= right.intValue());
908                                         case T_long:    return Constant.fromValue(left.longValue() <= right.longValue());
909                                 }
910                         }
911                 
912                 return NotAConstant;
913         }  
914         
915         public static final Constant computeConstantOperationMINUS(Constant left, int leftId, int operator, Constant right, int rightId) {
916                 
917                 switch (leftId){
918                         case T_char : 
919                                 switch (rightId){
920                                         case T_char :   return Constant.fromValue(left.charValue() - right.charValue());
921                                         case T_float:   return Constant.fromValue(left.charValue() - right.floatValue());
922                                         case T_double:  return Constant.fromValue(left.charValue() - right.doubleValue());
923                                         case T_byte:    return Constant.fromValue(left.charValue() - right.byteValue());
924                                         case T_short:   return Constant.fromValue(left.charValue() - right.shortValue());
925                                         case T_int:             return Constant.fromValue(left.charValue() - right.intValue());
926                                         case T_long:    return Constant.fromValue(left.charValue() - right.longValue());
927                                 }
928                         break;
929                         case T_float :
930                                 switch (rightId){
931                                         case T_char :   return Constant.fromValue(left.floatValue() - right.charValue());
932                                         case T_float:   return Constant.fromValue(left.floatValue() - right.floatValue());
933                                         case T_double:  return Constant.fromValue(left.floatValue() - right.doubleValue());
934                                         case T_byte:    return Constant.fromValue(left.floatValue() - right.byteValue());
935                                         case T_short:   return Constant.fromValue(left.floatValue() - right.shortValue());
936                                         case T_int:             return Constant.fromValue(left.floatValue() - right.intValue());
937                                         case T_long:    return Constant.fromValue(left.floatValue() - right.longValue());
938                                 }
939                         break;
940                         case T_double :
941                                 switch (rightId){
942                                         case T_char :   return Constant.fromValue(left.doubleValue() - right.charValue());
943                                         case T_float:   return Constant.fromValue(left.doubleValue() - right.floatValue());
944                                         case T_double:  return Constant.fromValue(left.doubleValue() - right.doubleValue());
945                                         case T_byte:    return Constant.fromValue(left.doubleValue() - right.byteValue());
946                                         case T_short:   return Constant.fromValue(left.doubleValue() - right.shortValue());
947                                         case T_int:             return Constant.fromValue(left.doubleValue() - right.intValue());
948                                         case T_long:    return Constant.fromValue(left.doubleValue() - right.longValue());
949                                 }
950                         break;
951                         case T_byte :
952                                 switch (rightId){
953                                         case T_char :   return Constant.fromValue(left.byteValue() - right.charValue());
954                                         case T_float:   return Constant.fromValue(left.byteValue() - right.floatValue());
955                                         case T_double:  return Constant.fromValue(left.byteValue() - right.doubleValue());
956                                         case T_byte:    return Constant.fromValue(left.byteValue() - right.byteValue());
957                                         case T_short:   return Constant.fromValue(left.byteValue() - right.shortValue());
958                                         case T_int:             return Constant.fromValue(left.byteValue() - right.intValue());
959                                         case T_long:    return Constant.fromValue(left.byteValue() - right.longValue());
960                                 }
961                         break;                  
962                         case T_short :
963                                 switch (rightId){
964                                         case T_char :   return Constant.fromValue(left.shortValue() - right.charValue());
965                                         case T_float:   return Constant.fromValue(left.shortValue() - right.floatValue());
966                                         case T_double:  return Constant.fromValue(left.shortValue() - right.doubleValue());
967                                         case T_byte:    return Constant.fromValue(left.shortValue() - right.byteValue());
968                                         case T_short:   return Constant.fromValue(left.shortValue() - right.shortValue());
969                                         case T_int:             return Constant.fromValue(left.shortValue() - right.intValue());
970                                         case T_long:    return Constant.fromValue(left.shortValue() - right.longValue());
971                                 }
972                         break;
973                         case T_int :
974                                 switch (rightId){
975                                         case T_char :   return Constant.fromValue(left.intValue() - right.charValue());
976                                         case T_float:   return Constant.fromValue(left.intValue() - right.floatValue());
977                                         case T_double:  return Constant.fromValue(left.intValue() - right.doubleValue());
978                                         case T_byte:    return Constant.fromValue(left.intValue() - right.byteValue());
979                                         case T_short:   return Constant.fromValue(left.intValue() - right.shortValue());
980                                         case T_int:             return Constant.fromValue(left.intValue() - right.intValue());
981                                         case T_long:    return Constant.fromValue(left.intValue() - right.longValue());
982                                 }
983                         break;          
984                         case T_long :
985                                 switch (rightId){
986                                         case T_char :   return Constant.fromValue(left.longValue() - right.charValue());
987                                         case T_float:   return Constant.fromValue(left.longValue() - right.floatValue());
988                                         case T_double:  return Constant.fromValue(left.longValue() - right.doubleValue());
989                                         case T_byte:    return Constant.fromValue(left.longValue() - right.byteValue());
990                                         case T_short:   return Constant.fromValue(left.longValue() - right.shortValue());
991                                         case T_int:             return Constant.fromValue(left.longValue() - right.intValue());
992                                         case T_long:    return Constant.fromValue(left.longValue() - right.longValue());
993                                 }
994                                 
995                         }
996                 
997                 return NotAConstant;
998         }
999         
1000         public static final Constant computeConstantOperationMULTIPLY(Constant left, int leftId, int operator, Constant right, int rightId) {
1001         
1002                 switch (leftId){
1003                         case T_char :
1004                                 switch (rightId){
1005                                         case T_char :   return Constant.fromValue(left.charValue() * right.charValue());
1006                                         case T_float:   return Constant.fromValue(left.charValue() * right.floatValue());
1007                                         case T_double:  return Constant.fromValue(left.charValue() * right.doubleValue());
1008                                         case T_byte:    return Constant.fromValue(left.charValue() * right.byteValue());
1009                                         case T_short:   return Constant.fromValue(left.charValue() * right.shortValue());
1010                                         case T_int:             return Constant.fromValue(left.charValue() * right.intValue());
1011                                         case T_long:    return Constant.fromValue(left.charValue() * right.longValue());
1012                                 }
1013                         break;
1014                         case T_float :
1015                                 switch (rightId){
1016                                         case T_char :   return Constant.fromValue(left.floatValue() * right.charValue());
1017                                         case T_float:   return Constant.fromValue(left.floatValue() * right.floatValue());
1018                                         case T_double:  return Constant.fromValue(left.floatValue() * right.doubleValue());
1019                                         case T_byte:    return Constant.fromValue(left.floatValue() * right.byteValue());
1020                                         case T_short:   return Constant.fromValue(left.floatValue() * right.shortValue());
1021                                         case T_int:             return Constant.fromValue(left.floatValue() * right.intValue());
1022                                         case T_long:    return Constant.fromValue(left.floatValue() * right.longValue());
1023                                 }
1024                         break;
1025                         case T_double :
1026                                 switch (rightId){
1027                                         case T_char :   return Constant.fromValue(left.doubleValue() * right.charValue());
1028                                         case T_float:   return Constant.fromValue(left.doubleValue() * right.floatValue());
1029                                         case T_double:  return Constant.fromValue(left.doubleValue() * right.doubleValue());
1030                                         case T_byte:    return Constant.fromValue(left.doubleValue() * right.byteValue());
1031                                         case T_short:   return Constant.fromValue(left.doubleValue() * right.shortValue());
1032                                         case T_int:             return Constant.fromValue(left.doubleValue() * right.intValue());
1033                                         case T_long:    return Constant.fromValue(left.doubleValue() * right.longValue());
1034                                 }
1035                         break;
1036                         case T_byte :
1037                                 switch (rightId){
1038                                         case T_char :   return Constant.fromValue(left.byteValue() * right.charValue());
1039                                         case T_float:   return Constant.fromValue(left.byteValue() * right.floatValue());
1040                                         case T_double:  return Constant.fromValue(left.byteValue() * right.doubleValue());
1041                                         case T_byte:    return Constant.fromValue(left.byteValue() * right.byteValue());
1042                                         case T_short:   return Constant.fromValue(left.byteValue() * right.shortValue());
1043                                         case T_int:             return Constant.fromValue(left.byteValue() * right.intValue());
1044                                         case T_long:    return Constant.fromValue(left.byteValue() * right.longValue());
1045                                 }
1046                         break;
1047                         case T_short :
1048                                 switch (rightId){
1049                                         case T_char :   return Constant.fromValue(left.shortValue() * right.charValue());
1050                                         case T_float:   return Constant.fromValue(left.shortValue() * right.floatValue());
1051                                         case T_double:  return Constant.fromValue(left.shortValue() * right.doubleValue());
1052                                         case T_byte:    return Constant.fromValue(left.shortValue() * right.byteValue());
1053                                         case T_short:   return Constant.fromValue(left.shortValue() * right.shortValue());
1054                                         case T_int:             return Constant.fromValue(left.shortValue() * right.intValue());
1055                                         case T_long:    return Constant.fromValue(left.shortValue() * right.longValue());
1056                                 }
1057                         break;
1058                         case T_int :
1059                                 switch (rightId){
1060                                         case T_char :   return Constant.fromValue(left.intValue() * right.charValue());
1061                                         case T_float:   return Constant.fromValue(left.intValue() * right.floatValue());
1062                                         case T_double:  return Constant.fromValue(left.intValue() * right.doubleValue());
1063                                         case T_byte:    return Constant.fromValue(left.intValue() * right.byteValue());
1064                                         case T_short:   return Constant.fromValue(left.intValue() * right.shortValue());
1065                                         case T_int:             return Constant.fromValue(left.intValue() * right.intValue());
1066                                         case T_long:    return Constant.fromValue(left.intValue() * right.longValue());
1067                                 }
1068                         break;
1069                         case T_long :
1070                                 switch (rightId){
1071                                         case T_char :   return Constant.fromValue(left.longValue() * right.charValue());
1072                                         case T_float:   return Constant.fromValue(left.longValue() * right.floatValue());
1073                                         case T_double:  return Constant.fromValue(left.longValue() * right.doubleValue());
1074                                         case T_byte:    return Constant.fromValue(left.longValue() * right.byteValue());
1075                                         case T_short:   return Constant.fromValue(left.longValue() * right.shortValue());
1076                                         case T_int:             return Constant.fromValue(left.longValue() * right.intValue());
1077                                         case T_long:    return Constant.fromValue(left.longValue() * right.longValue());
1078                                 }
1079                         }
1080         
1081                 return NotAConstant;
1082         }
1083         
1084         public static final Constant computeConstantOperationOR(Constant left, int leftId, int operator, Constant right, int rightId) {
1085                 
1086                 switch (leftId){
1087                         case T_boolean :                return Constant.fromValue(left.booleanValue() | right.booleanValue());
1088                         case T_char :
1089                                 switch (rightId){
1090                                         case T_char :   return Constant.fromValue(left.charValue() | right.charValue());
1091                                         case T_byte:    return Constant.fromValue(left.charValue() | right.byteValue());
1092                                         case T_short:   return Constant.fromValue(left.charValue() | right.shortValue());
1093                                         case T_int:             return Constant.fromValue(left.charValue() | right.intValue());
1094                                         case T_long:    return Constant.fromValue(left.charValue() | right.longValue());
1095                                 }
1096                         break;
1097                         case T_byte :
1098                                 switch (rightId){
1099                                         case T_char :   return Constant.fromValue(left.byteValue() | right.charValue());
1100                                         case T_byte:    return Constant.fromValue(left.byteValue() | right.byteValue());
1101                                         case T_short:   return Constant.fromValue(left.byteValue() | right.shortValue());
1102                                         case T_int:             return Constant.fromValue(left.byteValue() | right.intValue());
1103                                         case T_long:    return Constant.fromValue(left.byteValue() | right.longValue());
1104                                 }
1105                         break;
1106                         case T_short :
1107                                 switch (rightId){
1108                                         case T_char :   return Constant.fromValue(left.shortValue() | right.charValue());
1109                                         case T_byte:    return Constant.fromValue(left.shortValue() | right.byteValue());
1110                                         case T_short:   return Constant.fromValue(left.shortValue() | right.shortValue());
1111                                         case T_int:             return Constant.fromValue(left.shortValue() | right.intValue());
1112                                         case T_long:    return Constant.fromValue(left.shortValue() | right.longValue());
1113                                 }
1114                         break;
1115                         case T_int :
1116                                 switch (rightId){
1117                                         case T_char :   return Constant.fromValue(left.intValue() | right.charValue());
1118                                         case T_byte:    return Constant.fromValue(left.intValue() | right.byteValue());
1119                                         case T_short:   return Constant.fromValue(left.intValue() | right.shortValue());
1120                                         case T_int:             return Constant.fromValue(left.intValue() | right.intValue());
1121                                         case T_long:    return Constant.fromValue(left.intValue() | right.longValue());
1122                                 }
1123                         break;
1124                         case T_long :
1125                                 switch (rightId){
1126                                         case T_char :   return Constant.fromValue(left.longValue() | right.charValue());
1127                                         case T_byte:    return Constant.fromValue(left.longValue() | right.byteValue());
1128                                         case T_short:   return Constant.fromValue(left.longValue() | right.shortValue());
1129                                         case T_int:             return Constant.fromValue(left.longValue() | right.intValue());
1130                                         case T_long:    return Constant.fromValue(left.longValue() | right.longValue());
1131                                 }
1132         
1133                         }       
1134         
1135                 return NotAConstant;
1136         }
1137         
1138         public static final Constant computeConstantOperationOR_OR(Constant left, int leftId, int operator, Constant right, int rightId) {
1139         
1140                 return Constant.fromValue(left.booleanValue() || right.booleanValue());
1141         }
1142                 
1143         public static final Constant computeConstantOperationPLUS(Constant left, int leftId, int operator, Constant right, int rightId) {
1144                 
1145                 switch (leftId){
1146                         case T_Object :
1147                                 if (rightId == T_String) {
1148                                         return Constant.fromValue(left.stringValue() + right.stringValue());
1149                                 }
1150                         case T_boolean :
1151                                 if (rightId == T_String) {
1152                                         return Constant.fromValue(left.stringValue() + right.stringValue());
1153                                 }
1154                         break;
1155                         case T_char :
1156                                 switch (rightId){
1157                                         case T_char :   return Constant.fromValue(left.charValue() + right.charValue());
1158                                         case T_float:   return Constant.fromValue(left.charValue() + right.floatValue());
1159                                         case T_double:  return Constant.fromValue(left.charValue() + right.doubleValue());
1160                                         case T_byte:    return Constant.fromValue(left.charValue() + right.byteValue());
1161                                         case T_short:   return Constant.fromValue(left.charValue() + right.shortValue());
1162                                         case T_int:             return Constant.fromValue(left.charValue() + right.intValue());
1163                                         case T_long:    return Constant.fromValue(left.charValue() + right.longValue());
1164                                         case T_String:  return Constant.fromValue(left.stringValue() + right.stringValue());
1165                                 }
1166                         break;
1167                         case T_float :
1168                                 switch (rightId){
1169                                         case T_char :   return Constant.fromValue(left.floatValue() + right.charValue());
1170                                         case T_float:   return Constant.fromValue(left.floatValue() + right.floatValue());
1171                                         case T_double:  return Constant.fromValue(left.floatValue() + right.doubleValue());
1172                                         case T_byte:    return Constant.fromValue(left.floatValue() + right.byteValue());
1173                                         case T_short:   return Constant.fromValue(left.floatValue() + right.shortValue());
1174                                         case T_int:             return Constant.fromValue(left.floatValue() + right.intValue());
1175                                         case T_long:    return Constant.fromValue(left.floatValue() + right.longValue());
1176                                         case T_String:  return Constant.fromValue(left.stringValue() + right.stringValue()); 
1177                                 }
1178                         break;
1179                         case T_double :
1180                                 switch (rightId){
1181                                         case T_char :   return Constant.fromValue(left.doubleValue() + right.charValue());
1182                                         case T_float:   return Constant.fromValue(left.doubleValue() + right.floatValue());
1183                                         case T_double:  return Constant.fromValue(left.doubleValue() + right.doubleValue());
1184                                         case T_byte:    return Constant.fromValue(left.doubleValue() + right.byteValue());
1185                                         case T_short:   return Constant.fromValue(left.doubleValue() + right.shortValue());
1186                                         case T_int:             return Constant.fromValue(left.doubleValue() + right.intValue());
1187                                         case T_long:    return Constant.fromValue(left.doubleValue() + right.longValue());
1188                                         case T_String:  return Constant.fromValue(left.stringValue() + right.stringValue());
1189                                 }
1190                         break;
1191                         case T_byte :
1192                                 switch (rightId){
1193                                         case T_char :   return Constant.fromValue(left.byteValue() + right.charValue());
1194                                         case T_float:   return Constant.fromValue(left.byteValue() + right.floatValue());
1195                                         case T_double:  return Constant.fromValue(left.byteValue() + right.doubleValue());
1196                                         case T_byte:    return Constant.fromValue(left.byteValue() + right.byteValue());
1197                                         case T_short:   return Constant.fromValue(left.byteValue() + right.shortValue());
1198                                         case T_int:             return Constant.fromValue(left.byteValue() + right.intValue());
1199                                         case T_long:    return Constant.fromValue(left.byteValue() + right.longValue());
1200                                         case T_String:  return Constant.fromValue(left.stringValue() + right.stringValue()); 
1201                                 }
1202         
1203                         break;                  
1204                         case T_short :
1205                                 switch (rightId){
1206                                         case T_char :   return Constant.fromValue(left.shortValue() + right.charValue());
1207                                         case T_float:   return Constant.fromValue(left.shortValue() + right.floatValue());
1208                                         case T_double:  return Constant.fromValue(left.shortValue() + right.doubleValue());
1209                                         case T_byte:    return Constant.fromValue(left.shortValue() + right.byteValue());
1210                                         case T_short:   return Constant.fromValue(left.shortValue() + right.shortValue());
1211                                         case T_int:             return Constant.fromValue(left.shortValue() + right.intValue());
1212                                         case T_long:    return Constant.fromValue(left.shortValue() + right.longValue());
1213                                         case T_String:  return Constant.fromValue(left.stringValue() + right.stringValue());
1214                                 }
1215                         break;
1216                         case T_int :
1217                                 switch (rightId){
1218                                         case T_char :   return Constant.fromValue(left.intValue() + right.charValue());
1219                                         case T_float:   return Constant.fromValue(left.intValue() + right.floatValue());
1220                                         case T_double:  return Constant.fromValue(left.intValue() + right.doubleValue());
1221                                         case T_byte:    return Constant.fromValue(left.intValue() + right.byteValue());
1222                                         case T_short:   return Constant.fromValue(left.intValue() + right.shortValue());
1223                                         case T_int:             return Constant.fromValue(left.intValue() + right.intValue());
1224                                         case T_long:    return Constant.fromValue(left.intValue() + right.longValue());
1225                                         case T_String:  return Constant.fromValue(left.stringValue() + right.stringValue());
1226                                 }
1227                         break;          
1228                         case T_long :
1229                                 switch (rightId){
1230                                         case T_char :   return Constant.fromValue(left.longValue() + right.charValue());
1231                                         case T_float:   return Constant.fromValue(left.longValue() + right.floatValue());
1232                                         case T_double:  return Constant.fromValue(left.longValue() + right.doubleValue());
1233                                         case T_byte:    return Constant.fromValue(left.longValue() + right.byteValue());
1234                                         case T_short:   return Constant.fromValue(left.longValue() + right.shortValue());
1235                                         case T_int:             return Constant.fromValue(left.longValue() + right.intValue());
1236                                         case T_long:    return Constant.fromValue(left.longValue() + right.longValue());
1237                                         case T_String:  return Constant.fromValue(left.stringValue() + right.stringValue()); 
1238                                 }
1239                         break;
1240                         case T_String :
1241                                 switch (rightId){
1242                                         case T_char :   return Constant.fromValue(left.stringValue() + right.stringValue());
1243                                         case T_float:   return Constant.fromValue(left.stringValue() + right.stringValue());
1244                                         case T_double:  return Constant.fromValue(left.stringValue() + right.stringValue());
1245                                         case T_byte:    return Constant.fromValue(left.stringValue() + right.stringValue());
1246                                         case T_short:   return Constant.fromValue(left.stringValue() + right.stringValue());
1247                                         case T_int:             return Constant.fromValue(left.stringValue() + right.stringValue());
1248                                         case T_long:    return Constant.fromValue(left.stringValue() + right.stringValue());
1249                                         case T_String:  return Constant.fromValue(left.stringValue() + right.stringValue()); 
1250                                         case T_boolean: return Constant.fromValue(left.stringValue() + right.stringValue());
1251                                 }
1252                         break;  
1253                         case T_null :
1254                                 switch (rightId){
1255                                         case T_char :   return Constant.fromValue(left.stringValue() + right.stringValue());
1256                                         case T_float:   return Constant.fromValue(left.stringValue() + right.stringValue());
1257                                         case T_double:  return Constant.fromValue(left.stringValue() + right.stringValue());
1258                                         case T_byte:    return Constant.fromValue(left.stringValue() + right.stringValue());
1259                                         case T_short:   return Constant.fromValue(left.stringValue() + right.stringValue());
1260                                         case T_int:             return Constant.fromValue(left.stringValue() + right.stringValue());
1261                                         case T_long:    return Constant.fromValue(left.stringValue() + right.stringValue());
1262                                         case T_String:  return Constant.fromValue(left.stringValue() + right.stringValue()); 
1263                                 }
1264                                 
1265                         }
1266                 
1267                 return NotAConstant;
1268         }
1269                 
1270         public static final Constant computeConstantOperationREMAINDER(Constant left, int leftId, int operator, Constant right, int rightId) {
1271                 
1272                 switch (leftId){
1273                         case T_char : 
1274                                 switch (rightId){
1275                                         case T_char :   return Constant.fromValue(left.charValue() % right.charValue());
1276                                         case T_float:   return Constant.fromValue(left.charValue() % right.floatValue());
1277                                         case T_double:  return Constant.fromValue(left.charValue() % right.doubleValue());
1278                                         case T_byte:    return Constant.fromValue(left.charValue() % right.byteValue());
1279                                         case T_short:   return Constant.fromValue(left.charValue() % right.shortValue());
1280                                         case T_int:             return Constant.fromValue(left.charValue() % right.intValue());
1281                                         case T_long:    return Constant.fromValue(left.charValue() % right.longValue());
1282                                 }
1283                         break;
1284                         case T_float :
1285                                 switch (rightId){
1286                                         case T_char :   return Constant.fromValue(left.floatValue() % right.charValue());
1287                                         case T_float:   return Constant.fromValue(left.floatValue() % right.floatValue());
1288                                         case T_double:  return Constant.fromValue(left.floatValue() % right.doubleValue());
1289                                         case T_byte:    return Constant.fromValue(left.floatValue() % right.byteValue());
1290                                         case T_short:   return Constant.fromValue(left.floatValue() % right.shortValue());
1291                                         case T_int:             return Constant.fromValue(left.floatValue() % right.intValue());
1292                                         case T_long:    return Constant.fromValue(left.floatValue() % right.longValue());
1293                                 }
1294                         break;
1295                         case T_double :
1296                                 switch (rightId){
1297                                         case T_char :   return Constant.fromValue(left.doubleValue() % right.charValue());
1298                                         case T_float:   return Constant.fromValue(left.doubleValue() % right.floatValue());
1299                                         case T_double:  return Constant.fromValue(left.doubleValue() % right.doubleValue());
1300                                         case T_byte:    return Constant.fromValue(left.doubleValue() % right.byteValue());
1301                                         case T_short:   return Constant.fromValue(left.doubleValue() % right.shortValue());
1302                                         case T_int:             return Constant.fromValue(left.doubleValue() % right.intValue());
1303                                         case T_long:    return Constant.fromValue(left.doubleValue() % right.longValue());
1304                                 }
1305                         break;
1306                         case T_byte :
1307                                 switch (rightId){
1308                                         case T_char :   return Constant.fromValue(left.byteValue() % right.charValue());
1309                                         case T_float:   return Constant.fromValue(left.byteValue() % right.floatValue());
1310                                         case T_double:  return Constant.fromValue(left.byteValue() % right.doubleValue());
1311                                         case T_byte:    return Constant.fromValue(left.byteValue() % right.byteValue());
1312                                         case T_short:   return Constant.fromValue(left.byteValue() % right.shortValue());
1313                                         case T_int:             return Constant.fromValue(left.byteValue() % right.intValue());
1314                                         case T_long:    return Constant.fromValue(left.byteValue() % right.longValue());
1315                                 }
1316                         break;                  
1317                         case T_short :
1318                                 switch (rightId){
1319                                         case T_char :   return Constant.fromValue(left.shortValue() % right.charValue());
1320                                         case T_float:   return Constant.fromValue(left.shortValue() % right.floatValue());
1321                                         case T_double:  return Constant.fromValue(left.shortValue() % right.doubleValue());
1322                                         case T_byte:    return Constant.fromValue(left.shortValue() % right.byteValue());
1323                                         case T_short:   return Constant.fromValue(left.shortValue() % right.shortValue());
1324                                         case T_int:             return Constant.fromValue(left.shortValue() % right.intValue());
1325                                         case T_long:    return Constant.fromValue(left.shortValue() % right.longValue());
1326                                 }
1327                         break;
1328                         case T_int :
1329                                 switch (rightId){
1330                                         case T_char :   return Constant.fromValue(left.intValue() % right.charValue());
1331                                         case T_float:   return Constant.fromValue(left.intValue() % right.floatValue());
1332                                         case T_double:  return Constant.fromValue(left.intValue() % right.doubleValue());
1333                                         case T_byte:    return Constant.fromValue(left.intValue() % right.byteValue());
1334                                         case T_short:   return Constant.fromValue(left.intValue() % right.shortValue());
1335                                         case T_int:             return Constant.fromValue(left.intValue() % right.intValue());
1336                                         case T_long:    return Constant.fromValue(left.intValue() % right.longValue());
1337                                 }
1338                         break;          
1339                         case T_long :
1340                                 switch (rightId){
1341                                         case T_char :   return Constant.fromValue(left.longValue() % right.charValue());
1342                                         case T_float:   return Constant.fromValue(left.longValue() % right.floatValue());
1343                                         case T_double:  return Constant.fromValue(left.longValue() % right.doubleValue());
1344                                         case T_byte:    return Constant.fromValue(left.longValue() % right.byteValue());
1345                                         case T_short:   return Constant.fromValue(left.longValue() % right.shortValue());
1346                                         case T_int:             return Constant.fromValue(left.longValue() % right.intValue());
1347                                         case T_long:    return Constant.fromValue(left.longValue() % right.longValue());
1348                                 }
1349                                 
1350                         }
1351                 
1352                 return NotAConstant;
1353         } 
1354         
1355         public static final Constant computeConstantOperationRIGHT_SHIFT(Constant left, int leftId, int operator, Constant right, int rightId) {
1356                 
1357                 switch (leftId){
1358                         case T_char :
1359                                 switch (rightId){
1360                                         case T_char :   return Constant.fromValue(left.charValue() >> right.charValue());
1361                                         case T_byte:    return Constant.fromValue(left.charValue() >> right.byteValue());
1362                                         case T_short:   return Constant.fromValue(left.charValue() >> right.shortValue());
1363                                         case T_int:             return Constant.fromValue(left.charValue() >> right.intValue());
1364                                         case T_long:    return Constant.fromValue(left.charValue() >> right.longValue());
1365                                 }
1366                         break;
1367                         case T_byte :
1368                                 switch (rightId){
1369                                         case T_char :   return Constant.fromValue(left.byteValue() >> right.charValue());
1370                                         case T_byte:    return Constant.fromValue(left.byteValue() >> right.byteValue());
1371                                         case T_short:   return Constant.fromValue(left.byteValue() >> right.shortValue());
1372                                         case T_int:             return Constant.fromValue(left.byteValue() >> right.intValue());
1373                                         case T_long:    return Constant.fromValue(left.byteValue() >> right.longValue());
1374                                 }
1375                         break;
1376                         case T_short :
1377                                 switch (rightId){
1378                                         case T_char :   return Constant.fromValue(left.shortValue() >> right.charValue());
1379                                         case T_byte:    return Constant.fromValue(left.shortValue() >> right.byteValue());
1380                                         case T_short:   return Constant.fromValue(left.shortValue() >> right.shortValue());
1381                                         case T_int:             return Constant.fromValue(left.shortValue() >> right.intValue());
1382                                         case T_long:    return Constant.fromValue(left.shortValue() >> right.longValue());
1383                                 }
1384                         break;
1385                         case T_int :
1386                                 switch (rightId){
1387                                         case T_char :   return Constant.fromValue(left.intValue() >> right.charValue());
1388                                         case T_byte:    return Constant.fromValue(left.intValue() >> right.byteValue());
1389                                         case T_short:   return Constant.fromValue(left.intValue() >> right.shortValue());
1390                                         case T_int:             return Constant.fromValue(left.intValue() >> right.intValue());
1391                                         case T_long:    return Constant.fromValue(left.intValue() >> right.longValue());
1392                                 }
1393                         break;
1394                         case T_long :
1395                                 switch (rightId){
1396                                         case T_char :   return Constant.fromValue(left.longValue() >> right.charValue());
1397                                         case T_byte:    return Constant.fromValue(left.longValue() >> right.byteValue());
1398                                         case T_short:   return Constant.fromValue(left.longValue() >> right.shortValue());
1399                                         case T_int:             return Constant.fromValue(left.longValue() >> right.intValue());
1400                                         case T_long:    return Constant.fromValue(left.longValue() >> right.longValue());
1401                                 }
1402         
1403                         }
1404                 
1405                 return NotAConstant;
1406         }
1407
1408         public static final Constant computeConstantOperationUNSIGNED_RIGHT_SHIFT(Constant left, int leftId, int operator, Constant right, int rightId) {
1409                 
1410                 switch (leftId){
1411                         case T_char :
1412                                 switch (rightId){
1413                                         case T_char :   return Constant.fromValue(left.charValue() >>> right.charValue());
1414                                         case T_byte:    return Constant.fromValue(left.charValue() >>> right.byteValue());
1415                                         case T_short:   return Constant.fromValue(left.charValue() >>> right.shortValue());
1416                                         case T_int:             return Constant.fromValue(left.charValue() >>> right.intValue());
1417                                         case T_long:    return Constant.fromValue(left.charValue() >>> right.longValue());
1418                                 }
1419                         break;
1420                         case T_byte :
1421                                 switch (rightId){
1422                                         case T_char :   return Constant.fromValue(left.byteValue() >>> right.charValue());
1423                                         case T_byte:    return Constant.fromValue(left.byteValue() >>> right.byteValue());
1424                                         case T_short:   return Constant.fromValue(left.byteValue() >>> right.shortValue());
1425                                         case T_int:             return Constant.fromValue(left.byteValue() >>> right.intValue());
1426                                         case T_long:    return Constant.fromValue(left.byteValue() >>> right.longValue());
1427                                 }
1428                         break;
1429                         case T_short :
1430                                 switch (rightId){
1431                                         case T_char :   return Constant.fromValue(left.shortValue() >>> right.charValue());
1432                                         case T_byte:    return Constant.fromValue(left.shortValue() >>> right.byteValue());
1433                                         case T_short:   return Constant.fromValue(left.shortValue() >>> right.shortValue());
1434                                         case T_int:             return Constant.fromValue(left.shortValue() >>> right.intValue());
1435                                         case T_long:    return Constant.fromValue(left.shortValue() >>> right.longValue());
1436                                 }
1437                         break;
1438                         case T_int :
1439                                 switch (rightId){
1440                                         case T_char :   return Constant.fromValue(left.intValue() >>> right.charValue());
1441                                         case T_byte:    return Constant.fromValue(left.intValue() >>> right.byteValue());
1442                                         case T_short:   return Constant.fromValue(left.intValue() >>> right.shortValue());
1443                                         case T_int:             return Constant.fromValue(left.intValue() >>> right.intValue());
1444                                         case T_long:    return Constant.fromValue(left.intValue() >>> right.longValue());
1445                                 }
1446                         break;
1447                         case T_long :
1448                                 switch (rightId){
1449                                         case T_char :   return Constant.fromValue(left.longValue() >>> right.charValue());
1450                                         case T_byte:    return Constant.fromValue(left.longValue() >>> right.byteValue());
1451                                         case T_short:   return Constant.fromValue(left.longValue() >>> right.shortValue());
1452                                         case T_int:             return Constant.fromValue(left.longValue() >>> right.intValue());
1453                                         case T_long:    return Constant.fromValue(left.longValue() >>> right.longValue());
1454                                 }
1455         
1456                         }
1457         
1458                 return NotAConstant;
1459         }
1460         
1461         public static final Constant computeConstantOperationXOR(Constant left, int leftId, int operator, Constant right, int rightId) {
1462                 
1463                 switch (leftId){
1464                         case T_boolean :                return Constant.fromValue(left.booleanValue() ^ right.booleanValue());
1465                         case T_char :
1466                                 switch (rightId){
1467                                         case T_char :   return Constant.fromValue(left.charValue() ^ right.charValue());
1468                                         case T_byte:    return Constant.fromValue(left.charValue() ^ right.byteValue());
1469                                         case T_short:   return Constant.fromValue(left.charValue() ^ right.shortValue());
1470                                         case T_int:             return Constant.fromValue(left.charValue() ^ right.intValue());
1471                                         case T_long:    return Constant.fromValue(left.charValue() ^ right.longValue());
1472                                 }
1473                         break;
1474                         case T_byte :
1475                                 switch (rightId){
1476                                         case T_char :   return Constant.fromValue(left.byteValue() ^ right.charValue());
1477                                         case T_byte:    return Constant.fromValue(left.byteValue() ^ right.byteValue());
1478                                         case T_short:   return Constant.fromValue(left.byteValue() ^ right.shortValue());
1479                                         case T_int:             return Constant.fromValue(left.byteValue() ^ right.intValue());
1480                                         case T_long:    return Constant.fromValue(left.byteValue() ^ right.longValue());
1481                                 }
1482                         break;
1483                         case T_short :
1484                                 switch (rightId){
1485                                         case T_char :   return Constant.fromValue(left.shortValue() ^ right.charValue());
1486                                         case T_byte:    return Constant.fromValue(left.shortValue() ^ right.byteValue());
1487                                         case T_short:   return Constant.fromValue(left.shortValue() ^ right.shortValue());
1488                                         case T_int:             return Constant.fromValue(left.shortValue() ^ right.intValue());
1489                                         case T_long:    return Constant.fromValue(left.shortValue() ^ right.longValue());
1490                                 }
1491                         break;
1492                         case T_int :
1493                                 switch (rightId){
1494                                         case T_char :   return Constant.fromValue(left.intValue() ^ right.charValue());
1495                                         case T_byte:    return Constant.fromValue(left.intValue() ^ right.byteValue());
1496                                         case T_short:   return Constant.fromValue(left.intValue() ^ right.shortValue());
1497                                         case T_int:             return Constant.fromValue(left.intValue() ^ right.intValue());
1498                                         case T_long:    return Constant.fromValue(left.intValue() ^ right.longValue());
1499                                 }
1500                         break;
1501                         case T_long :
1502                                 switch (rightId){
1503                                         case T_char :   return Constant.fromValue(left.longValue() ^ right.charValue());
1504                                         case T_byte:    return Constant.fromValue(left.longValue() ^ right.byteValue());
1505                                         case T_short:   return Constant.fromValue(left.longValue() ^ right.shortValue());
1506                                         case T_int:             return Constant.fromValue(left.longValue() ^ right.intValue());
1507                                         case T_long:    return Constant.fromValue(left.longValue() ^ right.longValue());
1508                                 }
1509                         }
1510         
1511                 return NotAConstant;
1512         }
1513
1514         public double doubleValue() {
1515
1516                 throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto",typeName(),"double")); //$NON-NLS-2$ //$NON-NLS-1$
1517         }
1518
1519         public float floatValue() {
1520
1521                 throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto",typeName(),"float")); //$NON-NLS-2$ //$NON-NLS-1$
1522         }
1523
1524 //      public static Constant fromValue(byte value) {
1525 //
1526 //              return new ByteConstant(value);
1527 //      }
1528
1529 //      public static Constant fromValue(char value) {
1530 //
1531 //              return new CharConstant(value);
1532 //      }
1533
1534         public static Constant fromValue(double value) {
1535
1536                 return new DoubleConstant(value);
1537         }
1538
1539 //      public static Constant fromValue(float value) {
1540 //
1541 //              return new FloatConstant(value);
1542 //      }
1543
1544         public static Constant fromValue(int value) {
1545
1546                 return new IntConstant(value);
1547         }
1548
1549 //      public static Constant fromValue(long value) {
1550 //
1551 //              return new LongConstant(value);
1552 //      }
1553
1554         public static Constant fromValue(String value) {
1555                 
1556                 return new StringConstant(value);
1557         }
1558
1559 //      public static Constant fromValue(short value) {
1560 //
1561 //              return new ShortConstant(value);
1562 //      }
1563
1564         public static Constant fromValue(boolean value) {
1565
1566                 return new BooleanConstant(value);
1567         }
1568
1569         public int intValue() {
1570
1571                 throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto",typeName(),"int")); //$NON-NLS-2$ //$NON-NLS-1$
1572         }
1573
1574         public long longValue() {
1575
1576                 throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto",typeName(),"long")); //$NON-NLS-2$ //$NON-NLS-1$
1577         }
1578
1579         public short shortValue() {
1580
1581                 throw new ShouldNotImplement(Util.bind("constant.cannotConvertedTo",typeName(),"short")); //$NON-NLS-2$ //$NON-NLS-1$
1582         }
1583
1584         public String stringValue() {
1585
1586                 throw new ShouldNotImplement(Util.bind("constant.cannotConvertedTo",typeName(),"String")); //$NON-NLS-1$ //$NON-NLS-2$
1587         }
1588
1589         public String toString(){
1590         
1591                 if (this == NotAConstant) return "(Constant) NotAConstant"; //$NON-NLS-1$
1592                 return super.toString(); }
1593
1594         public abstract int typeID();
1595
1596         public String typeName() {
1597                 switch (typeID()) {
1598                         case T_int : return "int"; //$NON-NLS-1$
1599                         case T_byte : return "byte"; //$NON-NLS-1$
1600                         case T_short : return "short"; //$NON-NLS-1$
1601                         case T_char : return "char"; //$NON-NLS-1$
1602                         case T_float : return "float"; //$NON-NLS-1$
1603                         case T_double : return "double"; //$NON-NLS-1$
1604                         case T_boolean : return "boolean"; //$NON-NLS-1$
1605                         case T_long : return "long";//$NON-NLS-1$
1606                         case T_String : return "java.lang.String"; //$NON-NLS-1$
1607                         case T_null : return "null";     //$NON-NLS-1$
1608                         default: return "unknown"; //$NON-NLS-1$
1609                 }
1610         }
1611 }