compiler: support package test runtime aliases

This commit is contained in:
2026-08-12 03:46:28 +09:00
parent 0ac0fd68ec
commit e59881cb30
7 changed files with 92 additions and 50 deletions

View File

@@ -28,6 +28,7 @@ main(int argc, char **argv)
const char *src = NULL;
const char *out = NULL;
const char *wwiout = NULL; /* -I <out.wwi>: M2 export-data producer */
const char *testsupport = NULL;
int testmode = 0;
int sepmode = 0; /* -c: #22 M3 separate-compile / primary-
* only codegen (emit imported==0 decls
@@ -40,6 +41,12 @@ main(int argc, char **argv)
wwiout = argv[++i];
} else if (strcmp(a, "-T") == 0) {
testmode = 1;
} else if (strcmp(a, "--test-support-module") == 0) {
if (i + 1 >= argc) {
fputs("w6c: --test-support-module requires arg\n", stderr);
return 2;
}
testsupport = argv[++i];
} else if (strcmp(a, "-c") == 0) {
sepmode = 1;
} else if (a[0] == '-') {
@@ -56,6 +63,12 @@ main(int argc, char **argv)
fputs("usage: w6c [-T] [-c] [-I out.wwi] [-o out.s] file.ww\n", stderr);
return 2;
}
if (testsupport != NULL && (!sepmode
|| (strcmp(testsupport, "test") != 0
&& strcmp(testsupport, "__wwtest") != 0))) {
fputs("w6c: invalid --test-support-module\n", stderr);
return 2;
}
char *buf;
u64 len;
@@ -72,11 +85,13 @@ main(int argc, char **argv)
lexinit(&l, a, src, buf, len);
parserinit(&p, a, &l);
p.testmodule = testsupport;
Node *file = parsefile(&p);
if (l.errs || p.errs) return 1;
check_init(&c, a);
c.is_test = testmode;
if (testsupport != NULL) c.test_module = testsupport;
c.sep_mode = sepmode;
check_file(&c, file);
if (c.errs) return 1;