Mercurial > projects > dil
comparison trunk/src/dil/Expressions.d @ 539:3418027c3914
Added semantic() method to RealExpression.
Added code to IntExpression.semantic().
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Tue, 18 Dec 2007 22:46:07 +0100 |
parents | db7913148b29 |
children | 660684f559a4 |
comparison
equal
deleted
inserted
replaced
538:d0d40bcca9c6 | 539:3418027c3914 |
---|---|
746 assert(token.type == TOK.Int32); | 746 assert(token.type == TOK.Int32); |
747 } | 747 } |
748 this(token.ulong_, type); | 748 this(token.ulong_, type); |
749 } | 749 } |
750 | 750 |
751 Expression semantic(Scope scop) | 751 Expression semantic(Scope) |
752 { | 752 { |
753 if (type) | 753 if (type) |
754 return this; | 754 return this; |
755 | |
756 if (number & 0x8000_0000_0000_0000) | |
757 type = Types.Ulong; // 0xFFFF_FFFF_FFFF_FFFF | |
758 else if (number & 0xFFFF_FFFF_0000_0000) | |
759 type = Types.Long; // 0x7FFF_FFFF_FFFF_FFFF | |
760 else if (number & 0x8000_0000) | |
761 type = Types.Uint; // 0xFFFF_FFFF | |
762 else | |
763 type = Types.Int; // 0x7FFF_FFFF | |
755 return this; | 764 return this; |
756 } | 765 } |
757 } | 766 } |
758 | 767 |
759 class RealExpression : Expression | 768 class RealExpression : Expression |
760 { | 769 { |
761 TOK type; | |
762 real number; | 770 real number; |
763 this(TOK type, real number) | 771 |
772 this(real number, Type type) | |
764 { | 773 { |
765 mixin(set_kind); | 774 mixin(set_kind); |
766 this.number = number; | 775 this.number = number; |
767 this.type = type; | 776 this.type = type; |
777 } | |
778 | |
779 this(Token* token) | |
780 { | |
781 auto type = Types.Float; // Most common case? | |
782 switch (token.type) | |
783 { | |
784 // case T.Float32: | |
785 // type = Types.Float; break; | |
786 case TOK.Float64: | |
787 type = Types.Double; break; | |
788 case TOK.Float80: | |
789 type = Types.Double; break; | |
790 case TOK.Imaginary32: | |
791 type = Types.Ifloat; break; | |
792 case TOK.Imaginary64: | |
793 type = Types.Idouble; break; | |
794 case TOK.Imaginary80: | |
795 type = Types.Ireal; break; | |
796 default: | |
797 assert(token.type == TOK.Float32); | |
798 } | |
799 this(token.real_, type); | |
800 } | |
801 | |
802 Expression semantic(Scope) | |
803 { | |
804 if (type) | |
805 return this; | |
806 type = Types.Double; | |
807 return this; | |
768 } | 808 } |
769 } | 809 } |
770 | 810 |
771 class CharExpression : Expression | 811 class CharExpression : Expression |
772 { | 812 { |