diff lwasm/pass1.c @ 370:8764142b3192

Convert internal error/warning handling framework to a new unified system Replace the ad hoc error and warning handling with a new system that codifies the errors with specific codes. This makes it possible in the future for error numbers to be used for testing and other purposes. It also makes sure the error strings themselves are consistent. Thanks to Erik G <erik@6809.org> for the patch.
author William Astle <lost@l-w.ca>
date Mon, 22 Jun 2015 18:49:38 -0600
parents c6d2a1f54e0c
children 2593fd529be5
line wrap: on
line diff
--- a/lwasm/pass1.c	Mon Jun 22 18:38:30 2015 -0600
+++ b/lwasm/pass1.c	Mon Jun 22 18:49:38 2015 -0600
@@ -322,7 +322,7 @@
 						if (expand_struct(as, cl, &p1, sym) != 0)
 						{
 							// structure expansion failed
-							lwasm_register_error(as, cl, "Bad opcode");
+							lwasm_register_error(as, cl, E_OPCODE_BAD);
 						}
 					}
 				}
@@ -334,9 +334,9 @@
 				if (instab[opnum].parse)
 				{
 					if (CURPRAGMA(cl, PRAGMA_6809) && (instab[opnum].flags & lwasm_insn_is6309))
-						lwasm_register_error(as, cl, "Illegal use of 6309 instruction in 6809 mode (%s)", sym);
+						lwasm_register_error2(as, cl, E_6309_INVALID, "(%s)", sym);
 					if (!CURPRAGMA(cl, PRAGMA_6809) && (instab[opnum].flags & lwasm_insn_is6809))
-						lwasm_register_error(as, cl, "Illegal use of 6809 instruction in 6309 mode (%s)", sym);
+						lwasm_register_error2(as, cl, E_6809_INVALID, "(%s)", sym);
 
 					if (as -> instruct == 0 || instab[opnum].flags & lwasm_insn_struct)
 					{
@@ -360,7 +360,7 @@
 						if (*p1 && !isspace(*p1) && !(cl -> err))
 						{
 							// flag bad operand error
-							lwasm_register_error(as, cl, "Bad operand (%s)", p1);
+							lwasm_register_error2(as, cl, E_OPERAND_BAD, "(%s)", p1);
 						}
 						
 						/* do a reduction on the line expressions to avoid carrying excessive expression baggage if not needed */
@@ -368,7 +368,7 @@
 					}
 					else if (as -> instruct == 1)
 					{
-						lwasm_register_error(as, cl, "Bad operand (%s)", p1);
+						lwasm_register_error2(as, cl, E_OPERAND_BAD, "(%s)", p1);
 					}
 				}
 			}
@@ -387,7 +387,7 @@
 					if (!register_symbol(as, cl, cl -> sym, cl -> daddr, symbol_flag_none))
 					{
 						// symbol error
-						// lwasm_register_error(as, cl, "Bad symbol '%s'", cl -> sym);
+						// lwasm_register_error2(as, cl, E_SYMBOL_BAD, "(%s)", cl -> sym);
 					}
 				}
 				else
@@ -395,7 +395,7 @@
 					if (!register_symbol(as, cl, cl -> sym, cl -> addr, symbol_flag_none))
 					{
 						// symbol error
-						// lwasm_register_error(as, cl, "Bad symbol '%s'", cl -> sym);
+						// lwasm_register_error2(as, cl, E_SYMBOL_BAD, "(%s)", cl -> sym);
 					}
 				}
 			}