diff lwasm/lwasm.c @ 344:0215a0fbf61b

Added assembly error system and additional checks for symbol syntax
author lost@starbug
date Thu, 25 Mar 2010 22:06:50 -0600
parents 04c80c51b16a
children 7416c3f9c321
line wrap: on
line diff
--- a/lwasm/lwasm.c	Thu Mar 25 20:51:34 2010 -0600
+++ b/lwasm/lwasm.c	Thu Mar 25 22:06:50 2010 -0600
@@ -19,14 +19,19 @@
 this program. If not, see <http://www.gnu.org/licenses/>.
 */
 
+#define ___lwasm_c_seen___
+
 #include <config.h>
 
+#include <stdio.h>
+#include <stdarg.h>
+
 #include <lw_expr.h>
+#include <lw_alloc.h>
+#include <lw_string.h>
 
 #include "lwasm.h"
 
-#define NULL 0;
-
 lw_expr_t lwasm_evaluate_var(char *var)
 {
 	return NULL;
@@ -47,3 +52,28 @@
 	}
 	return NULL;
 }
+
+void lwasm_register_error(asmstate_t *as, line_t *l, const char *msg, ...)
+{
+	lwasm_error_t *e;
+	va_list args;
+	char errbuff[1024];
+	int r;
+	
+	if (!l)
+		return;
+
+	va_start(args, msg);
+	
+	e = lw_alloc(sizeof(lwasm_error_t));
+	
+	e -> next = l -> err;
+	l -> err = e;
+	
+	as -> errorcount++;
+	
+	r = vsnprintf(errbuff, 1024, msg, args);
+	e -> mess = lw_strdup(errbuff);
+	
+	va_end(args);
+}