diff lwasm/symbol.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 3f8abaac214c
children b1adf549d181
line wrap: on
line diff
--- a/lwasm/symbol.c	Mon Jun 22 18:38:30 2015 -0600
+++ b/lwasm/symbol.c	Mon Jun 22 18:49:38 2015 -0600
@@ -90,18 +90,18 @@
 	{
 		if (!sym || !*sym)
 		{
-			lwasm_register_error(as, cl, "Bad symbol (%s)", sym);
+			lwasm_register_error2(as, cl, E_SYMBOL_BAD, "(%s)", sym);
 			return NULL;
 		}
 		if (*(unsigned char *)sym < 0x80 && (!strchr(SSYMCHARS, *sym) && !strchr(sym + 1, '$') && !strchr(sym + 1, '@') && !strchr(sym + 1, '?')))
 		{
-			lwasm_register_error(as, cl, "Bad symbol (%s)", sym);
+			lwasm_register_error2(as, cl, E_SYMBOL_BAD, "(%s)", sym);
 			return NULL;
 		}
 
 		if ((*sym == '$' || *sym == '@') && (sym[1] >= '0' && sym[1] <= '9'))
 		{
-			lwasm_register_error(as, cl, "Bad symbol (%s)", sym);
+			lwasm_register_error2(as, cl, E_SYMBOL_BAD, "(%s)", sym);
 			return NULL;
 		}
 	}
@@ -116,7 +116,7 @@
 		// bad symbol
 		if (!(flags & symbol_flag_nocheck) && *(unsigned char *)cp < 0x80 && !strchr(SYMCHARS, *cp))
 		{
-			lwasm_register_error(as, cl, "Bad symbol (%s)", sym);
+			lwasm_register_error2(as, cl, E_SYMBOL_BAD, "(%s)", sym);
 			return NULL;
 		}
 	}
@@ -163,7 +163,7 @@
 	if (se && version == -1)
 	{
 		// multiply defined symbol
-		lwasm_register_error(as, cl, "Multiply defined symbol (%s)", sym);
+		lwasm_register_error2(as, cl, E_SYMBOL_DUPE, "(%s)", sym);
 		return NULL;
 	}