diff lwasm/insn_gen.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 433dbc18fb41
children 8e25147c2aa8
line wrap: on
line diff
--- a/lwasm/insn_gen.c	Mon Jun 22 18:38:30 2015 -0600
+++ b/lwasm/insn_gen.c	Mon Jun 22 18:49:38 2015 -0600
@@ -43,7 +43,7 @@
 
 	if (!**p)
 	{
-		lwasm_register_error(as, l, "Bad operand");
+		lwasm_register_error(as, l, E_OPERAND_BAD);
 		return;
 	}
 
@@ -93,7 +93,7 @@
 	s = lwasm_parse_expr(as, p);
 	if (!s)
 	{
-		lwasm_register_error(as, l, "Bad operand");
+		lwasm_register_error(as, l, E_OPERAND_BAD);
 		return;
 	}
 	
@@ -276,7 +276,7 @@
 			if (l -> lint == 1)
 			{
 				if (i < -128 || i > 127)
-					lwasm_register_error(as, l, "Byte overflow");
+					lwasm_register_error(as, l, E_BYTE_OVERFLOW);
 			}
 			lwasm_emitexpr(l, e, l -> lint);
 		}
@@ -294,7 +294,7 @@
 {
 	if (**p == '#')
 	{
-		lwasm_register_error(as, l, "Immediate mode not allowed");
+		lwasm_register_error(as, l, E_IMMEDIATE_INVALID);
 		return;
 	}
 	
@@ -328,7 +328,7 @@
 		as -> exprwidth = 16;
 		if (!e)
 		{
-			lwasm_register_error(as, l, "Bad operand");
+			lwasm_register_error(as, l, E_OPERAND_BAD);
 			return;
 		}
 		l -> len = OPLEN(instab[l -> insn].ops[3]) + 1;
@@ -377,7 +377,7 @@
 			i = lw_expr_intval(e);
 			if (i < -128 || i > 255)
 			{
-				lwasm_register_error(as, l, "Byte overflow");
+				lwasm_register_error(as, l, E_BYTE_OVERFLOW);
 			}
 		}
 
@@ -399,7 +399,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;
 		}
 		l -> len = OPLEN(instab[l -> insn].ops[3]) + 2;
@@ -460,7 +460,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;
 		}
 		l -> len = OPLEN(instab[l -> insn].ops[3]) + 4;
@@ -524,7 +524,7 @@
 		as -> exprwidth = 16;
 		if (!e)
 		{
-			lwasm_register_error(as, l, "Bad operand");
+			lwasm_register_error(as, l, E_OPERAND_BAD);
 			return;
 		}
 		l -> len = OPLEN(instab[l -> insn].ops[0]) + 1;
@@ -532,7 +532,7 @@
 	}
 	else
 	{
-		lwasm_register_error(as, l, "Bad operand");
+		lwasm_register_error(as, l, E_OPERAND_BAD);
 	}
 }
 
@@ -548,7 +548,7 @@
 		i = lw_expr_intval(e);
 		if (i < -128 || i > 255)
 		{
-			lwasm_register_error(as, l, "Byte overflow");
+			lwasm_register_error(as, l, E_BYTE_OVERFLOW);
 		}
 	}
 	lwasm_emitexpr(l, e, 1);