changeset 206:080bb67d84f2

Add export pragma Added a pragma "export" which causes all exportable symbols to be exported automatically.
author William Astle <lost@l-w.ca>
date Thu, 24 May 2012 17:28:15 -0600
parents 806e5fc6dd93
children 07e1fac76321
files lwasm/lwasm.h lwasm/pragma.c lwasm/symbol.c
diffstat 3 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lwasm/lwasm.h	Wed May 23 19:37:30 2012 -0600
+++ b/lwasm/lwasm.h	Thu May 24 17:28:15 2012 -0600
@@ -82,7 +82,8 @@
 	PRAGMA_PCASPCR = 0x0020,			// treats ,PC as ,PCR instead of constant offset
 	PRAGMA_SHADOW = 0x0040,				// allow macros to shadow builtin operations
 	PRAGMA_NOLIST = 0x0080,				// don't show line in listing
-	PRAGMA_AUTOBRANCHLENGTH = 0x0100	// automatically select proper length for relative branches
+	PRAGMA_AUTOBRANCHLENGTH = 0x0100,	// automatically select proper length for relative branches
+	PRAGMA_EXPORT = 0x0200				// export symbols by default, unless local
 };
 
 
--- a/lwasm/pragma.c	Wed May 23 19:37:30 2012 -0600
+++ b/lwasm/pragma.c	Thu May 24 17:28:15 2012 -0600
@@ -56,6 +56,7 @@
 	{ "shadow", "noshadow", PRAGMA_SHADOW },
 	{ "nolist", "list", PRAGMA_NOLIST },
 	{ "autobranchlength", "noautobranchlength", PRAGMA_AUTOBRANCHLENGTH },
+	{ "export", "noexport", PRAGMA_EXPORT },
 	{ 0, 0, 0}
 };
 
--- a/lwasm/symbol.c	Wed May 23 19:37:30 2012 -0600
+++ b/lwasm/symbol.c	Thu May 24 17:28:15 2012 -0600
@@ -205,6 +205,18 @@
 		else
 			sprev -> right = nse;
 	}
+	if (CURPRAGMA(cl, PRAGMA_EXPORT) && cl -> csect && !islocal)
+	{
+		exportlist_t *e;
+		
+		/* export symbol if not already exported */
+		e = lw_alloc(sizeof(exportlist_t));
+		e -> next = as -> exportlist;
+		e -> symbol = lw_strdup(sym);
+		e -> line = cl;
+		e -> se = nse;
+		as -> exportlist = e;
+	}
 	return nse;
 }