shithub: mc

Download patch

ref: 4e018273cd06542a0605cebd840dbcb8b14ad906
parent: 547d6b96e5536f97d161e0a6544344534af3bde2
author: Ori Bernstein <ori@eigenstate.org>
date: Sun Nov 5 16:27:14 EST 2017

Accept the globalness of file.

--- a/6/main.c
+++ b/6/main.c
@@ -276,8 +276,8 @@
 			dump(file, stdout);
 		infer();
 		if (hasmain(file))
-			geninit(file);
-		tagexports(file, 0);
+			geninit();
+		tagexports(0);
 		/* after all type inference */
 		if (debugopt['t'])
 			dump(file, stdout);
--- a/muse/muse.c
+++ b/muse/muse.c
@@ -105,8 +105,8 @@
 	for (i = 0; i < ctx.nargs; i++)
 		mergeuse(ctx.args[i]);
 	infer();
-	tagexports(file, 1);
-	addextlibs(file, extralibs, nextralibs);
+	tagexports(1);
+	addextlibs(extralibs, nextralibs);
 
 	/* generate the usefile */
 	f = fopen(outfile, "w");
--- a/parse/export.c
+++ b/parse/export.c
@@ -210,7 +210,7 @@
 }
 
 void
-tagexports(Node *file, int hidelocal)
+tagexports(int hidelocal)
 {
 	size_t i, j, n;
 	Trait *tr;
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -572,7 +572,7 @@
 		if (!tytab[t->tid] && t->type == Tyunres) {
 			ns = curstab();
 			if (t->name->name.ns)
-				ns = getns(file, t->name->name.ns);
+				ns = getns(t->name->name.ns);
 			if (!ns)
 				fatal(t->name, "no namespace \"%s\"", t->name->name.ns);
 			lu = gettype(ns, t->name);
@@ -741,7 +741,7 @@
 	args = n->expr.args;
 	ns = curstab();
 	if (args[0]->name.ns)
-		ns = getns(file, args[0]->name.ns);
+		ns = getns(args[0]->name.ns);
 	if (!ns)
 		fatal(n, "no namespace %s\n", args[0]->name.ns);
 	uc = getucon(ns, args[0]);
@@ -1397,7 +1397,7 @@
 	if (args[0]->type != Nexpr || exprop(args[0]) != Ovar)
 		return n;
 	name = args[0]->expr.args[0];
-	stab = getns(file, namestr(name));
+	stab = getns(namestr(name));
 	if (!stab)
 		return n;
 
@@ -1565,7 +1565,7 @@
 	case Ovar:
 		ns = curstab();
 		if (args[0]->name.ns)
-			ns = getns(file, args[0]->name.ns);
+			ns = getns(args[0]->name.ns);
 		s = getdcl(ns, args[0]);
 		if (s && !s->decl.ishidden) {
 			if (s->decl.isgeneric)
@@ -1815,7 +1815,7 @@
 			return;
 		ns = curstab();
 		if (args[0]->name.ns)
-			ns = getns(file, args[0]->name.ns);
+			ns = getns(args[0]->name.ns);
 		s = getdcl(ns, args[0]);
 		if (!s)
 			fatal(n, "undeclared var %s", ctxstr(args[0]));
@@ -2797,7 +2797,7 @@
 		n = impl->impl.traitname;
 		ns = file->file.globls;
 		if (n->name.ns)
-			ns = getns(file, n->name.ns);
+			ns = getns(n->name.ns);
 		if (ns)
 			tr = gettrait(ns, n);
 		if (!tr)
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -404,7 +404,7 @@
 /* stab creation */
 Stab *mkstab(int isfunc);
 
-void putns(Node *file, Stab *scope);
+void putns(Stab *scope);
 void puttype(Stab *st, Node *n, Type *ty);
 void puttrait(Stab *st, Node *n, Trait *trait);
 void putimpl(Stab *st, Node *impl);
@@ -414,7 +414,7 @@
 void putucon(Stab *st, Ucon *uc);
 void putlbl(Stab *st, char *name, Node *lbl);
 
-Stab *getns(Node *file, char *n);
+Stab *getns(char *n);
 Node *getdcl(Stab *st, Node *n);
 Node *getclosed(Stab *st, Node *n);
 Node **getclosure(Stab *st, size_t *n);
@@ -521,7 +521,7 @@
 Type *decltype(Node * n);
 Type *exprtype(Node *n);
 Type *nodetype(Node *n);
-void addstmt(Node *file, Node *stmt);
+void addstmt(Node *stmt);
 void setns(Node *n, char *ns);
 void updatens(Stab *st, char *ns);
 ulong varhash(void *dcl);
@@ -536,15 +536,15 @@
 Node *specializedcl(Node *n, Type *param, Type *to, Node **name);
 Type *tyspecialize(Type *t, Tysubst *tymap, Htab *delayed, Htab *tybase);
 Node *genericname(Node *n, Type *param, Type *t);
-void geninit(Node *file);
+void geninit(void);
 
 /* usefiles */
 int loaduse(char *path, FILE *f, Stab *into, Vis vis);
 void readuse(Node *use, Stab *into, Vis vis);
 void writeuse(FILE *fd, Node *file);
-void tagexports(Node *file, int hidelocal);
+void tagexports(int hidelocal);
 void tagreflect(Type *t);
-void addextlibs(Node *file, char **libs, size_t nlibs);
+void addextlibs(char **libs, size_t nlibs);
 
 /* expression folding */
 Node *fold(Node *n, int foldvar);
--- a/parse/specialize.c
+++ b/parse/specialize.c
@@ -233,7 +233,7 @@
 		if (n->expr.op == Ovar) {
 			ns = curstab();
 			if (n->expr.args[0]->name.ns)
-				ns = getns(file, n->expr.args[0]->name.ns);
+				ns = getns(n->expr.args[0]->name.ns);
 			if (!ns)
 				fatal(n, "No namespace %s\n", n->expr.args[0]->name.ns);
 			d = getdcl(ns, n->expr.args[0]);
@@ -513,7 +513,7 @@
 	n = genericname(gnode, param, to);
 	*name = n;
 	if (n->name.ns)
-		st = getns(file, n->name.ns);
+		st = getns(n->name.ns);
 	else
 		st = file->file.globls;
 	if (!st)
@@ -603,7 +603,7 @@
 }
 
 void
-geninit(Node *file)
+geninit(void)
 {
 	Node *name, *decl, *func, *block, *init;
 	Type *tyvoid, *tyvoidfn;
--- a/parse/stab.c
+++ b/parse/stab.c
@@ -171,7 +171,7 @@
 	Stab *ns;
 
 	if (n->name.ns) {
-		ns = getns(file, n->name.ns);
+		ns = getns(n->name.ns);
 		if (!ns) {
 			ns = mkstab(0);
 			updatens(ns, n->name.ns);
@@ -319,7 +319,7 @@
 	Traitdefn *c;
 
 	if (n->name.ns)
-		st = getns(file, n->name.ns);
+		st = getns(n->name.ns);
 	do {
 		if ((c = htget(st->tr, n)))
 			return c->trait;
@@ -329,7 +329,7 @@
 }
 
 Stab *
-getns(Node *file, char *name) {
+getns(char *name) {
 	return htget(file->file.ns, name);
 }
 
@@ -606,11 +606,11 @@
 }
 
 void
-putns(Node *file, Stab *scope)
+putns(Stab *scope)
 {
 	Stab *s;
 
-	s = getns(file, scope->name);
+	s = getns(scope->name);
 	if (s)
 		lfatal(Zloc, "Namespace %s already defined", scope->name);
 	htput(file->file.ns, scope->name, scope);
--- a/parse/use.c
+++ b/parse/use.c
@@ -52,7 +52,7 @@
 static size_t nimplfix;		/* size of replacement list */
 
 void
-addextlibs(Node *file, char **libs, size_t nlibs)
+addextlibs(char **libs, size_t nlibs)
 {
 	size_t i, j;
 
@@ -751,11 +751,11 @@
 			return NULL;
 	}
 
-	s = getns(file, pkg);
+	s = getns(pkg);
 	if (!s) {
 		s = mkstab(0);
 		s->name = strdup(pkg);
-		putns(file, s);
+		putns(s);
 	}
 	return s;
 }