changeset 200:348e2816ce32

Short ciruit some recursion in expression library
author William Astle <lost@l-w.ca>
date Fri, 16 Mar 2012 19:44:12 -0600
parents 3132b1742eca
children 4503199d56ba
files lwasm/lwasm.c lwasm/pass4.c lwlib/lw_expr.c
diffstat 3 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/lwasm/lwasm.c	Fri Mar 16 17:29:53 2012 -0600
+++ b/lwasm/lwasm.c	Fri Mar 16 19:44:12 2012 -0600
@@ -649,8 +649,7 @@
 
 int lwasm_reduce_expr(asmstate_t *as, lw_expr_t expr)
 {
-	if (expr)
-		lw_expr_simplify(expr, as);
+	lw_expr_simplify(expr, as);
 	return 0;
 }
 
--- a/lwasm/pass4.c	Fri Mar 16 17:29:53 2012 -0600
+++ b/lwasm/pass4.c	Fri Mar 16 19:44:12 2012 -0600
@@ -51,6 +51,8 @@
 	sl = as -> line_head;
 	while (cnt > 0)
 	{
+		debug_message(as, 60, "%d unresolved instructions", cnt);
+
 		// find an unresolved instruction
 		for ( ; sl && sl -> len != -1; sl = sl -> next)
 		{
--- a/lwlib/lw_expr.c	Fri Mar 16 17:29:53 2012 -0600
+++ b/lwlib/lw_expr.c	Fri Mar 16 19:44:12 2012 -0600
@@ -676,7 +676,8 @@
 	
 	// simplify operands
 	for (o = E -> operands; o; o = o -> next)
-		lw_expr_simplify_l(o -> p, priv);
+		if (o -> p -> type != lw_expr_type_int)
+			lw_expr_simplify_l(o -> p, priv);
 
 	for (o = E -> operands; o; o = o -> next)
 	{
@@ -1070,6 +1071,8 @@
 
 void lw_expr_simplify(lw_expr_t E, void *priv)
 {
+	if (E -> type == lw_expr_type_int)
+		return;
 	lw_expr_simplify_l(E, priv);
 }