shithub: scc

Download patch

ref: 4ca822523b4538c4267bdd8604fd6a71c7e6aca8
parent: ca543c97d5f35334bc9784a3b5c7c5a8fe7a8f8a
author: Roberto E. Vargas Caballero <[email protected]>
date: Sat Feb 3 16:31:54 EST 2018

[as] Remove FNTYPE and FMASK

We can use only one bit for every type of symbol.

--- a/as/as.h
+++ b/as/as.h
@@ -3,16 +3,13 @@
  * type of segment
  */
 enum symflags {
-	FTMASK   = 0x3,
-	FNTYPE  = 0,
-	FREG    = 1,
-	FSECT   = 2,
-	FSYM    = 3,
-
-	FCOMMON = 1 << 2,
-	FEXTERN = 1 << 3,
-	FDEF  = 1 << 4,
-	FGLOBAL = 1 << 5,
+	FREG    = 1 << 0,
+	FSECT   = 1 << 1,
+	FSYM    = 1 << 2,
+	FCOMMON = 1 << 3,
+	FEXTERN = 1 << 4,
+	FDEF    = 1 << 5,
+	FGLOBAL = 1 << 6,
 	FABS    = 1 << 7,
 };
 
--- a/as/myro.c
+++ b/as/myro.c
@@ -27,7 +27,7 @@
 	off = sizeof(FORMAT);
 
 	for (sym = symlist; sym; sym = sym->next) {
-		if ((sym->flags & FTMASK) == FREG)
+		if (sym->flags & FREG)
 			continue;
 		str = &sym->name;
 		len = strlen(str->buf) + 1;
@@ -100,14 +100,12 @@
 static size_t
 writesymbols(FILE *fp)
 {
-	int type;
 	Symbol *sym;
 	size_t off = 0;
 	struct myrosym symbol;
 
 	for (sym = symlist; sym; sym = sym->next) {
-		type = sym->flags & FTMASK;
-		if (type == FREG || type == FSECT)
+		if (sym->flags & (FREG|FSECT))
 			continue;
 		symbol.name = sym->name.offset;
 		symbol.type = -1;
--- a/as/parser.c
+++ b/as/parser.c
@@ -84,7 +84,7 @@
 	tok2str();
 	yylval.sym = lookup(yytext);
 
-	return ((yylval.sym->flags & FTMASK) == FREG) ? REG : IDEN;
+	return (yylval.sym->flags & FREG) ? REG : IDEN;
 }
 
 static int
--- a/as/symbol.c
+++ b/as/symbol.c
@@ -64,7 +64,7 @@
 
 	sym = xmalloc(sizeof(*sym));
 	sym->name = newstring(name);
-	sym->flags = FNTYPE;
+	sym->flags = 0;
 	sym->size = sym->value = 0;
 	sym->section = cursec;
 	sym->hash = *list;
@@ -190,12 +190,10 @@
 {
 	Section *sec;
 	Symbol *sym;
-	int flags, type;
 
 	cursec = NULL;
 	sym = lookup(name);
-	type = sym->flags & FTMASK;
-	if (type != FNTYPE && type != FSECT)
+	if (sym->flags & ~FSECT)
 		error("invalid section name '%s'", name);
 
 	if ((sec = sym->section) == NULL) {