Mercurial > projects > dil
comparison src/dil/ast/Expressions.d @ 821:09a64d96967a
Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
author | Jarrett Billingsley <jarrett.billingsley@gmail.com> |
---|---|
date | Fri, 14 Mar 2008 11:01:05 -0400 |
parents | bcb74c9b895c |
children | 451ede0105e0 |
comparison
equal
deleted
inserted
replaced
819:438ed3a72c9d | 821:09a64d96967a |
---|---|
660 mixin(copyMethod); | 660 mixin(copyMethod); |
661 } | 661 } |
662 | 662 |
663 class BoolExpression : Expression | 663 class BoolExpression : Expression |
664 { | 664 { |
665 IntExpression value; /// IntExpression of type bool. | |
666 | |
665 this() | 667 this() |
666 { | 668 { |
667 mixin(set_kind); | 669 mixin(set_kind); |
668 } | 670 } |
669 | 671 |
670 bool toBool() | 672 bool toBool() |
671 { | 673 { |
672 assert(begin !is null); | 674 assert(begin !is null); |
673 return begin.kind == TOK.True ? true : false; | 675 return begin.kind == TOK.True ? true : false; |
674 } | 676 } |
675 | |
676 Expression value; /// IntExpression of type int. | |
677 | 677 |
678 mixin(copyMethod); | 678 mixin(copyMethod); |
679 } | 679 } |
680 | 680 |
681 class IntExpression : Expression | 681 class IntExpression : Expression |
763 mixin(copyMethod); | 763 mixin(copyMethod); |
764 } | 764 } |
765 | 765 |
766 class CharExpression : Expression | 766 class CharExpression : Expression |
767 { | 767 { |
768 dchar character; | 768 IntExpression value; // IntExpression of type Char/Wchar/Dchar. |
769 // dchar character; | |
769 this(dchar character) | 770 this(dchar character) |
770 { | 771 { |
771 mixin(set_kind); | 772 mixin(set_kind); |
772 this.character = character; | 773 // this.character = character; |
774 if(character <= 0xFF) | |
775 this.value = new IntExpression(character, Types.Char); | |
776 else if(character <= 0xFFFF) | |
777 this.value = new IntExpression(character, Types.Wchar); | |
778 else | |
779 this.value = new IntExpression(character, Types.Dchar); | |
780 | |
781 assert(this.value.type !is null); | |
782 | |
783 this.type = this.value.type; | |
773 } | 784 } |
774 mixin(copyMethod); | 785 mixin(copyMethod); |
775 } | 786 } |
776 | 787 |
777 class StringExpression : Expression | 788 class StringExpression : Expression |