summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2018-01-17 13:53:44 -0800
committerOri Bernstein <ori@markovcorp.com>2018-01-17 13:53:44 -0800
commitc7ad247d35a719539fc4df4e7a78d07e77a6f538 (patch)
tree81b9ebd0c54b366101ed98f50c4f86c71ea24f77
parentb5c63138b4f40766dacc40e8ce91d44abdbb3b0e (diff)
downloadmc-c7ad247d35a719539fc4df4e7a78d07e77a6f538.tar.gz
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().
-rw-r--r--6/main.c3
-rw-r--r--parse/infer.c11
-rw-r--r--parse/parse.h1
-rw-r--r--parse/use.c9
4 files changed, 12 insertions, 12 deletions
diff --git a/6/main.c b/6/main.c
index 2f54284..a153b8b 100644
--- a/6/main.c
+++ b/6/main.c
@@ -274,9 +274,10 @@ main(int argc, char **argv)
/* 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'])
diff --git a/parse/infer.c b/parse/infer.c
index 1b81bb1..548c1f2 100644
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -1314,16 +1314,6 @@ unifyparams(Node *ctx, Type *a, Type *b)
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 @@ void
infer(void)
{
delayed = mkht(tyhash, tyeq);
- loaduses();
initimpl();
/* do the inference */
diff --git a/parse/parse.h b/parse/parse.h
index c622623..06b0b11 100644
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -549,6 +549,7 @@ Node *genericname(Node *n, Type *param, Type *t);
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);
diff --git a/parse/use.c b/parse/use.c
index 906e59b..cf9ba90 100644
--- a/parse/use.c
+++ b/parse/use.c
@@ -1189,6 +1189,15 @@ readuse(Node *use, Stab *st, Vis vis)
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>