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

@@ -97,27 +97,27 @@ export fn main(argc: i32, argv: **u8) i32 = {
return 1;
};
let l: lex;
lexinit(&l, argstr(path), buf.ptr, sz: u64);
let l: syntax.lex;
syntax.lexinit(&l, argstr(path), buf.ptr, sz: u64);
if (mode == 116) { // '-t'
for (true) {
let t: tok;
lexnext(&l, &t);
tokprint(1i32, &t);
if (t.kind == tkind.TK_EOF) { break; };
if (t.kind == tkind.TK_ERR) { break; };
let t: syntax.tok;
syntax.lexnext(&l, &t);
syntax.tokprint(1i32, &t);
if (t.kind == syntax.tkind.TK_EOF) { break; };
if (t.kind == syntax.tkind.TK_ERR) { break; };
};
} else { if (mode == 97) { // '-a'
let ps: parser;
parserinit(&ps, &l);
let f: *node = parsefile(&ps);
astprint(1i32, f);
let ps: syntax.parser;
syntax.parserinit(&ps, &l);
let f: *syntax.node = syntax.parsefile(&ps);
syntax.astprint(1i32, f);
if (ps.errs > 0) { return 1; };
} else { if (mode == 114) { // '-r' — name resolve report
let ps: parser;
parserinit(&ps, &l);
let f: *node = parsefile(&ps);
let ps: syntax.parser;
syntax.parserinit(&ps, &l);
let f: *syntax.node = syntax.parsefile(&ps);
// #52: gate the resolve report on parse-stage errors. Without
// this a parse-errored decl is silently dropped from the AST
// and the report is printed with rc=0. Mirrors w6c main.ww:162
@@ -138,9 +138,9 @@ export fn main(argc: i32, argv: **u8) i32 = {
os.write(1, " resolved\n".ptr, 10u64);
if (checkrc != 0) { return 1; };
} else { if (mode == 99) { // '-c' — codegen / emit asm
let ps: parser;
parserinit(&ps, &l);
let f: *node = parsefile(&ps);
let ps: syntax.parser;
syntax.parserinit(&ps, &l);
let f: *syntax.node = syntax.parsefile(&ps);
// #52: gate cgen on parse-stage errors BEFORE check/cgen.
// A parse-errored decl is silently dropped from the AST; the
// remaining file would otherwise emit asm with rc=0 (silent