ww: add file-scoped import aliases

This commit is contained in:
2026-08-14 10:56:34 +09:00
parent 351f4a25bc
commit 792b6ecbe5
14 changed files with 587 additions and 430 deletions

View File

@@ -2076,8 +2076,10 @@ use_node_cmp(const void *a, const void *b)
{
const Node *x = *(Node *const *)a;
const Node *y = *(Node *const *)b;
const char *xp = x->usepath ? x->usepath : x->str;
const char *yp = y->usepath ? y->usepath : y->str;
const char *xp = x->usesource ? x->usesource
: x->usepath ? x->usepath : x->str;
const char *yp = y->usesource ? y->usesource
: y->usepath ? y->usepath : y->str;
int r = strcmp(xp, yp);
if (r != 0) return r;
r = strcmp(x->pos.file ? x->pos.file : "",
@@ -2503,7 +2505,8 @@ sep_scan_file(struct sepgraph *g, int pi, const char *file,
int rc = 0;
for (int i = 0; i < nuse && rc == 0; i++) {
Node *u = uses[i];
const char *name = u->usepath ? u->usepath : u->str;
const char *name = u->usesource ? u->usesource
: u->usepath ? u->usepath : u->str;
if (reserved_import_path(name)) {
errorf(u->pos, "package path %s is reserved", name);
rc = -1;
@@ -3663,7 +3666,7 @@ static void
workdir_stamp_text(char *buf, size_t bufsz, int is_test, int emit_asm)
{
snprintf(buf, bufsz, "ww workdir fmt %d mode %s asm %d\n",
is_test ? 13 : 14, is_test ? "test" : "build", emit_asm);
is_test ? 14 : 15, is_test ? "test" : "build", emit_asm);
}
/* A stale global builder identity invalidates every committed unit voucher in