diff lwasm/insn_indexed.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 35d4213e6657
line wrap: on
line diff
--- a/lwasm/insn_indexed.c	Mon Jun 22 18:38:30 2015 -0600
+++ b/lwasm/insn_indexed.c	Mon Jun 22 18:49:38 2015 -0600
@@ -169,7 +169,7 @@
 		e = lwasm_parse_expr(as, p);
 		if (!e || **p != ']')
 		{
-			lwasm_register_error(as, l, "Bad operand");
+			lwasm_register_error(as, l, E_OPERAND_BAD);
 			return;
 		}
 		lwasm_save_expr(l, 0, e);
@@ -199,7 +199,7 @@
 	e = lwasm_parse_expr(as, p);
 	if (!e)
 	{
-		lwasm_register_error(as, l, "Bad operand");
+		lwasm_register_error(as, l, E_OPERAND_BAD);
 		return;
 	}
 	lwasm_save_expr(l, 0, e);
@@ -207,7 +207,7 @@
 	// now look for a comma; if not present, explode
 	if (*(*p)++ != ',')
 	{
-		lwasm_register_error(as, l, "Bad operand");
+		lwasm_register_error(as, l, E_OPERAND_BAD);
 		return;
 	}
 	
@@ -215,7 +215,7 @@
 	rn = lwasm_lookupreg3(reglist, p);
 	if (rn < 0)
 	{
-		lwasm_register_error(as, l, "Bad register");
+		lwasm_register_error(as, l, E_REGISTER_BAD);
 		return;
 	}
 	
@@ -223,7 +223,7 @@
 	{
 		if (**p != ']')
 		{
-			lwasm_register_error(as, l, "Bad operand");
+			lwasm_register_error(as, l, E_OPERAND_BAD);
 			return;
 		}
 		else
@@ -250,7 +250,7 @@
 	{
 		if (l -> lint == 1)
 		{
-			lwasm_register_error(as, l, "n,W cannot be 8 bit");
+			lwasm_register_error(as, l, E_NW_8);
 			return;
 		}
 
@@ -588,7 +588,7 @@
 		i = lw_expr_intval(e);
 		if (i < -128 || i > 127)
 		{
-			lwasm_register_error(as, l, "Byte overflow");
+			lwasm_register_error(as, l, E_BYTE_OVERFLOW);
 		}
 	}