ww: preserve command package identities
This commit is contained in:
@@ -67,6 +67,7 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
let testsupport: *u8 = nil;
|
||||
let testmode: i32 = 0i32; // #15: `-T` test-mode
|
||||
let testpackage: i32 = 0i32;
|
||||
let commandpackage: i32 = 0i32;
|
||||
let entrymode: i32 = 0i32;
|
||||
let sepmode: i32 = 0i32; // -c: #22 M3 separate-compile / primary-
|
||||
// only codegen (emit imported==0 decls
|
||||
@@ -100,6 +101,8 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
testmode = 1i32;
|
||||
} else { if (cstreq(a, "--test-package")) {
|
||||
testpackage = 1i32;
|
||||
} else { if (cstreq(a, "--command-package")) {
|
||||
commandpackage = 1i32;
|
||||
} else { if (cstreq(a, "--entry")) {
|
||||
entrymode = 1i32;
|
||||
} else { if (cstreq(a, "--test-support-module")) {
|
||||
@@ -133,12 +136,12 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
return 2;
|
||||
};
|
||||
src = a;
|
||||
}; }; }; }; }; }; }; }; };
|
||||
}; }; }; }; }; }; }; }; }; };
|
||||
i += 1;
|
||||
};
|
||||
|
||||
if (src == nil) {
|
||||
let m: str = "usage: w6c_ww [-T|--test-package] [--entry] [-c] [-I out.wwi] [--import path dep.wwi]... [-o out.s] file.ww\n";
|
||||
let m: str = "usage: w6c_ww [-T|--test-package] [--command-package] [--entry] [-c] [-I out.wwi] [--import path dep.wwi]... [-o out.s] file.ww\n";
|
||||
os.write(2, m.ptr, m.len: u64);
|
||||
return 2;
|
||||
};
|
||||
@@ -147,8 +150,9 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
os.write(2, m.ptr, m.len: u64);
|
||||
return 2;
|
||||
};
|
||||
if ((entrymode != 0 || testpackage != 0) && sepmode == 0) {
|
||||
let m: str = "w6c: --entry and --test-package require -c\n";
|
||||
if ((entrymode != 0 || testpackage != 0 || commandpackage != 0)
|
||||
&& sepmode == 0) {
|
||||
let m: str = "w6c: --entry, --test-package, and --command-package require -c\n";
|
||||
os.write(2, m.ptr, m.len: u64);
|
||||
return 2;
|
||||
};
|
||||
@@ -233,6 +237,9 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
let ps: parser;
|
||||
parserinit(&ps, &l);
|
||||
if (testsupport != nil) { ps.testmodule = pathstr(testsupport); };
|
||||
// Entry compilation classifies an ordinary command package. The explicit
|
||||
// marker carries only that parser fact for non-entry command test variants.
|
||||
ps.commandpackage = commandpackage != 0 || entrymode != 0;
|
||||
let f: *node = parsefile(&ps);
|
||||
// Gate cgen on parse-stage errors. Mirrors cmd/w6c/main.c's
|
||||
// `if (l.errs || p.errs) return 1;` — broken AST otherwise reaches
|
||||
|
||||
Reference in New Issue
Block a user