diff options
author | Ori Bernstein <ori@eigenstate.org> | 2014-12-18 23:38:38 -0800 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2014-12-18 23:38:38 -0800 |
commit | f46267a4c5ff0c4c143ab5179b399c4aeca3d5c1 (patch) | |
tree | 0f560ce27dbf093df8004798551b6f6db071ba2a /muse | |
parent | 94f16d7da3d10bb5a037fad194f428a53dea83c3 (diff) | |
download | mc-f46267a4c5ff0c4c143ab5179b399c4aeca3d5c1.tar.gz |
Remove useless option from muse.
Now, merging is the only thing muse does.
Diffstat (limited to 'muse')
-rw-r--r-- | muse/muse.c | 93 |
1 files changed, 21 insertions, 72 deletions
diff --git a/muse/muse.c b/muse/muse.c index eb59e10..7f409b4 100644 --- a/muse/muse.c +++ b/muse/muse.c @@ -16,8 +16,7 @@ /* FIXME: move into one place...? */ Node *file; char *outfile; -int merge; -int debug; +int show; char debugopt[128]; char **incpaths; size_t nincpaths; @@ -26,7 +25,6 @@ static void usage(char *prog) { printf("%s [-hIdos] [-o outfile] [-m] inputs\n", prog); printf("\t-h\tprint this help\n"); - printf("\t-m\ttreat the inputs as usefiles and merge them into outfile\n"); printf("\t\tThe outfile must be the same name as each package merged.\n"); printf("\t-I path\tAdd 'path' to use search path\n"); printf("\t-d\tPrint debug dumps\n"); @@ -34,43 +32,6 @@ static void usage(char *prog) printf("\t-s\tShow the contents of usefiles `inputs`\n"); } -static void dumpuse(char *path) -{ - Stab *globls; - FILE *f; - - globls = file->file.globls; - f = fopen(path, "r"); - loaduse(f, globls, Visexport); - fclose(f); - dumpstab(globls, stdout); -} - -static void genuse(char *path) -{ - Stab *globls; - char *p; - FILE *f; - char buf[1024]; - - globls = file->file.globls; - tyinit(globls); - tokinit(path); - yyparse(); - - infer(file); - tagexports(file->file.globls, 0); - if (outfile) { - p = outfile; - } else { - swapsuffix(buf, sizeof buf, path, ".myr", ".use"); - p = buf; - } - f = fopen(p, "w"); - writeuse(f, file); - fclose(f); -} - static void mergeuse(char *path) { FILE *f; @@ -97,20 +58,19 @@ int main(int argc, char **argv) usage(argv[0]); exit(0); break; - case 'm': - merge = 1; - break; case 'o': outfile = ctx.optarg; break; case 'd': - debug = 1; while (ctx.optarg && *ctx.optarg) debugopt[*ctx.optarg++ & 0x7f] = 1; break; case 'I': lappend(&incpaths, &nincpaths, ctx.optarg); break; + case 's': + show = 1; + break; default: usage(argv[0]); exit(0); @@ -119,35 +79,24 @@ int main(int argc, char **argv) } lappend(&incpaths, &nincpaths, Instroot "/lib/myr"); - if (merge) { - if (!outfile) { - fprintf(stderr, "Output file needed when merging usefiles."); - exit(1); - } - - file = mkfile("internal"); - file->file.globls = mkstab(); - updatens(file->file.globls, outfile); - tyinit(file->file.globls); - for (i = 0; i < ctx.nargs; i++) - mergeuse(ctx.args[i]); - infer(file); - tagexports(file->file.globls, 1); - f = fopen(outfile, "w"); - if (debugopt['s']) - dumpstab(file->file.globls, stdout); - writeuse(f, file); - fclose(f); - } else { - for (i = 0; i < ctx.nargs; i++) { - file = mkfile(ctx.args[i]); - file->file.globls = mkstab(); - if (debugopt['s']) - dumpuse(ctx.args[i]); - else - genuse(ctx.args[i]); - } + if (!outfile) { + fprintf(stderr, "Output file needed when merging usefiles."); + exit(1); } + file = mkfile("internal"); + file->file.globls = mkstab(); + updatens(file->file.globls, outfile); + tyinit(file->file.globls); + for (i = 0; i < ctx.nargs; i++) + mergeuse(ctx.args[i]); + infer(file); + tagexports(file->file.globls, 1); + f = fopen(outfile, "w"); + if (debugopt['s'] || show) + dumpstab(file->file.globls, stdout); + else + writeuse(f, file); + fclose(f); return 0; } |