2 // cfold.cs: Constant Folding
5 // Miguel de Icaza (miguel@ximian.com)
7 // (C) 2002 Ximian, Inc.
12 namespace Mono.CSharp {
14 public class ConstantFold {
17 // Performs the numeric promotions on the left and right expresions
18 // and desposits the results on `lc' and `rc'.
20 // On success, the types of `lc' and `rc' on output will always match,
21 // and the pair will be one of:
30 static void DoConstantNumericPromotions (Binary.Operator oper,
31 ref Constant left, ref Constant right,
34 if (left is DoubleConstant || right is DoubleConstant){
36 // If either side is a double, convert the other to a double
38 if (!(left is DoubleConstant))
39 left = left.ToDouble (loc);
41 if (!(right is DoubleConstant))
42 right = right.ToDouble (loc);
44 } else if (left is FloatConstant || right is FloatConstant) {
46 // If either side is a float, convert the other to a float
48 if (!(left is FloatConstant))
49 left = left.ToFloat (loc);
51 if (!(right is FloatConstant))
52 right = right.ToFloat (loc);
54 } else if (left is ULongConstant || right is ULongConstant){
56 // If either operand is of type ulong, the other operand is
57 // converted to type ulong. or an error ocurrs if the other
58 // operand is of type sbyte, short, int or long
60 Constant match, other;
62 if (left is ULongConstant){
65 if (!(right is ULongConstant))
66 right = right.ToULong (loc);
70 left = left.ToULong (loc);
74 if (other is SByteConstant || other is ShortConstant ||
75 other is IntConstant || other is LongConstant){
76 Binary.Error_OperatorAmbiguous
77 (loc, oper, other.Type, match.Type);
83 } else if (left is LongConstant || right is LongConstant){
85 // If either operand is of type long, the other operand is converted
88 if (!(left is LongConstant))
89 left = left.ToLong (loc);
90 else if (!(right is LongConstant))
91 right = right.ToLong (loc);
93 } else if (left is UIntConstant || right is UIntConstant){
95 // If either operand is of type uint, and the other
96 // operand is of type sbyte, short or int, othe operands are
97 // converted to type long.
99 if (!(left is UIntConstant))
100 left = left.ToUInt (loc);
101 else if (!(right is UIntConstant))
102 right = right.ToUInt (loc);
106 // Force conversions to int32
108 if (!(left is IntConstant))
109 left = left.ToInt (loc);
110 if (!(right is IntConstant))
111 right = right.ToInt (loc);
116 static void Error_CompileTimeOverflow (Location loc)
118 Report.Error (220, loc, "The operation overflows at compile time in checked mode");
122 /// Constant expression folder for binary operations.
124 /// Returns null if the expression can not be folded.
126 static public Expression BinaryFold (EmitContext ec, Binary.Operator oper,
127 Constant left, Constant right, Location loc)
130 Type rt = right.Type;
131 Type result_type = null;
135 // Enumerator folding
137 if (rt == lt && left is EnumConstant)
141 case Binary.Operator.BitwiseOr:
142 DoConstantNumericPromotions (oper, ref left, ref right, loc);
143 if (left == null || right == null)
146 if (left is IntConstant){
148 int res = ((IntConstant) left).Value | ((IntConstant) right).Value;
150 v = new IntConstant (res);
151 if (result_type == null)
154 return new EnumConstant (v, result_type);
155 } else if (left is UIntConstant){
157 uint res = ((UIntConstant)left).Value | ((UIntConstant)right).Value;
159 v = new UIntConstant (res);
160 if (result_type == null)
163 return new EnumConstant (v, result_type);
164 } else if (left is LongConstant){
166 long res = ((LongConstant)left).Value | ((LongConstant)right).Value;
168 v = new LongConstant (res);
169 if (result_type == null)
172 return new EnumConstant (v, result_type);
173 } else if (left is ULongConstant){
175 ulong res = ((ULongConstant)left).Value |
176 ((ULongConstant)right).Value;
178 v = new ULongConstant (res);
179 if (result_type == null)
182 return new EnumConstant (v, result_type);
186 case Binary.Operator.BitwiseAnd:
187 DoConstantNumericPromotions (oper, ref left, ref right, loc);
188 if (left == null || right == null)
191 if (left is IntConstant){
193 int res = ((IntConstant) left).Value & ((IntConstant) right).Value;
195 v = new IntConstant (res);
196 if (result_type == null)
199 return new EnumConstant (v, result_type);
200 } else if (left is UIntConstant){
202 uint res = ((UIntConstant)left).Value & ((UIntConstant)right).Value;
204 v = new UIntConstant (res);
205 if (result_type == null)
208 return new EnumConstant (v, result_type);
209 } else if (left is LongConstant){
211 long res = ((LongConstant)left).Value & ((LongConstant)right).Value;
213 v = new LongConstant (res);
214 if (result_type == null)
217 return new EnumConstant (v, result_type);
218 } else if (left is ULongConstant){
220 ulong res = ((ULongConstant)left).Value &
221 ((ULongConstant)right).Value;
223 v = new ULongConstant (res);
224 if (result_type == null)
227 return new EnumConstant (v, result_type);
231 case Binary.Operator.ExclusiveOr:
232 DoConstantNumericPromotions (oper, ref left, ref right, loc);
233 if (left == null || right == null)
236 if (left is IntConstant){
238 int res = ((IntConstant) left).Value ^ ((IntConstant) right).Value;
240 v = new IntConstant (res);
241 if (result_type == null)
244 return new EnumConstant (v, result_type);
245 } else if (left is UIntConstant){
247 uint res = ((UIntConstant)left).Value ^ ((UIntConstant)right).Value;
249 v = new UIntConstant (res);
250 if (result_type == null)
253 return new EnumConstant (v, result_type);
254 } else if (left is LongConstant){
256 long res = ((LongConstant)left).Value ^ ((LongConstant)right).Value;
258 v = new LongConstant (res);
259 if (result_type == null)
262 return new EnumConstant (v, result_type);
263 } else if (left is ULongConstant){
265 ulong res = ((ULongConstant)left).Value ^
266 ((ULongConstant)right).Value;
268 v = new ULongConstant (res);
269 if (result_type == null)
272 return new EnumConstant (v, result_type);
276 case Binary.Operator.Addition:
277 bool left_is_string = left is StringConstant;
278 bool right_is_string = right is StringConstant;
281 // If both sides are strings, then concatenate, if
282 // one is a string, and the other is not, then defer
283 // to runtime concatenation
285 if (left_is_string || right_is_string){
286 if (left_is_string && right_is_string)
287 return new StringConstant (
288 ((StringConstant) left).Value +
289 ((StringConstant) right).Value);
294 DoConstantNumericPromotions (oper, ref left, ref right, loc);
295 if (left == null || right == null)
299 if (left is DoubleConstant){
302 if (ec.ConstantCheckState)
303 res = checked (((DoubleConstant) left).Value +
304 ((DoubleConstant) right).Value);
306 res = unchecked (((DoubleConstant) left).Value +
307 ((DoubleConstant) right).Value);
309 return new DoubleConstant (res);
310 } else if (left is FloatConstant){
313 if (ec.ConstantCheckState)
314 res = checked (((FloatConstant) left).Value +
315 ((FloatConstant) right).Value);
317 res = unchecked (((FloatConstant) left).Value +
318 ((FloatConstant) right).Value);
320 return new FloatConstant (res);
321 } else if (left is ULongConstant){
324 if (ec.ConstantCheckState)
325 res = checked (((ULongConstant) left).Value +
326 ((ULongConstant) right).Value);
328 res = unchecked (((ULongConstant) left).Value +
329 ((ULongConstant) right).Value);
331 return new ULongConstant (res);
332 } else if (left is LongConstant){
335 if (ec.ConstantCheckState)
336 res = checked (((LongConstant) left).Value +
337 ((LongConstant) right).Value);
339 res = unchecked (((LongConstant) left).Value +
340 ((LongConstant) right).Value);
342 return new LongConstant (res);
343 } else if (left is UIntConstant){
346 if (ec.ConstantCheckState)
347 res = checked (((UIntConstant) left).Value +
348 ((UIntConstant) right).Value);
350 res = unchecked (((UIntConstant) left).Value +
351 ((UIntConstant) right).Value);
353 return new UIntConstant (res);
354 } else if (left is IntConstant){
357 if (ec.ConstantCheckState)
358 res = checked (((IntConstant) left).Value +
359 ((IntConstant) right).Value);
361 res = unchecked (((IntConstant) left).Value +
362 ((IntConstant) right).Value);
364 return new IntConstant (res);
366 throw new Exception ( "Unexepected input: " + left);
368 } catch (OverflowException){
369 Error_CompileTimeOverflow (loc);
373 case Binary.Operator.Subtraction:
374 DoConstantNumericPromotions (oper, ref left, ref right, loc);
375 if (left == null || right == null)
379 if (left is DoubleConstant){
382 if (ec.ConstantCheckState)
383 res = checked (((DoubleConstant) left).Value -
384 ((DoubleConstant) right).Value);
386 res = unchecked (((DoubleConstant) left).Value -
387 ((DoubleConstant) right).Value);
389 return new DoubleConstant (res);
390 } else if (left is FloatConstant){
393 if (ec.ConstantCheckState)
394 res = checked (((FloatConstant) left).Value -
395 ((FloatConstant) right).Value);
397 res = unchecked (((FloatConstant) left).Value -
398 ((FloatConstant) right).Value);
400 return new FloatConstant (res);
401 } else if (left is ULongConstant){
404 if (ec.ConstantCheckState)
405 res = checked (((ULongConstant) left).Value -
406 ((ULongConstant) right).Value);
408 res = unchecked (((ULongConstant) left).Value -
409 ((ULongConstant) right).Value);
411 return new ULongConstant (res);
412 } else if (left is LongConstant){
415 if (ec.ConstantCheckState)
416 res = checked (((LongConstant) left).Value -
417 ((LongConstant) right).Value);
419 res = unchecked (((LongConstant) left).Value -
420 ((LongConstant) right).Value);
422 return new LongConstant (res);
423 } else if (left is UIntConstant){
426 if (ec.ConstantCheckState)
427 res = checked (((UIntConstant) left).Value -
428 ((UIntConstant) right).Value);
430 res = unchecked (((UIntConstant) left).Value -
431 ((UIntConstant) right).Value);
433 return new UIntConstant (res);
434 } else if (left is IntConstant){
437 if (ec.ConstantCheckState)
438 res = checked (((IntConstant) left).Value -
439 ((IntConstant) right).Value);
441 res = unchecked (((IntConstant) left).Value -
442 ((IntConstant) right).Value);
444 return new IntConstant (res);
446 throw new Exception ( "Unexepected input: " + left);
448 } catch (OverflowException){
449 Error_CompileTimeOverflow (loc);
453 case Binary.Operator.Multiply:
454 DoConstantNumericPromotions (oper, ref left, ref right, loc);
455 if (left == null || right == null)
459 if (left is DoubleConstant){
462 if (ec.ConstantCheckState)
463 res = checked (((DoubleConstant) left).Value *
464 ((DoubleConstant) right).Value);
466 res = unchecked (((DoubleConstant) left).Value *
467 ((DoubleConstant) right).Value);
469 return new DoubleConstant (res);
470 } else if (left is FloatConstant){
473 if (ec.ConstantCheckState)
474 res = checked (((FloatConstant) left).Value *
475 ((FloatConstant) right).Value);
477 res = unchecked (((FloatConstant) left).Value *
478 ((FloatConstant) right).Value);
480 return new FloatConstant (res);
481 } else if (left is ULongConstant){
484 if (ec.ConstantCheckState)
485 res = checked (((ULongConstant) left).Value *
486 ((ULongConstant) right).Value);
488 res = unchecked (((ULongConstant) left).Value *
489 ((ULongConstant) right).Value);
491 return new ULongConstant (res);
492 } else if (left is LongConstant){
495 if (ec.ConstantCheckState)
496 res = checked (((LongConstant) left).Value *
497 ((LongConstant) right).Value);
499 res = unchecked (((LongConstant) left).Value *
500 ((LongConstant) right).Value);
502 return new LongConstant (res);
503 } else if (left is UIntConstant){
506 if (ec.ConstantCheckState)
507 res = checked (((UIntConstant) left).Value *
508 ((UIntConstant) right).Value);
510 res = unchecked (((UIntConstant) left).Value *
511 ((UIntConstant) right).Value);
513 return new UIntConstant (res);
514 } else if (left is IntConstant){
517 if (ec.ConstantCheckState)
518 res = checked (((IntConstant) left).Value *
519 ((IntConstant) right).Value);
521 res = unchecked (((IntConstant) left).Value *
522 ((IntConstant) right).Value);
524 return new IntConstant (res);
526 throw new Exception ( "Unexepected input: " + left);
528 } catch (OverflowException){
529 Error_CompileTimeOverflow (loc);
533 case Binary.Operator.Division:
534 DoConstantNumericPromotions (oper, ref left, ref right, loc);
535 if (left == null || right == null)
539 if (left is DoubleConstant){
542 if (ec.ConstantCheckState)
543 res = checked (((DoubleConstant) left).Value /
544 ((DoubleConstant) right).Value);
546 res = unchecked (((DoubleConstant) left).Value /
547 ((DoubleConstant) right).Value);
549 return new DoubleConstant (res);
550 } else if (left is FloatConstant){
553 if (ec.ConstantCheckState)
554 res = checked (((FloatConstant) left).Value /
555 ((FloatConstant) right).Value);
557 res = unchecked (((FloatConstant) left).Value /
558 ((FloatConstant) right).Value);
560 return new FloatConstant (res);
561 } else if (left is ULongConstant){
564 if (ec.ConstantCheckState)
565 res = checked (((ULongConstant) left).Value /
566 ((ULongConstant) right).Value);
568 res = unchecked (((ULongConstant) left).Value /
569 ((ULongConstant) right).Value);
571 return new ULongConstant (res);
572 } else if (left is LongConstant){
575 if (ec.ConstantCheckState)
576 res = checked (((LongConstant) left).Value /
577 ((LongConstant) right).Value);
579 res = unchecked (((LongConstant) left).Value /
580 ((LongConstant) right).Value);
582 return new LongConstant (res);
583 } else if (left is UIntConstant){
586 if (ec.ConstantCheckState)
587 res = checked (((UIntConstant) left).Value /
588 ((UIntConstant) right).Value);
590 res = unchecked (((UIntConstant) left).Value /
591 ((UIntConstant) right).Value);
593 return new UIntConstant (res);
594 } else if (left is IntConstant){
597 if (ec.ConstantCheckState)
598 res = checked (((IntConstant) left).Value /
599 ((IntConstant) right).Value);
601 res = unchecked (((IntConstant) left).Value /
602 ((IntConstant) right).Value);
604 return new IntConstant (res);
606 throw new Exception ( "Unexepected input: " + left);
608 } catch (OverflowException){
609 Error_CompileTimeOverflow (loc);
613 case Binary.Operator.Modulus:
614 DoConstantNumericPromotions (oper, ref left, ref right, loc);
615 if (left == null || right == null)
619 if (left is DoubleConstant){
622 if (ec.ConstantCheckState)
623 res = checked (((DoubleConstant) left).Value %
624 ((DoubleConstant) right).Value);
626 res = unchecked (((DoubleConstant) left).Value %
627 ((DoubleConstant) right).Value);
629 return new DoubleConstant (res);
630 } else if (left is FloatConstant){
633 if (ec.ConstantCheckState)
634 res = checked (((FloatConstant) left).Value %
635 ((FloatConstant) right).Value);
637 res = unchecked (((FloatConstant) left).Value %
638 ((FloatConstant) right).Value);
640 return new FloatConstant (res);
641 } else if (left is ULongConstant){
644 if (ec.ConstantCheckState)
645 res = checked (((ULongConstant) left).Value %
646 ((ULongConstant) right).Value);
648 res = unchecked (((ULongConstant) left).Value %
649 ((ULongConstant) right).Value);
651 return new ULongConstant (res);
652 } else if (left is LongConstant){
655 if (ec.ConstantCheckState)
656 res = checked (((LongConstant) left).Value %
657 ((LongConstant) right).Value);
659 res = unchecked (((LongConstant) left).Value %
660 ((LongConstant) right).Value);
662 return new LongConstant (res);
663 } else if (left is UIntConstant){
666 if (ec.ConstantCheckState)
667 res = checked (((UIntConstant) left).Value %
668 ((UIntConstant) right).Value);
670 res = unchecked (((UIntConstant) left).Value %
671 ((UIntConstant) right).Value);
673 return new UIntConstant (res);
674 } else if (left is IntConstant){
677 if (ec.ConstantCheckState)
678 res = checked (((IntConstant) left).Value %
679 ((IntConstant) right).Value);
681 res = unchecked (((IntConstant) left).Value %
682 ((IntConstant) right).Value);
684 return new IntConstant (res);
686 throw new Exception ( "Unexepected input: " + left);
688 } catch (OverflowException){
689 Error_CompileTimeOverflow (loc);
694 // There is no overflow checking on left shift
696 case Binary.Operator.LeftShift:
697 IntConstant ic = right.ToInt (loc);
699 Binary.Error_OperatorCannotBeApplied (loc, "<<", lt, rt);
702 int lshift_val = ic.Value;
705 if ((lic = left.ConvertToInt ()) != null)
706 return new IntConstant (lic.Value << lshift_val);
709 if ((luic = left.ConvertToUInt ()) != null)
710 return new UIntConstant (luic.Value << lshift_val);
713 if ((llc = left.ConvertToLong ()) != null)
714 return new LongConstant (llc.Value << lshift_val);
717 if ((lulc = left.ConvertToULong ()) != null)
718 return new ULongConstant (lulc.Value << lshift_val);
720 Binary.Error_OperatorCannotBeApplied (loc, "<<", lt, rt);
724 // There is no overflow checking on right shift
726 case Binary.Operator.RightShift:
727 IntConstant sic = right.ToInt (loc);
729 Binary.Error_OperatorCannotBeApplied (loc, ">>", lt, rt);
732 int rshift_val = sic.Value;
735 if ((ric = left.ConvertToInt ()) != null)
736 return new IntConstant (ric.Value >> rshift_val);
739 if ((ruic = left.ConvertToUInt ()) != null)
740 return new UIntConstant (ruic.Value >> rshift_val);
743 if ((rlc = left.ConvertToLong ()) != null)
744 return new LongConstant (rlc.Value >> rshift_val);
747 if ((rulc = left.ConvertToULong ()) != null)
748 return new ULongConstant (rulc.Value >> rshift_val);
750 Binary.Error_OperatorCannotBeApplied (loc, ">>", lt, rt);
753 case Binary.Operator.LogicalAnd:
754 if (left is BoolConstant && right is BoolConstant){
755 return new BoolConstant (
756 ((BoolConstant) left).Value &&
757 ((BoolConstant) right).Value);
761 case Binary.Operator.LogicalOr:
762 if (left is BoolConstant && right is BoolConstant){
763 return new BoolConstant (
764 ((BoolConstant) left).Value ||
765 ((BoolConstant) right).Value);
769 case Binary.Operator.Equality:
770 if (left is BoolConstant && right is BoolConstant){
771 return new BoolConstant (
772 ((BoolConstant) left).Value ==
773 ((BoolConstant) right).Value);
776 if (left is StringConstant && right is StringConstant){
777 return new BoolConstant (
778 ((StringConstant) left).Value ==
779 ((StringConstant) right).Value);
783 DoConstantNumericPromotions (oper, ref left, ref right, loc);
784 if (left == null || right == null)
788 if (left is DoubleConstant)
789 bool_res = ((DoubleConstant) left).Value ==
790 ((DoubleConstant) right).Value;
791 else if (left is FloatConstant)
792 bool_res = ((FloatConstant) left).Value ==
793 ((FloatConstant) right).Value;
794 else if (left is ULongConstant)
795 bool_res = ((ULongConstant) left).Value ==
796 ((ULongConstant) right).Value;
797 else if (left is LongConstant)
798 bool_res = ((LongConstant) left).Value ==
799 ((LongConstant) right).Value;
800 else if (left is UIntConstant)
801 bool_res = ((UIntConstant) left).Value ==
802 ((UIntConstant) right).Value;
803 else if (left is IntConstant)
804 bool_res = ((IntConstant) left).Value ==
805 ((IntConstant) right).Value;
809 return new BoolConstant (bool_res);
811 case Binary.Operator.Inequality:
812 if (left is BoolConstant && right is BoolConstant){
813 return new BoolConstant (
814 ((BoolConstant) left).Value !=
815 ((BoolConstant) right).Value);
817 if (left is StringConstant && right is StringConstant){
818 return new BoolConstant (
819 ((StringConstant) left).Value !=
820 ((StringConstant) right).Value);
823 DoConstantNumericPromotions (oper, ref left, ref right, loc);
824 if (left == null || right == null)
828 if (left is DoubleConstant)
829 bool_res = ((DoubleConstant) left).Value !=
830 ((DoubleConstant) right).Value;
831 else if (left is FloatConstant)
832 bool_res = ((FloatConstant) left).Value !=
833 ((FloatConstant) right).Value;
834 else if (left is ULongConstant)
835 bool_res = ((ULongConstant) left).Value !=
836 ((ULongConstant) right).Value;
837 else if (left is LongConstant)
838 bool_res = ((LongConstant) left).Value !=
839 ((LongConstant) right).Value;
840 else if (left is UIntConstant)
841 bool_res = ((UIntConstant) left).Value !=
842 ((UIntConstant) right).Value;
843 else if (left is IntConstant)
844 bool_res = ((IntConstant) left).Value !=
845 ((IntConstant) right).Value;
849 return new BoolConstant (bool_res);
851 case Binary.Operator.LessThan:
852 DoConstantNumericPromotions (oper, ref left, ref right, loc);
853 if (left == null || right == null)
857 if (left is DoubleConstant)
858 bool_res = ((DoubleConstant) left).Value <
859 ((DoubleConstant) right).Value;
860 else if (left is FloatConstant)
861 bool_res = ((FloatConstant) left).Value <
862 ((FloatConstant) right).Value;
863 else if (left is ULongConstant)
864 bool_res = ((ULongConstant) left).Value <
865 ((ULongConstant) right).Value;
866 else if (left is LongConstant)
867 bool_res = ((LongConstant) left).Value <
868 ((LongConstant) right).Value;
869 else if (left is UIntConstant)
870 bool_res = ((UIntConstant) left).Value <
871 ((UIntConstant) right).Value;
872 else if (left is IntConstant)
873 bool_res = ((IntConstant) left).Value <
874 ((IntConstant) right).Value;
878 return new BoolConstant (bool_res);
880 case Binary.Operator.GreaterThan:
881 DoConstantNumericPromotions (oper, ref left, ref right, loc);
882 if (left == null || right == null)
886 if (left is DoubleConstant)
887 bool_res = ((DoubleConstant) left).Value >
888 ((DoubleConstant) right).Value;
889 else if (left is FloatConstant)
890 bool_res = ((FloatConstant) left).Value >
891 ((FloatConstant) right).Value;
892 else if (left is ULongConstant)
893 bool_res = ((ULongConstant) left).Value >
894 ((ULongConstant) right).Value;
895 else if (left is LongConstant)
896 bool_res = ((LongConstant) left).Value >
897 ((LongConstant) right).Value;
898 else if (left is UIntConstant)
899 bool_res = ((UIntConstant) left).Value >
900 ((UIntConstant) right).Value;
901 else if (left is IntConstant)
902 bool_res = ((IntConstant) left).Value >
903 ((IntConstant) right).Value;
907 return new BoolConstant (bool_res);
909 case Binary.Operator.GreaterThanOrEqual:
910 DoConstantNumericPromotions (oper, ref left, ref right, loc);
911 if (left == null || right == null)
915 if (left is DoubleConstant)
916 bool_res = ((DoubleConstant) left).Value >=
917 ((DoubleConstant) right).Value;
918 else if (left is FloatConstant)
919 bool_res = ((FloatConstant) left).Value >=
920 ((FloatConstant) right).Value;
921 else if (left is ULongConstant)
922 bool_res = ((ULongConstant) left).Value >=
923 ((ULongConstant) right).Value;
924 else if (left is LongConstant)
925 bool_res = ((LongConstant) left).Value >=
926 ((LongConstant) right).Value;
927 else if (left is UIntConstant)
928 bool_res = ((UIntConstant) left).Value >=
929 ((UIntConstant) right).Value;
930 else if (left is IntConstant)
931 bool_res = ((IntConstant) left).Value >=
932 ((IntConstant) right).Value;
936 return new BoolConstant (bool_res);
938 case Binary.Operator.LessThanOrEqual:
939 DoConstantNumericPromotions (oper, ref left, ref right, loc);
940 if (left == null || right == null)
944 if (left is DoubleConstant)
945 bool_res = ((DoubleConstant) left).Value <=
946 ((DoubleConstant) right).Value;
947 else if (left is FloatConstant)
948 bool_res = ((FloatConstant) left).Value <=
949 ((FloatConstant) right).Value;
950 else if (left is ULongConstant)
951 bool_res = ((ULongConstant) left).Value <=
952 ((ULongConstant) right).Value;
953 else if (left is LongConstant)
954 bool_res = ((LongConstant) left).Value <=
955 ((LongConstant) right).Value;
956 else if (left is UIntConstant)
957 bool_res = ((UIntConstant) left).Value <=
958 ((UIntConstant) right).Value;
959 else if (left is IntConstant)
960 bool_res = ((IntConstant) left).Value <=
961 ((IntConstant) right).Value;
965 return new BoolConstant (bool_res);