shithub: mc

Download patch

ref: c7ad247d35a719539fc4df4e7a78d07e77a6f538
parent: b5c63138b4f40766dacc40e8ce91d44abdbb3b0e
author: Ori Bernstein <[email protected]>
date: Wed Jan 17 08:53:44 EST 2018

Infer after generating init functions.

	Pull out the usefile loading, so we can call it separately
	from inference. Then shuffle the infer() call to after we
	generate init().

--- a/6/main.c
+++ b/6/main.c
@@ -274,9 +274,10 @@
 		/* before we do anything to the parse */
 		if (debugopt['T'])
 			dump(file, stdout);
-		infer();
+		loaduses();
 		if (hasmain(file))
 			geninit();
+		infer();
 		tagexports(0);
 		/* after all type inference */
 		if (debugopt['t'])
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -1314,16 +1314,6 @@
 		unify(ctx, a->arg[i], b->arg[i]);
 }
 
-static void
-loaduses(void)
-{
-	size_t i;
-
-	/* uses only allowed at top level. Do we want to keep it this way? */
-	for (i = 0; i < file->file.nuses; i++)
-		readuse(file->file.uses[i], file->file.globls, Visintern);
-}
-
 static Type *
 initvar(Node *n, Node *s)
 {
@@ -2957,7 +2947,6 @@
 infer(void)
 {
 	delayed = mkht(tyhash, tyeq);
-	loaduses();
 	initimpl();
 
 	/* do the inference */
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -549,6 +549,7 @@
 void geninit(void);
 
 /* usefiles */
+void loaduses(void);
 int loaduse(char *path, FILE *f, Stab *into, Vis vis);
 void readuse(Node *use, Stab *into, Vis vis);
 void writeuse(FILE *fd, Node *file);
--- a/parse/use.c
+++ b/parse/use.c
@@ -1189,6 +1189,15 @@
 	free(p);
 }
 
+void
+loaduses(void)
+{
+	size_t i;
+
+	for (i = 0; i < file->file.nuses; i++)
+		readuse(file->file.uses[i], file->file.globls, Visintern);
+}
+
 /* Usefile format:
  * U<pkgname>
  * L<liblist>