changeset 562:6237505ee1dc

Add pragma nolistcode which works like nolist but also suppresses code lines It is occasionally useful to suppress parts of a listing that generate code. This nolistcode pragma works exactly like nolist but also suppresses code for just that reason.
author William Astle <lost@l-w.ca>
date Fri, 01 Dec 2023 21:11:56 -0700
parents a6a9d46f071f
children 8c6c3363e18e
files lwasm/list.c lwasm/lwasm.h lwasm/pragma.c
diffstat 3 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lwasm/list.c	Thu Nov 30 16:54:12 2023 -0700
+++ b/lwasm/list.c	Fri Dec 01 21:11:56 2023 -0700
@@ -73,6 +73,10 @@
 		char *linespec;
 
 		nl = cl -> next;
+		if (CURPRAGMA(cl, PRAGMA_NOLISTCODE))
+		{
+			continue;
+		}
 		if (CURPRAGMA(cl, PRAGMA_NOLIST))
 		{
 			if (cl -> outputl <= 0)
--- a/lwasm/lwasm.h	Thu Nov 30 16:54:12 2023 -0700
+++ b/lwasm/lwasm.h	Fri Dec 01 21:11:56 2023 -0700
@@ -115,6 +115,7 @@
 	PRAGMA_EMUEXT				= 1 << 26,  // enable emulator extensions
 	PRAGMA_NOOUTPUT             = 1 << 27,  // disable object code output
 	PRAGMA_NOEXPANDCOND         = 1 << 28,  // hide conditionals and skipped output in listings
+	PRAGMA_NOLISTCODE           = 1 << 29,  // hide line in listing even if it generates code
 	PRAGMA_CLEARBIT				= 1 << 31	// reserved to indicate negated pragma flag status
 };
 
--- a/lwasm/pragma.c	Thu Nov 30 16:54:12 2023 -0700
+++ b/lwasm/pragma.c	Fri Dec 01 21:11:56 2023 -0700
@@ -55,6 +55,7 @@
 	{ "pcaspcr", "nopcaspcr", PRAGMA_PCASPCR },
 	{ "shadow", "noshadow", PRAGMA_SHADOW },
 	{ "nolist", "list", PRAGMA_NOLIST },
+	{ "nolistcode", "listcode", PRAGMA_NOLISTCODE },
 	{ "autobranchlength", "noautobranchlength", PRAGMA_AUTOBRANCHLENGTH },
 	{ "export", "noexport", PRAGMA_EXPORT },
 	{ "symbolnocase", "nosymbolnocase", PRAGMA_SYMBOLNOCASE },
@@ -147,6 +148,8 @@
 	}
 	if (as -> pragmas & PRAGMA_NOLIST)
 		l -> pragmas |= PRAGMA_NOLIST;
+	if (as -> pragmas & PRAGMA_NOLISTCODE)
+		l -> pragmas |= PRAGMA_NOLISTCODE;
 	if (as->pragmas & PRAGMA_CC)
 	{
 		l->pragmas |= PRAGMA_CC;
@@ -171,6 +174,8 @@
 	parse_pragma_string(as, ps, 1);
 	if (as -> pragmas & PRAGMA_NOLIST)
 		l -> pragmas |= PRAGMA_NOLIST;
+	if (as -> pragmas & PRAGMA_NOLISTCODE)
+		l -> pragmas |= PRAGMA_NOLISTCODE;
 	if (as->pragmas & PRAGMA_CC)
 	{
 		l->pragmas |= PRAGMA_CC;
@@ -226,6 +231,8 @@
 				}
 				if (set_pragmas[i].flag == PRAGMA_NOLIST)
 					l -> pragmas |= PRAGMA_NOLIST;
+				if (set_pragmas[i].flag == PRAGMA_NOLISTCODE)
+					l -> pragmas |= PRAGMA_NOLISTCODE;
 			}
 		}
 		lw_free(pp);
@@ -282,6 +289,8 @@
 				
 				if (set_pragmas[i].flag == PRAGMA_NOLIST)
 					l -> pragmas |= PRAGMA_NOLIST;
+				if (set_pragmas[i].flag == PRAGMA_NOLISTCODE)
+					l -> pragmas |= PRAGMA_NOLISTCODE;
 			}
 		}
 		lw_free(pp);