diff options
-rw-r--r-- | muse/muse.c | 93 | ||||
-rw-r--r-- | myrbuild/myrbuild.c | 2 |
2 files changed, 22 insertions, 73 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; } diff --git a/myrbuild/myrbuild.c b/myrbuild/myrbuild.c index 652d3a2..b74b20f 100644 --- a/myrbuild/myrbuild.c +++ b/myrbuild/myrbuild.c @@ -333,7 +333,7 @@ void mergeuse(char **files, size_t nfiles) args = NULL; nargs = 0; lappend(&args, &nargs, strdup(muse)); - lappend(&args, &nargs, strdup("-mo")); + lappend(&args, &nargs, strdup("-o")); lappend(&args, &nargs, strdup(libname)); for (i = 0; i < nfiles; i++) { if (hassuffix(files[i], ".myr")) { |