shithub: mc

Download patch

ref: 9f4568a0cd45791102980cecb76aaba3ff5b254e
parent: 129d74197a3de99fab0a386ebf152a06b3d4bf17
author: Ori Bernstein <ori@eigenstate.org>
date: Tue Aug 22 18:47:40 EDT 2017

Clean up usefile cruft.

--- a/parse/parse.h
+++ b/parse/parse.h
@@ -1,4 +1,4 @@
-#define Abiversion 13
+#define Abiversion 14
 
 typedef struct Srcloc Srcloc;
 typedef struct Tysubst Tysubst;
--- a/parse/use.c
+++ b/parse/use.c
@@ -226,25 +226,25 @@
 	}
 	wrbyte(fd, ty->type);
 	wrbyte(fd, ty->vis);
-	/* tid is generated; don't write */
-	/* FIXME: since we only support hardcoded traits, we just write
-	* out the set of them. we should write out the trait list a
-	* well */
-	if (!ty->trneed) {
-		wrint(fd, 0);
-	} else {
-		wrint(fd, bscount(ty->trneed));
-		for (i = 0; bsiter(ty->trneed, &i); i++) {
-			if (i < Ntraits)
-				wrint(fd, i | Builtinmask);
-			else
-				wrint(fd, traittab[i]->uid);
-		}
-	}
 	wrint(fd, ty->nsub);
 	switch (ty->type) {
-	case Tyunres:	pickle(fd, ty->name);	break;
-	case Typaram:	wrstr(fd, ty->pname);	break;
+	case Tyunres:
+		pickle(fd, ty->name);
+		break;
+	case Typaram:
+		/* tid is generated; don't write */
+		if (ty->trneed) {
+			wrint(fd, bscount(ty->trneed));
+			for (i = 0; bsiter(ty->trneed, &i); i++) {
+				if (i < Ntraits)
+					wrint(fd, i | Builtinmask);
+				else
+					wrint(fd, traittab[i]->uid);
+			}
+		} else {
+			wrint(fd, 0);
+		}
+		wrstr(fd, ty->pname);	break;
 	case Tystruct:
 		wrint(fd, ty->nmemb);
 		for (i = 0; i < ty->nmemb; i++)
@@ -263,7 +263,6 @@
 	case Tyvar:	die("Attempting to pickle %s. This will not work.\n", tystr(ty));	break;
 	case Tyname:
 		pickle(fd, ty->name);
-		wrbool(fd, 0); /* TRFIX: fixme, compat */
 		wrint(fd, ty->narg);
 		for (i = 0; i < ty->narg; i++)
 			wrtype(fd, ty->arg[i]);
@@ -271,7 +270,6 @@
 		break;
 	case Tygeneric:
 		pickle(fd, ty->name);
-		wrbool(fd, 0);	/* TRFIX: fixme, compat */
 		wrint(fd, ty->ngparam);
 		for (i = 0; i < ty->ngparam; i++)
 			wrtype(fd, ty->gparam[i]);
@@ -361,10 +359,6 @@
 	ty->isimport = 1;
 	if (rdbyte(fd) == Vishidden)
 		ty->ishidden = 1;
-	/* tid is generated; don't write */
-	n = rdint(fd);
-	for (i = 0; i < n; i++)
-		rdtrait(fd, NULL, ty);
 	ty->nsub = rdint(fd);
 	if (ty->nsub > 0)
 		ty->sub = zalloc(ty->nsub * sizeof(Type *));
@@ -373,6 +367,9 @@
 		ty->name = unpickle(fd);
 		break;
 	case Typaram:	
+		n = rdint(fd);
+		for (i = 0; i < n; i++)
+			rdtrait(fd, NULL, ty);
 		ty->pname = rdstr(fd);
 		break;
 	case Tystruct:
@@ -396,7 +393,6 @@
 		break;
 	case Tyname:
 		ty->name = unpickle(fd);
-		/*TRFIX: ty->issynth = */ rdbool(fd);
 		ty->narg = rdint(fd);
 		ty->arg = zalloc(ty->narg * sizeof(Type *));
 		for (i = 0; i < ty->narg; i++)
@@ -405,7 +401,6 @@
 		break;
 	case Tygeneric:
 		ty->name = unpickle(fd);
-		/* TRFIX: ty->issynth = */ rdbool(fd);
 		ty->ngparam = rdint(fd);
 		ty->gparam = zalloc(ty->ngparam * sizeof(Type *));
 		for (i = 0; i < ty->ngparam; i++)