# HG changeset patch # User lost@l-w.ca # Date 1301732342 21600 # Node ID 7e92484cfbc3911732bd15775b08b030e46da77b # Parent a5d4693483af8c1d8bf0c684926139fab37e4794 Caused expressions used in setdp and conditionals to be reduced on pass 1 diff -r a5d4693483af -r 7e92484cfbc3 lwasm/lwasm.c --- a/lwasm/lwasm.c Fri Apr 01 23:58:55 2011 -0600 +++ b/lwasm/lwasm.c Sat Apr 02 02:19:02 2011 -0600 @@ -602,7 +602,8 @@ int lwasm_reduce_expr(asmstate_t *as, lw_expr_t expr) { - lw_expr_simplify(expr, as); + if (expr) + lw_expr_simplify(expr, as); return 0; } diff -r a5d4693483af -r 7e92484cfbc3 lwasm/pseudo.c --- a/lwasm/pseudo.c Fri Apr 01 23:58:55 2011 -0600 +++ b/lwasm/pseudo.c Sat Apr 02 02:19:02 2011 -0600 @@ -686,6 +686,8 @@ return; } + // try simplifying the expression and see if it turns into an int + lwasm_reduce_expr(as, e); if (!lw_expr_istype(e, lw_expr_type_int)) { lwasm_register_error(as, l, "SETDP must be constant on pass 1"); @@ -739,6 +741,7 @@ } e = lwasm_parse_cond(as, p); + lwasm_reduce_expr(as, e); if (e && lw_expr_intval(e) != 0) { as -> skipcond = 1; @@ -760,6 +763,7 @@ } e = lwasm_parse_cond(as, p); + lwasm_reduce_expr(as, e); if (e && lw_expr_intval(e) == 0) { as -> skipcond = 1; @@ -782,6 +786,7 @@ } e = lwasm_parse_cond(as, p); + lwasm_reduce_expr(as, e); if (e && lw_expr_intval(e) <= 0) { as -> skipcond = 1; @@ -803,6 +808,7 @@ } e = lwasm_parse_cond(as, p); + lwasm_reduce_expr(as, e); if (e && lw_expr_intval(e) < 0) { as -> skipcond = 1; @@ -824,6 +830,7 @@ } e = lwasm_parse_cond(as, p); + lwasm_reduce_expr(as, e); if (e && lw_expr_intval(e) >= 0) { as -> skipcond = 1; @@ -845,6 +852,7 @@ } e = lwasm_parse_cond(as, p); + lwasm_reduce_expr(as, e); if (e && lw_expr_intval(e) > 0) { as -> skipcond = 1;