changeset 380:cc154dc614fe

Added extdep pseudo back in
author lost@starbug
date Mon, 26 Apr 2010 19:44:44 -0600
parents 85b592c8b8f6
children 1624a36f12a3
files lwasm/instab.c lwasm/section.c
diffstat 2 files changed, 65 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lwasm/instab.c	Mon Apr 26 19:31:35 2010 -0600
+++ b/lwasm/instab.c	Mon Apr 26 19:44:44 2010 -0600
@@ -261,6 +261,10 @@
 #define pseudo_resolve_emod NULL
 extern EMITFUNC(pseudo_emit_emod);
 
+extern PARSEFUNC(pseudo_parse_extdep);
+#define pseudo_resolve_extdep NULL
+#define pseudo_emit_extdep NULL
+
 extern PARSEFUNC(pseudo_parse_extern);
 #define pseudo_resolve_extern NULL
 #define pseudo_emit_extern NULL
@@ -549,6 +553,7 @@
 	{ "external",	{	-1, 	-1, 	-1, 	-1 },	pseudo_parse_extern,	pseudo_resolve_extern,			pseudo_emit_extern,			lwasm_insn_setsym},
 	{ "import",		{	-1, 	-1, 	-1, 	-1 },	pseudo_parse_extern,	pseudo_resolve_extern,			pseudo_emit_extern,			lwasm_insn_setsym},
 	{ "export",		{	-1, 	-1, 	-1, 	-1 },	pseudo_parse_export,	pseudo_resolve_export,			pseudo_emit_export,			lwasm_insn_setsym},
+	{ "extdep",		{	-1,		-1,		-1,		-1 },	pseudo_parse_extdep,	pseudo_resolve_extdep,			pseudo_emit_extdep,			lwasm_insn_setsym},
 
 	{ "rmb", 		{	-1, 	-1, 	-1, 	-1 },	pseudo_parse_rmb,		pseudo_resolve_rmb,				pseudo_emit_rmb,			lwasm_insn_normal},
 	{ "rmd", 		{	-1, 	-1, 	-1, 	-1 },	pseudo_parse_rmd,		pseudo_resolve_rmd,				pseudo_emit_rmd,			lwasm_insn_normal},
--- 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;
+	}
+}