shithub: scc

Download patch

ref: 681c75d4db6045572033f07cad7c365ec011f3a3
parent: 1bc2ce4189efa355a5ca0b845fd93fa3ace6092d
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Mon Dec 11 16:39:38 EST 2017

[as] Remove symtype enum

This enum doesn't make sense anymore and we can use symflags
for this purpouse.

--- a/as/as.h
+++ b/as/as.h
@@ -2,17 +2,12 @@
  * First 3 bits of flags in segments and symbols are for the
  * type of segment
  */
-enum symtype {
-	TUNDEF  = 1 << 0,
-	TREG    = 1 << 1,
-	TMASK   = 0x3,
-};
-
 enum symflags {
-	FCOMMON = 1 << 2,
-	FLOCAL  = 1 << 3,
-	FEXTERN = 1 << 6,
-	FUNDEF  = 1 << 7,
+	FREG    = 1 << 0,
+	FCOMMON = 1 << 1,
+	FLOCAL  = 1 << 2,
+	FEXTERN = 1 << 3,
+	FUNDEF  = 1 << 4,
 };
 
 enum secflags {
--- a/as/expr.c
+++ b/as/expr.c
@@ -200,7 +200,7 @@
 	while (isalnum(c = *endp) || c == '_' || c == '.')
 		++endp;
 	tok2str();
-	yylval.sym = lookup(yytext, TUNDEF);
+	yylval.sym = lookup(yytext, FUNDEF);
 
 	return IDEN;
 }
@@ -267,7 +267,7 @@
 	while (isalnum(c = *endp))
 		++endp;
 	tok2str();
-	yylval.sym = lookup(yytext, TREG);
+	yylval.sym = lookup(yytext, FREG);
 	if (!yylval.sym->argtype)
 		error("incorrect register name");
 	return REG;
--- a/as/myro.c
+++ b/as/myro.c
@@ -26,7 +26,7 @@
 	off = sizeof(FORMAT);
 
 	for (sym = symlist; sym; sym = sym->next) {
-		if ((sym->flags & TMASK) == TREG)
+		if (sym->flags & FREG)
 			continue;
 		str = &sym->name;
 		len = strlen(str->buf) + 1;
@@ -94,7 +94,7 @@
 	struct myrosym symbol;
 
 	for (sym = symlist; sym; sym = sym->next) {
-		if ((sym->flags & TMASK) == TREG)
+		if (sym->flags & FREG)
 			continue;
 		symbol.name = sym->name.offset;
 		symbol.type = -1;
--- a/as/symbol.c
+++ b/as/symbol.c
@@ -83,8 +83,8 @@
 		t = sym->name.buf;
 		if (c != toupper(*t) || casecmp(t, name))
 			continue;
-		symtype = sym->flags & TMASK;
-		if (symtype != TUNDEF && symtype != type)
+		symtype = sym->flags;
+		if (((symtype | type) & FUNDEF) == 0 && symtype != type)
 			continue;
 		return sym;
 	}
@@ -93,6 +93,7 @@
 	sym->name = newstring(name);
 	sym->flags = FLOCAL | FUNDEF | type;
 	sym->value = 0;
+	sym->section = cursec;
 	sym->hash = *list;
 	sym->next = symlist;
 
@@ -124,7 +125,7 @@
 		name = label;
 	}
 
-	sym = lookup(name, TUNDEF);
+	sym = lookup(name, FUNDEF);
 	if (pass == 1 && (sym->flags & FUNDEF) == 0)
 		error("redefinition of label '%s'", name);
 	sym->flags &= ~FUNDEF;
--- a/as/target/i386/proc.c
+++ b/as/target/i386/proc.c
@@ -92,7 +92,7 @@
 	}, *bp;
 
 	for (bp = regs; bp->name; ++bp) {
-		Symbol *sym = lookup(bp->name, TREG);
+		Symbol *sym = lookup(bp->name, FREG);
 		sym->argtype = bp->type;
 	}
 }
--- a/as/target/z80/proc.c
+++ b/as/target/z80/proc.c
@@ -45,7 +45,7 @@
 	}, *bp;
 
 	for (bp = regs; bp->name; ++bp) {
-		Symbol *sym = lookup(bp->name, TREG);
+		Symbol *sym = lookup(bp->name, FREG);
 		sym->argtype = bp->type;
 	}
 }