shithub: mc

Download patch

ref: 62f197bc9c8a7d3493596e55462d7eb9bbe21ae1
parent: e27b298f60cf74d25179ceb09326735b724e8d6e
author: Ori Bernstein <[email protected]>
date: Wed Jul 25 07:24:32 EDT 2012

Load the stab into the exports file.

--- a/parse/parse.h
+++ b/parse/parse.h
@@ -399,8 +399,9 @@
 Node *specializedcl(Node *n, Type *to, Node **name);
 
 /* usefiles */
+int  loaduse(FILE *f, Stab *into);
 void readuse(Node *use, Stab *into);
-void writeuse(Node *file, FILE *out);
+void writeuse(FILE *fd, Node *file);
 
 /* typechecking/inference */
 void infer(Node *file);
--- a/parse/use.c
+++ b/parse/use.c
@@ -27,7 +27,7 @@
     return s;
 }
 
-static int loaduse(FILE *f, Stab *st)
+int loaduse(FILE *f, Stab *st)
 {
     char *pkg;
     Stab *s;
@@ -111,7 +111,7 @@
  * G<pickled-decl><pickled-initializer>
  * Z
  */
-void writeuse(Node *file, FILE *f)
+void writeuse(FILE *f, Node *file)
 {
     Stab *st;
     void **k;
--- a/util/muse.c
+++ b/util/muse.c
@@ -27,7 +27,7 @@
     printf("\t-m\ttreat the inputs as usefiles and merge them\n");
     printf("\t-I path\tAdd 'path' to use search path\n");
     printf("\t-d\tPrint debug dumps\n");
-    printf("\t-o\tOutput to outfile\n");
+    printf("\t-o out\tOutput to outfile\n");
     printf("\t-s\tShow the contents of usefiles `inputs`\n");
 }
 
@@ -37,7 +37,7 @@
     FILE *f;
 
     globls = file->file.globls;
-    readuse(file, globls);
+    loaduse(f, globls);
     f = fopen(path, "r");
     dumpstab(globls, stdout);
     fclose(f);
@@ -57,16 +57,19 @@
     if (!outfile)
         die("need output file name right now. FIX THIS.");
     f = fopen(outfile, "w");
-    writeuse(file, f);
+    writeuse(f, file);
     fclose(f);
 }
 
 static void mergeuse(char *path)
 {
-    Stab *globls;
+    FILE *f;
+    Stab *st;
 
-    globls = file->file.globls;
-    readuse(file, globls);
+    st = file->file.exports;
+    f = fopen(path, "r");
+    loaduse(f, st);
+    fclose(f);
 }
 
 int main(int argc, char **argv)
@@ -75,7 +78,7 @@
     int opt;
     int i;
 
-    while ((opt = getopt(argc, argv, "d::ho:I:")) != -1) {
+    while ((opt = getopt(argc, argv, "d::hmo:I:")) != -1) {
         switch (opt) {
             case 'h':
                 usage(argv[0]);
@@ -115,7 +118,7 @@
     }
     if (merge) {
         f = fopen(outfile, "w");
-        writeuse(file, f);
+        writeuse(f, file);
         fclose(f);
     }