# HG changeset patch # User William Astle # Date 1337902095 21600 # Node ID 080bb67d84f2e6e2d105cb242429b763e0fb2e8f # Parent 806e5fc6dd9354b1d2a1ec9de2435244481523fd Add export pragma Added a pragma "export" which causes all exportable symbols to be exported automatically. diff -r 806e5fc6dd93 -r 080bb67d84f2 lwasm/lwasm.h --- 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 }; diff -r 806e5fc6dd93 -r 080bb67d84f2 lwasm/pragma.c --- 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} }; diff -r 806e5fc6dd93 -r 080bb67d84f2 lwasm/symbol.c --- 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; }