diff lwasm/lwasm.c @ 210:5d969517db74

Added condundefzero pragma Added pragma condundefzero to allow the assembler to treat symbols that are undefined in a conditional expression as if their value had been set to zero.
author William Astle <lost@l-w.ca>
date Sat, 09 Jun 2012 16:25:19 -0600
parents 52d9dd71f555
children 6f2e18f1fe67
line wrap: on
line diff
--- a/lwasm/lwasm.c	Sat Jun 09 16:03:36 2012 -0600
+++ b/lwasm/lwasm.c	Sat Jun 09 16:25:19 2012 -0600
@@ -58,6 +58,12 @@
 		return e;
 	}
 	
+	if (as -> undefzero)
+	{
+		e = lw_expr_build(lw_expr_type_int, 0);
+		return e;
+	}
+	
 	// undefined here is undefied unless output is object
 	if (as -> output_format != OUTPUT_OBJ)
 		goto nomatch;
@@ -896,6 +902,14 @@
 		return NULL;
 	}
 
+	/* handle condundefzero */
+	if (CURPRAGMA(as -> cl, PRAGMA_CONDUNDEFZERO))
+	{
+		as -> undefzero = 1;
+		lwasm_reduce_expr(as, e);
+		as -> undefzero = 0;
+	}
+
 	/* we need to simplify the expression here */
 	debug_message(as, 250, "Doing interim reductions");
 	lwasm_interim_reduce(as);