diff lwasm/pass1.c @ 372:90de73ba0cac

Created a useful debug framework and adjusted lw_expr_print() to return a "static" dynamic string
author lost@starbug
date Thu, 22 Apr 2010 18:19:06 -0600
parents 6b33faa21a0a
children d99322ef6f21
line wrap: on
line diff
--- a/lwasm/pass1.c	Wed Apr 21 23:29:18 2010 -0600
+++ b/lwasm/pass1.c	Thu Apr 22 18:19:06 2010 -0600
@@ -76,7 +76,7 @@
 			lw_free(line);
 			continue;
 		}
-		printf("%s\n", line);
+		debug_message(as, 75, "Read line: %s", line);
 		
 		cl = lw_alloc(sizeof(line_t));
 		memset(cl, 0, sizeof(line_t));
@@ -252,9 +252,7 @@
 		{
 			if (cl -> sym && cl -> symset == 0)
 			{
-				printf("Register symbol %s:", cl -> sym);
-				lw_expr_print(cl -> addr, stderr);
-				printf("\n");
+				debug_message(as, 50, "Register symbol %s: %s", cl -> sym, lw_expr_print(cl -> addr));
 	
 				// register symbol at line address
 				if (!register_symbol(as, cl, cl -> sym, cl -> addr, symbol_flag_none))
@@ -263,9 +261,7 @@
 					// lwasm_register_error(as, cl, "Bad symbol '%s'", cl -> sym);
 				}
 			}
-		
-			lw_expr_print(cl -> addr, stderr);
-			printf("\n");
+			debug_message(as, 40, "Line address: %s", lw_expr_print(cl -> addr));
 		}
 		
 	nextline: