diff lwasm/section.c @ 380:cc154dc614fe

Added extdep pseudo back in
author lost@starbug
date Mon, 26 Apr 2010 19:44:44 -0600
parents d99322ef6f21
children cf8c92d70eb1
line wrap: on
line diff
--- a/lwasm/section.c	Mon Apr 26 19:31:35 2010 -0600
+++ b/lwasm/section.c	Mon Apr 26 19:44:44 2010 -0600
@@ -269,3 +269,63 @@
 		goto again;
 	}
 }
+
+PARSEFUNC(pseudo_parse_extdep)
+{
+	int after = 0;
+	char *sym = NULL;
+	importlist_t *e;
+	
+	if (as -> output_format != OUTPUT_OBJ)
+	{
+		lwasm_register_error(as, l, "EXTDEP only supported for object target");
+		return;
+	}
+	
+	if (!as -> csect)
+	{
+		lwasm_register_error(as, l, "EXTDEP must be within a section");
+		return;
+	}
+	
+	if (l -> sym)
+		sym = lw_strdup(l -> sym);
+	
+	if (l -> sym)
+	{
+		skip_operand(p);
+	}
+
+again:
+	if (after || !sym)
+	{
+		char *p2;
+		
+		after = 1;
+		for (p2 = *p; *p2 && *p2 != ',' && !isspace(*p2); p2++)
+			/* do nothing */ ;
+		
+		sym = lw_strndup(*p, p2 - *p);
+	}
+	if (!sym)
+	{
+		lwasm_register_error(as, l, "No symbol for EXTDEP");
+		return;
+	}
+	
+	// create a zero-width dependency
+	{
+		lw_expr_t e;
+		e = lw_expr_build(lw_expr_type_int, 0);
+		lwasm_emitexpr(l, e, 0);
+		lw_expr_destroy(e);
+	}
+	
+	if (after && **p == ',')
+	{
+		(*p)++;
+		for (; **p && isspace(**p); (*p)++)
+			/* do nothing */ ;
+		goto again;
+	}
+}