diff 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
line wrap: on
line diff
--- 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;