comparison lwasm/lwasm.c @ 387:a741d2e4869f

Various bugfixes; fixed lwobjdump to display symbols with unprintable characters more sensibly; start of a (nonfunctional for now) testing framework
author lost@l-w.ca
date Wed, 14 Jul 2010 20:15:23 -0600
parents cf8c92d70eb1
children c1d83336e1d1
comparison
equal deleted inserted replaced
386:af5f2c51db76 387:a741d2e4869f
779 } 779 }
780 780
781 fprintf(stderr, " LINE: %s\n", cl -> ltext); 781 fprintf(stderr, " LINE: %s\n", cl -> ltext);
782 } 782 }
783 } 783 }
784
785 /*
786 this does any passes and other gymnastics that might be useful
787 to see if an expression reduces early
788 */
789 extern void do_pass3(asmstate_t *as);
790 extern void do_pass4_aux(asmstate_t *as, int force);
791
792 void lwasm_interim_reduce(asmstate_t *as)
793 {
794 do_pass3(as);
795 // do_pass4_aux(as, 0);
796 }
797
798 lw_expr_t lwasm_parse_cond(asmstate_t *as, char **p)
799 {
800 lw_expr_t e;
801
802 debug_message(as, 250, "Parsing condition");
803 e = lwasm_parse_expr(as, p);
804 debug_message(as, 250, "COND EXPR: %s", lw_expr_print(e));
805
806 if (!e)
807 {
808 lwasm_register_error(as, as -> cl, "Bad expression");
809 return NULL;
810 }
811
812 /* we need to simplify the expression here */
813 debug_message(as, 250, "Doing interim reductions");
814 lwasm_interim_reduce(as);
815 debug_message(as, 250, "COND EXPR: %s", lw_expr_print(e));
816 debug_message(as, 250, "Reducing expression");
817 lwasm_reduce_expr(as, e);
818 debug_message(as, 250, "COND EXPR: %s", lw_expr_print(e));
819 /* lwasm_reduce_expr(as, e);
820 debug_message(as, 250, "COND EXPR: %s", lw_expr_print(e));
821 lwasm_reduce_expr(as, e);
822 debug_message(as, 250, "COND EXPR: %s", lw_expr_print(e));
823 lwasm_reduce_expr(as, e);
824 debug_message(as, 250, "COND EXPR: %s", lw_expr_print(e));
825 */
826
827 lwasm_save_expr(as -> cl, 4242, e);
828
829 if (!lw_expr_istype(e, lw_expr_type_int))
830 {
831 debug_message(as, 250, "Non-constant expression");
832 lwasm_register_error(as, as -> cl, "Conditions must be constant on pass 1");
833 return NULL;
834 }
835 debug_message(as, 250, "Returning expression");
836 return e;
837 }