Mercurial > projects > ddmd
comparison dmd/BinExp.d @ 115:6caaf0256da1
+ interpretation of (non-assign) binary expressions
+ BinExp.isunsigned
+ EqualExp.isBit
author | Trass3r |
---|---|
date | Thu, 02 Sep 2010 01:29:29 +0200 |
parents | e28b18c23469 |
children | 352a5164f692 |
comparison
equal
deleted
inserted
replaced
114:e28b18c23469 | 115:6caaf0256da1 |
---|---|
653 return this; | 653 return this; |
654 } | 654 } |
655 | 655 |
656 bool isunsigned() | 656 bool isunsigned() |
657 { | 657 { |
658 assert(false); | 658 return e1.type.isunsigned() || e2.type.isunsigned(); |
659 } | 659 } |
660 | 660 |
661 void incompatibleTypes() | 661 void incompatibleTypes() |
662 { | 662 { |
663 error("incompatible types for ((%s) %s (%s)): '%s' and '%s'", | 663 error("incompatible types for ((%s) %s (%s)): '%s' and '%s'", |
668 override void dump(int indent) | 668 override void dump(int indent) |
669 { | 669 { |
670 assert(false); | 670 assert(false); |
671 } | 671 } |
672 | 672 |
673 void scanForNestedRef(Scope *sc) | 673 void scanForNestedRef(Scope sc) |
674 { | 674 { |
675 assert(false); | 675 assert(false); |
676 } | 676 } |
677 | 677 |
678 Expression interpretCommon(InterState istate, Expression *(*fp)(Type *, Expression *, Expression *)) | 678 Expression interpretCommon(InterState istate, Expression function(Type, Expression, Expression) fp) |
679 { | 679 { |
680 assert(false); | 680 Expression e; |
681 } | 681 Expression e1; |
682 | 682 Expression e2; |
683 Expression interpretCommon2(InterState istate, Expression *(*fp)(TOK, Type *, Expression *, Expression *)) | 683 |
684 { | 684 version(LOG) |
685 assert(false); | 685 { |
686 writef("BinExp::interpretCommon() %s\n", toChars()); | |
687 } | |
688 e1 = this.e1.interpret(istate); | |
689 if (e1 == EXP_CANT_INTERPRET) | |
690 goto Lcant; | |
691 if (e1.isConst() != 1) | |
692 goto Lcant; | |
693 | |
694 e2 = this.e2.interpret(istate); | |
695 if (e2 == EXP_CANT_INTERPRET) | |
696 goto Lcant; | |
697 if (e2.isConst() != 1) | |
698 goto Lcant; | |
699 | |
700 e = fp(type, e1, e2); | |
701 return e; | |
702 | |
703 Lcant: | |
704 return EXP_CANT_INTERPRET; | |
705 } | |
706 | |
707 Expression interpretCommon2(InterState istate, Expression function(TOK, Type, Expression, Expression) fp) | |
708 { | |
709 Expression e; | |
710 Expression e1; | |
711 Expression e2; | |
712 | |
713 version(LOG) | |
714 { | |
715 writef("BinExp::interpretCommon2() %s\n", toChars()); | |
716 } | |
717 e1 = this.e1.interpret(istate); | |
718 if (e1 == EXP_CANT_INTERPRET) | |
719 goto Lcant; | |
720 if (e1.isConst() != 1 && | |
721 e1.op != TOKnull && | |
722 e1.op != TOKstring && | |
723 e1.op != TOKarrayliteral && | |
724 e1.op != TOKstructliteral) | |
725 goto Lcant; | |
726 | |
727 e2 = this.e2.interpret(istate); | |
728 if (e2 == EXP_CANT_INTERPRET) | |
729 goto Lcant; | |
730 if (e2.isConst() != 1 && | |
731 e2.op != TOKnull && | |
732 e2.op != TOKstring && | |
733 e2.op != TOKarrayliteral && | |
734 e2.op != TOKstructliteral) | |
735 goto Lcant; | |
736 | |
737 e = fp(op, type, e1, e2); | |
738 return e; | |
739 | |
740 Lcant: | |
741 return EXP_CANT_INTERPRET; | |
686 } | 742 } |
687 | 743 |
688 Expression interpretAssignCommon(InterState istate, Expression (*fp)(Type, Expression, Expression), int post = 0) | 744 Expression interpretAssignCommon(InterState istate, Expression (*fp)(Type, Expression, Expression), int post = 0) |
689 { | 745 { |
690 version (LOG) { | 746 version (LOG) { |
1322 dump(0); | 1378 dump(0); |
1323 } | 1379 } |
1324 } | 1380 } |
1325 return e; | 1381 return e; |
1326 } | 1382 } |
1327 | 1383 |
1384 version(DMDV2) | |
1328 override bool canThrow() | 1385 override bool canThrow() |
1329 { | 1386 { |
1330 return e1.canThrow() || e2.canThrow(); | 1387 return e1.canThrow() || e2.canThrow(); |
1331 } | 1388 } |
1332 | 1389 |