summary refs log tree commit diff
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2016-08-14 18:11:49 -0700
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2016-08-14 20:02:56 -0700
commit8ca73af85a2351b99e0d19564548dd35ccf61011 (patch)
tree721de6856ab032da1d28e367a76559fc5b936a92
parentfaa084cca9c764e86c2751109352a599a8782b8a (diff)
downloadroux-8ca73af85a2351b99e0d19564548dd35ccf61011.tar.gz
use an enum for aggregate segments
-rw-r--r--all.h11
-rw-r--r--parse.c13
-rw-r--r--sysv.c13
3 files changed, 22 insertions, 15 deletions
diff --git a/all.h b/all.h
index 5a5c3c0..34ad47e 100644
--- a/all.h
+++ b/all.h
@@ -425,9 +425,14 @@ struct Typ {
 	ulong size;
 	int align;
 
-	struct {
-		uint isflt:1;
-		uint ispad:1;
+	struct Seg {
+		enum {
+			Spad,
+			Sint,
+			Sflt,
+			Styp,
+		};
+		uint type:2;
 		uint len:30;
 	} seg[NSeg+1];
 };
diff --git a/parse.c b/parse.c
index 4d6b345..924b5f5 100644
--- a/parse.c
+++ b/parse.c
@@ -791,7 +791,7 @@ static void
 parsetyp()
 {
 	Typ *ty;
-	int t, n, c, a, al, flt;
+	int t, n, c, a, al, type;
 	ulong sz, s;
 
 	if (ntyp >= NTyp)
@@ -825,12 +825,12 @@ parsetyp()
 		sz = 0;
 		al = 0;
 		while (t != Trbrace) {
-			flt = 0;
+			type = Sint;
 			switch (t) {
 			default: err("invalid size specifier %c", tokval.chr);
-			case Td: flt = 1;
+			case Td: type = Sflt;
 			case Tl: s = 8; a = 3; break;
-			case Ts: flt = 1;
+			case Ts: type = Sflt;
 			case Tw: s = 4; a = 2; break;
 			case Th: s = 2; a = 1; break;
 			case Tb: s = 1; a = 0; break;
@@ -841,7 +841,7 @@ parsetyp()
 				a = s - a;
 				if (n < NSeg) {
 					/* padding segment */
-					ty->seg[n].ispad = 1;
+					ty->seg[n].type = Spad;
 					ty->seg[n].len = a;
 					n++;
 				}
@@ -854,8 +854,7 @@ parsetyp()
 				c = 1;
 			sz += a + c*s;
 			for (; c>0 && n<NSeg; c--, n++) {
-				ty->seg[n].isflt = flt;
-				ty->seg[n].ispad = 0;
+				ty->seg[n].type = type;
 				ty->seg[n].len = s;
 			}
 			if (t != Tcomma)
diff --git a/sysv.c b/sysv.c
index b011bff..c8bc730 100644
--- a/sysv.c
+++ b/sysv.c
@@ -49,15 +49,18 @@ aclass(AClass *a, Typ *t)
 	for (e=0, s=0; e<2; e++) {
 		cls = -1;
 		for (n=0; n<8 && t->seg[s].len; s++) {
-			if (t->seg[s].ispad) {
+			switch (t->seg[s].type) {
+			case Spad:
 				/* don't change anything */
-			}
-			else if (t->seg[s].isflt) {
+				break;
+			case Sflt:
 				if (cls == -1)
 					cls = Kd;
-			}
-			else
+				break;
+			case Sint:
 				cls = Kl;
+				break;
+			}
 			n += t->seg[s].len;
 		}
 		assert(n <= 8);