comparison lwasm/pseudo.c @ 38:7e92484cfbc3

Caused expressions used in setdp and conditionals to be reduced on pass 1
author lost@l-w.ca
date Sat, 02 Apr 2011 02:19:02 -0600
parents 127e5b1e01c0
children c6b8b455d67f
comparison
equal deleted inserted replaced
37:a5d4693483af 38:7e92484cfbc3
684 { 684 {
685 lwasm_register_error(as, l, "Bad operand"); 685 lwasm_register_error(as, l, "Bad operand");
686 return; 686 return;
687 } 687 }
688 688
689 // try simplifying the expression and see if it turns into an int
690 lwasm_reduce_expr(as, e);
689 if (!lw_expr_istype(e, lw_expr_type_int)) 691 if (!lw_expr_istype(e, lw_expr_type_int))
690 { 692 {
691 lwasm_register_error(as, l, "SETDP must be constant on pass 1"); 693 lwasm_register_error(as, l, "SETDP must be constant on pass 1");
692 return; 694 return;
693 } 695 }
737 skip_operand(p); 739 skip_operand(p);
738 return; 740 return;
739 } 741 }
740 742
741 e = lwasm_parse_cond(as, p); 743 e = lwasm_parse_cond(as, p);
744 lwasm_reduce_expr(as, e);
742 if (e && lw_expr_intval(e) != 0) 745 if (e && lw_expr_intval(e) != 0)
743 { 746 {
744 as -> skipcond = 1; 747 as -> skipcond = 1;
745 as -> skipcount = 1; 748 as -> skipcount = 1;
746 } 749 }
758 skip_operand(p); 761 skip_operand(p);
759 return; 762 return;
760 } 763 }
761 764
762 e = lwasm_parse_cond(as, p); 765 e = lwasm_parse_cond(as, p);
766 lwasm_reduce_expr(as, e);
763 if (e && lw_expr_intval(e) == 0) 767 if (e && lw_expr_intval(e) == 0)
764 { 768 {
765 as -> skipcond = 1; 769 as -> skipcond = 1;
766 as -> skipcount = 1; 770 as -> skipcount = 1;
767 } 771 }
780 skip_operand(p); 784 skip_operand(p);
781 return; 785 return;
782 } 786 }
783 787
784 e = lwasm_parse_cond(as, p); 788 e = lwasm_parse_cond(as, p);
789 lwasm_reduce_expr(as, e);
785 if (e && lw_expr_intval(e) <= 0) 790 if (e && lw_expr_intval(e) <= 0)
786 { 791 {
787 as -> skipcond = 1; 792 as -> skipcond = 1;
788 as -> skipcount = 1; 793 as -> skipcount = 1;
789 } 794 }
801 skip_operand(p); 806 skip_operand(p);
802 return; 807 return;
803 } 808 }
804 809
805 e = lwasm_parse_cond(as, p); 810 e = lwasm_parse_cond(as, p);
811 lwasm_reduce_expr(as, e);
806 if (e && lw_expr_intval(e) < 0) 812 if (e && lw_expr_intval(e) < 0)
807 { 813 {
808 as -> skipcond = 1; 814 as -> skipcond = 1;
809 as -> skipcount = 1; 815 as -> skipcount = 1;
810 } 816 }
822 skip_operand(p); 828 skip_operand(p);
823 return; 829 return;
824 } 830 }
825 831
826 e = lwasm_parse_cond(as, p); 832 e = lwasm_parse_cond(as, p);
833 lwasm_reduce_expr(as, e);
827 if (e && lw_expr_intval(e) >= 0) 834 if (e && lw_expr_intval(e) >= 0)
828 { 835 {
829 as -> skipcond = 1; 836 as -> skipcond = 1;
830 as -> skipcount = 1; 837 as -> skipcount = 1;
831 } 838 }
843 skip_operand(p); 850 skip_operand(p);
844 return; 851 return;
845 } 852 }
846 853
847 e = lwasm_parse_cond(as, p); 854 e = lwasm_parse_cond(as, p);
855 lwasm_reduce_expr(as, e);
848 if (e && lw_expr_intval(e) > 0) 856 if (e && lw_expr_intval(e) > 0)
849 { 857 {
850 as -> skipcond = 1; 858 as -> skipcond = 1;
851 as -> skipcount = 1; 859 as -> skipcount = 1;
852 } 860 }