w6c: preserve grouped and qualified types in wwi

This commit is contained in:
2026-08-09 03:31:40 +09:00
parent 53a9e94736
commit 0a16811ab1
3 changed files with 87 additions and 18 deletions

View File

@@ -74,20 +74,34 @@ fn wquote(fd: i32, s: str) void = {
fn wwitypesym(c: *checker, nm: str) *syntax.sym = {
let empty: str;
let s: *syntax.sym = syntax.scopelookuptype(c.cur, empty, nm);
if (s == nil) {
let dotidx: i32 = -1;
let i: i32 = 0;
for (i < nm.len) {
if (nm[i] == 46u8) { dotidx = i; };
i += 1;
};
if (dotidx >= 0) {
let leaf: str;
leaf.ptr = nm.ptr + ((dotidx + 1): u64);
leaf.len = nm.len - dotidx - 1;
s = syntax.scopelookuptype(c.cur, empty, leaf);
let dotidx: i32 = -1;
let i: i32 = 0;
for (i < nm.len) {
if (nm[i] == 46u8) { dotidx = i; };
i += 1;
};
let s: *syntax.sym = nil;
if (dotidx >= 0) {
let head: str;
head.ptr = nm.ptr;
head.len = dotidx;
let leaf: str;
leaf.ptr = nm.ptr + ((dotidx + 1): u64);
leaf.len = nm.len - dotidx - 1;
let u: *syntax.node = c.file.list;
for (u != nil) {
if (u.kind == syntax.nkind.N_USE && wwiprimary(u)) {
if (syntax.streq(u.str, head)) {
let mod: str = u.usepath;
if (mod.len == 0) { mod = u.str; };
s = syntax.scopelookupinmodule(c.cur, mod, leaf);
break;
};
};
u = u.next;
};
} else {
s = syntax.scopelookuptype(c.cur, empty, nm);
};
if (s == nil) { return nil; };
if (s.skind != syntax.skind.SK_TYPE) { return nil; };
@@ -279,11 +293,13 @@ fn wwiexpr(fd: i32, e: *syntax.node) void = {
// `0x10ffff: rune` emits as the plain int 1114111).
wwirune(fd, e.uval);
} else { if (e.kind == syntax.nkind.N_BIN) {
wputb(fd, '(');
wwiexpr(fd, e.lhs);
wputb(fd, 32u8);
wputs(fd, syntax.tokname(e.op));
wputb(fd, 32u8);
wwiexpr(fd, e.rhs);
wputb(fd, ')');
} else { if (e.kind == syntax.nkind.N_UN) {
wputs(fd, syntax.tokname(e.op));
wwiexpr(fd, e.lhs);