Lines 213-219
Link Here
|
213 |
switch (operator) { |
213 |
switch (operator) { |
214 |
case NOT : |
214 |
case NOT : |
215 |
return Constant.fromValue(!cst.booleanValue()); |
215 |
return Constant.fromValue(!cst.booleanValue()); |
216 |
case PLUS : return cst; |
216 |
case PLUS : |
|
|
217 |
return computeConstantOperationPLUS(Zero,T_int,cst,id); |
217 |
case MINUS : //the two special -9223372036854775808L and -2147483648 are inlined at parseTime |
218 |
case MINUS : //the two special -9223372036854775808L and -2147483648 are inlined at parseTime |
218 |
switch (id){ |
219 |
switch (id){ |
219 |
case T_float : float f; |
220 |
case T_float : float f; |
Lines 233-239
Link Here
|
233 |
return Constant.fromValue(0.0d);} |
234 |
return Constant.fromValue(0.0d);} |
234 |
break; //default case |
235 |
break; //default case |
235 |
} |
236 |
} |
236 |
return computeConstantOperationMINUS(Zero,T_int,operator,cst,id); |
237 |
return computeConstantOperationMINUS(Zero,T_int,cst,id); |
237 |
case TWIDDLE: |
238 |
case TWIDDLE: |
238 |
switch (id){ |
239 |
switch (id){ |
239 |
case T_char : return Constant.fromValue(~ cst.charValue()); |
240 |
case T_char : return Constant.fromValue(~ cst.charValue()); |
Lines 250-278
Link Here
|
250 |
public static final Constant computeConstantOperation(Constant left, int leftId, int operator, Constant right, int rightId) { |
251 |
public static final Constant computeConstantOperation(Constant left, int leftId, int operator, Constant right, int rightId) { |
251 |
|
252 |
|
252 |
switch (operator) { |
253 |
switch (operator) { |
253 |
case AND : return computeConstantOperationAND (left,leftId,operator,right,rightId); |
254 |
case AND : return computeConstantOperationAND (left,leftId,right,rightId); |
254 |
case AND_AND : return computeConstantOperationAND_AND (left,leftId,operator,right,rightId); |
255 |
case AND_AND : return computeConstantOperationAND_AND (left,leftId,right,rightId); |
255 |
case DIVIDE : return computeConstantOperationDIVIDE (left,leftId,operator,right,rightId); |
256 |
case DIVIDE : return computeConstantOperationDIVIDE (left,leftId,right,rightId); |
256 |
case GREATER : return computeConstantOperationGREATER (left,leftId,operator,right,rightId); |
257 |
case GREATER : return computeConstantOperationGREATER (left,leftId,right,rightId); |
257 |
case GREATER_EQUAL : return computeConstantOperationGREATER_EQUAL(left,leftId,operator,right,rightId); |
258 |
case GREATER_EQUAL : return computeConstantOperationGREATER_EQUAL(left,leftId,right,rightId); |
258 |
case LEFT_SHIFT : return computeConstantOperationLEFT_SHIFT (left,leftId,operator,right,rightId); |
259 |
case LEFT_SHIFT : return computeConstantOperationLEFT_SHIFT (left,leftId,right,rightId); |
259 |
case LESS : return computeConstantOperationLESS (left,leftId,operator,right,rightId); |
260 |
case LESS : return computeConstantOperationLESS (left,leftId,right,rightId); |
260 |
case LESS_EQUAL : return computeConstantOperationLESS_EQUAL (left,leftId,operator,right,rightId); |
261 |
case LESS_EQUAL : return computeConstantOperationLESS_EQUAL (left,leftId,right,rightId); |
261 |
case MINUS : return computeConstantOperationMINUS (left,leftId,operator,right,rightId); |
262 |
case MINUS : return computeConstantOperationMINUS (left,leftId,right,rightId); |
262 |
case MULTIPLY : return computeConstantOperationMULTIPLY (left,leftId,operator,right,rightId); |
263 |
case MULTIPLY : return computeConstantOperationMULTIPLY (left,leftId,right,rightId); |
263 |
case OR : return computeConstantOperationOR (left,leftId,operator,right,rightId); |
264 |
case OR : return computeConstantOperationOR (left,leftId,right,rightId); |
264 |
case OR_OR : return computeConstantOperationOR_OR (left,leftId,operator,right,rightId); |
265 |
case OR_OR : return computeConstantOperationOR_OR (left,leftId,right,rightId); |
265 |
case PLUS : return computeConstantOperationPLUS (left,leftId,operator,right,rightId); |
266 |
case PLUS : return computeConstantOperationPLUS (left,leftId,right,rightId); |
266 |
case REMAINDER : return computeConstantOperationREMAINDER (left,leftId,operator,right,rightId); |
267 |
case REMAINDER : return computeConstantOperationREMAINDER (left,leftId,right,rightId); |
267 |
case RIGHT_SHIFT: return computeConstantOperationRIGHT_SHIFT(left,leftId,operator,right,rightId); |
268 |
case RIGHT_SHIFT: return computeConstantOperationRIGHT_SHIFT(left,leftId,right,rightId); |
268 |
case UNSIGNED_RIGHT_SHIFT: return computeConstantOperationUNSIGNED_RIGHT_SHIFT(left,leftId,operator,right,rightId); |
269 |
case UNSIGNED_RIGHT_SHIFT: return computeConstantOperationUNSIGNED_RIGHT_SHIFT(left,leftId,right,rightId); |
269 |
case XOR : return computeConstantOperationXOR (left,leftId,operator,right,rightId); |
270 |
case XOR : return computeConstantOperationXOR (left,leftId,right,rightId); |
270 |
|
271 |
|
271 |
default : return NotAConstant; |
272 |
default : return NotAConstant; |
272 |
} |
273 |
} |
273 |
} |
274 |
} |
274 |
|
275 |
|
275 |
public static final Constant computeConstantOperationAND(Constant left, int leftId, int operator, Constant right, int rightId) { |
276 |
public static final Constant computeConstantOperationAND(Constant left, int leftId, Constant right, int rightId) { |
276 |
|
277 |
|
277 |
switch (leftId){ |
278 |
switch (leftId){ |
278 |
case T_boolean : return Constant.fromValue(left.booleanValue() & right.booleanValue()); |
279 |
case T_boolean : return Constant.fromValue(left.booleanValue() & right.booleanValue()); |
Lines 325-336
Link Here
|
325 |
return NotAConstant; |
326 |
return NotAConstant; |
326 |
} |
327 |
} |
327 |
|
328 |
|
328 |
public static final Constant computeConstantOperationAND_AND(Constant left, int leftId, int operator, Constant right, int rightId) { |
329 |
public static final Constant computeConstantOperationAND_AND(Constant left, int leftId, Constant right, int rightId) { |
329 |
|
330 |
|
330 |
return Constant.fromValue(left.booleanValue() && right.booleanValue()); |
331 |
return Constant.fromValue(left.booleanValue() && right.booleanValue()); |
331 |
} |
332 |
} |
332 |
|
333 |
|
333 |
public static final Constant computeConstantOperationDIVIDE(Constant left, int leftId, int operator, Constant right, int rightId) { |
334 |
public static final Constant computeConstantOperationDIVIDE(Constant left, int leftId, Constant right, int rightId) { |
334 |
// division by zero must be handled outside this method (error reporting) |
335 |
// division by zero must be handled outside this method (error reporting) |
335 |
|
336 |
|
336 |
switch (leftId){ |
337 |
switch (leftId){ |
Lines 416-422
Link Here
|
416 |
return NotAConstant; |
417 |
return NotAConstant; |
417 |
} |
418 |
} |
418 |
|
419 |
|
419 |
public static final Constant computeConstantOperationEQUAL_EQUAL(Constant left, int leftId, int operator, Constant right, int rightId) { |
420 |
public static final Constant computeConstantOperationEQUAL_EQUAL(Constant left, int leftId, Constant right, int rightId) { |
420 |
|
421 |
|
421 |
switch (leftId){ |
422 |
switch (leftId){ |
422 |
case T_boolean : |
423 |
case T_boolean : |
Lines 520-526
Link Here
|
520 |
return Constant.fromValue(false); |
521 |
return Constant.fromValue(false); |
521 |
} |
522 |
} |
522 |
|
523 |
|
523 |
public static final Constant computeConstantOperationGREATER(Constant left, int leftId, int operator, Constant right, int rightId) { |
524 |
public static final Constant computeConstantOperationGREATER(Constant left, int leftId, Constant right, int rightId) { |
524 |
|
525 |
|
525 |
switch (leftId){ |
526 |
switch (leftId){ |
526 |
case T_char : |
527 |
case T_char : |
Lines 605-611
Link Here
|
605 |
return NotAConstant; |
606 |
return NotAConstant; |
606 |
} |
607 |
} |
607 |
|
608 |
|
608 |
public static final Constant computeConstantOperationGREATER_EQUAL(Constant left, int leftId, int operator, Constant right, int rightId) { |
609 |
public static final Constant computeConstantOperationGREATER_EQUAL(Constant left, int leftId, Constant right, int rightId) { |
609 |
|
610 |
|
610 |
switch (leftId){ |
611 |
switch (leftId){ |
611 |
case T_char : |
612 |
case T_char : |
Lines 690-696
Link Here
|
690 |
return NotAConstant; |
691 |
return NotAConstant; |
691 |
} |
692 |
} |
692 |
|
693 |
|
693 |
public static final Constant computeConstantOperationLEFT_SHIFT(Constant left, int leftId, int operator, Constant right, int rightId) { |
694 |
public static final Constant computeConstantOperationLEFT_SHIFT(Constant left, int leftId, Constant right, int rightId) { |
694 |
|
695 |
|
695 |
switch (leftId){ |
696 |
switch (leftId){ |
696 |
case T_char : |
697 |
case T_char : |
Lines 743-749
Link Here
|
743 |
return NotAConstant; |
744 |
return NotAConstant; |
744 |
} |
745 |
} |
745 |
|
746 |
|
746 |
public static final Constant computeConstantOperationLESS(Constant left, int leftId, int operator, Constant right, int rightId) { |
747 |
public static final Constant computeConstantOperationLESS(Constant left, int leftId, Constant right, int rightId) { |
747 |
|
748 |
|
748 |
switch (leftId){ |
749 |
switch (leftId){ |
749 |
case T_char : |
750 |
case T_char : |
Lines 828-834
Link Here
|
828 |
return NotAConstant; |
829 |
return NotAConstant; |
829 |
} |
830 |
} |
830 |
|
831 |
|
831 |
public static final Constant computeConstantOperationLESS_EQUAL(Constant left, int leftId, int operator, Constant right, int rightId) { |
832 |
public static final Constant computeConstantOperationLESS_EQUAL(Constant left, int leftId, Constant right, int rightId) { |
832 |
|
833 |
|
833 |
switch (leftId){ |
834 |
switch (leftId){ |
834 |
case T_char : |
835 |
case T_char : |
Lines 912-918
Link Here
|
912 |
return NotAConstant; |
913 |
return NotAConstant; |
913 |
} |
914 |
} |
914 |
|
915 |
|
915 |
public static final Constant computeConstantOperationMINUS(Constant left, int leftId, int operator, Constant right, int rightId) { |
916 |
public static final Constant computeConstantOperationMINUS(Constant left, int leftId, Constant right, int rightId) { |
916 |
|
917 |
|
917 |
switch (leftId){ |
918 |
switch (leftId){ |
918 |
case T_char : |
919 |
case T_char : |
Lines 997-1003
Link Here
|
997 |
return NotAConstant; |
998 |
return NotAConstant; |
998 |
} |
999 |
} |
999 |
|
1000 |
|
1000 |
public static final Constant computeConstantOperationMULTIPLY(Constant left, int leftId, int operator, Constant right, int rightId) { |
1001 |
public static final Constant computeConstantOperationMULTIPLY(Constant left, int leftId, Constant right, int rightId) { |
1001 |
|
1002 |
|
1002 |
switch (leftId){ |
1003 |
switch (leftId){ |
1003 |
case T_char : |
1004 |
case T_char : |
Lines 1081-1087
Link Here
|
1081 |
return NotAConstant; |
1082 |
return NotAConstant; |
1082 |
} |
1083 |
} |
1083 |
|
1084 |
|
1084 |
public static final Constant computeConstantOperationOR(Constant left, int leftId, int operator, Constant right, int rightId) { |
1085 |
public static final Constant computeConstantOperationOR(Constant left, int leftId, Constant right, int rightId) { |
1085 |
|
1086 |
|
1086 |
switch (leftId){ |
1087 |
switch (leftId){ |
1087 |
case T_boolean : return Constant.fromValue(left.booleanValue() | right.booleanValue()); |
1088 |
case T_boolean : return Constant.fromValue(left.booleanValue() | right.booleanValue()); |
Lines 1135-1146
Link Here
|
1135 |
return NotAConstant; |
1136 |
return NotAConstant; |
1136 |
} |
1137 |
} |
1137 |
|
1138 |
|
1138 |
public static final Constant computeConstantOperationOR_OR(Constant left, int leftId, int operator, Constant right, int rightId) { |
1139 |
public static final Constant computeConstantOperationOR_OR(Constant left, int leftId, Constant right, int rightId) { |
1139 |
|
1140 |
|
1140 |
return Constant.fromValue(left.booleanValue() || right.booleanValue()); |
1141 |
return Constant.fromValue(left.booleanValue() || right.booleanValue()); |
1141 |
} |
1142 |
} |
1142 |
|
1143 |
|
1143 |
public static final Constant computeConstantOperationPLUS(Constant left, int leftId, int operator, Constant right, int rightId) { |
1144 |
public static final Constant computeConstantOperationPLUS(Constant left, int leftId, Constant right, int rightId) { |
1144 |
|
1145 |
|
1145 |
switch (leftId){ |
1146 |
switch (leftId){ |
1146 |
case T_Object : |
1147 |
case T_Object : |
Lines 1267-1273
Link Here
|
1267 |
return NotAConstant; |
1268 |
return NotAConstant; |
1268 |
} |
1269 |
} |
1269 |
|
1270 |
|
1270 |
public static final Constant computeConstantOperationREMAINDER(Constant left, int leftId, int operator, Constant right, int rightId) { |
1271 |
public static final Constant computeConstantOperationREMAINDER(Constant left, int leftId, Constant right, int rightId) { |
1271 |
|
1272 |
|
1272 |
switch (leftId){ |
1273 |
switch (leftId){ |
1273 |
case T_char : |
1274 |
case T_char : |
Lines 1352-1358
Link Here
|
1352 |
return NotAConstant; |
1353 |
return NotAConstant; |
1353 |
} |
1354 |
} |
1354 |
|
1355 |
|
1355 |
public static final Constant computeConstantOperationRIGHT_SHIFT(Constant left, int leftId, int operator, Constant right, int rightId) { |
1356 |
public static final Constant computeConstantOperationRIGHT_SHIFT(Constant left, int leftId, Constant right, int rightId) { |
1356 |
|
1357 |
|
1357 |
switch (leftId){ |
1358 |
switch (leftId){ |
1358 |
case T_char : |
1359 |
case T_char : |
Lines 1405-1411
Link Here
|
1405 |
return NotAConstant; |
1406 |
return NotAConstant; |
1406 |
} |
1407 |
} |
1407 |
|
1408 |
|
1408 |
public static final Constant computeConstantOperationUNSIGNED_RIGHT_SHIFT(Constant left, int leftId, int operator, Constant right, int rightId) { |
1409 |
public static final Constant computeConstantOperationUNSIGNED_RIGHT_SHIFT(Constant left, int leftId, Constant right, int rightId) { |
1409 |
|
1410 |
|
1410 |
switch (leftId){ |
1411 |
switch (leftId){ |
1411 |
case T_char : |
1412 |
case T_char : |
Lines 1458-1464
Link Here
|
1458 |
return NotAConstant; |
1459 |
return NotAConstant; |
1459 |
} |
1460 |
} |
1460 |
|
1461 |
|
1461 |
public static final Constant computeConstantOperationXOR(Constant left, int leftId, int operator, Constant right, int rightId) { |
1462 |
public static final Constant computeConstantOperationXOR(Constant left, int leftId, Constant right, int rightId) { |
1462 |
|
1463 |
|
1463 |
switch (leftId){ |
1464 |
switch (leftId){ |
1464 |
case T_boolean : return Constant.fromValue(left.booleanValue() ^ right.booleanValue()); |
1465 |
case T_boolean : return Constant.fromValue(left.booleanValue() ^ right.booleanValue()); |