changeset 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 a5d4693483af
children 23b01aa3ecf9
files lwasm/lwasm.c lwasm/pseudo.c
diffstat 2 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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;
 }
 
--- 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;