wcc: route DATA-emit through emitsymname mangler (#127)

wwstage cgen.ww emitdefconstants now uses the same emitsymname
mangler that LOAD/CALL sites use, replacing 8 lines of duplicate
`d.exported`/`d.nmod` logic. Rule-12 sea-of-stars consolidation —
one path, not two parallel paths that can desynchronise.

Cstage twin: cmd/w6c/cgen.c:8510 (mod_mangle in emit_defs). Bootstrap-
neutral post-90d31c5 (the duplicate PATH_MAX def that motivated the
divergence was cleaned up in drew's source-hygiene fold); all 5 tool
combined.ww emit cs==ww byte-identical asm post-fix. New test 913
(4 rows: exported i64 def, main-local i64 def, u64 width, multi-def
sequence) pins the simple-shape invariant forward — a future caller
introducing a colliding name produces the same symbol from both
stages by construction.

Drew's (a) ruling. Reviewer-127 noted the new path additionally
consults FFI (ffiresolve) which the old d.exported/d.nmod block did
not — incidental improvement to cs/ww symmetry beyond the mod-mangle
consolidation.
This commit is contained in:
2026-05-27 01:51:12 +09:00
parent 13441c5e2e
commit bdfb5cda58
5 changed files with 249 additions and 24 deletions

View File

@@ -1480,15 +1480,17 @@ fn emitdefconstants(c: *cgen, file: *node) void = {
ok = foldintliteral(r, &v);
};
if (ok) {
// #127: route DATA-emit through the SAME emitsymname
// SSoT that LOAD/CALL sites use. Replaces the prior
// 8-line d.exported/d.nmod prefix logic with a single
// modlookup-based mangle, removing duplicate logic
// (rule-12 sea-of-stars). Mirrors cstage emit_defs at
// cmd/w6c/cgen.c:8494 (mod_mangle). Bootstrap-neutral
// post-90d31c5 (the PATH_MAX duplicate-def consumer
// that motivated the divergence is gone), so the asm
// surface is unchanged on the corpus.
emitline("DATA ");
if (d.exported == 0) {
if (d.nmod.len > 0) {
emitbytes( d.nmod.ptr, d.nmod.len: u64);
emitbytes( ".".ptr, 1u64);
};
};
let nm: str = d.str;
emitbytes( nm.ptr, nm.len: u64);
emitsymname(c, d.str);
emitline("(SB),\"");
let i: i32 = 0;
let n: u64 = v;