selfhost: migrate tool sources to directory packages
Build w6a and w6l from package-main directories and expose the wcc backend through a narrow package API so w6c and wwdump no longer import implementation files. Retarget the remaining load-bearing fixtures and example sources to directory packages; retain the one intentional flat compiler collision as an explicitly composed raw unit.
This commit is contained in:
@@ -6,8 +6,7 @@ package main;
|
||||
|
||||
import os;
|
||||
import syntax;
|
||||
import check;
|
||||
import cgen;
|
||||
import wcc;
|
||||
import strconv;
|
||||
|
||||
// argv strings are always NUL-terminated (kernel-supplied), so the
|
||||
@@ -124,24 +123,20 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
// and the report is printed with rc=0. Mirrors w6c main.ww:162
|
||||
// / cmd/w6c/main.c.
|
||||
if (l.errs > 0 || ps.errs > 0) { return 1; };
|
||||
let tc: tctx;
|
||||
typesinit(&tc);
|
||||
let ck: checker;
|
||||
checkinit(&ck, &tc);
|
||||
// Quiet by default; flip to 1 when debugging missing names.
|
||||
ck.verbose = 0;
|
||||
checkfile(&ck, f);
|
||||
let nresolved: i32 = 0;
|
||||
let nunresolved: i32 = 0;
|
||||
let checkrc: i32 = wcc.resolvefile(f, 0, &nresolved, &nunresolved);
|
||||
// "<file>: <resolved>/<resolved+unresolved> resolved"
|
||||
os.write(1, argstr(path).ptr, argstrlen(path): u64);
|
||||
os.write(1, ": ".ptr, 2u64);
|
||||
let rs: str = strconv.i64tos(ck.nresolved: i64, strconv.base.DEC);
|
||||
let rs: str = strconv.i64tos(nresolved: i64, strconv.base.DEC);
|
||||
os.write(1, rs.ptr, rs.len: u64);
|
||||
os.write(1, "/".ptr, 1u64);
|
||||
let total: i32 = ck.nresolved + ck.nunresolved;
|
||||
let total: i32 = nresolved + nunresolved;
|
||||
let ts: str = strconv.i64tos(total: i64, strconv.base.DEC);
|
||||
os.write(1, ts.ptr, ts.len: u64);
|
||||
os.write(1, " resolved\n".ptr, 10u64);
|
||||
if (ck.nunresolved > 0) { return 1; };
|
||||
if (checkrc != 0) { return 1; };
|
||||
} else { if (mode == 99) { // '-c' — codegen / emit asm
|
||||
let ps: parser;
|
||||
parserinit(&ps, &l);
|
||||
@@ -152,20 +147,8 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
// miscompile, and the 994 byte-identity probe ships wrong asm
|
||||
// silently). Mirrors w6c main.ww:162 / cmd/w6c/main.c.
|
||||
if (l.errs > 0 || ps.errs > 0) { return 1; };
|
||||
// #50: mirror w6c — run check before cgen so AST mutations
|
||||
// from #42 (size/align/offset fold) and audit §1.8 (node.type_
|
||||
// population) land before cgen walks. Without this, wwdump -c
|
||||
// (the byte-identity probe for 994) would diverge from w6c_ww
|
||||
// on any program that uses the size/align/offset typed builtins.
|
||||
let tc: tctx;
|
||||
typesinit(&tc);
|
||||
let ck: checker;
|
||||
checkinit(&ck, &tc);
|
||||
checkfile(&ck, f);
|
||||
if (ck.errs > 0) { return 1; };
|
||||
let cg: cgen;
|
||||
cgeninit(&cg);
|
||||
cgfile(&cg, f);
|
||||
let empty: str;
|
||||
if (wcc.compilefile(f, 0, empty, 0, empty) != 0) { return 1; };
|
||||
};};};};
|
||||
|
||||
if (l.errs > 0) { return 1; };
|
||||
|
||||
Reference in New Issue
Block a user